How to remove contextual help on WP 3.3.2?

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' );

Related posts

Leave a Reply

1 comment

  1. 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();
        }
    }
    ?>