Modifying The Contextual Help Menu in WordPress

Contextual help menu in WordPressStarting in version 2.7, WordPress has a pull-down “Help” menu in the upper-right corner of the screen, often joined by another menu for configuring display options for the page in question.

By default the “Help” menu doesn’t do much. It gives some useful pointers on the Dashboard and Write screen, but other than that it pretty much just shows links to the Codex and WordPress.org support forums.

What if you wanted to make the “contextual menu” actually…contextual? If you’re a plugin or theme developer, you can add your own helpful information to the menu. It’s as simple as hooking into the contextual_help filter:

function my_contextual_help($text) {
$screen = $_GET['page'];
if ($screen == 'my_plugin') {
$text = "<h5>Need help with this plugin?</h5>";
$text .= "<p>Check out the documentation and support forums for help with this plugin.</p>";
$text .= "<a href=\"http://example.org/docs\">Documentation</a><br /><a href=\"http://example.org/support\">Support forums</a>";
}
return $text;
}

add_action('contextual_help', 'my_contextual_help');

The basic idea is to take the default contents of the menu, $text, and replace it with your own content. The $screen variable is used to make sure that the menu is only changed on the plugin’s pages, rather than universally through the Admin.

  • http://edward.de.leau.net edward de leau

    use: screen$current_screen = get_current_screen(); echo $current_screen->id; instead!

    • http://www.webmaster-source.com Matt

      I didn’t know about that. Thanks for the tip.

  • David Hilton

    It took me a while to find it but you may want to look at the WordPress “Advanced Menu Widget” plugin.