WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/add contextual help


This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists. See also wp-includes/deprecated.php. Use any of these functions instead.

Use WP_Screen::add_help_tab() instead.

Description

This function is used to add HTML to the Contextual Help tab for a specific admin page.

Usage

 <?php add_contextual_help$screen$help ); ?> 

Parameters

$screen
(string) (required) The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
Default: None
$help
(string) (required) An arbitrary string containing HTML for help text.
Default: None

Example

Default Usage

This example shows how you would add contextual help to an admin page you've created with the add_theme_page() function. Here, we will assume that your page has a slug of 'my_theme_options' and exists under the Appearance tab, which has a slug of 'appearance_page'. To keep things organized, we can use the 'admin_init' hook to declare a function with our custom contextual help.

<?php 
function add_my_contextual_help() {
    $text = __("<p>This is a help text for 'my_theme_options' page (a subpage of 'appearance_page').</p>");
    add_contextual_help( 'appearance_page_my_theme_options', $text ); 
}
add_action( 'admin_init', 'add_my_contextual_help' );
?>

Finding the Screen Name

If you need to find the current screen name (for the $screen parameter) then you can use this function. Just put it in your functions.php file and then browse to the page you wish to find the screen name. It will then be printed across the top of your admin screen. This is very useful for people who create custom administration menus (typically advanced premium themes) and aren't quite sure what the screen name would be.

<?php
function check_current_screen() {
    if( !is_admin() ) return;
    global $current_screen;
    print_r( $current_screen );
}
add_action( 'admin_notices', 'check_current_screen' );
?>

Notes

When using this function to add contextual help to an admin page created by a plugin or theme, it is important to remember that the add_*_page() set of functions build and return custom hook names - which are needed in order to use add_contextual_help().

This page hook name is usually made up of two page slugs separated by an underscore - the slug for the current page (as defined in your add_*_page() function), an underscore, and the slug for the parent page.

For example, if you created a new "theme_options" subpage under the Admin > Appearance menu (which itself has a slug of "appearance_page"), your page hook would be "appearance_page_theme_options".

To modify or add to the hard-coded help text for default WordPress admin pages, you have to use the gettext filter hook.

Change Log

Source File

add_contextual_help() is located in wp-admin/includes/template.php.

Related

Topics

Functions

Resources