remove_filter
函数
remove_filter ( $hook_name, $callback, $priority = 10 )
- 参数
-
-
(string)
$hook_name
The filter hook to which the function to be removed is hooked.- Required: 是
-
(callable|string|array)
$callback
The callback to be removed from running when the filter is applied. This function can be called unconditionally to speculatively remove a callback that may or may not exist.- Required: 是
-
(int)
$priority
Optional. The exact priority used when adding the original filter callback. Default 10.- Required: 否
- Default: 10
-
(string)
- 返回值
-
- (bool) Whether the function existed before it was removed.
- 定义位置
-
-
wp-includes/plugin.php
, line 313
-
wp-includes/plugin.php
- 引入
- 1.2.0
- 弃用
- –
从一个过滤器钩子上删除一个回调函数。
这可以用来移除附加在特定过滤器钩子上的默认函数,并可能用一个替代品来替代它们。
要删除一个钩子,`$callback`和`$priority`参数必须与钩子被添加时相匹配。这对过滤器和动作都适用。移除失败时不会有任何警告。
function remove_filter( $hook_name, $callback, $priority = 10 ) { global $wp_filter; $r = false; if ( isset( $wp_filter[ $hook_name ] ) ) { $r = $wp_filter[ $hook_name ]->remove_filter( $hook_name, $callback, $priority ); if ( ! $wp_filter[ $hook_name ]->callbacks ) { unset( $wp_filter[ $hook_name ] ); } } return $r; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。