did_action()
did_action( string $tag )
检索触发操作的次数。
Retrieve the number of times an action is fired.
参数(Parameters)
参数 | 类型 | 必填 | 说明 |
---|---|---|---|
$tag | (string) | 必需 | 动作挂钩的名称。 |
返回(Return)
(int)触发action hook$标记的次数。
源码(Source)
/** * Retrieve the number of times an action is fired. * * @since 2.1.0 * * @global array $wp_actions Increments the amount of times action was triggered. * * @param string $tag The name of the action hook. * @return int The number of times action hook $tag is fired. */ function did_action($tag) { global $wp_actions; if ( ! isset( $wp_actions[ $tag ] ) ) return 0; return $wp_actions[$tag]; }
更新版本 | 源码位置 | 使用 | 被使用 |
---|---|---|---|
2.1.0 | wp-includes/plugin.php:493 | 36 | 0 |
笔记(Notes)
例子
did_action() 为WP2原创文章,链接:https://www.wp2.cn/functions/did_action/