Changeset 57367 for trunk/src/wp-includes/script-loader.php
- Timestamp:
- 01/27/2024 01:02:35 AM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/script-loader.php
r57341 r57367 2835 2835 2836 2836 /** 2837 * Wraps inline JavaScript in `<script>`tag.2837 * Constructs an inline script tag. 2838 2838 * 2839 2839 * It is possible to inject attributes in the `<script>` tag via the {@see 'wp_script_attributes'} filter. … … 2842 2842 * @since 5.7.0 2843 2843 * 2844 * @param string $ javascript Inline JavaScript code.2844 * @param string $data Data for script tag: JavaScript, importmap, speculationrules, etc. 2845 2845 * @param array $attributes Optional. Key-value pairs representing `<script>` tag attributes. 2846 2846 * @return string String containing inline JavaScript code wrapped around `<script>` tag. 2847 2847 */ 2848 function wp_get_inline_script_tag( $ javascript, $attributes = array() ) {2848 function wp_get_inline_script_tag( $data, $attributes = array() ) { 2849 2849 $is_html5 = current_theme_supports( 'html5', 'script' ) || is_admin(); 2850 2850 if ( ! isset( $attributes['type'] ) && ! $is_html5 ) { … … 2900 2900 * an additional `<![CDATA[` leaves the contents unchanged. 2901 2901 */ 2902 $ javascript = str_replace( ']]>', ']]]]><![CDATA[>', $javascript);2902 $data = str_replace( ']]>', ']]]]><![CDATA[>', $data ); 2903 2903 2904 2904 // Wrap the entire escaped script inside a CDATA section. 2905 $ javascript = sprintf( "/* <![CDATA[ */\n%s\n/* ]]> */", $javascript);2906 } 2907 2908 $ javascript = "\n" . trim( $javascript, "\n\r " ) . "\n";2905 $data = sprintf( "/* <![CDATA[ */\n%s\n/* ]]> */", $data ); 2906 } 2907 2908 $data = "\n" . trim( $data, "\n\r " ) . "\n"; 2909 2909 2910 2910 /** … … 2916 2916 * Only the attribute name is added to the `<script>` tag for 2917 2917 * entries with a boolean value, and that are true. 2918 * @param string $ javascript Inline JavaScript code.2918 * @param string $data Inline data. 2919 2919 */ 2920 $attributes = apply_filters( 'wp_inline_script_attributes', $attributes, $ javascript);2921 2922 return sprintf( "<script%s>%s</script>\n", wp_sanitize_script_attributes( $attributes ), $ javascript);2923 } 2924 2925 /** 2926 * Prints inline JavaScript wrapped in `<script>`tag.2920 $attributes = apply_filters( 'wp_inline_script_attributes', $attributes, $data ); 2921 2922 return sprintf( "<script%s>%s</script>\n", wp_sanitize_script_attributes( $attributes ), $data ); 2923 } 2924 2925 /** 2926 * Prints an inline script tag. 2927 2927 * 2928 2928 * It is possible to inject attributes in the `<script>` tag via the {@see 'wp_script_attributes'} filter. … … 2931 2931 * @since 5.7.0 2932 2932 * 2933 * @param string $ javascript Inline JavaScript code.2933 * @param string $data Data for script tag: JavaScript, importmap, speculationrules, etc. 2934 2934 * @param array $attributes Optional. Key-value pairs representing `<script>` tag attributes. 2935 2935 */ 2936 function wp_print_inline_script_tag( $ javascript, $attributes = array() ) {2937 echo wp_get_inline_script_tag( $ javascript, $attributes );2936 function wp_print_inline_script_tag( $data, $attributes = array() ) { 2937 echo wp_get_inline_script_tag( $data, $attributes ); 2938 2938 } 2939 2939
Note: See TracChangeset
for help on using the changeset viewer.