diff --git a/src/wp-content/themes/twentyfifteen/functions.php b/src/wp-content/themes/twentyfifteen/functions.php index 71b42e6c6e151..837929fad310f 100644 --- a/src/wp-content/themes/twentyfifteen/functions.php +++ b/src/wp-content/themes/twentyfifteen/functions.php @@ -412,7 +412,14 @@ function twentyfifteen_fonts_url() { * @since Twenty Fifteen 1.1 */ function twentyfifteen_javascript_detection() { - echo "\n"; + $js = "(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);"; + $js .= "\n//# sourceURL=" . rawurlencode( __FUNCTION__ ); + + if ( function_exists( 'wp_print_inline_script_tag' ) ) { + wp_print_inline_script_tag( $js ); + } else { + echo "\n"; + } } add_action( 'wp_head', 'twentyfifteen_javascript_detection', 0 ); diff --git a/src/wp-content/themes/twentyfifteen/inc/customizer.php b/src/wp-content/themes/twentyfifteen/inc/customizer.php index d2e6358022556..30d883a5d30f0 100644 --- a/src/wp-content/themes/twentyfifteen/inc/customizer.php +++ b/src/wp-content/themes/twentyfifteen/inc/customizer.php @@ -772,10 +772,11 @@ function twentyfifteen_get_color_scheme_css( $colors ) { /** * Outputs an Underscore template for generating CSS for the color scheme. * - * The template generates the css dynamically for instant display in the Customizer + * The template generates the CSS dynamically for instant display in the Customizer * preview. * * @since Twenty Fifteen 1.0 + * @since Twenty Fifteen 4.1 Added `wp_print_inline_script_tag()` support. */ function twentyfifteen_color_scheme_css_template() { $colors = array( @@ -792,10 +793,19 @@ function twentyfifteen_color_scheme_css_template() { 'secondary_sidebar_textcolor' => '{{ data.secondary_sidebar_textcolor }}', 'meta_box_background_color' => '{{ data.meta_box_background_color }}', ); - ?> - - 'text/html', + 'id' => 'tmpl-twentyfifteen-color-scheme', + ) + ); + } else { + echo ''; + } } add_action( 'customize_controls_print_footer_scripts', 'twentyfifteen_color_scheme_css_template' ); diff --git a/src/wp-content/themes/twentyseventeen/functions.php b/src/wp-content/themes/twentyseventeen/functions.php index 742db0b143e6e..138bfd33d1cce 100644 --- a/src/wp-content/themes/twentyseventeen/functions.php +++ b/src/wp-content/themes/twentyseventeen/functions.php @@ -406,7 +406,14 @@ function twentyseventeen_excerpt_more( $link ) { * @since Twenty Seventeen 1.0 */ function twentyseventeen_javascript_detection() { - echo "\n"; + $js = "(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);"; + $js .= "\n//# sourceURL=" . rawurlencode( __FUNCTION__ ); + + if ( function_exists( 'wp_print_inline_script_tag' ) ) { + wp_print_inline_script_tag( $js ); + } else { + echo "\n"; + } } add_action( 'wp_head', 'twentyseventeen_javascript_detection', 0 ); diff --git a/src/wp-content/themes/twentysixteen/functions.php b/src/wp-content/themes/twentysixteen/functions.php index 49b3f2cb9ad01..0cf65cd55ca96 100644 --- a/src/wp-content/themes/twentysixteen/functions.php +++ b/src/wp-content/themes/twentysixteen/functions.php @@ -373,7 +373,14 @@ function twentysixteen_fonts_url() { * @since Twenty Sixteen 1.0 */ function twentysixteen_javascript_detection() { - echo "\n"; + $js = "(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);"; + $js .= "\n//# sourceURL=" . rawurlencode( __FUNCTION__ ); + + if ( function_exists( 'wp_print_inline_script_tag' ) ) { + wp_print_inline_script_tag( $js ); + } else { + echo "\n"; + } } add_action( 'wp_head', 'twentysixteen_javascript_detection', 0 ); diff --git a/src/wp-content/themes/twentysixteen/inc/customizer.php b/src/wp-content/themes/twentysixteen/inc/customizer.php index 43a43f8c9e9b6..dac588120daaf 100644 --- a/src/wp-content/themes/twentysixteen/inc/customizer.php +++ b/src/wp-content/themes/twentysixteen/inc/customizer.php @@ -838,6 +838,7 @@ function twentysixteen_get_color_scheme_css( $colors ) { * Customizer preview. * * @since Twenty Sixteen 1.0 + * @since Twenty Sixteen 4.1 Added `wp_print_inline_script_tag()` support. */ function twentysixteen_color_scheme_css_template() { $colors = array( @@ -848,11 +849,20 @@ function twentysixteen_color_scheme_css_template() { 'secondary_text_color' => '{{ data.secondary_text_color }}', 'border_color' => '{{ data.border_color }}', ); - ?> - - 'text/html', + 'id' => 'tmpl-twentysixteen-color-scheme', + ) + ); + } else { + echo ''; + } } add_action( 'customize_controls_print_footer_scripts', 'twentysixteen_color_scheme_css_template' ); diff --git a/src/wp-content/themes/twentytwenty/inc/template-tags.php b/src/wp-content/themes/twentytwenty/inc/template-tags.php index 0154c11117eb8..23f30df80272a 100644 --- a/src/wp-content/themes/twentytwenty/inc/template-tags.php +++ b/src/wp-content/themes/twentytwenty/inc/template-tags.php @@ -660,10 +660,14 @@ function twentytwenty_nav_menu_social_icons( $item_output, $item, $depth, $args * @since Twenty Twenty 1.0 */ function twentytwenty_no_js_class() { + $js = "document.documentElement.className = document.documentElement.className.replace( 'no-js', 'js' );"; + $js .= "\n//# sourceURL=" . rawurlencode( __FUNCTION__ ); - ?> - - $js\n"; + } } add_action( 'wp_head', 'twentytwenty_no_js_class' ); diff --git a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php index 39b3fb726fc88..f302f85426202 100644 --- a/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php +++ b/src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php @@ -363,9 +363,14 @@ public function the_html( $attrs = array() ) { * @return void */ public function the_script() { - echo ''; + $path = 'assets/js/dark-mode-toggler.js'; + $js = rtrim( file_get_contents( trailingslashit( get_template_directory() ) . $path ) ); + $js .= "\n//# sourceURL=" . esc_url_raw( trailingslashit( get_template_directory_uri() ) . $path ); + if ( function_exists( 'wp_print_inline_script_tag' ) ) { + wp_print_inline_script_tag( $js ); + } else { + printf( "\n", $js ); + } } /** diff --git a/src/wp-content/themes/twentytwentyone/functions.php b/src/wp-content/themes/twentytwentyone/functions.php index f163e394df734..993025f272a01 100644 --- a/src/wp-content/themes/twentytwentyone/functions.php +++ b/src/wp-content/themes/twentytwentyone/functions.php @@ -630,13 +630,18 @@ function twentytwentyone_the_html_classes() { * @return void */ function twentytwentyone_add_ie_class() { - ?> - \n"; } - - document.body.classList.remove("no-js");'; + $js = "document.body.classList.remove('no-js');"; + $js .= "\n//# sourceURL=" . rawurlencode( __FUNCTION__ ); + + if ( function_exists( 'wp_print_inline_script_tag' ) ) { + wp_print_inline_script_tag( $js ); + } else { + echo "\n"; + } } add_action( 'wp_footer', 'twenty_twenty_one_supports_js' ); diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php index 47d10cb453286..8cde1ebb99594 100644 --- a/src/wp-includes/embed.php +++ b/src/wp-includes/embed.php @@ -520,7 +520,7 @@ function get_post_embed_html( $width, $height, $post = null ) { */ $js_path = '/js/wp-embed' . wp_scripts_get_suffix() . '.js'; $output .= wp_get_inline_script_tag( - trim( file_get_contents( ABSPATH . WPINC . $js_path ) ) . "\n//# sourceURL=" . includes_url( $js_path ) + trim( file_get_contents( ABSPATH . WPINC . $js_path ) ) . "\n//# sourceURL=" . esc_url_raw( includes_url( $js_path ) ) ); /** @@ -1093,7 +1093,7 @@ function wp_enqueue_embed_styles() { function print_embed_scripts() { $js_path = '/js/wp-embed-template' . wp_scripts_get_suffix() . '.js'; wp_print_inline_script_tag( - trim( file_get_contents( ABSPATH . WPINC . $js_path ) ) . "\n//# sourceURL=" . includes_url( $js_path ) + trim( file_get_contents( ABSPATH . WPINC . $js_path ) ) . "\n//# sourceURL=" . esc_url_raw( includes_url( $js_path ) ) ); } diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index 141b245548053..2f22ec25f8738 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -5992,7 +5992,7 @@ function _print_emoji_detection_script() { $emoji_loader_script_path = '/js/wp-emoji-loader' . wp_scripts_get_suffix() . '.js'; wp_print_inline_script_tag( rtrim( file_get_contents( ABSPATH . WPINC . $emoji_loader_script_path ) ) . "\n" . - '//# sourceURL=' . includes_url( $emoji_loader_script_path ), + '//# sourceURL=' . esc_url_raw( includes_url( $emoji_loader_script_path ) ), array( 'type' => 'module', )