wp_script_attributes

過濾鉤子
apply_filters( 'wp_script_attributes', $attributes )
引數
  • (array) $attributes Key-value pairs representing `<script>` tag attributes. Only the attribute name is added to the `<script>` tag for entries with a boolean value, and that are true.
    Required:
定義位置
相關勾子
wp_inline_script_attributeswp_kses_uri_attributesprevious_posts_link_attributespage_menu_link_attributesnav_menu_link_attributes
相關方法
wp_sanitize_script_attributeswp_kses_uri_attributeswp_script_iswp_scriptswp_script_add_datawp_list_categories
引入
5.7.0
棄用
-

wp_script_attributes: 這是一個 WordPress 內建的函式,用於新增 JavaScript 指令碼的屬性: 該函式接收兩個引數:第一個是 JavaScript 指令碼的名稱,第二個是需要新增的屬性陣列: 該函式會在載入 JavaScript 指令碼前將這些屬性新增到指令碼標籤中。

過濾器屬性將被新增到指令碼標籤中。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$attributes = apply_filters( 'wp_script_attributes', $attributes );
$attributes = apply_filters( 'wp_script_attributes', $attributes );
$attributes = apply_filters( 'wp_script_attributes', $attributes );

常見問題

FAQs
檢視更多 >