Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
321fef2
Update Inline script tags with wp_inline_script_tag and added the fun…
Debarghya-Banerjee Aug 11, 2025
0d33936
Add Newline at EOF
Debarghya-Banerjee Aug 11, 2025
2caffa5
Address PR feedback
Debarghya-Banerjee Aug 28, 2025
9cda127
Merge branch 'trunk' into fix/63806-update-themes-to-use-wp_print_scr…
Debarghya-Banerjee Aug 28, 2025
bbcf99b
Remove Polyfills and Add SourceURL comment
Debarghya-Banerjee Sep 23, 2025
c5caa7b
Update the customizer color_scheme_css_template function
Debarghya-Banerjee Sep 23, 2025
87f5519
Revert back the deprecated functions
Debarghya-Banerjee Sep 23, 2025
086b2b9
Fix PHPCS errors
Debarghya-Banerjee Sep 23, 2025
fb67f9b
Merge branch 'trunk' into fix/63806-update-themes-to-use-wp_print_scr…
Debarghya-Banerjee Sep 23, 2025
0faa697
Remove Polyfills
Debarghya-Banerjee Sep 23, 2025
25d0cd5
Fix PHPCS Errors on Customizer
Debarghya-Banerjee Sep 23, 2025
5388427
Fix
Debarghya-Banerjee Sep 23, 2025
253cb83
Fix twentydixteen functions.php
Debarghya-Banerjee Sep 24, 2025
d9c441d
Fix TwentyTwentyOne Functions errors
Debarghya-Banerjee Sep 24, 2025
1d5ecbc
Use echo instead of printf
Debarghya-Banerjee Oct 7, 2025
ca2e7da
Update the customizer
Debarghya-Banerjee Oct 7, 2025
fdddfb9
Merge branch 'trunk' into fix/63806-update-themes-to-use-wp_print_scr…
westonruter Oct 7, 2025
186e543
Remove sourceURL comments from HTML templates
westonruter Oct 7, 2025
697a78f
Remove file_exists() check since not in original
westonruter Oct 7, 2025
c8c8038
Reuse relative path
westonruter Oct 7, 2025
7ebe75c
Use the same JS regardless of whether wp_print_inline_script_tag() ex…
westonruter Oct 7, 2025
3ce69ca
Add esc_url_raw() around URLs for good measure
westonruter Oct 7, 2025
fd0763a
Revert "Remove sourceURL comments from HTML templates"
westonruter Oct 7, 2025
6a1f5c1
Re-add use of wp_print_inline_script_tag() in CSS template scripts
westonruter Oct 7, 2025
33151aa
Remove unnecessary backslashes
westonruter Oct 7, 2025
35d16d8
Add missing file_get_contents()
westonruter Oct 7, 2025
72f535e
Remove extra line break in twentytwentyone_add_ie_class()
westonruter Oct 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/wp-content/themes/twentyfifteen/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,14 @@ function twentyfifteen_fonts_url() {
* @since Twenty Fifteen 1.1
*/
function twentyfifteen_javascript_detection() {
echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\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 "<script>$js</script>\n";
}
}
add_action( 'wp_head', 'twentyfifteen_javascript_detection', 0 );

Expand Down
22 changes: 16 additions & 6 deletions src/wp-content/themes/twentyfifteen/inc/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 }}',
);
?>
<script type="text/html" id="tmpl-twentyfifteen-color-scheme">
<?php echo twentyfifteen_get_color_scheme_css( $colors ); ?>
</script>
<?php

$css_template = twentyfifteen_get_color_scheme_css( $colors );

if ( function_exists( 'wp_print_inline_script_tag' ) ) {
wp_print_inline_script_tag(
$css_template,
array(
'type' => 'text/html',
'id' => 'tmpl-twentyfifteen-color-scheme',
)
);
} else {
echo '<script type="text/html" id="tmpl-twentyfifteen-color-scheme">' . $css_template . '</script>';
}
}
add_action( 'customize_controls_print_footer_scripts', 'twentyfifteen_color_scheme_css_template' );
9 changes: 8 additions & 1 deletion src/wp-content/themes/twentyseventeen/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,14 @@ function twentyseventeen_excerpt_more( $link ) {
* @since Twenty Seventeen 1.0
*/
function twentyseventeen_javascript_detection() {
echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\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 "<script>$js</script>\n";
}
}
add_action( 'wp_head', 'twentyseventeen_javascript_detection', 0 );

