• Posted: 2012-08-14
  • Author: Damian
  • Tags:

Add contextual help tabs on any admin page

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
<?php

function mqw_example_contextual_help( $contextual_help, $screen_id) {
    
   # Uncomment this to see actual screen
   # echo 'Screen ID = '.$screen_id.'<br />';
     
    switch( $screen_id ) {
        case 'toplevel_page_settings_page' :
     // To add a whole tab group
            get_current_screen()->add_help_tab( array(
            'id'        => 'my-help-tab',
            'title'     => __( 'How to get started?' ),
            'content'   => __( 'Put any text here bla bla bla ....' )
            ) );
            
            break;
        case 'mi_plugin_page' :
            //Just to modify text of first tab
            $contextual_help .= '<p>';
            $contextual_help = __( 'Your text here.' );
            $contextual_help .= '</p>';
            break;
    }
    return $contextual_help;
}
add_filter('contextual_help', 'mqw_example_contextual_help', 10, 2);
?>

Instructions:

Place this on functions.php or in your plugin file. Create as many helps tabs you need by switching the $screen_id.

Uncomment the echo line to see the current page id.


Related links:
http://www.masquewordpress.com/como-anadir-pestanas-de-ayuda-en-themes-o-plugins/
Share this snippet

If you like this snippet, share it with friends!