wp_inline_script_attributes filter-hookWP 5.7.0

Filters attributes to be added to a script tag.

Usage

add_filter( 'wp_inline_script_attributes', 'wp_kama_inline_script_attributes_filter', 10, 2 );

/**
 * Function for `wp_inline_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.
 * @param string $javascript Inline JavaScript code.
 *
 * @return array
 */
function wp_kama_inline_script_attributes_filter( $attributes, $javascript ){

	// filter...
	return $attributes;
}
$attributes(array)
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.
$javascript(string)
Inline JavaScript code.

Changelog

Since 5.7.0 Introduced.

Where the hook is called

wp_get_inline_script_tag()
wp_inline_script_attributes
wp-includes/script-loader.php 2731
$attributes = apply_filters( 'wp_inline_script_attributes', $attributes, $javascript );

Where the hook is used in WordPress

Usage not found.