Skip to content

Commit 5136870

Browse files
committed
Make sure saved milestone comments are removed from stored CSS when previewing
1 parent 6ce405e commit 5136870

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/wp-includes/script-loader.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2547,9 +2547,14 @@ function wp_enqueue_global_styles() {
25472547
if ( is_customize_preview() ) {
25482548
/*
25492549
* When in the Customizer preview, wrap the Custom CSS in milestone comments to allow customize-preview.js
2550-
* to locate the CSS to replace for live previewing.
2550+
* to locate the CSS to replace for live previewing. Make sure that the milestone comments are omitted from
2551+
* the stored Custom CSS if by chance someone tried to add them, which would be highly unlikely, but it
2552+
* would break live previewing.
25512553
*/
2552-
$custom_css = "\n/*BEGIN_CUSTOMIZER_CUSTOM_CSS*/\n{$custom_css}\n/*END_CUSTOMIZER_CUSTOM_CSS*/\n";
2554+
$before_milestone = '/*BEGIN_CUSTOMIZER_CUSTOM_CSS*/';
2555+
$after_milestone = '/*END_CUSTOMIZER_CUSTOM_CSS*/';
2556+
$custom_css = str_replace( array( $before_milestone, $after_milestone ), '', $custom_css );
2557+
$custom_css = $before_milestone . $custom_css . $after_milestone;
25532558
}
25542559
$stylesheet .= $custom_css;
25552560

0 commit comments

Comments
 (0)