0

I followed this tutorial: http://wp.tutsplus.com/tutorials/using-the-settings-api-part-1-create-a-theme-options-page/

There is a deprecated tag

add_contextual_help

It says to use this instead

get_current_screen()->add_help_tab()

However, I don't understand how to translate add_contextual_help to get_current_screen()->add_help_tab()

This is the block of code that uses add_contextual_help

/**
 * The Admin menu page
 */
function wptuts_add_menu(){

$settings_output        = wptuts_get_settings();
// collect our contextual help text
$wptuts_contextual_help = $settings_output['wptuts_contextual_help'];

// Display Settings Page link under the "Appearance" Admin Menu
// add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function);
$wptuts_settings_page = add_theme_page(__('Wptuts Options'), __('Wptuts Options','wptuts_textdomain'), 'manage_options', WPTUTS_PAGE_BASENAME, 'wptuts_settings_page_fn');
    // contextual help
    if ($wptuts_settings_page) {
        add_contextual_help( $wptuts_settings_page, $wptuts_contextual_help );
    }
    // css & js
    add_action( 'load-'. $wptuts_settings_page, 'wptuts_settings_scripts' );    
}

How do I do it?

0

Sorry only have time to offer a quick fix....

See where you can go from here..

/**
 * The Admin menu page
 */
function wptuts_add_menu(){

    // Display Settings Page link under the "Appearance" Admin Menu
    // add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function);
    $wptuts_settings_page = add_theme_page(__('Wptuts Options'), __('Wptuts Options','wptuts_textdomain'), 'manage_options', WPTUTS_PAGE_BASENAME, 'wptuts_settings_page_fn');

    // css & js
    add_action( 'load-'. $wptuts_settings_page, 'wptuts_settings_scripts' );
    add_action( 'load-'. $wptuts_settings_page, 'wptuts_add_help' );
}
function wptuts_add_help() {

    $screen = get_current_screen();

    if( !method_exists( $screen, 'add_help_tab' ) )
        return;

    $settings_output        = wptuts_get_settings();

    // collect our contextual help text
    $wptuts_contextual_help = $settings_output['wptuts_contextual_help'];

    $sidebar = '<ul>
        <li><a href="http://wordpress.org/extend/plugins/YOUR_PLUGIN/faq/">' . __( 'FAQ', 'your_text_domain' ) . '</a></li>
        <li><a href="http://wordpress.org/extend/plugins/YOUR_PLUGIN/other_notes/">' . __( 'Other notes', 'your_text_domain' ) . '</a></li>
        <li><a href="http://wordpress.org/extend/plugins/YOUR_PLUGIN/changelog/">' . __( 'Change Log', 'your_text_domain' ) . '</a></li>
        <li><a href="http://wordpress.org/support/plugin/YOUR_PLUGIN#topic">' . __( 'Support', 'your_text_domain' ) . '</a></li>
    </ul>';


    $screen->add_help_tab( array( 'title' => __( 'Title One', 'your_text_domain' ), 'id' => 'id1', 'content' => 'text example'));
    $screen->add_help_tab( array( 'title' => __( 'Title Two', 'your_text_domain' ), 'id' => 'id2',    'content' => 'text example'));
    $screen->add_help_tab( array( 'title' => __( 'Title Three', 'your_text_domain' ), 'id' => 'id3', 'content' => 'text example'));
    $screen->set_help_sidebar( $sidebar );
}
0

It's actually pretty easy. You're already adding your options page using add_theme_page. So add something like this:

add_action( 'load-'. $wptuts_settings_page, 'mytheme_contextual_help' );

Now, make a function to add your contextual help tabs, like so:

function mytheme_contextual_help() {
   $screen = get_current_screen();
   $screen->add_help_tab( array(
      'id'      => 'help-tab-1',
      'title'   => 'Title of the first Help Tab',
      'content' => '<p>HTML for this help tab</p>',
   ));

   $screen->add_help_tab( array(
      'id'      => 'help-tab-2',
      'title'   => 'Title of the second Help Tab',
      'content' => '<p>HTML for this help tab</p>',
   ));

}

And so forth.

You can also call set_help_sidebar in this function to add a right hand sidebar for links and similar.

More info:

http://ottopress.com/2011/new-in-wordpress-3-3-more-useful-help-screens/

http://codex.wordpress.org/Class_Reference/WP_Screen/add_help_tab

http://codex.wordpress.org/Class_Reference/WP_Screen/set_help_sidebar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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