首页 WordPress函数大全 apply_filters()

apply_filters()

2020-05-01 / 4699阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

apply_filters( string $tag, mixed $value )

Calls the callback functions that have been added to a filter hook.

描述

The callback functions attached to the filter hook 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.

The function also allows for multiple additional arguments to be passed to hooks.

Example usage:

// 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>

参数

$tag

(string)
(Required)
The name of the filter hook.

$value

(mixed)
(Required)
The value to filter.

$args

(mixed)
(Required)
Additional parameters to pass to the callback functions.

返回

(mixed) The filtered value after all hooked functions are applied to it.

大家谈论
    我的见解