Skip to main content
2 of 4
added 9 characters in body
Tom J Nowell
  • 60.6k
  • 7
  • 77
  • 147

Modify Contextual Help

Currently I have searched a lot of pages and information covering the contextual help tab (much like here:: 50787, 51861, 77308. Search term:: centextual help), and while there are many useful bits of information out there, it's not quiet honing in on what it is I'm looking for, failing that I'm not quite peicing the information together properly.

functions.php / Contextual Help Tab / Global

The aim is to avoid installing any more plugins than I have to. Additionally, I'm not interest in targeting any particular page, post or plugin, this is a global help as per defualt worpress help tab.

I have managed to cobble together fragments of coding to be able to start the adjustment of the current help tab, however, I'm falling short when it comes to calling and removing the old links.

As it stands, The below coding removes and adds/replaces the right sidebars global content, but with the left menu it is adding the new content but not removing/replacing the old.

function add_context_menu_help(){
// get the current screen object
    $current_screen = get_current_screen();
// content for help tab
    $content = '<p>Has this replaced it?</p>';
// register our main help tab - Overview
    $current_screen->add_help_tab( array(
            'id'        => 'overview-link',
            'title'     => __('Overview'),
            'content'   => $content
        )
    );
// content for help tab
    $content = '<p>Im a help tab, woo!</p>';
// register our main help tab
    $current_screen->add_help_tab( array(
            'id'        => 'sp_basic_help_tab',
            'title'     => __('Basic Help Tab'),
            'content'   => $content
        )
    );
// register our secondary help tab (with a callback instead of content)
    $current_screen->add_help_tab( array(
            'id'        => 'sp_help_tab_callback',
            'title'     => __('Help Tab With Callback'),
            'callback'  => 'display_help_tab'
        )
    );
// This sets the sidebar, which is common for all tabs of this screen
    get_current_screen()->set_help_sidebar(
        '<p><strong>' . __('For more information:') . '</strong></p>' .
        '<p>' . __('<a href="http://wordpress.stackexchange.com/" title="WordPress StackExchange" target="_blank">WordPress Answers</a>') . '</p>' .
        '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    );
}
add_filter('admin_head', 'add_context_menu_help');
//function used to display the second help tab
function display_help_tab(){
    $content = '<p>This is text from our output function</p>';
    echo $content;
}

I know I'm missing something, and not for looking; How do I call on the relevant 'id and title' to either remove and or overwrite it, or do I have to call on a link such as Dashboard / Home or Updates, etc?

Your help would be greatly appreciated

KR, John

John
  • 1
  • 2