Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

How to remove the contextual help and its tab completely from Wordpress v3.3.2? The add_filter for contextual help that used to work like wonder on older version no longer work now.

Update: (trimmed solution from Chip Bennett)

function wpse50787_remove_contextual_help() {
    $screen = get_current_screen();
    $screen->remove_help_tabs();
}
add_action( 'admin_head', 'wpse50787_remove_contextual_help' );
share|improve this question
    
What contextual help are you trying to remove: a Theme/Plugin-specific page contextual help, or all contextual help? –  Chip Bennett May 1 '12 at 17:34
    
Default wordpress contextual help for all screens. Basically the tab and anything you see when the tab drops. –  Sean Lee May 1 '12 at 17:39

1 Answer 1

up vote 3 down vote accepted

Since WordPress 3.3, contextual help tabs are added via the Screen object, using add_help_tab(). The basic structure is as follows:

<?php
$screen = get_current_screen();
$screen->add_help_tab( array(
    'id'      => 'sfc-base',
    'title'   => __('Connecting to Facebook', 'sfc'),
    'content' => "HTML for help content",
) );
?>

If you know the $id of a specific help tab, you can remove it using remove_help_tab():

<?php
$screen = get_current_screen();
$screen->remove_help_tab( $id );
?>

If you want to remove all help tabs from the current screen, use remove_help_tabs():

<?php
$screen = get_current_screen();
$screen->remove_help_tabs();
?>

You just need to wrap that in a callback hooked into admin_head, and you're good to go:

<?php
function wpse50787_remove_contextual_help() {
    $screen = get_current_screen();
    $screen->remove_help_tabs();
}
add_action( 'admin_head', 'wpse50787_remove_contextual_help' );
?>

Some of these functions aren't well-documented in the Codex yet. Try source directly; they are defined in /wp-admin/includes/screen.php.

Caveat

As-written, these functions will act globally. Most users will want to target a Theme- or Plugin-specific page for doing something like this. If you want to target a specific Theme's screens, you'll need to use the Theme-specific hook, e.g.:

<?php
global $wpse50787_options_page;
$wpse50787_options_page = add_theme_page( $args );
?>

Note that, at this point, you can also hook into the load action for your page-specific hook, to execute your contextual help callback:

<?php
global $wpse50787_options_page;
$wpse50787_options_page = add_theme_page( $args );

// Load contextual help
add_action( 'load-' . $wpse50787_options_page, 'wpse50787_remove_contextual_help' );
?>

Then, query for that hook in your callback:

<?php
function wpse50787_remove_contextual_help() {
    // Get Theme-specific page hook
    global $wpse50787_options_page;
    // Get current screen
    $screen = get_current_screen();
    // Determine if we're on our Theme-specific page
    if ( $wpse50787_options_page != $screen->id ) {
        return;
    } else {
        $screen->remove_help_tabs();
    }
}
?>
share|improve this answer
    
Just tried the code, got "Fatal error: Call to a member function remove_help_tabs() on a non-object" on this line "$screen->remove_help_tabs();" Anything else I need? –  Sean Lee May 1 '12 at 18:06
    
Try hooking into admin_head instead of admin_init? –  Chip Bennett May 1 '12 at 18:14
    
did admin_head, no more error, but the help tab and its content still stick. Any suggestion? –  Sean Lee May 1 '12 at 18:36
    
Okay, try one other hook: global $pagenow; add_action( 'load-' . $pagenow, 'wpse50787_remove_contextual_help' ); –  Chip Bennett May 1 '12 at 18:47
    
that hook doesn't work either, but I shorten your original code, and it worked. I'll edit my original post and put the code there. Thanks. –  Sean Lee May 1 '12 at 18:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.