• Resolved olivier89

    (@olivier89)


    Hi all,
    I’ve been asking recently how to write a correct oop plugin and thnaks to the ansqwers i’ve been able to start a good skeleton.
    But i’m stuck with the help screen.
    I want to have contextual help for each of my menu/submenus
    I read this and this but i stll can’t manage to display any help screen whatsoever.
    I’m on a clean WP 3.3, so no risk of upgrade problem here.

    Here what i have sofar :
    file is myplugin1.php

    if ( ! class_exists('myplugin1') )
    {
    	class myplugin1
    	{
    		private $textdom = 'myplugin1';//traduction prefix
    
    		public function __construct()
    		{
    			if ( is_admin() )
    			{
    				$this->register_hooks();//install stuff
    				add_action('admin_menu', array(&$this, 'myplugin1_adminmenu'));
    			}
    		}
    ...
    		public function myplugin1_adminmenu()
    		{
    			$pluginpath = $this->pluginURL;
    			if (function_exists('add_menu_page'))
    			{
    				$menu_page = add_menu_page(__('My main menu page title', $this->textdom), __('My main menu title', $this->textdom), 'manage_options', 'mainmenu', array(&$this, 'mainmenu'), $pluginpath.'images/menuicon.gif' );
    			}
    			if (function_exists('add_submenu_page'))
    			{
    				$submenu_page = add_submenu_page('mainmenu', __('My main submenu page title', $this->textdom), __('My main submenu title', $this->textdom), 'manage_options', 'mysubmenu', array(&$this, 'mysubmenu') );
    			}
    		}
    		public function mainmenu()
    		{
    			echo '
    			<div class="wrap"><div id="icon-options-general" class="icon32"><br></div>
    			<h2>Main menu</h2>
    			<p>Menu content</p>
    			</div>';
    			$screen = get_current_screen();
    			$screen->add_help_tab( array(
    				'id' => $screen->id,
    				'title' => __('Menu help'),
    				'content' => __('My Help Content'),));
    		}
    		public function mysubmenu()
    		{
    			echo '
    			<div class="wrap"><div id="icon-options-general" class="icon32"><br></div>
    			<h2>Submenu</h2>
    			<p>Submenu content</p>
    			</div>';
    			$screen = get_current_screen();
    			$screen->add_help_tab( array(
    				'id' => $screen->id,
    				'title' => __('Submenu help'),
    				'content' => __('My Submenu Help Content'),));
    		}
    	}
    }
    $myplugin1_instance = new myplugin1();

    But neither the menu nor the submenu display the help.

    Is this a problem with my code or is there a specific syntax for plugin help.
    Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter olivier89

    (@olivier89)

    if i make a dump of $screen->add_help_tab, the data are here. But there is no help menu on the screen

    Does it need anything else than

    $screen = get_current_screen();
    $screen->add_help_tab( array(
    	'id' => $screen->id,
    	'title' => __('Submenu help'),
    	'content' => __('My Submenu Help Content'),));

    to display a menu tab ?
    Do i need to require some extra file before ?

    Thread Starter olivier89

    (@olivier89)

    ok, i found a solution here

    I saw nowhere else in the codex example or in the topics concerning this point that a WP_Screen object had to be used this way :

    i saw

    $screen = get_current_screen();
    $screen->add_help_tab( array( $id, $title, $content, $callback ) );

    and not

    $screen = WP_Screen::get($hook);
    $screen->add_help_tab( array( $id, $title, $content, $callback ) );

    hope this will help someone else.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add help screen to my plugin with $screen->add_help_tab’ is closed to new replies.