did_action

函式
did_action ( $hook_name )
引數
  • (string) $hook_name The name of the action hook.
    Required:
返回值
  • (int) The number of times the action hook has been fired.
定義位置
相關方法
add_actiondo_actiondoing_actionhas_actionadd_option
引入
2.1.0
棄用
-

did_action是WordPress的一個函式,用來確定某個動作是否已經被執行: 這個函式把一個動作的名稱作為引數,並返回一個布林值,表示該動作是否已經被執行。

檢索一個動作在當前請求中被觸發的次數。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function did_action( $hook_name ) {
global $wp_actions;
if ( ! isset( $wp_actions[ $hook_name ] ) ) {
return 0;
}
return $wp_actions[ $hook_name ];
}
function did_action( $hook_name ) { global $wp_actions; if ( ! isset( $wp_actions[ $hook_name ] ) ) { return 0; } return $wp_actions[ $hook_name ]; }
function did_action( $hook_name ) {
	global $wp_actions;

	if ( ! isset( $wp_actions[ $hook_name ] ) ) {
		return 0;
	}

	return $wp_actions[ $hook_name ];
}

常見問題

FAQs
檢視更多 >