Class Bigace_Hooks

Description

The plugin API is located in this file, which allows for creating actions and filters and hooking functions, and methods. The functions or methods will then be run when the action or filter is called.

The API callback examples reference functions, but can be methods of classes. To hook methods, you'll need to pass an array one of two ways.

Any of the syntaxes explained in the PHP documentation for the 'callback' type are valid.

Also see the Plugin API for more information and examples on how to use a lot of these functions.

A list of existing hooks can be found here:

apply_filter('admin_menu', $menu); The Admin navigation structure is given in $menu, so you can customize the menu to your needs (most often you will add items).

apply_filters('edit_item_meta', array(), $item) Called before the Item Attribute screen is rendered (currently only for pages). If you want to add further input fields from your plugin, add a key/value pair entry to the first argument array. Each pair is one collapsable admin box, with "key" = box title and "value" = box content.

apply_filters('credits', $allCredits) If you want to add an entry to the credits screen, use this filter.

apply_filters('admin_portlets', $portlets, $menu, $controller) If you want to add a portlet to a portlet enabled admin screen, use this filter. The first argument is an array with all portlets instances, the second one is the name of the admin menu displaying the portlets and the last one the controller itself.

apply_filters('get_pagetypes', $pagetypes) An array of lowercased names for all available pagetypes. Pagetype names are controller names in the sense of the Zend Framework. The 'redirect' pagetypes for example points to the Bigace_RedirectController.

apply_filters('metatags', $values, $item); Send from the {metatags} Smarty TAG and Zend_View_Helper, default tags like description, author, robots. Strictly for <meta> TAGs. Only operate with the given array.

apply_filters('metatags_more', array(), $item); Send from the {metatags} Smarty TAG and Zend_View_Helper, for any additional HTML TAG in the pages <header>. Add any HTML string to the array you want.

apply_filters('create_item_meta', array(), _BIGACE_ITEM_MENU) Send from the "Create Page" dialog. See "edit_item_meta" for more infos.

apply_filters('dialog_setting_images', $vars, $id) Returns an array with the values for the image inserting/linking dialog.

apply_filters('dialog_setting_links', $vars, $id) Returns an array with the values for the cms link/url inserting dialog.

#############################################################################

do_action('update_item', $itemtype, $id, $langid, $val, $timestamp) Called when updating any Item. $val is the array with all submitted item properties. Fetch your required values from $_POST.

do_action('create_item', $this->getItemtypeID(), $id, $langid) Called when an Item was created.

do_action('page_header', $MENU) Send from the Smarty and Menu command, right before the pages layout is displayed. Register to send additional header() for example.

do_action('uninstall_community', Bigace_Community $community) Send when a community is uninstalled.

