Codex

Function Reference/add help tab

This page is marked as incomplete. You can help Codex by expanding it.

Contents

Description

This function is used to add a tab to the Contextual Help menu in an admin page.

add_help_tab() is a method of the WP_Screen() class, and can not be called directly.

To use the method, fetch the $current_screen object or use get_current_screen() and then call the method from the object. Developers should keep in mind that you may need to filter $current_screen using an if or switch statement to prevent new help tabs from being added to ALL admin screens.

Usage

 <?php
$screen = get_current_screen();
$screen->add_help_tab( array( 
   'id' => $id,            //unique id for the tab
   'title' => $title,      //unique visible title for the tab
   'content' => $content,  //actual help text
   'callback' => $callback //optional function to callback
) );
?> 

Parameters

$args
(array) (required) Contains values to be displayed by the created help tab and a callback argument
Default: None

Arguments

$title
(string) (required) Title for the tab.
Default: None
$id
(string) (required) Tab ID. Must be HTML-safe and should be unique for this menu.
Default: None
$content
(string) (optional) Help tab content in plain text or HTML.
Default: None
$function
(callback) (optional) The function to be called to output the content for this page.
Default: None


Example

Default Usage

This example shows how you would add contextual help to an admin page you've created with the add_options_page() function. Here, we assume that your admin page has a slug of 'my_admin_page' and exists under the Options tab.

<?php 
add_action('admin_menu', 'my_admin_add_page');
function my_admin_add_page() {
    global $my_admin_page;
    $my_admin_page = add_options_page(__('My Admin Page', 'map'), __('My Admin Page', 'map'), 'manage_options', 'map', 'my_admin_page');

    // Adds my_help_tab when my_admin_page loads
    add_action('load-'.$my_admin_page, 'my_admin_add_help_tab');
}

function my_admin_add_help_tab () {
    global $my_admin_page;
    $screen = get_current_screen();

    /*
     * Check if current screen is My Admin Page
     * Don't add help tab if it's not
     */
    if ( $screen->id != $my_admin_page )
        return;

    // Add my_help_tab if current screen is My Admin Page
    $screen->add_help_tab( array(
        'id'	=> 'my_help_tab',
        'title'	=> __('My Help Tab'),
        'content'	=> '<p>' . __( 'Descriptive content that will show in My Help Tab-body goes here.' ) . '</p>',
    ) );
}
?>

Change Log

Source File

add_help_tab() is located in wp-admin/includes/screen.php.

Related

Topics

Functions

Resources