[ class tree: functions ] [ index: functions ] [ all elements ]

Procedural File: functions-filter.php

Source Location: /functions-filter.php

Page Details

Filter functions used by zenphoto

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

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

This API is heavily inspired by the plugin API used in WordPress.

Author:  Ozh
Since:  1.3
Functions
zp_apply_filter  [line 133]

Performs a filtering operation on a zenphoto element or event.

This function is called for each zenphoto element which supports plugin filtering. It is called after any zenphoto specific actions are completed and before the element is used.

Typical use:

1) Modify a variable if a function is attached to hook 'zp_hook' $zp_var = "default value"; $zp_var = zp_apply_filter( 'zp_hook', $zp_var );

2) Trigger functions is attached to event 'zp_event' zp_apply_filter( 'zp_event' );

Returns an element which may have been filtered by a filter.

global array $_zp_filters storage for all of the filters

Parameters:
string   $hook:  the name of the zenphoto element
mixed   $value:  the value of the element before filtering


mixed zp_apply_filter( string $hook, [mixed $value = '']  )

[ Top ]
zp_filter_slot  [line 225]

Returns the position of the function in the hook queue

Parameters:
$hook   $hook: 
$function   $function: 


void zp_filter_slot( $hook $hook, $function $function  )

[ Top ]
zp_filter_unique_id  [line 85]

Build Unique ID for storage and retrieval.

Simply using a function name is not enough, as several functions can have the same name when they are enclosed in classes.

global array $_zp_filters storage for all of the filters

Parameters:
string   $hook:  hook to which the function is attached
string|array   $function:  used for creating unique id
int|bool   $priority:  used in counting how many hooks were applied. If === false and $function is an object reference, we return the unique id only if it already has one, false otherwise.
string   $type:  filter or action

API Tags:
Return:  unique ID for usage as array key


string zp_filter_unique_id( string $hook, string|array $function, int|bool $priority, string $type  )

[ Top ]
zp_has_filter  [line 201]

Check if any filter has been registered for a hook.

global array $_zp_filters storage for all of the filters

Parameters:
string   $hook:  The name of the filter hook.
callback   $function_to_check:  optional. If specified, return the priority of that function on this hook or false if not attached.

API Tags:
Return:  Optionally returns the priority on that hook for the specified function.


int|boolean zp_has_filter( string $hook, [callback $function_to_check = false]  )

[ Top ]
zp_register_filter  [line 44]

Registers a filtering function Filtering functions are used to post process zenphoto elements or to trigger functions when a filter occur

Typical use:

zp_register_filter('some_hook', 'function_handler_for_hook');

global array $_zp_filters Storage for all of the filters

Parameters:
string   $hook:  the name of the zenphoto element to be filtered
callback   $function_name:  the name of the function that is to be called.
integer   $priority:  optional. Used to specify the order in which the functions associated with a particular action are executed (default=5, lower=earlier execution, and functions with the same priority are executed in the order in which they were added to the filter)


void zp_register_filter( string $hook, callback $function_name, [integer $priority = NULL]  )

[ Top ]
zp_remove_filter  [line 176]

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 $function_to_remove and $priority arguments must match when the hook was added.

global array $_zp_filters storage for all of the filters

Parameters:
string   $hook:  The filter hook to which the function to be removed is hooked.
callback   $function_to_remove:  The name of the function which should be removed.
int   $priority:  optional. The priority of the function (default: 10).
int   $accepted_args:  optional. The number of arguments the function accpets (default: 1).

API Tags:
Return:  Whether the function was registered as a filter before it was removed.


boolean zp_remove_filter( string $hook, callback $function_to_remove, [int $priority = 10], [int $accepted_args = 1]  )

[ Top ]


Documentation generated on Tue, 20 Dec 2011 16:07:18 +0100 by phpDocumentor 1.4.3