apply_filters
apply_filters ( $hook_name, $value, $args )
Parameters:- (string) hook_name The name of the filter hook.
- (mixed) value The value to filter.
- (mixed) args Optional. Additional parameters to pass to the callback functions.
Returns:- (mixed) The filtered value after all hooked functions are applied to it.
Defined at:Change Log: - Introduced in WordPress: 0.71
- Deprecated in WordPress: —
Description
Calls the callback functions that have been added to a filter hook.This function invokes all functions attached to filter hook `$hook_name`.
It is possible to create new filter hooks by simply calling this function,
specifying the name of the new hook using the `$hook_name` parameter.
The function also allows for multiple additional arguments to be passed to hooks.
Example usage:
// The filter callback function.
function example_callback( $string, $arg1, $arg2 ) {
// (maybe) modify $string.
return $string;
}
add_filter( 'example_filter', 'example_callback', 10, 3 );
/*
* Apply the filters by calling the 'example_callback()' function
* that's hooked onto `example_filter` above.
*
* - 'example_filter' is the filter hook.
* - 'filter me' is the value being filtered.
* - $arg1 and $arg2 are the additional arguments passed to the callback.
$value = apply_filters( 'example_filter', 'filter me', $arg1, $arg2 );