WP_Screen::add_help_tab( array $args )

Add a help tab to the contextual help for the screen.


Description Description

Call this on the load-$pagenow hook for the relevant screen.


Parameters Parameters

$args

(array) (Required) Array of arguments used to display the help tab.

  • 'title'
    (string) Title for the tab. Default false.
  • 'id'
    (string) Tab ID. Must be HTML-safe. Default false.
  • 'content'
    (string) Optional. Help tab content in plain text or HTML. Default empty string.
  • 'callback'
    (string) Optional. A callback to generate the tab content. Default false.
  • 'priority'
    (int) Optional. The priority of the tab, used for ordering. Default 10.


Top ↑

Source Source

File: wp-admin/includes/class-wp-screen.php

	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;
	}

Top ↑

Changelog Changelog

Changelog
Version Description
4.4.0 The $priority argument was added.
3.3.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

  1. Skip to note content
    Contributed by Pratik Shrestha
    add_filter( 'contextual_help', 'my_admin_help', 5, 3 );
    function my_admin_help( $old_help, $screen_id, $screen ) {
    	// Not our screen, exit earlier
        if( 'my-admin' != $screen_id ) {
            return;
        }
    
        // Add one help tab
        $screen->add_help_tab( array(
            'id'      => 'my-admin-help',
            'title'   => esc_html__( 'My Help Tab', 'my-text-domain' ),
            'content' => '<p>' . esc_html__( 'Descriptive content that will show in My Help Tab-body goes here.', 'my-text-domain' ) . '</p>',
    		// Use 'callback' to use callback function to display tab content
        ) );
    
        // This sets the sidebar for help screen, if required
        get_current_screen()->set_help_sidebar(
            '<p><strong>' . esc_html__( 'For more information:', 'my-text-domain' ) . '</strong></p>' .
            '<p><a href="https://wordpress.org/">WordPress</a></p>' .
            '<p><a href="https://wordpress.org/support/" target="_blank">' . esc_html__( 'Support Forums', 'my-text-domain' ) . '</a></p>'
        );
    
        return $old_help;
    }

You must log in before being able to contribute a note or feedback.