函数原型
did_action( string $hook_name ): int
函数描述
Retrieves the number of times an action has been fired during the current request.
是否弃用
未弃用
函数参数
-
$hook_name
string
Required - The name of the action hook.
函数返回值
int The number of times the action hook has been fired.
函数位置
File: wp-includes/plugin.php.
函数源码
function did_action( $hook_name ) {
global $wp_actions;
if ( ! isset( $wp_actions[ $hook_name ] ) ) {
return 0;
}
return $wp_actions[ $hook_name ];
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |

