Skip to content

Fix ability to preview Additional CSS changes in the Customizer in Block Themes #9000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/wp-includes/deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -6372,7 +6372,7 @@ function wp_get_global_styles_custom_css() {
*/
function wp_enqueue_global_styles_custom_css() {
_deprecated_function( __FUNCTION__, '6.7.0', 'wp_enqueue_global_styles' );
if ( ! wp_is_block_theme() ) {
if ( ! wp_is_block_theme() || is_customize_preview() ) {
Copy link
Member Author

@westonruter westonruter Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think this change can be undone. It's a deprecated function anyway so it is not used. And the logic here is not right as it should rather be doing something like this:

$custom_css = '';
if ( ! is_customize_preview() ) {
	// Don't enqueue Customizer's custom CSS separately.
	remove_action( 'wp_head', 'wp_custom_css_cb', 101 );

	$custom_css .= wp_get_custom_css();
}

$custom_css .= wp_get_global_styles_custom_css();
Suggested change
if ( ! wp_is_block_theme() || is_customize_preview() ) {
if ( ! wp_is_block_theme() ) {

But again, given that this function is deprecated it doesn't seem necessary to make this change.

return;
}

Expand Down
5 changes: 4 additions & 1 deletion src/wp-includes/script-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2533,10 +2533,13 @@ function wp_enqueue_global_styles() {

$stylesheet = wp_get_global_stylesheet();

if ( $is_block_theme ) {
if ( $is_block_theme && ! is_customize_preview() ) {
/*
* Dequeue the Customizer's custom CSS
* and add it before the global styles custom CSS.
* This is not done in the Customizer preview to
* facilitate live previewing changes via
* wp-includes/js/customize-preview.js.
*/
remove_action( 'wp_head', 'wp_custom_css_cb', 101 );
// Get the custom CSS from the Customizer and add it to the global stylesheet.
Expand Down
Loading