函数原型
remove_filter( string $hook_name, callable|string|array $callback, int $priority = 10 ): bool
函数描述
Removes a callback function from a filter hook.
是否弃用
未弃用
函数参数
-
$hook_name
string
Required - The filter hook to which the function to be removed is hooked.
-
$callback
callable|string|array
Required - 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. -
$priority
int
Optional - The exact priority used when adding the original filter callback.
Default:
10
函数返回值
bool Whether the function existed before it was removed.
函数位置
File: wp-includes/plugin.php.
函数源码
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;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 1.2.0 | Introduced. |

