2012-03-07, 01:53:30
This documentation is not entirely accurate.
This is how tabs work.
These are the requirements I have found, I do not know if this is as per design.
// Syntax
// add_action('nav-tab','createNavTab',array(TABNAME, PLUGINID, 'Tab Title', 'optionalarg'));
// TABNAME is a unique name for the tabs page, it is used to reference the page, eg. adding sidebars. The Tabname must be also be set as your plugins pagetype in register_plugin. It is not necessary for it to match the plugin_id but can for convenience.
// TABID is actually PLUGIN_ID and is used to identify tab selection in querystrings and ties it to the plugin itself, tab ID is the same as your Plugin_id and must match as such, or must match some other valid plugin_id.
// Tab Title is the text title on the tab.
Hope it helps someone.
This is how tabs work.
These are the requirements I have found, I do not know if this is as per design.
// Syntax
// add_action('nav-tab','createNavTab',array(TABNAME, PLUGINID, 'Tab Title', 'optionalarg'));
// TABNAME is a unique name for the tabs page, it is used to reference the page, eg. adding sidebars. The Tabname must be also be set as your plugins pagetype in register_plugin. It is not necessary for it to match the plugin_id but can for convenience.
// TABID is actually PLUGIN_ID and is used to identify tab selection in querystrings and ties it to the plugin itself, tab ID is the same as your Plugin_id and must match as such, or must match some other valid plugin_id.
// Tab Title is the text title on the tab.
Code:
# get plugin_id from plugin filename
$thisfile=basename(__FILE__, ".php");
$plugin_id = $thisfile;
$tab_name = $plugin_id; // can be unique if you so choose
# register plugin
register_plugin(
$plugin_id, //Plugin id
'pluginname', //Plugin name
'0.1', //Plugin version
'author', //Plugin author
'url', //author website
'desc', //Plugin description
$tab_name, //page type - on which admin tab to display
'tabcalloutfunc' //main function (administration)
);
add_action('nav-tab','createNavTab',array($tab_name,$plugin_id,'Plugin Tab','tabargument'));
add_action($tab_name.'-sidebar','createSideMenu',array($plugin_id,'Setup Hello World','sidebarargument'));
function tabcalloutfunc(){
echo "Hello World";
}
Hope it helps someone.