Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem adding custom nav-tab
#4
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.


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.
NEW: SA Admin Toolbar Plugin | View All My Plugins
- Shawn A aka Tablatronix
Reply


Messages In This Thread
Problem adding custom nav-tab - by ePirat - 2012-01-23, 16:57:09
Problem adding custom nav-tab - by mvlcek - 2012-01-23, 18:05:23
Problem adding custom nav-tab - by leenm - 2012-01-24, 17:33:40
Problem adding custom nav-tab - by shawn_a - 2012-03-07, 01:53:30
Problem adding custom nav-tab - by mvlcek - 2012-03-07, 02:30:33



Users browsing this thread: 1 Guest(s)