wp_script_attributes
Filters attributes to be added to a script tag.
Использование
add_filter( 'wp_script_attributes', 'wp_kama_script_attributes_filter' );
/**
* Function for `wp_script_attributes` filter-hook.
*
* @param 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.
*
* @return array
*/
function wp_kama_script_attributes_filter( $attributes ){
// filter...
return $attributes;
}
- $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.
Список изменений
| С версии 5.7.0 | Введена. |
Где вызывается хук
wp_script_attributes
wp-includes/script-loader.php 2952
$attributes = apply_filters( 'wp_script_attributes', $attributes );
Где используется хук в WordPress
wp-includes/interactivity-api/class-wp-interactivity-api.php 406
add_filter( 'wp_script_attributes', array( $this, 'add_load_on_client_navigation_attribute_to_script_modules' ) );