Skip to content

Commit d0296b5

Browse files
committed
Only output sourceURL if SCRIPT_DEBUG enabled.
1 parent 8a82e67 commit d0296b5

21 files changed

Lines changed: 50 additions & 36 deletions

src/wp-content/themes/twentyfifteen/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ function twentyfifteen_fonts_url() {
413413
*/
414414
function twentyfifteen_javascript_detection() {
415415
$js = "(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);";
416-
$js .= "\n//# sourceURL=" . rawurlencode( __FUNCTION__ );
416+
$js .= SCRIPT_DEBUG ? "\n//# sourceURL=" . rawurlencode( __FUNCTION__ ) : '';
417417

418418
if ( function_exists( 'wp_print_inline_script_tag' ) ) {
419419
wp_print_inline_script_tag( $js );

src/wp-content/themes/twentyseventeen/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ function twentyseventeen_excerpt_more( $link ) {
407407
*/
408408
function twentyseventeen_javascript_detection() {
409409
$js = "(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);";
410-
$js .= "\n//# sourceURL=" . rawurlencode( __FUNCTION__ );
410+
$js .= SCRIPT_DEBUG ? "\n//# sourceURL=" . rawurlencode( __FUNCTION__ ) : '';
411411

412412
if ( function_exists( 'wp_print_inline_script_tag' ) ) {
413413
wp_print_inline_script_tag( $js );

src/wp-content/themes/twentysixteen/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ function twentysixteen_fonts_url() {
381381
*/
382382
function twentysixteen_javascript_detection() {
383383
$js = "(function(html){html.className = html.className.replace(/\bno-js\b/,'js')})(document.documentElement);";
384-
$js .= "\n//# sourceURL=" . rawurlencode( __FUNCTION__ );
384+
$js .= SCRIPT_DEBUG ? "\n//# sourceURL=" . rawurlencode( __FUNCTION__ ) : '';
385385

386386
if ( function_exists( 'wp_print_inline_script_tag' ) ) {
387387
wp_print_inline_script_tag( $js );

src/wp-content/themes/twentytwenty/inc/template-tags.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ function twentytwenty_nav_menu_social_icons( $item_output, $item, $depth, $args
662662
*/
663663
function twentytwenty_no_js_class() {
664664
$js = "document.documentElement.className = document.documentElement.className.replace( 'no-js', 'js' );";
665-
$js .= "\n//# sourceURL=" . rawurlencode( __FUNCTION__ );
665+
$js .= SCRIPT_DEBUG ? "\n//# sourceURL=" . rawurlencode( __FUNCTION__ ) : '';
666666

667667
if ( function_exists( 'wp_print_inline_script_tag' ) ) {
668668
wp_print_inline_script_tag( $js );

src/wp-content/themes/twentytwentyone/classes/class-twenty-twenty-one-dark-mode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ public function the_html( $attrs = array() ) {
367367
public function the_script() {
368368
$path = 'assets/js/dark-mode-toggler.js';
369369
$js = rtrim( file_get_contents( trailingslashit( get_template_directory() ) . $path ) );
370-
$js .= "\n//# sourceURL=" . esc_url_raw( trailingslashit( get_template_directory_uri() ) . $path );
370+
$js .= SCRIPT_DEBUG ? "\n//# sourceURL=" . esc_url_raw( trailingslashit( get_template_directory_uri() ) . $path ) : '';
371371
if ( function_exists( 'wp_print_inline_script_tag' ) ) {
372372
wp_print_inline_script_tag( $js );
373373
} else {

src/wp-content/themes/twentytwentyone/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ function twentytwentyone_add_ie_class() {
600600
document.body.classList.add('is-IE');
601601
}
602602
";
603-
$script .= '//# sourceURL=' . rawurlencode( __FUNCTION__ );
603+
$script .= SCRIPT_DEBUG ? "\n//# sourceURL=" . rawurlencode( __FUNCTION__ ) : '';
604604

605605
if ( function_exists( 'wp_print_inline_script_tag' ) ) {
606606
wp_print_inline_script_tag( $script );

src/wp-content/themes/twentytwentyone/inc/template-functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function twenty_twenty_one_pingback_header() {
7575
*/
7676
function twenty_twenty_one_supports_js() {
7777
$js = "document.body.classList.remove('no-js');";
78-
$js .= "\n//# sourceURL=" . rawurlencode( __FUNCTION__ );
78+
$js .= SCRIPT_DEBUG ? "\n//# sourceURL=" . rawurlencode( __FUNCTION__ ) : '';
7979

8080
if ( function_exists( 'wp_print_inline_script_tag' ) ) {
8181
wp_print_inline_script_tag( $js );

src/wp-includes/class-wp-customize-manager.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ protected function wp_die( $ajax_message, $message = null ) {
479479
} )( wp.customize, <?php echo wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ); ?> );
480480
</script>
481481
<?php
482-
$message .= wp_get_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) . "\n//# sourceURL=" . rawurlencode( __METHOD__ ) );
482+
$message .= wp_get_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) . ( SCRIPT_DEBUG ? "\n//# sourceURL=" . rawurlencode( __METHOD__ ) : '' ) );
483483
}
484484

485485
wp_die( $message );
@@ -2105,7 +2105,7 @@ public function remove_frameless_preview_messenger_channel() {
21052105
} )();
21062106
</script>
21072107
<?php
2108-
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) . "\n//# sourceURL=" . rawurlencode( __METHOD__ ) );
2108+
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) . ( SCRIPT_DEBUG ? "\n//# sourceURL=" . rawurlencode( __METHOD__ ) : '' ) );
21092109
}
21102110

21112111
/**
@@ -2227,7 +2227,7 @@ public function customize_preview_settings() {
22272227
})( _wpCustomizeSettings.values );
22282228
</script>
22292229
<?php
2230-
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) . "\n//# sourceURL=" . rawurlencode( __METHOD__ ) );
2230+
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) . ( SCRIPT_DEBUG ? "\n//# sourceURL=" . rawurlencode( __METHOD__ ) : '' ) );
22312231
}
22322232

22332233
/**
@@ -5022,7 +5022,7 @@ public function customize_pane_settings() {
50225022
?>
50235023
</script>
50245024
<?php
5025-
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) . "\n//# sourceURL=" . rawurlencode( __METHOD__ ) );
5025+
wp_print_inline_script_tag( wp_remove_surrounding_empty_script_tags( ob_get_clean() ) . ( SCRIPT_DEBUG ? "\n//# sourceURL=" . rawurlencode( __METHOD__ ) : '' ) );
50265026
}
50275027

50285028
/**

src/wp-includes/class-wp-customize-nav-menus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ public function export_preview_data() {
15561556
$exports = array(
15571557
'navMenuInstanceArgs' => $this->preview_nav_menu_instance_args,
15581558
);
1559-
wp_print_inline_script_tag( sprintf( 'var _wpCustomizePreviewNavMenusExports = %s;', wp_json_encode( $exports, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) . "\n//# sourceURL=" . rawurlencode( __METHOD__ ) );
1559+
wp_print_inline_script_tag( sprintf( 'var _wpCustomizePreviewNavMenusExports = %s;', wp_json_encode( $exports, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) . ( SCRIPT_DEBUG ? "\n//# sourceURL=" . rawurlencode( __METHOD__ ) : '' ) );
15601560
}
15611561

15621562
/**

src/wp-includes/class-wp-customize-widgets.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1335,7 +1335,7 @@ public function export_preview_data() {
13351335
unset( $registered_widget['callback'] ); // May not be JSON-serializable.
13361336
}
13371337
wp_print_inline_script_tag(
1338-
sprintf( 'var _wpWidgetCustomizerPreviewSettings = %s;', wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) . "\n//# sourceURL=" . rawurlencode( __METHOD__ )
1338+
sprintf( 'var _wpWidgetCustomizerPreviewSettings = %s;', wp_json_encode( $settings, JSON_HEX_TAG | JSON_UNESCAPED_SLASHES ) ) . ( SCRIPT_DEBUG ? "\n//# sourceURL=" . rawurlencode( __METHOD__ ) : '' )
13391339
);
13401340
}
13411341

0 commit comments

Comments
 (0)