doing_filter

函式
doing_filter ( $hook_name = null )
引數
  • (string|null) $hook_name Optional. Filter hook to check. Defaults to null, which checks if any filter is currently being run.
    Required:
    Default: null
返回值
  • (bool) Whether the filter is currently in the stack.
相關
  • current_filter()
  • did_filter()
定義位置
相關方法
did_filteradd_filterlogin_footer_doing_it_wrongprivacy_ping_filter
引入
3.9.0
棄用
-

doing_filter: 這是一個WordPress的動作,當一個特定的過濾器被執行時就會被觸發。開發者可以使用這個動作在WordPress的過濾過程中的一個特定點上執行程式碼。

返回當前是否正在處理一個過濾器鉤子。

函式current_filter()只返回最近正在執行的過濾器。 did_filter()返回過濾器在當前請求中被應用的次數。
當前請求中應用過濾器的次數: 這個函式允許對當前正在執行的任何過濾器(不管它是否是最近啟動的過濾器,在從鉤子回撥呼叫的鉤子的情況下)的檢測進行驗證。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function doing_filter( $hook_name = null ) {
global $wp_current_filter;
if ( null === $hook_name ) {
return ! empty( $wp_current_filter );
}
return in_array( $hook_name, $wp_current_filter, true );
}
function doing_filter( $hook_name = null ) { global $wp_current_filter; if ( null === $hook_name ) { return ! empty( $wp_current_filter ); } return in_array( $hook_name, $wp_current_filter, true ); }
function doing_filter( $hook_name = null ) {
	global $wp_current_filter;

	if ( null === $hook_name ) {
		return ! empty( $wp_current_filter );
	}

	return in_array( $hook_name, $wp_current_filter, true );
}

常見問題

FAQs
檢視更多 >