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.


$idstringtrue-The filter ID.
$callbackcallbacktrue-The name of the function you wish to be called. Inline content will automatically create an anonymous function.
$priorityintfalse10Used 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.
$argsintfalse1The number of arguments the function accepts. Default 1.


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 );