*
    	 *     <script>console.log('&hellip;');</script>
    	 *
    	 *     In an HTML document this would print "&hellip;" to the console,
    	 *     but in an XHTML document it would print "…" to the console.
    	 *
    	 *     <script>console.log('An image is <img> in HTML');</script>
    	 *
    	 *     In an HTML document this would print "An image is <img> in HTML",
    	 *     but it's an invalid XHTML document because it interprets the `<img>`
    	 *     as an empty tag missing its closing `/`.
    	 *
    	 * @see https://www.w3.org/TR/xhtml1/#h-4.8
    	 */
    	if (
    		! $is_html5 &&
    		(
    			! isset( $attributes['type'] ) ||
    			'module' === $attributes['type'] ||
    			str_contains( $attributes['type'], 'javascript' ) ||
    			str_contains( $attributes['type'], 'ecmascript' ) ||
    			str_contains( $attributes['type'], 'jscript' ) ||
    			str_contains( $attributes['type'], 'livescript' )
    		)
    	) {
    		/*
    		 * If the string `]]>` exists within the JavaScript it would break
    		 * out of any wrapping CDATA section added here, so to start, it's
    		 * necessary to escape that sequence which requires splitting the
    		 * content into two CDATA sections wherever it's found.
    		 *
    		 * Note: it's only necessary to escape the closing `]]>` because
    		 * an additional `<![CDATA[` leaves the contents unchanged.
    		 */
    		$data = str_replace( ']]>', ']]]]><![CDATA[>', $data );
    
    		// Wrap the entire escaped script inside a CDATA section.
    		$data = sprintf( "/* <![CDATA[ */\n%s\n/* ]]> */", $data );
    	}
    
    	$data = "\n" . trim( $data, "\n\r " ) . "\n";
    
    	/**
    	 * Filters attributes to be added to a script tag.
    	 *
    	 * @since 5.7.0
    	 *
    	 * @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 $data       Inline data.
    	 */
    	$attributes = apply_filters( 'wp_inline_script_attributes', $attributes, $data );
    
    	return sprintf( "<script%s>%s</script>\n", wp_sanitize_script_attributes( $attributes ), $data );
    }
    

[ View all references ](https://developer.wordpress.org/reference/files/wp-
includes/script-loader.php/) [ View on Trac
](https://core.trac.wordpress.org/browser/tags/6.5/src/wp-includes/script-
loader.php#L2849) [ View on GitHub ](https://github.com/WordPress/wordpress-
develop/blob/6.5/src/wp-includes/script-loader.php#L2849-L2924)

##  Hooks

[ apply_filters  ( ‘wp_inline_script_attributes’,  array  $attributes  ,
string  $data  )
](https://developer.wordpress.org/reference/hooks/wp_inline_script_attributes/)

    

Filters attributes to be added to a script tag.

##  Related

Uses  |  Description   
---|---  
[ wp_sanitize_script_attributes() ](https://developer.wordpress.org/reference/functions/wp_sanitize_script_attributes/) ` wp-includes/script-loader.php ` |  Sanitizes an attributes array into an attributes string to be placed inside a ` ` tag.   
[ current_theme_supports() ](https://developer.wordpress.org/reference/functions/current_theme_supports/) ` wp-includes/theme.php ` |  Checks a theme’s support for a given feature.   
[ is_admin() ](https://developer.wordpress.org/reference/functions/is_admin/) ` wp-includes/load.php ` |  Determines whether the current request is for an administrative interface page.   
[ apply_filters() ](https://developer.wordpress.org/reference/functions/apply_filters/) ` wp-includes/plugin.php ` |  Calls the callback functions that have been added to a filter hook.   
Show 2 more  Show less  Used by  |  Description   
---|---  
[ WP_Scripts::get_inline_script_tag() ](https://developer.wordpress.org/reference/classes/wp_scripts/get_inline_script_tag/) ` wp-includes/class-wp-scripts.php ` |  Gets tags for inline scripts registered for a specif