On this page
WP_Screen::add_help_tab( array $args )
Adds a help tab to the contextual help for the screen.
Description
Call this on the load-$pagenow hook for the relevant screen, or fetch the $current_screen object, or use get_current_screen() and then call the method from the object.
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.
Parameters
$argsarray Required-
Array of arguments used to display the help tab.
titlestringTitle for the tab. Default false.idstringTab ID. Must be HTML-safe and should be unique for this menu.
It is NOT allowed to contain any empty spaces. Default false.contentstringOptional. Help tab content in plain text or HTML. Default empty string.callbackcallableOptional. A callback to generate the tab content. Default false.priorityintOptional. The priority of the tab, used for ordering. Default 10.
Source
File: wp-admin/includes/class-wp-screen.php. View all references
public function add_help_tab( $args ) {
$defaults = array(
'title' => false,
'id' => false,
'content' => '',
'callback' => false,
'priority' => 10,
);
$args = wp_parse_args( $args, $defaults );
$args['id'] = sanitize_html_class( $args['id'] );
// Ensure we have an ID and title.
if ( ! $args['id'] || ! $args['title'] ) {
return;
}
// Allows for overriding an existing tab with that ID.
$this->_help_tabs[ $args['id'] ] = $args;
}
Related
Uses
| Uses | Description |
|---|---|
| sanitize_html_class() wp-includes/formatting.php | Sanitizes an HTML classname to ensure it only contains valid characters. |
| wp_parse_args() wp-includes/functions.php | Merges user defined arguments into defaults array. |
Used By
| Used By | Description |
|---|---|
| WP_Screen::render_screen_meta() wp-admin/includes/class-wp-screen.php | Renders the screen’s help section. |
| Custom_Image_Header::help() wp-admin/includes/class-custom-image-header.php | Adds contextual help. |
| Custom_Background::admin_load() wp-admin/includes/class-custom-background.php | Sets up the enqueue for the CSS & JavaScript files. |
Changelog
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_screen/add_help_tab