从指定的筛选器挂钩中删除函数。
原型
remove_filter( string $tag, callable $function_to_remove, int $priority = 10 )
描述
此函数删除附加到指定筛选器挂钩的函数。此方法可用于删除附加到特定筛选器挂钩的默认函数,并可能用替换替换它们。
参数
$tag
(string)
(Required)
挂钩功能要挂钩的过滤器挂钩。
$function_to_remove
(callable)
(Required)
应删除的函数的名称。
$priority
(int)
(Optional)
功能的优先级。
返回值
(bool)
功能是否在删除之前存在。
源文件
路径:wp-includes/plugin.php
<?php
...
function remove_filter( $tag, $function_to_remove, $priority = 10 ) {
global $wp_filter;
$r = false;
if ( isset( $wp_filter[ $tag ] ) ) {
$r = $wp_filter[ $tag ]->remove_filter( $tag, $function_to_remove, $priority );
if ( ! $wp_filter[ $tag ]->callbacks ) {
unset( $wp_filter[ $tag ] );
}
}
return $r;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/remove_filter/