I have come up explaining the use of apply_filters and apply_filters_ref_array hooks .
apply_filters
The callback functions attached to filter hook $tag are invoked by calling this function. This function can be used to create a new filter hook by simply calling this function with the name of the new hook specified using the $tag parameter.
You use apply_filters to filter a given $value - with respect to the value itself as well as optionally provided variables $var_1 through $var_n.
Example:
apply_filters('the_title', ' My Custom Title ');
apply_filters_ref_array
This function is identical to apply_filters, but the only difference is that the arguments passed to the functions hooked to $tag are supplied using an array.
$args = array( 'arg_1', true, 'foo', 'arg_4' );
apply_filters_ref_array( 'my_filter', $args );
apply_filters
The callback functions attached to filter hook $tag are invoked by calling this function. This function can be used to create a new filter hook by simply calling this function with the name of the new hook specified using the $tag parameter.
You use apply_filters to filter a given $value - with respect to the value itself as well as optionally provided variables $var_1 through $var_n.
Example:
apply_filters('the_title', ' My Custom Title ');
apply_filters_ref_array
This function is identical to apply_filters, but the only difference is that the arguments passed to the functions hooked to $tag are supplied using an array.
$args = array( 'arg_1', true, 'foo', 'arg_4' );
apply_filters_ref_array( 'my_filter', $args );
No comments:
Post a Comment