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/03/06 16:29]
mvlcek [Side Menu Creation Function]
plugins:tabs_menus [2014/01/04 11:14]
Everyone [Tab Creation Function]
Line 3: Line 3:
 You can add menu links to any of GetSimple'​s tabs with the following code You can add menu links to any of GetSimple'​s tabs with the following code
  
-<​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 add an optional ​3rd parameter ​in the params array:
  
-<​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 ​**//​my-action//​** is added to the link so 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 ​in the params array as ''​false'':​
  
 <​code>​ <​code>​
-add_action('​xxxxxx-sidebar','​createSideMenu',​array('​your-plugin-filename','​Show ​list of It', '​list'​));​ +add_action( '​xxxxxx-sidebar',​ '​createSideMenu',​ array( '​your-plugin-filename',​ 'Show It', '​list'​ ) ); 
-add_action('​xxxxxx-sidebar','​createSideMenu',​array('​your-plugin-filename','​Edit It', '​edit',​ false));+add_action( '​xxxxxx-sidebar',​ '​createSideMenu',​ array( '​your-plugin-filename',​ 'Edit It', '​edit',​ false ) );
 </​code>​ </​code>​
  
Line 29: Line 29:
 # register plugin # register plugin
 register_plugin( register_plugin(
- $thisfile, //Plugin id+ $thisfile, ​     //Plugin id
  '​Hello World',​ //Plugin name  '​Hello World',​ //Plugin name
  '​1.0',​ //Plugin version  '​1.0',​ //Plugin version
Line 35: Line 35:
  '​http://​www.cagintranet.com/',​ //author website  '​http://​www.cagintranet.com/',​ //author website
  '​Finds email addresses in content and components and "​hides"​ them', //Plugin description  '​Finds email addresses in content and components and "​hides"​ them', //Plugin description
- @$_GET['​id'​] == $thisfile && @$_GET['​action'​] == '​setup'​ ? '​plugins'​ : '​theme',​  +  @$_GET['​id'​] == $thisfile && @$_GET['​action'​] == '​setup'​ ? '​plugins'​ : '​theme',​  
- //page type - on which admin tab to display+  //page type - on which admin tab to display
  '​hello_world_show' ​ //main function (administration)  '​hello_world_show' ​ //main function (administration)
 ); );
  
-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>​ </​code>​
  
Line 47: Line 47:
 <​code>​ <​code>​
 function hello_world_show() { function hello_world_show() {
-  if (@$_GET['​action'​] ​== '​setup'​) {+  if ( isset ( $_GET['​setup'] ) {
     ...     ...
-  } else if (@$_GET['​action'​] ​== '​show'​) {+  } elseif ( isset ( $_GET['​show'] ) {
     ...     ...
   }   }
Line 60: Line 60:
  
 <​code>​ <​code>​
-add_action('​nav-tab','​createNavTab',​array('​thetabname','​your-plugin-filename','​Tab Text', '​my-action'​));​+add_action( '​nav-tab',​ '​createNavTab',​ array( '​thetabname',​ '​your-plugin-filename',​ 'Tab Text', '​my-action'​ ) );
 </​code>​ </​code>​
  
Line 67: Line 67:
  
 <​code>​ <​code>​
-add_action('​thetabname-sidebar',​ ...); // e.g. '​newsmanager-sidebar'​+add_action( '​thetabname-sidebar',​ ... ); // e.g. '​newsmanager-sidebar'​
 </​code>​ </​code>​
  
  
 Only use this functionality,​ 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