Hooks a function or method to a specific filter action.
This function is similar to add_filter() with the exception that it accepts a $callback argument which is used to automatically create an anonymous function.
beans_add_filter( string $id, callback $callback, int $priority = 10, int $args = 1 )
Return: (bool) Will always return true.
Parameters
Name | Type | Required | Default | Description |
---|---|---|---|---|
$id | string | true | - | The filter ID. |
$callback | callback | true | - | The name of the function you wish to be called. Inline content will automatically create an anonymous function. |
$priority | int | false | 10 | 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. |
$args | int | false | 1 | The number of arguments the function accepts. Default 1. |
Source
function beans_add_filter( $id, $callback, $priority = 10, $args = 1 ) {
if ( is_callable( $callback ) ) {
return add_filter( $id, $callback, $priority, $args );
}
return _beans_add_anonymous_filter( $id, $callback, $priority, $args );
}