Helper tab in wordpress
/*
* helper class for all admin pages
*/
class my_wp_helper_class {
public function __construct() {
if (defined('WP_ADMIN') && WP_ADMIN) {
global $page_hook;
$this->current_screen = get_current_screen();
if (method_exists($this, $page_hook)) {
add_action("load-".$page_hook,array($this,$page_hook));
}
}
}
/* To add helper tab
* Accept the array in $args default is shown below
* $defaults = array('title' => false,'id'=> false,'content' => '','callback' => false);
*/
protected function add_help_tab($args) {
$this->current_screen->add_help_tab($args);
}
/*
* accept the string in $content args
* $content =" sample content";
*/
protected function set_help_sidebar($content) {
$this->current_screen->$args($content);
}
public function plugin_page_my_page() { // function name must be $page_hook name echo the $page_hook in the __construct()
$options_help = 'helper message for tab1';
$this->add_help_tab(array(
'id' => 'tab1',
'title' => __('tab1'),
'content' => $options_help,
));
$options_help2 = 'helper message for tab2';
$this->add_help_tab(array(
'id' => 'tab2',
'title' => __('tab2'),
'content' => $options_help2,
));
$this->set_help_sidebar("side bar content");
}
}
add_action('current_screen', create_function('', 'new my_wp_helper_class;'));