From 3f6dc403b5d6a0ff2666e160b79e83b47e4e040a Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 14 Oct 2025 22:50:28 -0700 Subject: [PATCH 1/7] Add notice to use Additional CSS in the Site Editor when using a block theme --- src/wp-admin/theme-editor.php | 41 ++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/wp-admin/theme-editor.php b/src/wp-admin/theme-editor.php index f82db5986dd8c..cac63041c7243 100644 --- a/src/wp-admin/theme-editor.php +++ b/src/wp-admin/theme-editor.php @@ -212,19 +212,34 @@ ); } -if ( preg_match( '/\.css$/', $file ) && ! wp_is_block_theme() && current_user_can( 'customize' ) ) { - $message = '

' . __( 'Did you know?' ) . '

' . sprintf( - /* translators: %s: Link to Custom CSS section in the Customizer. */ - __( 'There is no need to change your CSS here — you can edit and live preview CSS changes in the built-in CSS editor.' ), - esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) ) - ) . '

'; - wp_admin_notice( - $message, - array( - 'type' => 'info', - 'id' => 'message', - ) - ); +if ( preg_match( '/\.css$/', $file ) ) { + if ( ! wp_is_block_theme() && current_user_can( 'customize' ) ) { + $message = '

' . __( 'Did you know?' ) . '

' . sprintf( + /* translators: %s: Link to Custom CSS section in the Customizer. */ + __( 'There is no need to change your CSS here — you can edit and live preview CSS changes in the built-in CSS editor.' ), + esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) ) + ) . '

'; + wp_admin_notice( + $message, + array( + 'type' => 'info', + 'id' => 'message', + ) + ); + } elseif ( wp_is_block_theme() && current_user_can( 'edit_theme_options' ) ) { + $message = '

' . __( 'Did you know?' ) . '

' . sprintf( + /* translators: %s: Link to Additional CSS section in the Site Editor. */ + __( 'There is no need to change your CSS here — you can edit and live preview CSS changes in the built-in CSS editor.' ), + esc_url( admin_url( 'site-editor.php?p=%2Fstyles§ion=%2Fcss' ) ) + ) . '

'; + wp_admin_notice( + $message, + array( + 'type' => 'info', + 'id' => 'message', + ) + ); + } } ?> From ed037a07efad95fa56ec77ef2c7d78d19e8f7e4e Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 14 Oct 2025 22:51:37 -0700 Subject: [PATCH 2/7] Add warning about editing a stylesheet when there is a minified version --- src/wp-admin/theme-editor.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/wp-admin/theme-editor.php b/src/wp-admin/theme-editor.php index cac63041c7243..4201b49ae4ec4 100644 --- a/src/wp-admin/theme-editor.php +++ b/src/wp-admin/theme-editor.php @@ -240,6 +240,18 @@ ) ); } + if ( file_exists( preg_replace( '/\.css$/', '.min.css', $file ) ) ) { + $message = '

' . __( 'There is a minified version of this stylesheet.' ) . '

' . sprintf( + /* translators: %s: Link to Custom CSS section in the Customizer. */ + __( 'It is likely that this unminified stylesheet will not be served to visitors.' ) + ) . '

'; + wp_admin_notice( + $message, + array( + 'type' => 'warning', + ) + ); + } } ?> From bd06646149b4b3f4d81f02445ecfadb7277b4498 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 15 Oct 2025 07:18:22 -0700 Subject: [PATCH 3/7] Remove unneeded translators comment Co-authored-by: Aaron Jorbin --- src/wp-admin/theme-editor.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wp-admin/theme-editor.php b/src/wp-admin/theme-editor.php index 4201b49ae4ec4..96719d4989ecd 100644 --- a/src/wp-admin/theme-editor.php +++ b/src/wp-admin/theme-editor.php @@ -242,7 +242,6 @@ } if ( file_exists( preg_replace( '/\.css$/', '.min.css', $file ) ) ) { $message = '

' . __( 'There is a minified version of this stylesheet.' ) . '

' . sprintf( - /* translators: %s: Link to Custom CSS section in the Customizer. */ __( 'It is likely that this unminified stylesheet will not be served to visitors.' ) ) . '

'; wp_admin_notice( From 9383f2eb825985a24cf531aa62486597f16e5469 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 15 Oct 2025 07:42:09 -0700 Subject: [PATCH 4/7] Remove extraneous sprintf() Co-authored-by: Aaron Jorbin --- src/wp-admin/theme-editor.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/theme-editor.php b/src/wp-admin/theme-editor.php index 96719d4989ecd..7ef78d1bbf79c 100644 --- a/src/wp-admin/theme-editor.php +++ b/src/wp-admin/theme-editor.php @@ -241,9 +241,8 @@ ); } if ( file_exists( preg_replace( '/\.css$/', '.min.css', $file ) ) ) { - $message = '

' . __( 'There is a minified version of this stylesheet.' ) . '

' . sprintf( - __( 'It is likely that this unminified stylesheet will not be served to visitors.' ) - ) . '

'; + $message = '

' . __( 'There is a minified version of this stylesheet.' ) . '

' . + __( 'It is likely that this unminified stylesheet will not be served to visitors.' ) . '

'; wp_admin_notice( $message, array( From 36d9fc05e9d3e7076e64fc60ea998c4f1d9c6325 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 15 Oct 2025 15:26:19 -0700 Subject: [PATCH 5/7] Add ID attribute Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> --- src/wp-admin/theme-editor.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-admin/theme-editor.php b/src/wp-admin/theme-editor.php index 7ef78d1bbf79c..eb1afeb5bb1bf 100644 --- a/src/wp-admin/theme-editor.php +++ b/src/wp-admin/theme-editor.php @@ -247,6 +247,7 @@ $message, array( 'type' => 'warning', + 'id' => 'wp-css-min-warning', ) ); } From 449b9121809db8b2628b19fb9d87cc60631fbda5 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 15 Oct 2025 15:28:02 -0700 Subject: [PATCH 6/7] Use uniform translator comments for repeated strings Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> --- src/wp-admin/theme-editor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/theme-editor.php b/src/wp-admin/theme-editor.php index eb1afeb5bb1bf..9db6ac8e15f78 100644 --- a/src/wp-admin/theme-editor.php +++ b/src/wp-admin/theme-editor.php @@ -215,7 +215,7 @@ if ( preg_match( '/\.css$/', $file ) ) { if ( ! wp_is_block_theme() && current_user_can( 'customize' ) ) { $message = '

' . __( 'Did you know?' ) . '

' . sprintf( - /* translators: %s: Link to Custom CSS section in the Customizer. */ + /* translators: %s: Link to add custom CSS section in either the Customizer (classic themes) or Site Editor (block themes). */ __( 'There is no need to change your CSS here — you can edit and live preview CSS changes in the built-in CSS editor.' ), esc_url( add_query_arg( 'autofocus[section]', 'custom_css', admin_url( 'customize.php' ) ) ) ) . '

'; From 7058ee6456a81a1862a6717630a2544e1bb06782 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Wed, 15 Oct 2025 15:28:08 -0700 Subject: [PATCH 7/7] Use uniform translator comments for repeated strings Co-authored-by: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> --- src/wp-admin/theme-editor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/theme-editor.php b/src/wp-admin/theme-editor.php index 9db6ac8e15f78..98de8cb6e2fd2 100644 --- a/src/wp-admin/theme-editor.php +++ b/src/wp-admin/theme-editor.php @@ -228,7 +228,7 @@ ); } elseif ( wp_is_block_theme() && current_user_can( 'edit_theme_options' ) ) { $message = '

' . __( 'Did you know?' ) . '

' . sprintf( - /* translators: %s: Link to Additional CSS section in the Site Editor. */ + /* translators: %s: Link to add custom CSS section in either the Customizer (classic themes) or Site Editor (block themes). */ __( 'There is no need to change your CSS here — you can edit and live preview CSS changes in the built-in CSS editor.' ), esc_url( admin_url( 'site-editor.php?p=%2Fstyles§ion=%2Fcss' ) ) ) . '

';