User Tools

Site Tools


plugins:tabs_menus

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
plugins:tabs_menus [2012/01/24 15:59]
mvlcek [Tab Creation Function]
plugins:tabs_menus [2013/04/19 15:04]
127.0.0.1 external edit
Line 5: Line 5:
 <​code>​add_action('​xxxxxx-sidebar','​createSideMenu',​array('​your-plugin-filename','​Menu Text'​));</​code>​ <​code>​add_action('​xxxxxx-sidebar','​createSideMenu',​array('​your-plugin-filename','​Menu Text'​));</​code>​
  
-Replace xxxxxx-sidebar with the sidebar you want(e.g.: backups-sidebar,​ files-sidebar,​ pages-sidebar,​ plugins-sidebar,​ settings-sidebar,​ support-sidebar or theme-sidebar)+Replace ​''​xxxxxx-sidebar'' ​with the sidebar you want(e.g.: ​''​backups-sidebar''​''​files-sidebar''​''​pages-sidebar''​''​plugins-sidebar''​''​settings-sidebar''​''​support-sidebar'' ​or ''​theme-sidebar''​)
  
-(3.1+) If you want to add multiple links for your plugin, you can use the optional parameter action:+(3.1+) If you want to add multiple links for your plugin, you can use the optional parameter ​''​action''​:
  
 <​code>​add_action('​xxxxxx-sidebar','​createSideMenu',​array('​your-plugin-filename','​Menu Text', '​my-action'​));</​code>​ <​code>​add_action('​xxxxxx-sidebar','​createSideMenu',​array('​your-plugin-filename','​Menu Text', '​my-action'​));</​code>​
  
-This way a new parameter action=my-action is added to the link and you can determine which link was clicked.+This way a new parameter ​//action=my-action// is added to the link and you can determine which link was clicked.
  
-(3.1+) If you want a functionality like the "Edit Page" link which only shows if the function is active, add a 4th parameter false:+(3.1+) If you want a functionality like the "Edit Page" link which only shows if the function is active, add a 4th parameter ​''​false''​:
  
 <​code>​ <​code>​
Line 20: Line 20:
 </​code>​ </​code>​
  
-When you click the newly created menu link, the function you registered in register_plugin() will be called, and unless you specified the page your new menu link is on in the 7th argument of register_plugin(),​ the side menu will disappear.+When you click the newly created menu link, the function you registered in ''​register_plugin()'' ​will be called, and unless you specified the page your new menu link is on in the 7th argument of ''​register_plugin()''​, the side menu will disappear.
  
-Thus if you add side bar links to two different tabs, you need to change this parameter dynamically,​ e.g.+Thus if you add side bar links to two different tabs, you need to change this parameter dynamically,​ e.g. (setup on the plugins tab, other functionality on theme tab):
  
 <​code>​ <​code>​
Line 42: Line 42:
 add_action('​plugins-sidebar','​createSideMenu',​array($thisfile,'​Setup Hello World','​setup'​));​ add_action('​plugins-sidebar','​createSideMenu',​array($thisfile,'​Setup Hello World','​setup'​));​
 add_action('​theme-sidebar','​createSideMenu',​array($thisfile,'​Show Hello World','​show'​));​ add_action('​theme-sidebar','​createSideMenu',​array($thisfile,'​Show Hello World','​show'​));​
 +</​code>​
 +
 +If you have multiple sidebar items like above, your main function (here //​hello_world_show//​) would look like this:
 +<​code>​
 +function hello_world_show() {
 +  if (@$_GET['​action'​] == '​setup'​) {
 +    ...
 +  } else if (@$_GET['​action'​] == '​show'​) {
 +    ...
 +  }
 +}
 </​code>​ </​code>​
  
Line 49: Line 60:
  
 <​code>​ <​code>​
-add_action('​nav-tab','​createNavTab',​array('​thetabname','​your-plugin-filename','​Menu Text', '​my-action'​));​+add_action('​nav-tab','​createNavTab',​array('​thetabname','​your-plugin-filename','​Tab Text', '​my-action'​));​
 </​code>​ </​code>​
  
-Use a unique name for the tab, e.g. your plugin name like 'newsmanager'. Also use this name for the page type in register_plugin(). The action parameter is again optional.+Use a unique name for the tab, e.g. your plugin name like //newsmanager//. Also use this name for the page type in ''​register_plugin()''​. The ''​action'' ​parameter is again optional.
 You can then add sidebar links for this tab with You can then add sidebar links for this tab with
  
Line 60: Line 71:
  
  
-Only use this function, if you need a lot of side bar links for you plugin and want to group them.+Only use this functionality, if you need a lot of side bar links for you plugin and want to group them.
plugins/tabs_menus.txt ยท Last modified: 2014/02/07 10:02 by datiswous