Expand Down
9 changes: 8 additions & 1 deletion src/wp-content/themes/twentysixteen/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,14 @@ function twentysixteen_fonts_url() {
* @since Twenty Sixteen 1.0
*/
function twentysixteen_javascript_detection() {
echo "<script>(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);</script>\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 "<script>$js</script>\n";
}
}
add_action( 'wp_head', 'twentysixteen_javascript_detection', 0 );

Expand Down
20 changes: 15 additions & 5 deletions src/wp-content/themes/twentysixteen/inc/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -848,11 +849,20 @@ function twentysixteen_color_scheme_css_template() {
'secondary_text_color' => '{{ data.secondary_text_color }}',
'border_color' => '{{ data.border_color }}',
);
?>
<script type="text/html" id="tmpl-twentysixteen-color-scheme">
<?php echo twentysixteen_get_color_scheme_css( $colors ); ?>
</script>
<?php

$css_template = twentysixteen_get_color_scheme_css( $colors );

if ( function_exists( 'wp_print_inline_script_tag' ) ) {
wp_print_inline_script_tag(
$css_template,
array(
'type' => 'text/html',
'id' => 'tmpl-twentysixteen-color-scheme',
)
);
} else {
echo '<script type="text/html" id="tmpl-twentysixteen-color-scheme">' . $css_template . '</script>';
}
}
add_action( 'customize_controls_print_footer_scripts', 'twentysixteen_color_scheme_css_template' );

Expand Down
10 changes: 7 additions & 3 deletions src/wp-content/themes/twentytwenty/inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__ );

?>
<script>document.documentElement.className = document.documentElement.className.replace( 'no-js', 'js' );</script>
<?php
if ( function_exists( 'wp_print_inline_script_tag' ) ) {
wp_print_inline_script_tag( $js );
} else {
echo "<script>$js</script>\n";
}
}

add_action( 'wp_head', 'twentytwenty_no_js_class' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,14 @@ public function the_html( $attrs = array() ) {
* @return void
*/
public function the_script() {
echo '<script>';
include get_template_directory() . '/assets/js/dark-mode-toggler.js'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude
echo '</script>';
$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( "<script>%s</script>\n", $js );
}
}

/**
Expand Down
17 changes: 11 additions & 6 deletions src/wp-content/themes/twentytwentyone/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -630,13 +630,18 @@ function twentytwentyone_the_html_classes() {
* @return void
*/
function twentytwentyone_add_ie_class() {
?>
<script>
if ( -1 !== navigator.userAgent.indexOf( 'MSIE' ) || -1 !== navigator.appVersion.indexOf( 'Trident/' ) ) {
document.body.classList.add( 'is-IE' );
$script = "
if ( -1 !== navigator.userAgent.indexOf('MSIE') || -1 !== navigator.appVersion.indexOf('Trident/') ) {
document.body.classList.add('is-IE');
}
";
$script .= '//# sourceURL=' . rawurlencode( __FUNCTION__ );

if ( function_exists( 'wp_print_inline_script_tag' ) ) {
wp_print_inline_script_tag( $script );
} else {
echo "<script>$script</script>\n";
}
</script>
<?php
}
add_action( 'wp_footer', 'twentytwentyone_add_ie_class' );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,14 @@ function twenty_twenty_one_pingback_header() {
* @return void
*/
function twenty_twenty_one_supports_js() {
echo '<script>document.body.classList.remove("no-js");</script>';
$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 "<script>$js</script>\n";
}
}
add_action( 'wp_footer', 'twenty_twenty_one_supports_js' );

Expand Down
4 changes: 2 additions & 2 deletions src/wp-includes/embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) )
);

/**
Expand Down Expand Up @@ -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 ) )
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/wp-includes/formatting.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
)
Expand Down
Loading