Skip to content

Instantly share code, notes, and snippets.

@ControlledChaos
Last active July 6, 2018 05:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ControlledChaos/bbb40ca9a28c22c57201cc881fd7ec18 to your computer and use it in GitHub Desktop.
Save ControlledChaos/bbb40ca9a28c22c57201cc881fd7ec18 to your computer and use it in GitHub Desktop.

Remove Contextual Help and Screen Options

WordPress Snippet

These funtions do not remove individual tabs. It simply removes the functionality altogether.

<?php
/**
* Removes the contextual help tab.
*
* @param array $old_help
* @param int $screen_id
* @param obj $screen
* @return array Returns the amended array of tabs.
*/
function ccd_remove_help_tabs( $old_help, $screen_id, $screen ) {
$screen->remove_help_tabs();
return $old_help;
}
add_filter( 'contextual_help', 'ccd_remove_help_tabs', 999, 3 );
/**
* Removes screen options tab.
*
* @param boolean $display_boolean
* @param object $wp_screen_object
* @return boolean Returns false for the screens in the array.
*/
function ccd_remove_screen_options( $display_boolean, $wp_screen_object ) {
$blacklist = array(
'post.php',
'post-new.php',
'index.php',
'edit.php'
);
if ( in_array( $GLOBALS['pagenow'], $blacklist ) ) {
$wp_screen_object->render_screen_layout();
$wp_screen_object->render_per_page_options();
return false;
}
return true;
}
add_filter( 'screen_options_show_screen', 'ccd_remove_screen_options', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment