WordPress函数文档apply_filters()

创建一个过滤器钩子,调用所有回调方法 描述 译文 调用添加到过滤器hook上的函数。在Plugin API上查…

创建一个过滤器钩子,调用所有回调方法

描述

译文

调用添加到过滤器hook上的函数。在Plugin API上查看过滤器hook列表。

通过调用该函数,可以调用附着在过滤器hook $tag上的回调函数。用$tag参数所指定的新hook的名称调用该函数,可创建一个新的过滤器hook。

原文

Call the functions added to a filter hook. See the Plugin API for a list of filter hooks.

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.

用法

 <?php apply_filters$tag$value$var ... ); ?> 

参数

$tag

(string) (必填) The name of the filter hook.

默认值: None

$value

(mixed) (必填) The value which can be modified by filters hooked to $tag

默认值: None

$var

(mixed) (可选) One or more additional variables passed to the filter functions. You can use this parameter in your function but it will not be returned. This parameter is available since Version 1.5.1.

默认值: None

示例

Echo after Filtering

Get Filtered

Additional Filter Arguments

With the_title filter

$my_custom_title will now contain ‘My Custom Title ™’, since the_title filter applies wptexturize() and trim(), among others.

历史

  • 添加于 版本: 0.71

源文件

apply_filters() 函数的代码位于 wp-includes/plugin.php.

相关

Filters:
has_filter(),
add_filter(),
apply_filters(),
current_filter(),
merge_filters(),
remove_filter(),
remove_all_filters()

  • 原文:http://codex.wordpress.org/Function_Reference/apply_filters
类别:WordPress函数文档

本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

评论 (0)COMMENT