I have a function, which I'd like to pass as an argument to multiple functions. Is there a way to do this with anonymous functions, in one 'line'.
This is what it looks like without an anonymous function:
function my_function( $input ) {
return $input;
}
add_filter( 'filter_one', 'my_function' );
add_filter( 'filter_two', 'my_function' );
Here's what calling add_filter once with the anonymous setup would look like:
add_filter( 'filter_one', function ( $input ) {
return $input;
});
Does the syntax exist in PHP to do the same for filter_two without re-writing the function that's the argument?