函数原型
has_action( string $hook_name, callable|string|array|false $callback = false ): bool|int
函数描述
Checks if any action has been registered for a hook.
是否弃用
未弃用
函数参数
-
$hook_name
string
Required - The name of the action hook.
-
$callback
callable|string|array|false
Optional - The callback to check for.
This function can be called unconditionally to speculatively check a callback that may or may not exist.Default:
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.
函数位置
File: wp-includes/plugin.php.
函数源码
function has_action( $hook_name, $callback = false ) {
return has_filter( $hook_name, $callback );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.5.0 | Introduced. |

