User Tools

Site Tools


core_docs:plugin_functions

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
core_docs:plugin_functions [2016/06/04 18:13]
Tyblitz [get_styles_backend]
core_docs:plugin_functions [2018/02/09 08:56] (current)
backit [add_action]
Line 1: Line 1:
 ====== Plugin functions ====== ====== Plugin functions ======
-This page documents the GetSimpleCMS functions available from ''​admin/​inc/​plugin_functions.php''​.  +This page documents the GetSimpleCMS functions available from ''​admin/​inc/​plugin_functions.php''​.\\ 
-This page is currently ​work in progress.+The ones you will most commonly need as plugin/ theme developer are: 
 +<​code>​register_plugin,​ add_action, add_filter, createSideMenu,​ createNavTab,​ register_script,​ queue_script,​ register_style,​ queue_style</​code>​
  
 +The following functions are mostly used by GS internally:
 +<​code>​get_scripts_frontend,​ get_scripts_backend,​ get_styles_frontend,​ get_styles_backend,​ read_pluginsxml,​ create_pluginsxml,​ cdn_fallback,​ change_plugin</​code>​
 ===== add_action ===== ===== add_action =====
-**Signature:**+**Signature**
 <​code>​add_action($hook_name,​ $added_function[,​ $args])</​code>​ <​code>​add_action($hook_name,​ $added_function[,​ $args])</​code>​
-**Description:** Hooks ''​$added_function''​ in the function queue to be executed at ''​$hook_name''​.\\  + 
-**Parameters:** +**Description**\\  
-  * ''​$hook_name'',​ the name of the hook to add ''​$added_function''​ to+Hooks ''​$added_function''​ in the function queue to be executed at ''​$hook_name''​. 
 + 
 +**Parameters** 
 +  * ''​$hook_name'',​ the name of the hook to add ''​$added_function''​ to. See [[plugins:​hooks_filters|core hooks list]]
   * ''​$added_function'',​ the function you want to execute at ''​$hook_name''​   * ''​$added_function'',​ the function you want to execute at ''​$hook_name''​
   * ''​$args''​ (optional), additional arguments you can supply to the ''​$added_function''​   * ''​$args''​ (optional), additional arguments you can supply to the ''​$added_function''​
  
 ===== exec_action ===== ===== exec_action =====
-**Signature:** +**Signature** ​
 <​code>​exec_action($hook_name)</​code>​ <​code>​exec_action($hook_name)</​code>​
-**Description:** Registers a hook at the line where it is called. Other plugins can then execute a function in that hook by using ''​add_action($hook_name,'​their_function'​);''​\\  +**Description**\\  
-**Parameters:**+Registers a hook at the line where it is called. Other plugins can then execute a function in that hook by using ''​add_action($hook_name,'​their_function'​);''​ 
 + 
 +**Parameters**
   * ''​$hook_name'',​ the name of the hook to execute   * ''​$hook_name'',​ the name of the hook to execute
  
 ===== createSideMenu ===== ===== createSideMenu =====
