Using WordPress ‘default_contextual_help’ PHP filter

The default_contextual_help WordPress PHP filter allows you to modify the default legacy contextual help text.

Usage

add_filter('default_contextual_help', 'your_function_name');
function your_function_name($old_help_default) {
  // Your custom code here
  return $old_help_default;
}

Parameters

  • $old_help_default (string): The default contextual help text.

More information

See WordPress Developer Resources: default_contextual_help

Examples

Change the default contextual help text

Modify the default contextual help text to display custom text.

add_filter('default_contextual_help', 'change_help_text');
function change_help_text($old_help_default) {
  $new_help_text = 'This is a custom help text.';
  return $new_help_text;
}

Append custom text to the default contextual help

Add custom text to the default contextual help text.

add_filter('default_contextual_help', 'append_help_text');
function append_help_text($old_help_default) {
  $additional_text = ' This is additional help information.';
  return $old_help_default . $additional_text;
}

Remove default contextual help text

Remove the default contextual help text from the WordPress admin.

add_filter('default_contextual_help', 'remove_help_text');
function remove_help_text($old_help_default) {
  return '';
}

Display default contextual help text only for certain user roles

Show the default contextual help text only for administrators.

add_filter('default_contextual_help', 'help_text_for_admins', 10, 2);
function help_text_for_admins($old_help_default) {
  if (current_user_can('manage_options')) {
    return $old_help_default;
  }
  return '';
}

Modify default contextual help text based on the current screen

Change the default contextual help text depending on the current admin screen.

add_filter('default_contextual_help', 'help_text_based_on_screen');
function help_text_based_on_screen($old_help_default) {
  $screen = get_current_screen();
  if ('post' == $screen->id) {
    return 'This is the help text for the Posts screen.';
  } elseif ('page' == $screen->id) {
    return 'This is the help text for the Pages screen.';
  }
  return $old_help_default;
}