Properties

$filters

$filters : array

$filters holds list of hooks

Type

array

$mergedFilters

$mergedFilters : array

$mergedFilters

Type

array

$actions

$actions : array

$actions

Type

array

$currentFilter

$currentFilter : array

$currentFilter holds the name of the current filter

Type

array

Methods

addFilter()

addFilter(string  $tag, callback  $function_to_add, integer  $priority = 10, integer  $accepted_args = 1) : boolean

addFilter Hooks a function or method to a specific filter action.

Parameters

string $tag

The name of the filter to hook the $function_to_add to.

callback $function_to_add

The name of the function to be called when the filter is applied.

integer $priority

optional. 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.

integer $accepted_args

optional. The number of arguments the function accept (default 1).

Returns

boolean —

true

removeFilter()

removeFilter(string  $tag, callback  $function_to_remove, integer  $priority = 10) : boolean

removeFilter Removes a function from a specified filter hook.

Parameters

string $tag

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.

integer $priority

optional. The priority of the function (default: 10).

Returns

boolean —

Whether the function existed before it was removed.

removeAllFilters()

removeAllFilters(string  $tag, integer  $priority = false) : boolean

removeAllFilters Remove all of the hooks from a filter.

Parameters

string $tag

The filter to remove hooks from.

integer $priority

The priority number to remove.

Returns

boolean —

True when finished.

hasFilter()

hasFilter(string  $tag, callback  $function_to_check = false) : mixed

hasFilter Check if any filter has been registered for a hook.

Parameters

string $tag

The name of the filter hook.

callback $function_to_check

optional.

Returns

mixed —

If $function_to_check is omitted, returns boolean for whether the hook has anything registered. When checking a specific function, the priority of that hook is returned, or false if the function is not attached. When using the $function_to_check argument, this function may return a non-boolean value that evaluates to false (e.g.) 0, so use the === operator for testing the return value.

applyFilters()

applyFilters(string  $tag, mixed  $value) : mixed

applyFilters Call the functions added to a filter hook.

Parameters

string $tag

The name of the filter hook.

mixed $value

The value on which the filters hooked to $tag are applied on.

Returns

mixed —

The filtered value after all hooked functions are applied to it.

applyFiltersRefArray()

applyFiltersRefArray(string  $tag, array  $args) : mixed

applyFiltersRefArray Execute functions hooked on a specific filter hook, specifying arguments in an array.

Parameters

string $tag

The name of the filter hook.

array $args

The arguments supplied to the functions hooked to $tag

Returns

mixed —

The filtered value after all hooked functions are applied to it.

addAction()

addAction(string  $tag, callback  $function_to_add, integer  $priority = 10, integer  $accepted_args = 1) 

addAction Hooks a function on to a specific action.

Parameters

string $tag

The name of the action to which the $function_to_add is hooked.

callback $function_to_add

The name of the function you wish to be called.

integer $priority

optional. 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.

integer $accepted_args

optional. The number of arguments the function accept (default 1).

hasAction()

hasAction(string  $tag, callback  $function_to_check = false) : mixed

hasAction Check if any action has been registered for a hook.

Parameters

string $tag

The name of the action hook.

callback $function_to_check

optional.

Returns

mixed —

If $function_to_check is omitted, returns boolean for whether the hook has anything registered. When checking a specific function, the priority of that hook is returned, or false if the function is not attached. When using the $function_to_check argument, this function may return a non-boolean value that evaluates to false (e.g.) 0, so use the === operator for testing the return value.

removeAction()

removeAction(string  $tag, callback  $function_to_remove, integer  $priority = 10) : boolean

removeAction Removes a function from a specified action hook.

Parameters

string $tag

The action hook to which the function to be removed is hooked.

callback $function_to_remove

The name of the function which should be removed.

integer $priority

optional The priority of the function (default: 10).

Returns

boolean —

Whether the function is removed.

removeAllActions()

removeAllActions(string  $tag, integer  $priority = false) : boolean

removeAllActions Remove all of the hooks from an action.

Parameters

string $tag

The action to remove hooks from.

integer $priority

The priority number to remove them from.

Returns

boolean —

True when finished.

doAction()

doAction(string  $tag,   $arg = '') : null

doAction Execute functions hooked on a specific action hook.

Parameters

string $tag

The name of the action to be executed.

$arg

Returns

null —

Will return null if $tag does not exist in $filter array

doActionRefArray()

doActionRefArray(string  $tag, array  $args) : null

doActionRefArray Execute functions hooked on a specific action hook, specifying arguments in an array.

Parameters

string $tag

The name of the action to be executed.

array $args

The arguments supplied to the functions hooked to $tag

Returns

null —

Will return null if $tag does not exist in $filter array

didAction()

didAction(string  $tag) : integer

didAction Retrieve the number of times an action is fired.

Parameters

string $tag

The name of the action hook.

Returns

integer —

The number of times action hook $tag is fired

currentFilter()

currentFilter() : string

currentFilter Retrieve the name of the current filter or action.

Returns

string —

Hook name of the current filter or action.

currentAction()

currentAction() : string

Retrieve the name of the current action.

Returns

string —

Hook name of the current action.

doingFilter()

doingFilter(null|string  $filter = null) : boolean

Retrieve the name of a filter currently being processed.

The function currentFilter() only returns the most recent filter or action being executed. didAction() returns true once the action is initially processed. This function allows detection for any filter currently being executed (despite not being the most recent filter to fire, in the case of hooks called from hook callbacks) to be verified.

Parameters

null|string $filter

Optional. Filter to check. Defaults to null, which checks if any filter is currently being run.

Returns

boolean —

Whether the filter is currently in the stack

doingAction()

doingAction(string|null  $action = null) : boolean

Retrieve the name of an action currently being processed.

Parameters

string|null $action

Optional. Action to check. Defaults to null, which checks if any action is currently being run.

Returns

boolean —

Whether the action is currently in the stack.

__callAllHook()

__callAllHook(\(array)  $args) 

__callAllHook

Parameters

\(array) $args

[description]

_filterBuildUniqueID()

_filterBuildUniqueID(string  $tag, callback  $function, integer|boolean  $priority) : string|boolean

_filterBuildUniqueID Build Unique ID for storage and retrieval.

Parameters

string $tag

Used in counting how many hooks were applied

callback $function

Used for creating unique id

integer|boolean $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.

Returns

string|boolean —

Unique ID for usage as array key or false if $priority === false and $function is an object reference, and it does not already have a unique id.