-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Customize: Preserve CSS cascade for Additional CSS in classic themes #10726
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
Customize: Preserve CSS cascade for Additional CSS in classic themes #10726
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Restores the `$is_block_theme` check that was inadvertently removed in [61473]. This ensures that for classic themes, the Customizer's Additional CSS continues to be printed separately via `wp_custom_css_cb()` at priority 101 in `wp_head`, preserving its position at the end of the `<head>` for highest CSS specificity. For block themes, the Customizer CSS is merged into the global styles stylesheet before the global styles custom CSS, maintaining the intended cascade order. This fixes two issues introduced by the Global Styles lift for classic themes: 1. Live preview in the Customizer not working for Additional CSS changes. 2. Additional CSS losing its cascade advantage due to being buried in the global styles stylesheet. Props westonruter. Fixes #64408. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1bf4da5 to
906e0f2
Compare
|
Diff with 470fcfe, the commit prior to fd2693d in which the changes were introduced: git diff 470fcfe8d5371684eaaab87b4bc76af7811d6b74... -- src/wp-includes/script-loader.phpdiff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php
index 2946f19656..366f8f9366 100644
--- a/src/wp-includes/script-loader.php
+++ b/src/wp-includes/script-loader.php
@@ -2514,6 +2514,12 @@ function wp_enqueue_global_styles() {
$stylesheet = wp_get_global_stylesheet();
+ /*
+ * For block themes, merge Customizer's custom CSS into the global styles stylesheet
+ * before the global styles custom CSS, ensuring proper cascade order.
+ * For classic themes, let the Customizer CSS print separately via wp_custom_css_cb()
+ * at priority 101 in wp_head, preserving its position at the end of the <head>.
+ */
if ( $is_block_theme ) {
/*
* Dequeue the Customizer's custom CSS
@@ -3001,7 +3007,7 @@ function wp_maybe_inline_styles() {
usort(
$styles,
static function ( $a, $b ) {
- return ( $a['size'] <= $b['size'] ) ? -1 : 1;
+ return $a['size'] <=> $b['size'];
}
);
|
westonruter
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the regressions! Thank you.
Restores the
$is_block_themecheck that was inadvertently removed in [61473]. This ensures that for classic themes, the Customizer's Additional CSS continues to be printed separately viawp_custom_css_cb()at priority 101 inwp_head, preserving its position at the end of the<head>for highest CSS specificity.For block themes, the Customizer CSS is merged into the global styles stylesheet before the global styles custom CSS, maintaining the intended cascade order.
This fixes two issues introduced by the Global Styles lift for classic themes:
Props westonruter.
Trac ticket: https://core.trac.wordpress.org/ticket/64408
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.