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