-''''​+**Signature** 
 +<​code>​createSideMenu($id,​ $txt[, $action=null,​ $always=true])</​code>​ 
 + 
 +**Description**\\ 
 +Adds a sidebar link item to the sidebar with ''​$id'' ​as id. 
  
 **Parameters:​** **Parameters:​**
 +   ​*''​$id'',​ the id of the sidebar to output the link in
 +   ​*''​$txt'',​ the text of the sidebar item
 +   ​*''​$action''​ //​(optional)//,​ the action parameter in the link's query string. Eg, "​edit"​ will generate a link like ''​load.php?​id=myplugin&​action=edit''​
 +   ​*''​$always''​ //​(optional)//,​ set to true if the sidebar item should be loaded on every admin page with a sidebar.
 ===== createNavTab ===== ===== createNavTab =====
 **Signature** **Signature**
Line 58: Line 74:
  
 **Parameters** **Parameters**
-  * ''​$filter_name'',​ the name of the filter to hook into. Use one of the built-in filters, or one defined by a plugin.+  * ''​$filter_name'',​ the name of the filter to hook into. Use one of the [[plugins:​hooks_filters|built-in filters]], or one defined by a plugin.
   * ''​$added_function'',​ the name of a function to execute on ''​$filter_name''​.   * ''​$added_function'',​ the name of a function to execute on ''​$filter_name''​.
 ===== exec_filter ===== ===== exec_filter =====
 **Signature** **Signature**
-<​code>​exec_filter($script[, $data = array()])</​code>​+<​code>​exec_filter($filter_name[, $data = array()])</​code>​ 
 + 
 +**Description**\\ 
 +Allows filtering content passed as ''​$data''​. Functions called in ''​add_function''​ will have access to the ''​$data''​ parameter.\\  
 +These functions //must// return the modified data.
  
 **Parameters**\\ **Parameters**\\
-  * ''​$script''​ +  * ''​$filter_name'',​ the name of the filter. Other developers can add their filters by calling ''​add_filter($filter_name,​ '​their_function'​);​''​ 
-  * ''​$data''​ //​(optional)//​+  * ''​$data''​ //​(optional)//​, the data to be passed through the filter (an array of parameters). Defaults to null.
 ===== change_plugin ===== ===== change_plugin =====
 **Signature** **Signature**
Line 127: Line 147:
    * ''​$context'',​ pass "​GSBACK"​ or "​GSFRONT"​ constant as parameter, depending on where you want the script loaded    * ''​$context'',​ pass "​GSBACK"​ or "​GSFRONT"​ constant as parameter, depending on where you want the script loaded
 ===== dequeue_script ===== ===== dequeue_script =====
-''​dequeue_script($handle,​ $where)''​+**Signature** 
 +<​code>​dequeue_script($handle,​ $context)</​code>​
  
-**Parameters:**+**Description**\\ 
 +Removes a script queued with ''​register_script''​ from the script queue (effectively un-loading it). 
 + 
 +**Parameters** 
 +   ​*''​$handle'',​ identifier of the script as registered with ''​register_script''​. 
 +   ​*''​$context'',​ pass in either "​GSBACK"​ or "​GSFRONT",​ depending on where the script should be dequeued.
 ===== get_scripts_frontend ===== ===== get_scripts_frontend =====
-''​get_scripts_frontend($footer=FALSE)''​+**Signature** 
 +<​code>​get_scripts_frontend([$footer=FALSE])</​code>​
  
-**Parameters:**+**Description**\\ 
 +Outputs script tags for all scripts queued in the GSFRONT context. Is called once in the theme header, and once in the footer. 
 + 
 +**Parameters**\\ 
 +   ​*''​$footer''​ //​(optional)//,​ Whether to load scripts registered with ''​register_script''​ where the ''​$in_footer''​ parameter is either false or true. False by default.
 ===== get_scripts_backend ===== ===== get_scripts_backend =====
-''​get_scripts_backend($footer=FALSE)''​+**Signature** 
 +<​code>​get_scripts_backend([$footer=FALSE])</​code>​
  
-**Parameters:**+**Description**\\ 
 +Outputs script tags for all scripts queued in the GSBACK context. Is called once in the admin header, and once in the footer. 
 + 
 +**Parameters**\\ 
 +   ​*''​$footer''​ //​(optional)//,​ Whether to load scripts registered with ''​register_script''​ where the ''​$in_footer''​ parameter is either false or true. False by default.
 ===== cdn_fallback ===== ===== cdn_fallback =====
 **Signature** **Signature**
Line 170: Line 206:
    * ''​$context''​ //(optional but advised)//, usually you would pass "​GSBACK"​ or "​GSFRONT"​ as parameter, depending on where you want the style loaded. By default: loads it in both contexts.    * ''​$context''​ //(optional but advised)//, usually you would pass "​GSBACK"​ or "​GSFRONT"​ as parameter, depending on where you want the style loaded. By default: loads it in both contexts.
 ===== dequeue_style ===== ===== dequeue_style =====
-''​dequeue_style($handle,​$where)''​+**Signature** 
 +<​code>​dequeue_style($handle,​ $context)</​code>​
  
-**Parameters:**+**Description**\\ 
 +Removes a style queued with ''​queue_style''​ from the stylesheet queue (effectively un-loading it). 
 + 
 +**Parameters** 
 +   ​*''​$handle'',​ identifier of the style as registered with ''​register_style''​. 
 +   ​*''​$context'',​ pass in either "​GSBACK"​ or "​GSFRONT",​ depending on where the style should be dequeued.
 ===== get_styles_frontend ===== ===== get_styles_frontend =====
 **Signature** **Signature**
core_docs/plugin_functions.1465064001.txt.gz · Last modified: 2016/06/04 18:13 by Tyblitz