Using WordPress ‘get_site_screen_help_tab_args()’ PHP function

The get_site_screen_help_tab_args() WordPress PHP function retrieves the arguments for the help tab on the Edit Site screens.

Usage

$help_tab_args = get_site_screen_help_tab_args();

Parameters

  • None

More information

See WordPress Developer Resources: get_site_screen_help_tab_args()

Examples

Display Help Tab Arguments

Retrieve the help tab arguments and display them in a readable format.

$help_tab_args = get_site_screen_help_tab_args();
echo '<pre>';
print_r($help_tab_args);
echo '</pre>';

Add Custom Help Tab Content

Use the retrieved help tab arguments to create a custom help tab with your own content.

function my_custom_help_tab() {
  $screen = get_current_screen();
  $help_tab_args = get_site_screen_help_tab_args();

  // Create a custom help tab with your content
  $help_tab_args['title'] = 'My Custom Help Tab';
  $help_tab_args['content'] = '<p>Here is some custom help content for the Edit Site screen.</p>';

  // Add the custom help tab to the current screen
  $screen->add_help_tab($help_tab_args);
}
add_action('admin_head', 'my_custom_help_tab');

Modify Existing Help Tab Content

Modify the existing help tab content using the retrieved help tab arguments.

function modify_help_tab_content() {
  $screen = get_current_screen();
  $help_tab_args = get_site_screen_help_tab_args();

  // Modify the existing help tab content
  $help_tab_args['content'] .= '<p>Additional information about editing a site.</p>';

  // Update the help tab with the modified content
  $screen->add_help_tab($help_tab_args);
}
add_action('admin_head', 'modify_help_tab_content');

Remove Help Tab

Remove the help tab from the Edit Site screens using the retrieved help tab arguments.

function remove_help_tab() {
  $screen = get_current_screen();
  $help_tab_args = get_site_screen_help_tab_args();

  // Remove the help tab by its ID
  $screen->remove_help_tab($help_tab_args['id']);
}
add_action('admin_head', 'remove_help_tab');

Check for Help Tab Presence

Check if a help tab is present on the Edit Site screens using the retrieved help tab arguments.

function is_help_tab_present() {
  $screen = get_current_screen();
  $help_tab_args = get_site_screen_help_tab_args();

  // Check if the help tab is present on the current screen
  if ($screen->get_help_tab($help_tab_args['id'])) {
    echo "Help tab is present.";
  } else {
    echo "Help tab is not present.";
  }
}
add_action('admin_notices', 'is_help_tab_present');