has_filter()
最后更新于:2021-11-27 04:51:57
has_filter( string$hook_name, callable|false$callback=false)Checks if any filter has been registered for a hook.
参数
- $hook_name
-
(string) (Required) The name of the filter hook.
- $callback
-
(callable|false) (Optional) The callback to check for.
Default value: false
响应
(bool|int) If $callback
is omitted, returns boolean for whether the hook has anything registered. When checking a specific function, the priority of that hook is returned, or false if the function is not attached.
源文件
文件: gc-includes/plugin.php
function has_filter( $hook_name, $callback = false ) {
global $gc_filter;
if ( ! isset( $gc_filter[ $hook_name ] ) ) {
return false;
}
return $gc_filter[ $hook_name ]->has_filter( $hook_name, $callback );
}