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.

I wish to edit the text in the dashboard's help tab. I can add help to other pages, but I want to change the text in the grey box with links on the right-hand side of the help tab.

It is on the 'For more information:' section. I want to add links to my support page and not the WordPress support forum.

function my_contextual_help( $contextual_help, $screen_id, $screen ) {
    if ( 'product' == $screen->id ) {
        $contextual_help = '<h2>Products</h2>
                            <p>Products show the details of the items that we sell on the website. You can see a list of them on this page in reverse chronological order - the latest one we added is first.</p> 
                            <p>You can view/edit the details of each product by clicking on its name, or you can perform bulk actions using the dropdown menu and selecting multiple items.</p>';

    }
    return $contextual_help;
}

add_action( 'contextual_help', 'my_contextual_help', 10, 3 );

This adds the left tab 'Products' with help text in the middle, but it has no right section. How could I add this?

enter image description here

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

The documentation in the Codex seems outdated.

Use the following code (see comments):

// Priority 5 allows the removal of default tabs and insertion of other plugin's tabs 
add_filter( 'contextual_help', 'wpse_77308_products_help', 5, 3 );

function wpse_77308_products_help( $old_help, $screen_id, $screen )
{
    // Not our screen, exit earlier
    // Adjust for your correct screen_id, see plugin recommendation bellow
    if( 'edit-magazine' != $screen_id )
        return;

    // Remove default tabs
    $screen->remove_help_tabs();

    // Add one help tab
    // For new ones: duplicate this, change id's and create custom callbacks
    $screen->add_help_tab( array(
        'id'      => 'products-help',
        'title'   => 'Products',
        'content' => '', // left empty on purpose, we use the callback bellow
        'callback' => 'wpse_77308_print_help'
    ));

    // This sets the sidebar, which is common for all tabs of this screen
    get_current_screen()->set_help_sidebar(
        '<p><strong>' . __('For more information:') . '</strong></p>' .
        '<p>' . __('<a href="http://wordpress.stackexchange.com/" title="WordPress StackExchange" target="_blank">WordPress Answers</a>') . '</p>' .
        '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    );

    return $old_help;
}


function wpse_77308_print_help()
{
    echo '
        <p>Products show the details of the items that we sell on the website. 
        You can see a list of them on this page in reverse chronological order 
        - the latest one we added is first.</p> 

        <p>You can view/edit the details of each product
        by clicking on its name, or you can perform bulk actions 
        using the dropdown menu and selecting multiple items.</p>
    ';
}

Result:

cpt help tab


To get the right $screen_id, use the plugin Current Admin Info, born from two great Stack contributors (kaiser and Stephen Harris).

Displays info about the current admin screen and its globals, contextual hooks, etc.

The info appears in new tabs in the »Contextual Help«-panel in the upper right corner of an admin screen.

share|improve this answer
    
Thanks for the more in depth code. However what I am looking for is to include the right section, such as the on in the dashboard help tab. It is called For more information: –  Keith Dec 26 '12 at 22:35
    
@Keith, add detailed description (with screenshot, if possible) to the Question itself. The better the Q, the better the Answer... –  brasofilo Dec 27 '12 at 11:09
    
sorry, I am not explaining it right for you. I have included a screenshot now. It is the section marked with the green arrow. This is the area I wish to edit. –  Keith Dec 27 '12 at 13:16
    
@Keith, updated the Answer to include the sidebar. I really think it would be beneficial if you posted in your Question the full code you are using to add the help tab. –  brasofilo Dec 27 '12 at 17:09
    
thanks for the help, that worked perfectly :-) –  Keith Dec 28 '12 at 17:13
add comment

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.