wp_script_is

函式
wp_script_is ( $handle, $list = 'enqueued' )
引數
  • (string) $handle Name of the script.
    Required:
  • (string) $list Optional. Status of the script to check. Default 'enqueued'. Accepts 'enqueued', 'registered', 'queue', 'to_do', and 'done'.
    Required:
    Default: 'enqueued'
返回值
  • (bool) Whether the script is queued.
定義位置
相關方法
wp_scriptswp_creditswp_print_scriptswp_style_iswp_get_script_tag
引入
2.8.0
棄用
-

wp_script_is: 這是一個WordPress的函式,用來檢查一個指令碼是否被排在頁面上。它允許你檢查一個指令碼是否已經被載入,如果是的話,它是否被載入在頁面的頁首或頁尾。

確定一個指令碼是否已經被新增到佇列中。

關於這個和類似主題函式的更多資訊,請檢視《主題開發者手冊》中的{@link Conditional Tags}一文。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_script_is( $handle, $list = 'enqueued' ) {
_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );
return (bool) wp_scripts()->query( $handle, $list );
}
function wp_script_is( $handle, $list = 'enqueued' ) { _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle ); return (bool) wp_scripts()->query( $handle, $list ); }
function wp_script_is( $handle, $list = 'enqueued' ) {
	_wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );

	return (bool) wp_scripts()->query( $handle, $list );
}

常見問題

FAQs
檢視更多 >