do_action('tpl_header', $MENU) inside the html head of your template do_action('tpl_footer', $MENU) in a templates footer do_action('admin_header') do_action('admin_footer') do_action('admin_html_head') do_action('application_header', $MENU) do_action('delete-item', $itemtypeID, $id, $langid) // $langid is optional

  • copyright: Copyright (c) 2009-2010 Keleo (http://www.keleo.de)
  • license: GNU Public License

Located in /Hooks.php (line 113)


	
			
Method Summary
 static void add_action (string $tag, callback $functionToAdd, [int $priority = 10], [int $acceptedArgs = 1])
 static boolean add_filter (string $tag, callback $functionToAdd, [int $priority = 10], [int $acceptedArgs = 1])
 static mixed apply_filters (string $tag, mixed $value, mixed $var,...)
 static string current_filter ()
 static int did_action (string $tag)
 static null do_action (string $tag, [ $arg = ''], mixed $arg,...)
 static int|boolean has_action (string $tag, [callback $functionToCheck = false])
 static int|boolean has_filter (string $tag, [callback $functionToCheck = false])
 static boolean remove_action (string $tag, callback $functionToRemove, [int $priority = 10], [int $acceptedArgs = 1])
 static boolean remove_filter (string $tag, callback $functionToRemove, [int $priority = 10], [int $acceptedArgs = 1])
Methods
static add_action (line 335)

Hooks a function on to a specific action.

Actions are the hooks that the BIGACE core launches at specific points during execution, or when specific events occur. Plugins can specify that one or more of its PHP functions are executed at these points, using the Action API.

The $priority is used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.

void add_action (string $tag, callback $functionToAdd, [int $priority = 10], [int $acceptedArgs = 1])
  • string $tag: The name of the action to which the <tt>$function_to-add</tt> is hooked.
  • callback $functionToAdd: The name of the function you wish to be called.
  • int $priority: optional. see above for more infos.
  • int $acceptedArgs: optional. The number of arguments the function accept (default 1).
static add_filter (line 162)

Hooks a function or method to a specific filter action.

Filters are the hooks that BIGACE launches to modify text of various types before adding it to the database or sending it to the browser screen. Plugins can specify that one or more of its PHP functions is executed to modify specific types of text at these times, using the Filter API.

To use the API, the following code should be used to bind a callback to the filter

  1.  function example_hook($exampleecho $example}
  2.  
  3.  add_filter('example_filter''example_hook');

Hooked functions can take extra arguments that are set when the matching do_action() or apply_filters() call is run. The <tt>$acceptedArgs allow for calling functions only when the number of args match. Hooked functions can take extra arguments that are set when the matching <tt>do_action()</tt> or <tt>apply_filters()</tt> call is run. For example, the action <tt>comment_id_not_found</tt> will pass any functions that hook onto it the ID of the requested comment.

<strong>Note:</strong> the function will return true no matter if the function was hooked fails or not. There are no checks for whether the function exists beforehand and no checks to whether the <tt>$functionToAdd is even a string. It is up to you to take care and this is done for optimization purposes, so everything is as quick as possible.

Thr $priority is used to specify the order in which the functions associated with a particular action are executed (default: 10). Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.

boolean add_filter (string $tag, callback $functionToAdd, [int $priority = 10], [int $acceptedArgs = 1])
  • string $tag: The name of the filter to hook the <tt>$functionToAdd</tt> to.
  • callback $functionToAdd: The name of the function to be called when the filter is applied.
  • int $priority: The priority (see above for more infos)
  • int $acceptedArgs: The number of arguments the function accept (default 1).
static apply_filters (line 193)

Call the functions added to a filter hook.

The callback functions attached to filter hook <tt>$tag</tt> are invoked by calling this function. This function can be used to create a new filter hook by simply calling this function with the name of the new hook specified using the <tt>$tag</a> parameter.

The function allows for additional arguments to be added and passed to hooks.

  1.  function example_hook($string$arg1$arg2)
  2.  {
  3.       //Do stuff
  4.       return $string;
  5.  }
  6.  $value apply_filters('example_filter''filter me''arg1''arg2');

  • return: The filtered value after all hooked functions are applied to it.
  • access: public
mixed apply_filters (string $tag, mixed $value, mixed $var,...)
  • string $tag: The name of the filter hook.
  • mixed $value: The value on which the filters hooked to <tt>$tag</tt> are applied on.
  • mixed $var,...: Additional variables passed to the functions hooked to <tt>$tag</tt>.
static current_filter (line 412)

Return the name of the current filter or action.

  • return: Hook name of the current filter or action.
  • access: public
string current_filter ()
static did_action (line 462)

Return the number times an action is fired.

  • return: The number of times action hook <tt>$tag</tt> is fired
  • access: public
int did_action (string $tag)
  • string $tag: The name of the action hook.
static do_action (line 356)

Execute functions hooked on a specific action hook.

This function invokes all functions attached to action hook <tt>$tag</tt>. It is possible to create new action hooks by simply calling this function, specifying the name of the new hook using the <tt>$tag</tt> parameter.

You can pass extra arguments to the hooks, much like you can with apply_filters().

  • return: Will return null if $tag does not exist in self::$filter array
  • see: apply_filters() This function works similar with the exception that nothing is returned and only the functions or methods are called.
  • access: public
null do_action (string $tag, [ $arg = ''], mixed $arg,...)
  • string $tag: The name of the action to be executed.
  • mixed $arg,...: Optional additional arguments which are passed on to the functions hooked to the action.
  • $arg
static has_action (line 451)

Check if any action has been registered for a hook.

  • return: Optionally returns the priority on that hook for the specified function.
  • access: public
int|boolean has_action (string $tag, [callback $functionToCheck = false])
  • string $tag: The name of the action hook.
  • callback $functionToCheck: If specified, return the priority of that function on this hook or false if not attached.
static has_filter (line 424)

Check if any filter has been registered for a hook.

  • return: Optionally returns the priority on that hook for the specified function.
  • access: public
int|boolean has_filter (string $tag, [callback $functionToCheck = false])
  • string $tag: The name of the filter hook.
  • callback $functionToCheck: If specified, return the priority of that function on this hook or false if not attached.
static remove_action (line 484)

Removes a function from a specified action hook.

This function removes a function attached to a specified action hook. This method can be used to remove default functions attached to a specific filter hook and possibly replace them with a substitute.

  • return: Whether the function is removed.
  • access: public
boolean remove_action (string $tag, callback $functionToRemove, [int $priority = 10], [int $acceptedArgs = 1])
  • string $tag: The action hook to which the function to be removed is hooked.
  • callback $functionToRemove: The name of the function which should be removed.
  • int $priority: optional The priority of the function (default: 10).
  • int $acceptedArgs: optional. The number of arguments the function accpets (default: 1).
static remove_filter (line 506)

Removes a function from a specified filter hook.

This function removes a function attached to a specified filter hook. This method can be used to remove default functions attached to a specific filter hook and possibly replace them with a substitute.

To remove a hook, the <tt>$functionToRemove</tt> and <tt>$priority</tt> arguments must match when the hook was added. This goes for both filters and actions. No warning will be given on removal failure.

  • return: Whether the function existed before it was removed.
  • access: public
boolean remove_filter (string $tag, callback $functionToRemove, [int $priority = 10], [int $acceptedArgs = 1])
  • string $tag: The filter hook to which the function to be removed is hooked.
  • callback $functionToRemove: The name of the function which should be removed.
  • int $priority: optional. The priority of the function (default: 10).
  • int $acceptedArgs: optional. The number of arguments the function accpets (default: 1).

Documentation generated on Tue, 22 Feb 2011 12:01:37 +0100 by phpDocumentor 1.4.3