Changeset 60522
- Timestamp:
- 07/30/2025 04:22:38 AM (4 months ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
-
js/_enqueues/wp/customize/preview.js (modified) (1 diff)
-
wp-includes/class-wp-customize-manager.php (modified) (1 diff)
-
wp-includes/script-loader.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/wp/customize/preview.js
r48650 r60522 636 636 * Preview changes to custom css. 637 637 * 638 * @param {string} value Custom CSS. .638 * @param {string} value Custom CSS. 639 639 * @return {void} 640 640 */ 641 641 custom_css: function( value ) { 642 $( '#wp-custom-css' ).text( value ); 642 var style; 643 if ( api.settings.theme.isBlockTheme ) { 644 style = $( 'style#global-styles-inline-css' ); 645 646 // Forbid milestone comments from appearing in Custom CSS which would break live preview. 647 value = value.replace( /\/\*(BEGIN|END)_CUSTOMIZER_CUSTOM_CSS\*\//g, '' ); 648 649 var textContent = style.text().replace( 650 /(\/\*BEGIN_CUSTOMIZER_CUSTOM_CSS\*\/)((?:.|\s)*?)(\/\*END_CUSTOMIZER_CUSTOM_CSS\*\/)/, 651 function ( match, beforeComment, oldValue, afterComment ) { 652 return beforeComment + '\n' + value + '\n' + afterComment; 653 } 654 ); 655 style.text( textContent ); 656 } else { 657 style = $( 'style#wp-custom-css' ); 658 style.text( value ); 659 } 643 660 }, 644 661 -
trunk/src/wp-includes/class-wp-customize-manager.php
r60414 r60522 2162 2162 ), 2163 2163 'theme' => array( 2164 'stylesheet' => $this->get_stylesheet(), 2165 'active' => $this->is_theme_active(), 2164 'stylesheet' => $this->get_stylesheet(), 2165 'active' => $this->is_theme_active(), 2166 'isBlockTheme' => wp_is_block_theme(), 2166 2167 ), 2167 2168 'url' => array( -
trunk/src/wp-includes/script-loader.php
r60416 r60522 2542 2542 */ 2543 2543 remove_action( 'wp_head', 'wp_custom_css_cb', 101 ); 2544 // Get the custom CSS from the Customizer and add it to the global stylesheet. 2545 $custom_css = wp_get_custom_css(); 2544 2545 /* 2546 * Get the custom CSS from the Customizer and add it to the global stylesheet. 2547 * Always do this in Customizer preview for the sake of live preview since it be empty. 2548 */ 2549 $custom_css = trim( wp_get_custom_css() ); 2550 if ( $custom_css || is_customize_preview() ) { 2551 if ( is_customize_preview() ) { 2552 /* 2553 * When in the Customizer preview, wrap the Custom CSS in milestone comments to allow customize-preview.js 2554 * to locate the CSS to replace for live previewing. Make sure that the milestone comments are omitted from 2555 * the stored Custom CSS if by chance someone tried to add them, which would be highly unlikely, but it 2556 * would break live previewing. 2557 */ 2558 $before_milestone = '/*BEGIN_CUSTOMIZER_CUSTOM_CSS*/'; 2559 $after_milestone = '/*END_CUSTOMIZER_CUSTOM_CSS*/'; 2560 $custom_css = str_replace( array( $before_milestone, $after_milestone ), '', $custom_css ); 2561 $custom_css = $before_milestone . "\n" . $custom_css . "\n" . $after_milestone; 2562 } 2563 $custom_css = "\n" . $custom_css; 2564 } 2546 2565 $stylesheet .= $custom_css; 2547 2566
Note: See TracChangeset
for help on using the changeset viewer.