WP_Screen::add_help_tab()publicWP 3.3.0

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

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.

Метод класса: WP_Screen{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WP_Screen = new WP_Screen();
$WP_Screen->add_help_tab( $args );
$args(массив) (обязательный)

Array of arguments used to display the help tab.

  • title(строка)
    Title for the tab.
    По умолчанию: false

  • id(строка)
    Tab ID. Must be HTML-safe and should be unique for this menu. It is NOT allowed to contain any empty spaces.
    По умолчанию: false

  • content(строка)
    Optional. Help tab content in plain text or HTML.
    По умолчанию: empty string

  • callback(callable)
    Optional. A callback to generate the tab content.
    По умолчанию: false

  • priority(int)
    Optional. The priority of the tab, used for ordering.
    По умолчанию: 10

Список изменений

С версии 3.3.0 Введена.
С версии 4.4.0 The $priority argument was added.

Код WP_Screen::add_help_tab() WP 6.4.3

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