Skip to content

Conversation

westonruter
Copy link
Member

This is a follow-up to #10081 (r60934 and b56b386) based on a discussion with @peterwilsoncc. A CSS comment was added to the style.css for TT2 and TT5 to warn against editing since the style.min.css will likely be served instead:

/*
 * IMPORTANT: This file is only served on the frontend when `SCRIPT_DEBUG` is enabled;
 * in most instances, the `style.min.css` file will be served. It is not recommended that you
 * use the Theme File Editor to modify this stylesheet. Instead, add the necessary style
 * overrides via "Additional CSS" in the Site Editor.
 */

However, the user may not see this easily. Therefore, this PR adds an admin notice when editing a CSS file when there is also a .min.css version for that same file name in the current theme.

Additionally, for non-block themes there was an admin info notice about using the Custom CSS in the Customizer to edit CSS, but there was no corresponding notice to prompt users to use Additional CSS in the Site Editor for block themes. So this rectifies that issue. The new notices appear as follows when editing style.css in TT5:

image

Trac ticket: https://core.trac.wordpress.org/ticket/63012


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.

Copy link

github-actions bot commented Oct 15, 2025

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props westonruter, jorbin, peterwilsoncc.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

);
}
if ( file_exists( preg_replace( '/\.css$/', '.min.css', $file ) ) ) {
$message = '<p><strong>' . __( 'There is a minified version of this stylesheet.' ) . '</strong></p><p>' . sprintf(
Copy link
Member

Choose a reason for hiding this comment

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

The sprintf can also be eliminated since there is no substitution (sorry, didn't catch that earlier)

Copy link
Member Author

Choose a reason for hiding this comment

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

The apologies should be mine!

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed in 9383f2e

Co-authored-by: Aaron Jorbin <[email protected]>
Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

This looks good, thanks.

A couple of notes inline: I think it's best practice if translator comments are uniform for repeated strings. WP CLI throws a warning if they differ. Someone on the polyglots team will be able to confirm.

I've suggested an ID for the new warning message, feel free to come up with a better name.

Copy link
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

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

This looks good to me and tests well.

Testing notes:

  • 2025: Link goes to site editor
  • 2025: Warning shown when editing stylesheet
  • 2014: Link goes to customizer
  • 2014: touch src/wp-content/themes/twentyfourteen/style.min.css causes the warning to be shown.
  • 2014: Without the fake file, the warning is not shown.

@westonruter
Copy link
Member Author

FYI: In the SVN commit, I'm improving the construction of the Site Editor URL as follows:

--- a/src/wp-admin/theme-editor.php
+++ b/src/wp-admin/theme-editor.php
@@ -227,10 +227,22 @@ if ( preg_match( '/\.css$/', $file ) ) {
 			)
 		);
 	} elseif ( wp_is_block_theme() && current_user_can( 'edit_theme_options' ) ) {
+		$site_editor_url = admin_url(
+			add_query_arg(
+				urlencode_deep(
+					array(
+						'p'       => '/styles',
+						'section' => '/css',
+					)
+				),
+				'site-editor.php'
+			)
+		);
+
 		$message = '<p><strong>' . __( 'Did you know?' ) . '</strong></p><p>' . sprintf(
 			/* 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 &mdash; you can edit and live preview CSS changes in the <a href="%s">built-in CSS editor</a>.' ),
-			esc_url( admin_url( 'site-editor.php?p=%2Fstyles&section=%2Fcss' ) )
+			esc_url( $site_editor_url )
 		) . '</p>';
 		wp_admin_notice(
 			$message,

pento pushed a commit that referenced this pull request Oct 16, 2025
* When a block theme is active, add a notice to advise using Additional CSS in the Site Editor. A similar notice is already directing users to Custom CSS in the Customizer when a classic theme is active.
* When there is a minified file (`*.min.css`) present for the current CSS file, warn that any edits may not be served to visitors.

Developed in #10279

Follow-up to [60934].

Props westonruter, peterwilsoncc, jorbin.
See #63012.


git-svn-id: https://develop.svn.wordpress.org/trunk@60943 602fd350-edb4-49c9-b593-d223f7449a82
@westonruter
Copy link
Member Author

Committed in c978e55 (r60943).

markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Oct 16, 2025
* When a block theme is active, add a notice to advise using Additional CSS in the Site Editor. A similar notice is already directing users to Custom CSS in the Customizer when a classic theme is active.
* When there is a minified file (`*.min.css`) present for the current CSS file, warn that any edits may not be served to visitors.

Developed in WordPress/wordpress-develop#10279

Follow-up to [60934].

Props westonruter, peterwilsoncc, jorbin.
See #63012.

Built from https://develop.svn.wordpress.org/trunk@60943


git-svn-id: http://core.svn.wordpress.org/trunk@60279 1a063a9b-81f0-0310-95a4-ce76da25c4cd
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Oct 16, 2025
* When a block theme is active, add a notice to advise using Additional CSS in the Site Editor. A similar notice is already directing users to Custom CSS in the Customizer when a classic theme is active.
* When there is a minified file (`*.min.css`) present for the current CSS file, warn that any edits may not be served to visitors.

Developed in WordPress/wordpress-develop#10279

Follow-up to [60934].

Props westonruter, peterwilsoncc, jorbin.
See #63012.

Built from https://develop.svn.wordpress.org/trunk@60943


git-svn-id: https://core.svn.wordpress.org/trunk@60279 1a063a9b-81f0-0310-95a4-ce76da25c4cd
)
);
}
if ( file_exists( preg_replace( '/\.css$/', '.min.css', $file ) ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

@westonruter In the development version, SCRIPT_DEBUG is set to true, so this notice does not makes sense since it loads CSS from the unminified .css file. However, in production, SCRIPT_DEBUG is false, meaning that CSS won’t be applied as it load .min.css file.

This creates a bit of a trade-off not sure if we actually need this notice in that case 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure I understand. The issue is that the changes to style.css may not be served to visitors, depending on whether SCRIPT_DEBUG is enabled. If someone temporarily enables script debug, then they would confused why their fix no longer appears after changing the file and turning script debug off. So the warning seems important.

Copy link
Member

Choose a reason for hiding this comment

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

Got it. Thanks for clarification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants