#64762 Use sass to generate admin toolbar colours#11267
#64762 Use sass to generate admin toolbar colours#11267johnbillion wants to merge 2 commits intoWordPress:trunkfrom
Conversation
…chemes that uses the extracted admin toolbar styles.
|
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. |
huzaifaalmesbah
left a comment
There was a problem hiding this comment.
Looks good to me
trac-64762-pr-11267.mp4
There was a problem hiding this comment.
- ✅ The Fresh scheme does not have a separate stylesheet.
- ✅ The other 8 Core schemes properly fetch their small, external stylesheet on the front end.
- ✅ Plugins such as Contextual Adminbar Color and Dark Mode Toggle continue to show their colors because they set colors without
wp_admin_css_color(). Theadmin-bar-color-scheme-cssstylesheet can be enqueued unnecessarily, but the plugins' CSS would override that. - The new Sass partial removes
#wp-admin-bar-recovery-modestyles. Is that intentional? - 😢 I have trouble trying to add a new stylesheet with
wp_admin_css_color()in plugins such as bbPress. The front end continues to enqueue the Modern stylesheet instead of the plugin's stylesheet.
// Mint
wp_admin_css_color(
'bbp-mint',
esc_html_x( 'Mint', 'admin color scheme', 'bbpress' ),
$this->styles_url . 'mint/colors' . $suffix . '.css',
array( '#4f6d59', '#33834e', '#5FB37C', '#81c498' ),
array( 'base' => '#f1f3f2', 'focus' => '#fff', 'current' => '#fff' ),
$this->styles_url . 'mint/admin-bar.css' // trimmed copy of colors.css in the same directory
);Unless I just made a silly mistake editing the plugin, the toolbar function might check the $_wp_admin_css_colors global variable too early, before the plugin modifies it. I started another PR draft—using this Sass—to investigate a way to support the core schemes without reading or changing the global variable (though I have not tested it with plugins yet). That PR also restores the unit test to its original code.
| array( 'admin-bar' ), | ||
| false |
There was a problem hiding this comment.
Nit: false is the default value for the $ver param.
| array( 'admin-bar' ), | |
| false | |
| array( 'admin-bar' ) |
There was a problem hiding this comment.
This is a habit due to WPSC enforcing an explicit value for $in_footer 😄
| * @param string|false $admin_bar_url Optional. The URL of the CSS file containing admin bar color | ||
| * overrides for use on the front end. Default false. |
There was a problem hiding this comment.
With this introduced, the params are no longer aligned. If that is intended to be maintained, like so:
* @param string $key The unique key for this theme.
* @param string $name The name of the theme.
* @param string $url The URL of the CSS file containing the color scheme.
* @param array $colors Optional. An array of CSS color definition strings which are used
* to give the user a feel for the theme.
* @param array $icons {
* Optional. CSS color definitions used to color any SVG icons.
*
* @type string $base SVG icon base color.
* @type string $focus SVG icon color on focus.
* @type string $current SVG icon color of current admin menu link.
* }
* @param string|false $admin_bar_url Optional. The URL of the CSS file containing admin bar color
* overrides for use on the front end. Default false.
Then:
diff --git a/src/wp-includes/general-template.php b/src/wp-includes/general-template.php
index b16caf989d..70e186144c 100644
--- a/src/wp-includes/general-template.php
+++ b/src/wp-includes/general-template.php
@@ -4854,12 +4854,12 @@ function paginate_links( $args = '' ) {
*
* @global array $_wp_admin_css_colors
*
- * @param string $key The unique key for this theme.
- * @param string $name The name of the theme.
- * @param string $url The URL of the CSS file containing the color scheme.
- * @param array $colors Optional. An array of CSS color definition strings which are used
- * to give the user a feel for the theme.
- * @param array $icons {
+ * @param string $key The unique key for this theme.
+ * @param string $name The name of the theme.
+ * @param string $url The URL of the CSS file containing the color scheme.
+ * @param array $colors Optional. An array of CSS color definition strings which are used
+ * to give the user a feel for the theme.
+ * @param array $icons {
* Optional. CSS color definitions used to color any SVG icons.
*
* @type string $base SVG icon base color.|
Thanks for putting together this PR @johnbillion! It looks fairly better than the current implementation. |
|
I was having trouble with the registered schemes for bbPress and Grey Admin Color Schemes mainly because both plugins use
|
This extracts the admin toolbar styles into a mixin so a standalone admin-bar.css file can be generated for each colour scheme. Facilitates custom colour schemes registering their own admin toolbar CSS file too.
Trac ticket: https://core.trac.wordpress.org/ticket/64762
Use of AI Tools
Claude Code was used to initialise the separate admin bar color Sass files for each colour scheme. Worked ok-ish, I subsequently manually adjusted a lot of it.
Screenshots