has_action

函数


has_action ( $hook_name, $callback = false )
参数
  • (string)
    $hook_name
    The name of the action hook.
    Required:
  • (callable|string|array|false)
    $callback
    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.
    Required:
    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.
相关
  • has_filter()
定义位置
  • wp-includes/plugin.php
    , line 588
引入
2.5.0
弃用

Checks if any action has been registered for a hook.

When using the `$callback` argument, this function may return a non-boolean value
that evaluates to false (e.g. 0), so use the `===` operator for testing the return value.

function has_action( $hook_name, $callback = false ) {
	return has_filter( $hook_name, $callback );
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。