apply_filters
-
Hi,
I want to ask a point that I don’t understand.
(https://developer.www.ads-software.com/reference/functions/apply_filters/#parameters)1-) The $ args parameter is called “mandatory”, but it may not be defined in the examples. So, $ tag and $ value should definitely be found. Therefore, 2 parameter apply_filters can be defined. Did I get it wrong? Isn’t the undefined value in such a scenario $ args?
2-) Can $ arg1 and $ arg2 be changed in the example_callback function in a definition like the one below? If no, are these arguments ($ args1 and $ args2) just operable arguments? Just like actions?
// 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 <code>example_filter</code> 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 ); ?>
For example:
function example_callback( $string, $arg1, $arg2 ) { $args1 ['hierarchical'] = true; return $args; }
Is it right ?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘apply_filters’ is closed to new replies.