Make WordPress Core

Opened 8 months ago

Last modified 9 days ago

#64762 reopened defect (bug)

Frontend admin toolbar not using updated admin color scheme

Reported by: huzaifaalmesbah Owned by: audrasjb
Priority: normal Milestone: 7.2
Component: Toolbar Version:
Severity: normal Keywords: admin-reskin has-test-info has-patch has-unit-tests
Cc: Focuses: ui, css

Description

On the frontend, the admin toolbar menu is not using the updated Admin Reskin color scheme.

The toolbar menu item still appears with the old color on hover.

For visual consistency, the frontend admin toolbar should use the updated admin design tokens and color scheme so that it matches the rest of the admin interface.

Steps to reproduce:

  1. Log in to WordPress.
  2. Visit the frontend of the site.
  3. Observe the admin toolbar menu styling.

Expected behavior:

The frontend admin toolbar menu item should follow the updated Admin Reskin color scheme for consistent UI across admin and frontend views.

Attachments (16)

Huzaifa-20260228162201.png​ (186.5 KB ) - added by huzaifaalmesbah 8 months ago.
64762-before-sunrise-frontend.png​ (195.8 KB ) - added by softglaze 2 months ago.
Before patch, trunk 07220f23b7 (Sunrise scheme, front-end toolbar stays dark)
64762-before-ectoplasm-frontend.png​ (195.7 KB ) - added by softglaze 2 months ago.
Before patch, trunk 07220f23b7 (Ectoplasm scheme, front-end toolbar stays dark)
64762-after-sunrise-frontend.png​ (185.4 KB ) - added by softglaze 2 months ago.
After patch, PR 11267 (Sunrise scheme, front-end toolbar matches wp-admin)
64762-after-ectoplasm-frontend.png​ (188.3 KB ) - added by softglaze 2 months ago.
After patch, PR 11267 (Ectoplasm scheme, front-end toolbar matches wp-admin)
64762-after-fresh-frontend.png​ (189.5 KB ) - added by softglaze 2 months ago.
After patch, PR 11267 (Fresh scheme, front-end toolbar)
64762-after-default-frontend.png​ (182.6 KB ) - added by softglaze 2 months ago.
After patch, PR 11267 (Default scheme, front-end toolbar)
64762-after-sunrise-source.png​ (566.3 KB ) - added by softglaze 2 months ago.
After patch (page source showing admin-bar-color-scheme-css loading colors/sunrise/admin-bar.css)
64762-after-fresh-source-no-stylesheet.png​ (529.3 KB ) - added by softglaze 2 months ago.
After patch (page source with Fresh scheme, no admin-bar-color-scheme-css present)
11354-after-plugin-scheme-source-no-stylesheet.png​ (501.1 KB ) - added by softglaze 2 months ago.
11354-after-plugin-scheme-frontend-fallback.png​ (167.7 KB ) - added by softglaze 2 months ago.
11354-after-core-scheme-works-with-plugin-active.png​ (732.8 KB ) - added by softglaze 2 months ago.
11354-after-sunrise-source-scriptdebug-off-min-css.png​ (817.0 KB ) - added by softglaze 2 months ago.
11354-after-sunrise-min-css-loads-200.png​ (705.7 KB ) - added by softglaze 2 months ago.
11354-after-fresh-source-no-stylesheet.png​ (544.3 KB ) - added by softglaze 2 months ago.
11354-after-ectoplasm-frontend.png​ (186.4 KB ) - added by softglaze 2 months ago.

Change History (113)

#1 @huzaifaalmesbah
8 months ago

  • Keywords has-screenshots added

#2 @sabernhardt
8 months ago

  • Keywords admin-reskin 2nd-opinion added
  • Version → trunk

The front end intentionally did not use colors from the administration color scheme, and the $_wp_admin_css_colors variable is not available. See #26021 and #43742.

That is awkward now, after the default scheme changed within the admin area, but it was a decision.

If it is worth editing only for the Modern scheme, WP_Admin_Bar::initialize() theoretically could have something like this between enqueuing the admin-bar style and do_action( 'admin_bar_init' );.

if ( ! is_admin() ) {
	global $wp_version;

	$user_color = get_user_option( 'admin_color' );
	if ( isset( $user_color ) && 'modern' === $user_color ) {
		$suffix  = is_rtl() ? '-rtl' : '';
		$suffix .= SCRIPT_DEBUG ? '' : '.min';

		wp_enqueue_style(
			'admin-bar-admin-color',
			admin_url( "css/colors/modern/colors$suffix.css" ),
			array(),
			$wp_version
		);
	}
}

(I'm not sure whether it should check whether the user is logged in or any other conditions.)

#3 @sabernhardt
7 months ago

  • Milestone Awaiting Review → 7.0

#4 follow-up: @johnbillion
7 months ago

  • Keywords needs-patch added; 2nd-opinion removed

I've never understood or agreed with the reasons given in #26021 against using the admin colour scheme for the admin toolbar on the front end.

  • Arguments about colour clashes are moot. There are plenty of dark themes that clash with the toolbar, and light/dark colour schemes are prevalent.
  • Extra assets. The front end toolbar already loads admin-bar.css and dashicons.css. An extra stylesheet for the colour scheme is inconsequential compared to the 1,000+ lines of inline CSS output by the editor.

If we're going to facilitate the Modern colour scheme (which has been renamed to Default in 7.0) on the front end then we might as well facilitate all the available colour schemes.

I think for 7.0, support for the modern colour scheme must be added. Support for all other colour schemes can either come for free as part of that, or if there's still opposition then that can come at a later date.

#5 @noruzzaman
7 months ago

I think we should support all admin color schemes for the frontend toolbar. Currently, when a user changes the color scheme, the dashboard and the frontend toolbar look different. This creates an inconsistent experience and does not look good visually. Supporting the same color schemes on the frontend toolbar would make the UI more consistent across both the dashboard and the frontend.

#6 @JeffPaul
7 months ago

I concur with @johnbillion, it seems odd to be in the admin and have one set of colors/fonts/etc and then when you view the frontend of the site to potentially have a totally different set within the same adminbar. Aligning the frontend to the new admin color scheme feels like a step in correcting this odd UX.

#7 @joedolson
7 months ago

I agree with @johnbillion and @jeffpaul. Supporting the admin color scheme should apply to everything that's part of the admin, including the adminbar.

This ticket was mentioned in ​PR #11183 on ​WordPress/wordpress-develop by ​@huzaifaalmesbah.


7 months ago
#8

  • Keywords has-patch added; needs-patch removed

Enqueue the user's selected admin color scheme CSS for the toolbar on the front end to ensure visual consistency with the admin dashboard.

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

## Changes

  • Registers admin color schemes on the front end if not already available.
  • Enqueues the user's color scheme CSS with admin-bar as its sole dependency.
  • Supports all registered admin color schemes.
  • Schemes without a CSS URL (e.g., Fresh) gracefully fall back to base styles.

## Testing Instructions

  1. Log in to WordPress.
  2. Go to Users → Profile and select different color schemes.
  3. Visit the frontend.
  4. Expected: The toolbar matches the selected color scheme.

#10 @amesplant
7 months ago

  • Keywords dev-feedback added

#11 @amesplant
7 months ago

  • Keywords has-dev-note added

@huzaifaalmesbah overall, this looks like a solid solution. I left some comments in your PR for you to review.

#12 @amesplant
7 months ago

  • Keywords changes-requested added

#13 in reply to: ↑ 4 @sabernhardt
7 months ago

Arguments about colour clashes are moot. There are plenty of dark themes that clash with the toolbar, and light/dark colour schemes are prevalent.

Clashes can occur because the color scheme stylesheets contain many rules in addition to the toolbar styles, including common elements that the theme might not override:

body,
a,
a:hover,
a:active,
a:focus,
input[type=checkbox]:checked,
input[type=radio]:checked,
input[type=text]:focus,
input[type=password]:focus,
input[type=color]:focus,
input[type=date]:focus,
input[type=datetime]:focus,
input[type=datetime-local]:focus,
input[type=email]:focus,
input[type=month]:focus,
input[type=number]:focus,
input[type=search]:focus,
input[type=tel]:focus,
input[type=time]:focus,
input[type=url]:focus,
input[type=week]:focus,
select:focus,
textarea:focus,
input[type=checkbox]:focus,
input[type=radio]:focus

My earlier suggestion in comment:2 also would have had that problem.

I'll add a pull request that tries to trim the stylesheet and add it as an inline style.

#14 @JeffPaul
7 months ago

  • Keywords dev-feedback has-dev-note removed

This ticket was mentioned in ​PR #11192 on ​WordPress/wordpress-develop by ​@sabernhardt.


7 months ago
#15

  • Keywords has-unit-tests added

Adds CSS from admin color scheme stylesheets on the front end, as an inline style.

  • Uses a separate function, which can be removed from the admin_bar_init action (and possibly deprecated later if stylesheets are replaced with CSS custom properties, etc.).
  • Updates PHPUnit test.

Props: huzaifaalmesbah

Trac 64762

Use of AI Tools: none (by me)

​@sabernhardt commented on ​PR #11192:


7 months ago
#16

Built with code from #11183

#18 @r1k0
7 months ago

Patch Testing Report

Patch Tested: ​https://github.com/WordPress/wordpress-develop/pull/11192

Environment

  • WordPress: 7.0-beta3-20260306.170257
  • PHP: 8.3.30
  • Server: PHP.wasm
  • Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.51.0)
  • Browser: Chrome 145.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.1

Steps taken

  1. Log in to the admin dashboard.
  2. Visit the frontend.
  3. Observe the color of the admin toolbar ( with different Admin color schemes).
  4. ✅ Patch is solving the problem.

Expected result

  • The admin toolbar now matches the chosen admin color scheme.

Additional Notes

  • None

Screencast with results

Before:
​https://files.catbox.moe/jpqf8o.mp4
After:
​https://files.catbox.moe/6kyw6j.mp4

#19 @shailu25
7 months ago

Test Report

This Report Validates that the indicated patch address the issue.✅

Patch Tested: ​https://github.com/WordPress/wordpress-develop/pull/11192

Environment:

WordPress - 7.0-beta3-20260308.055323
OS - Windows
Browser - Chrome
Theme: Twenty Twenty Five
PHP - 8.2
Plugin - None

Actual Results:

  • Issue Resolved with Patch ✅

Supplemental Artifacts

Before Patch: ​https://drive.google.com/file/d/1KXC9_Pok5wgP5rbJlCGAIILhqArMfSl2/view

After Patch: ​https://drive.google.com/file/d/1z9l2IBV1Ry4jGDyDiNb85LjdMveNCN2z/view

#20 @sabernhardt
7 months ago

  • Keywords changes-requested removed

@SergeyBiryukov Please check how I edited the unit test.

#21 @audrasjb
7 months ago

  • Keywords commit added

Thanks for the PR @sabernhardt.
The unit test edits look good to me.

#22 @audrasjb
7 months ago

  • Owner set to audrasjb
  • Resolution → fixed
  • Status new → closed

In 62025:

Toolbar: add CSS from admin color scheme on front-end.

This changeset introduces the wp_admin_bar_add_color_scheme_to_front_end() which is hooked on admin_bar_init in order to use the CSS from admin color schemes on the admin bar on front-end, as inline styles.

Props sabernhardt, huzaifaalmesbah, audrasjb, johnbillion, noruzzaman, JeffPaul, joedolson, huzaifaalmesbah, amesplant, r1k0, shailu25.
Fixes #64762.

#24 @westonruter
7 months ago

  • Keywords changes-requested added
  • Resolution fixed
  • Status closed → reopened

There seems to be a couple problems with r62025:

First, PHPStan is rightly identifying that $start_position could be false while $end_position is true. This is a problem since then it passes false into strpos() as well as doing $end_position - $start_position with a non-int value:

1476   Parameter #2 $start of function substr expects int, int<0, max>|false given.                              
       🪪  argument.type

This patch seems to be needed:

  • src/wp-includes/admin-bar.php

    diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php
    index b9c7872d0c..be623baf9f 100644
    a b function wp_admin_bar_add_color_scheme_to_front_end() {  
    14721472                        if ( is_string( $css ) && str_contains( $css, '#wpadminbar' ) ) {
    14731473                                $start_position = strpos( $css, '#wpadminbar' );
    14741474                                $end_position   = strpos( $css, '.wp-pointer' );
    1475                                 if ( false !== $end_position && $end_position > $start_position ) {
     1475                                if ( false !== $start_position && false !== $end_position && $end_position > $start_position ) {
    14761476                                        $css = substr( $css, $start_position, $end_position - $start_position );
    14771477                                        if ( SCRIPT_DEBUG ) {
    14781478                                                $css = str_replace( '/* Pointers */', '', $css );

Secondly, I get a test failure when I try to test just the group in isolation:

$ npm run test:php -- --group=64762

There was 1 failure:

1) Tests_Dependencies_wpStyleLoaderSrc::test_without_wp_admin_css_colors_global
Failed asserting that '' contains "/colors.css".

/var/www/tests/phpunit/tests/dependencies/wpStyleLoaderSrc.php:28

It appears the test was passing before since some not-cleaned-up global is making is_admin() return true, so it doesn't enter both branches of the conditional in Tests_Dependencies_wpStyleLoaderSrc::test_without_wp_admin_css_colors_global().

A data provider needs to be added to test both when is_admin() and when not in the admin.

​@westonruter commented on ​PR #11192:


7 months ago
#25

There are a couple problems I identified with this commit. Details: https://core.trac.wordpress.org/ticket/64762#comment:24

#26 @sabernhardt
7 months ago

  • Keywords commit removed

If strpos( $css, '#wpadminbar' ) is false, then str_contains( $css, '#wpadminbar' ) also should be false. Then $start_position would not be defined and no CSS would be added.

I had trouble with the unit test just to make it pass in the GitHub action, so someone else would need to edit that.

This ticket was mentioned in ​PR #11255 on ​WordPress/wordpress-develop by ​@westonruter.


7 months ago
#27

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

## Use of AI Tools

None 🧠

#28 @westonruter
7 months ago

Ah, yes. I see that. In that case, better to just do the strpos( $css, '#wpadminbar' ) check instead of str_contains( $css, '#wpadminbar' ).

I was working on that, but then I found a more significant issue with the implementation: it was doing an HTTP request to obtain the color scheme CSS for every frontend page load. This resulted in the logic not working in the default Docker development environment where loopback requests are unfortunately broken (at least for me anyway), but it also is a performance problem. Query Monitor warns about this with each page load.

I've taken a stab in ​this PR to refactor the logic to not rely on HTTP requests but to load the file from the filesystem instead. Additionally, I've split the single test into two, one for the frontend and the other for the backend.

I admit I'm not fully familiar with the existing assertions or what the logic in wp_admin_bar_add_color_scheme_to_front_end() is supposed to be doing. I tried adding assertions to test that the existing logic is working as expected. I'm not sure what this assertion was supposed to be checking for originally:

<?php
$this->assertFalse( wp_style_loader_src( '', 'colors' ) )

Or what this was asserting with r62025:

<?php
$this->assertStringContainsString( '/colors.css', wp_style_loader_src( '', 'colors' ) );

The tests may fail, however, in GHA due to the files not being built. So the test may need to write a sample colors.css for test purposes, similar to how we have to touch files in other unit tests.

@sabernhardt I'll invite you to my fork so you can push up additional commits.

​@westonruter commented on ​PR #11255:


7 months ago
#29

With the Sunrise color scheme applied.

Before ❌

https://github.com/user-attachments/assets/c96fc4f4-31cc-43d5-95be-f6d9de1710e5

After ✅

https://github.com/user-attachments/assets/0dd21b48-b1eb-48c7-a2a8-d7d2b850487d

#30 @johnbillion
7 months ago

Sorry but this implementation falls quite short of what I would expect it to.

  • Why is a server-side HTTP request being performed on every front end page load to fetch the CSS file? Can the file not be loaded from the filesystem?
  • Pulling out a substring from the stylesheet seems fragile.

I appreciate that we're trying to squeeze this into 7.0 but there are Sass files with the source colours for each colour scheme available in wp-admin/css/colors and a colors task in Gruntfile.js to generate the stylesheets.

Can the task be updated to generate a separate stylesheet that just overrides the necessary admin bar colours with those from each colour scheme?

This ticket was mentioned in ​PR #11267 on ​WordPress/wordpress-develop by ​@johnbillion.


7 months ago
#31

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.

This ticket was mentioned in ​Slack in #core by audrasjb. ​View the logs.


7 months ago

​@andrewssanya commented on ​PR #11183:


7 months ago
#34

I have tested this out with different color schemes on the frontend, and it works.

https://github.com/user-attachments/assets/e39e4936-4d36-4e9e-b8f2-dce92113d432
https://github.com/user-attachments/assets/3f2f4c37-265e-43cb-b3be-bfb6b9a75512
https://github.com/user-attachments/assets/56e388e5-2b8e-45e3-834b-19433feff834

​@audrasjb commented on ​PR #11267:


7 months ago
#35

Thanks for putting together this PR @johnbillion! It looks fairly better than the current implementation.
I tested the PR on my side, and admin bar styles are correctly implemented on front end when we switch admin color schemes.

​@sabernhardt commented on ​PR #11267:


7 months ago
#36

I was ​having trouble with the registered schemes for bbPress and Grey Admin Color Schemes because both plugins use wp_admin_css_color() within the admin_init hook.

  • Switching the hook to init works for me on the front and back with Grey Admin Color Schemes and adding the fifth and sixth arguments. wp_admin_css_color( 'postmodern', __('Post Modern Grey', 'grey-admin-color-schemes'), plugins_url("postmodern/colors$rtl.css", __FILE__ ), array( '#464646', '#6D6D6D', '#D6D6D6', '#F1F1F1' ), array(), plugins_url("postmodern/admin-bar.css", __FILE__ ) );
  • bbPress would need more editing, and I have not solved that on the front.

#37 @mosescursor
7 months ago

Test Report

Description

Frontend admin toolbar not using updated admin color scheme

This report validates whether the indicated patch works as expected.

Patch tested: REPLACE_WITH_PATCH_URL

Environment

  • WordPress: 7.0-alpha-61215-src
  • PHP: 8.5.4
  • Server: nginx/1.29.5
  • Database: mysqli (Server: 8.4.8 / Client: mysqlnd 8.5.4)
  • Browser: Chrome 146.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.1

Actual Results

  1. ✅ Issue resolved with patch.

This ticket was mentioned in ​PR #11354 on ​WordPress/wordpress-develop by ​@sabernhardt.


7 months ago
#38

Alternative option to ​https://github.com/WordPress/wordpress-develop/pull/11267 that uses the same Sass and built stylesheets but avoids using the $_wp_admin_css_colors global variable.

  • Reverts the unit test to its original code.
  • Does not enqueue a stylesheet for the Fresh color scheme.
  • Enqueues an external stylesheet for the other 8 core schemes on the front end.
  • Does not attempt to support plugins' color schemes on the front.

Trac 64762

## Use of AI Tools

@johnbillion shared these details:

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.

#39 @sabernhardt
7 months ago

  • Keywords changes-requested removed

I was able to add Grey Admin Color Schemes on the front with PR 11267, but I would be more confident in that patch if someone could add color schemes from either bbPress or Jetpack on the front.

I submitted PR 11354 as an alternative option to consider, in case PR 11267 is not yet ready for this release.

#40 @noruzzaman
7 months ago

Test Report

Patch tested: ​https://github.com/WordPress/wordpress-develop/pull/11354

Environment

  • WordPress: 7.0-RC1-20260326.042417
  • PHP: 7.4.33
  • Server: PHP.wasm
  • Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.51.0)
  • Browser: Chrome 146.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.1

Actual Results

  1. ✅ Issue resolved with patch.

Video Link: ​https://vimeo.com/1177957494/aa513bbd90

#41 @vgnavada
7 months ago

Test Report

Description

I've tested using WordPress Playground (​https://playground.wordpress.net/wordpress.html?pr=11354) and can confirm the issue is resolved.

Patch tested: ​https://github.com/WordPress/wordpress-develop/pull/11354

Environment

  • WordPress: 7.0-RC1-20260326.042417
  • PHP: 8.3.30
  • Server: PHP.wasm
  • Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.51.0)
  • Browser: Chrome 146.0.0.0
  • OS: macOS
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.2.1

Actual Results

  1. ✅ Issue resolved with patch.

Supplemental Artifacts

Color Scheme LIGHT in wp-admin
https://i.ibb.co/rKvR2S0Y/image.png
Color Scheme LIGHT on Frontend
https://i.ibb.co/gMRrMJXN/image.png

Color Scheme SUNRISE in wp-admin
https://i.ibb.co/r257XRDk/LP6-HOyh-Sbm-EYTt-Ig-Dfpb-Q.png
Color Scheme SUNRISE on Frontend
https://i.ibb.co/5WZbGpN7/image.png

Color Scheme ECTOPLASM in wp-admin
https://i.ibb.co/s9p60vfy/image.png
Color Scheme ECTOPLASM on Frontend
https://i.ibb.co/0jV4s1N1/image.png

This ticket was mentioned in ​Slack in #core-test by r1k0. ​View the logs.


6 months ago

#43 @gaisma22
6 months ago

Patch Testing Report

Patch Tested: ​https://github.com/WordPress/wordpress-develop/pull/11354

Environment

  • WordPress: 7.0-beta6-62085-src
  • PHP: 8.3.30
  • Server: nginx/1.29.7
  • Database: MySQL 8.4.8
  • Browser: Brave
  • OS: Ubuntu 24.04
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None
  • Plugins: None

Steps Taken

  1. Went to Users > Profile and set color scheme to Sunrise.
  2. Visited the frontend. Before patch: Toolbar showed default black colors.
  3. Applied PR #11354 and hard refreshed. After patch: Toolbar matched Sunrise colors.
  4. Switched to Ectoplasm, saved, hard refreshed. After patch: Toolbar matched Ectoplasm colors.

✅ Patch is solving the problem

Expected Result

The frontend admin toolbar should match the color scheme selected in the user profile.

Additional Notes

  1. On 7.0-beta6 without the patch, the toolbar stays black on the frontend no matter what color scheme is set in the admin.
  2. Tested Sunrise and Ectoplasm. Both worked after the patch.

Screenshots/Screencast with results

Before Patch:
https://i.ibb.co/wZFyN4ww/before-sunrise.png

After Patch:
https://i.ibb.co/6cDTdJ2X/after-sunrise.png

https://i.ibb.co/C5vKwszr/after-ectoplasm.png

Last edited 6 months ago by gaisma22 (previous) (diff)

​@swissspidy commented on ​PR #11255:


6 months ago
#44

Thanks for working on this! I was perplexed why there was suddenly an extra HTTP request on very page by this function. 🤦

#45 @wildworks
6 months ago

#65080 was marked as a duplicate.

#46 @pavanpatil1
6 months ago

Patch Report
Patch Tested: ​https://github.com/WordPress/wordpress-develop/pull/11354

Environment
WordPress: 7.0-RC1-20260326.042417
PHP: 7.4.33
Browser: Chrome
OS: Mac

Patch is working fine ✅

Expected result
The admin toolbar now matches the chosen admin color scheme.

Screenshot:

#47 @wildworks
6 months ago

For the 7.0 release, it might be better to ship ​PR 11354, which has a minimal approach.

This ticket was mentioned in ​Slack in #core by jorbin. ​View the logs.


5 months ago

#49 follow-up: @jorbin
5 months ago

  • Keywords 2nd-opinion added

Each of these proposed solutions is a fairly large, and we are only two days away from the new beta 1. I think reverting [62025] and punting this to 7.1 is the safest solution.

#50 in reply to: ↑ 49 @desrosj
5 months ago

  • Keywords 2nd-opinion removed

Replying to jorbin:

Each of these proposed solutions is a fairly large, and we are only two days away from the new beta 1. I think reverting [62025] and punting this to 7.1 is the safest solution.

I tend to agree with this. Since this element has not matched the color scheme in the past, I think it's not surprising to a user if it does not after updating. Reverting gives us more time to find a better solution to this.

If we could find a minimal way to change the admin bar solely in the admin and leave it as it was in 6.9 on the front end for 7.0, I think that I would be in favor of that as an incremental step. But given that we're now less than 24 hours from the next pre-release, it's getting down to the wire.

This ticket was mentioned in ​PR #11771 on ​WordPress/wordpress-develop by ​@wildworks.


5 months ago
#51

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

## Use of AI Tools

#52 @wildworks
5 months ago

One drawback of reverting [62025] is that it causes a color theme mismatch between the frontend and backend. Specifically, the backend will use modern colors while the frontend will be stuck with the legacy fresh colors. This default color discrepancy did not occur in 6.9. As a more conservative approach, I've tried a PR that simply changes the frontend color theme to modern colors.

​https://github.com/WordPress/wordpress-develop/pull/11771

#53 @sabernhardt
5 months ago

I would prefer to revert [62025], even if the ticket stays in 7.0 (or moves to 7.1 and back to 7.0 if a patch is ready in time). Then the differences from 6.9 would be clearer.

PR that simply changes the frontend color theme to modern colors.

Anyone who purposely returns to the Fresh scheme should not have the Modern scheme CSS.

#54 @wildworks
5 months ago

PR that simply changes the frontend color theme to modern colors.

Anyone who purposely returns to the Fresh scheme should not have the Modern scheme CSS.

You're right. Indeed, it seems best to revert [62025] for now.

This ticket was mentioned in ​PR #11783 on ​WordPress/wordpress-develop by ​@wildworks.


5 months ago
#56

This reverts commit 421ac3612c1d221bcb930c29ac3a9252ed25d328 (r62025).

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

## Use of AI Tools

None

#57 @wildworks
5 months ago

In 62349:

Toolbar: Revert add CSS from admin color scheme on front-end.

The implementation issues a server-side HTTP request on every front-end page load and extracts the toolbar CSS via fragile substring matching. Alternatives are too large to land this late in the release cycle, so the fix is deferred to a future release.

Reverts [62025].

Props desrosj, jorbin, mukesh27, sabernhardt, wildworks.

See #64762.

#58 @wildworks
5 months ago

  • Keywords dev-feedback added

I propose backporting [62349] to the 7.0 branch.

#59 @JeffPaul
5 months ago

  • Keywords fixed-major added

#60 @audrasjb
5 months ago

  • Keywords dev-reviewed added; dev-feedback removed

Marking as dev-reviewed. Let's backport [62349] to branch 7.0.

#61 @audrasjb
5 months ago

In 62354:

Toolbar: Revert add CSS from admin color scheme on front-end.

The implementation issues a server-side HTTP request on every front-end page load and extracts the toolbar CSS via fragile substring matching. Alternatives are too large to land this late in the release cycle, so the fix is deferred to a future release.

Reverts [62025].

Reviewed by audrasjb, wildworks.
Merges [62349] to the 7.0 branch.
Props desrosj, jorbin, mukesh27, sabernhardt, wildworks.
See #64762.

#62 @audrasjb
5 months ago

  • Keywords has-screenshots has-patch has-unit-tests fixed-major dev-reviewed removed
  • Milestone 7.0 → 7.0.1

I backported the [62349] revert to 7.0. Moving this ticket to 7.0.1 for further development.

#63 @audrasjb
5 months ago

Removing trunk version as this is not going to be shipped with WP 7.0 but in the next releases.

#64 @sabernhardt
5 months ago

  • Version trunk

#65 @jorbin
5 months ago

#65285 was marked as a duplicate.

#66 @sabernhardt
5 months ago

#65290 was marked as a duplicate.

#67 @huzaifaalmesbah
4 months ago

#65385 was marked as a duplicate.

​@wildworks commented on ​PR #11783:


4 months ago
#68

This PR has already been committed. https://core.trac.wordpress.org/changeset/62349

​@wildworks commented on ​PR #11267:


4 months ago
#69

Now that 7.0 has been released, I believe we can resume this PR towards 7.1.

#70 @jorbin
4 months ago

  • Milestone 7.0.1 → 7.1

With ​PR #11267 looking like the best path forward and that PR adding new files which can't be done in a minor release, I am moving this to 7.1.

#71 @huzaifaalmesbah
3 months ago

Since ​Admin color scheme reflected in the Site Editor has landed for WordPress 7.1, I think this ticket would complement that work nicely. Having the frontend admin toolbar respect the selected admin color scheme would provide a more consistent experience across the Site Editor, wp-admin, and the frontend.

If everyone has the bandwidth to work on it, I'd love to see this land in 7.1 as well.

This ticket was mentioned in ​Slack in #core-test by noruzzaman. ​View the logs.


3 months ago

This ticket was mentioned in ​Slack in #core by adrianduffell. ​View the logs.


2 months ago

@softglaze
2 months ago

Before patch, trunk 07220f23b7 (Sunrise scheme, front-end toolbar stays dark)

@softglaze
2 months ago

Before patch, trunk 07220f23b7 (Ectoplasm scheme, front-end toolbar stays dark)

@softglaze
2 months ago

After patch, PR 11267 (Sunrise scheme, front-end toolbar matches wp-admin)

@softglaze
2 months ago

After patch, PR 11267 (Ectoplasm scheme, front-end toolbar matches wp-admin)

@softglaze
2 months ago

After patch, PR 11267 (Fresh scheme, front-end toolbar)

@softglaze
2 months ago

After patch, PR 11267 (Default scheme, front-end toolbar)

@softglaze
2 months ago

After patch (page source showing admin-bar-color-scheme-css loading colors/sunrise/admin-bar.css)

@softglaze
2 months ago

After patch (page source with Fresh scheme, no admin-bar-color-scheme-css present)

#74 @softglaze
2 months ago

Patch Testing Report

Patch tested: ​https://github.com/WordPress/wordpress-develop/pull/11267

Tested the PR branch directly at commit 8a7542d6aa. This reflects the state of the branch from March, which is why the version string below reports as 7.0-beta5 and not current trunk.

Environment

  • WordPress: 7.0-beta5-61991-src
  • Subdirectory: No
  • PHP: 8.3.32
  • Server: nginx/1.31.3
  • Database: mysqli (Server: 9.7.1 / Client: mysqlnd 8.3.32)
  • Browser: Chrome 150.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.4
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.3.0

Steps taken

  1. Cleaned trunk to commit 07220f23b7 and ran npm run build:dev.
  2. Set profile color scheme to Sunrise and checked the frontend toolbar.
  3. Set profile color scheme to Ectoplasm and checked the frontend toolbar.
  4. Checked the page source on trunk to verify the current stylesheet behavior.
  5. Fetched upstream pull/11267/head, checked it out, and rebuilt.
  6. Set each of the four schemes, checking the frontend toolbar and page source for each.
  7. ✅ Patch is solving the problem: The frontend toolbar now matches the selected admin scheme, and a per-scheme stylesheet is enqueued on the front end.

Expected result

  • The frontend toolbar should visually match the color scheme chosen in the user profile.

Additional Notes

Scheme Front-end toolbar admin-bar-color-scheme-css Stylesheet
Default matches wp-admin present colors/modern/admin-bar.css
Fresh matches wp-admin absent —
Sunrise matches wp-admin present colors/sunrise/admin-bar.css
Ectoplasm matches wp-admin present colors/ectoplasm/admin-bar.css
  • Fresh scheme: no extra stylesheet is enqueued.
  • Default scheme loads the stylesheet from the modern/ directory.
  • The "Howdy, admin" submenu now properly follows the scheme; on trunk, it stayed dark.
  • The PR branch is based on trunk from before [62349] and currently has conflicts. The last CI run was 16 March, meaning its logs and Playground artifact have expired.

Screenshots with results

Before:

After:

​@softglaze commented on ​PR #11267:


2 months ago
#75

I tested this branch locally at commit "8a7542d6aa". Default, Sunrise and Ectoplasm each enqueue their own admin-bar.css on the front end and the toolbar matches the selected admin scheme. Fresh enqueues no stylesheet. Note the branch can't currently be previewed via Playground (the CI artifact has expired).

https://github.com/user-attachments/assets/bfa4a060-28b0-48f3-8e50-dd3d1cd759bf
https://github.com/user-attachments/assets/9f434fb5-ed28-4156-a0d8-27d35d0ea344

This ticket was mentioned in ​Slack in #core by softglaze. ​View the logs.


2 months ago

​@johnbillion commented on ​PR #11267:


2 months ago
#77

@softglazee @fushar Appreciate your testing but I think #11354 supersedes this now. Are you able to take a look?

​@softglaze commented on ​PR #11267:


2 months ago
#78

@johnbillion yes, i'm going to test #11354, and thank you

#79 @softglaze
2 months ago

  • Keywords has-test-info added

Patch Testing Report

Patch tested: ​https://github.com/WordPress/wordpress-develop/pull/11354

Environment

  • WordPress: 7.0-RC1-62111-src
  • Subdirectory: No
  • PHP: 8.3.32
  • Server: nginx/1.31.3
  • Database: mysqli (Server: 9.7.1 / Client: mysqlnd 8.3.32)
  • Browser: Chrome 150.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Twenty-Five 1.5
  • MU Plugins: None activated
  • Plugins:
    • Test Reports 1.3.0
  • Gutenberg: not installed

Tested the PR branch at 794875760a (25 March), which is why the version string reads 7.0-RC1-62111-src. This is a different March snapshot from PR 11267.

Steps taken

  1. Cleaned trunk to commit 5bc2c6228c and ran build.
  2. Fetched pull/11354/head, checked out 794875760a, and rebuilt.
  3. Confirmed both admin-bar.css (4329 bytes) and admin-bar.min.css (3926 bytes) are successfully generated by the Grunt task for each scheme.
  4. Checked all nine options in the profile in the front-end page source.
  5. Turned SCRIPT_DEBUG off, then rechecked the front-end source and Network tab for the minified path.
  6. Installed the "Grey Admin Color Schemes" plugin, tested its three schemes, and re-tested a core scheme while the plugin was active.
  7. ✅ Patch is solving the problem: Core schemes successfully enqueue their front-end styles (handling both minified and non-minified paths), and custom plugin schemes fall back safely without breaking.

Expected result

  • The front-end toolbar should enqueue the correct stylesheet based on the selected core scheme and SCRIPT_DEBUG status.

Additional Notes

Scheme admin-bar-color-scheme-css Stylesheet
Modern (Default) present colors/modern/admin-bar.css
Light present colors/light/admin-bar.css
Blue present colors/blue/admin-bar.css
Coffee present colors/coffee/admin-bar.css
Ectoplasm present colors/ectoplasm/admin-bar.css
Midnight present colors/midnight/admin-bar.css
Ocean present colors/ocean/admin-bar.css
Sunrise present colors/sunrise/admin-bar.css
Fresh absent —
  • With SCRIPT_DEBUG off, the source correctly requests admin-bar.min.css. The file returns a 200 OK and transfers 4.2 kB, confirming the production path works.
  • For all three plugin-registered schemes (from Grey Admin Color Schemes), no stylesheet is enqueued on the front end. The toolbar gracefully falls back to the default dark style with no breakage.
  • Core schemes continue to work (1/1 stylesheet enqueued) even while the color scheme plugin is active.
  • The function returns early on is_admin(), meaning this logic is strictly front-end only. site-editor.php shows no stylesheet enqueued, which is the expected behavior.
  • Note: fushar raised a color question on PR 11267, and it is worth noting that PR 11354 contains the exact same Sass commits (3700f88 and 8a7542d) from PR 11267.

Screenshots with results

​@softglaze commented on ​PR #11354:


2 months ago
#80

I have tested this branch locally at commit 794875760a. Here is the detailed breakdown of the behavior:

  • Core Schemes: Modern, Light, Blue, Coffee, Ectoplasm, Midnight, Ocean, and Sunrise all correctly enqueue their respective colors/{scheme}/admin-bar.css on the front end. Fresh enqueues no stylesheet, as expected.
  • Production Path (SCRIPT_DEBUG off): The Grunt task successfully builds both variants. When SCRIPT_DEBUG is false, the source correctly requests admin-bar.min.css, which returns a 200 OK (4.2 kB transferred).
  • Plugin Schemes (Fallback Behavior): I tested this against the "Grey Admin Color Schemes" plugin. For plugin-registered schemes, no stylesheet is enqueued on the front end, and the toolbar safely falls back to the default dark style without any breakage. Core schemes remain unaffected and continue to work while the plugin is active.
  • Site Editor: The function correctly returns early on is_admin(), so the stylesheet is not loaded in site-editor.php.

Full test report and screenshots have been posted on Trac #64762.

​@softglaze commented on ​PR #11267:


2 months ago
#81

Just a heads-up that I have fully tested PR 11354 as requested. You can find the complete test report, including how it handles plugin-registered schemes and the minified production path, over on Trac #64762.

#82 @ugyensupport
2 months ago

@sabernhardt @audrasjb Which Patch should we foucs on to assure the case above

#83 @sabernhardt
2 months ago

  • Milestone 7.1 → 7.2

Both pull requests have conflicts to resolve because the toolbar styles have changed since March, and #65445 might change the styles again this week. Two days is not enough for both tickets (and maybe not enough for either ticket).

​@fushar commented on ​PR #11354:


3 weeks ago
#84

Let's get this to the finish line for 7.2! @sabernhardt, would you like to continue working on this? I have spare bandwidth to help if not.

​@wildworks commented on ​PR #11354:


3 weeks ago
#85

@fushar, if you have the bandwidth, please feel free to go ahead with this. We only have a month left until 7.2 Beta 1, which might seem like a long time, but it really isn't much time at all 😄

This ticket was mentioned in ​PR #13806 on ​WordPress/wordpress-develop by ​@fushar.


2 weeks ago
#86

  • Keywords has-patch has-unit-tests added

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

Follow-up to: ​https://github.com/WordPress/wordpress-develop/pull/11354 by @sabernhardt.

This PR enqueues a small CSS in the logged-in frontend pages so that the admin bar is shown using the current admin bar color scheme.

The improvements over the linked PR are as follows.

  • This PR is now rebased on top of latest upstream trunk.
  • Instead of having a second hardcoded list of core schemes (minus fresh), this PR simply checks for the existence of the newly built admin-bar CSS file using file_exists().
  • This PR avoids color duplication between colors.scss and admin-bar.scss by extracting the color definition into a shared _scheme.scss partial.

I also tried to resolve all review comments from the original PR.

I tested this PR using Core color schemes and plugin's (such as Sleeker Admin Color Schemes) and it works fine!

Use of AI Tools

Used Claude Opus 5.5 to rebase the original PR and brainstorm solutions for improvements.

​@fushar commented on ​PR #11354:


2 weeks ago
#87

Since I can't push to the fork, I opened a new PR instead. Rebased and continued the improvements here: ​https://github.com/WordPress/wordpress-develop/pull/13806

​@fushar commented on ​PR #13806:


2 weeks ago
#88

Tagging reviewers: @sabernhardt, @t-hamano, @westonruter 🙂

​@wildworks commented on ​PR #11354:


2 weeks ago
#89

Closing this in favor of #13806

​@fushar commented on ​PR #13806:


2 weeks ago
#90

I tested this PR using Core color schemes and plugin's (such as Sleeker Admin Color Schemes) and it works fine!

Does this mean the plugin-defined color scheme is properly applied to the front end? Based on what I checked with the AI, this doesn't seem to be true.

Sorry, it was bad phrasing from me. I meant when using a plugin-defined scheme, it does not enqueue the CSS as expected (as per the old PR's behavior) 🤦

​@fushar commented on ​PR #13806:


2 weeks ago
#91

With the current implementation, custom color schemes registered by plugins via wp_admin_css_color() are not applied to the admin bar on the front end. Most plugins register their color schemes on admin_init, so the registered data isn't available on the front end.

Even if we encouraged plugins to register them on init instead, the registered stylesheet targets the entire dashboard and includes generic selectors such as body and a. Loading it as-is on the front end would affect the theme's appearance.

Right, this is an unsolved problem right now. One solution is to allow wp_admin_css_color() to receive an admin bar CSS as a new arg, which Core will enqueue on frontend screen like this PR does. Note that we also have this issue https://core.trac.wordpress.org/ticket/65776 that proposes adding more args to allow passing color seeds. It looks like it's better if these issues are solved together later 🙂

​@fushar commented on ​PR #13806:


2 weeks ago
#92

One solution is to allow wp_admin_css_color() to receive an admin bar CSS as a new arg, which Core will enqueue on frontend screen like this PR does.

I explored this solution. Something like this:

<details>
<summary>Click to open</summary>

  • src/wp-includes/admin-bar.php

    diff --git i/src/wp-includes/admin-bar.php w/src/wp-includes/admin-bar.php
    index c847c8994c..c23fce361e 100644
    i w function _get_admin_bar_pref( $context = 'front', $user = 0 ) {  
    14911491 * Enqueues the admin bar color scheme stylesheet on the front end if present.
    14921492 *
    14931493 * @since 7.2.0
     1494 *
     1495 * @global array $_wp_admin_css_colors
    14941496 */
    14951497function wp_enqueue_admin_bar_color_scheme_styles() {
     1498        global $_wp_admin_css_colors;
     1499
    14961500        if ( is_admin() ) {
    14971501                return;
    14981502        }
    14991503
     1504        $registered_color_schemes = $_wp_admin_css_colors ?? array();
     1505        register_admin_color_schemes();
     1506        $_wp_admin_css_colors = array_merge( $_wp_admin_css_colors, $registered_color_schemes );
     1507
    15001508        $color_scheme = get_user_option( 'admin_color' );
    1501         if ( empty( $color_scheme ) ) {
     1509        if ( empty( $color_scheme ) || ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) {
    15021510                $color_scheme = 'modern';
    15031511        }
    15041512
    1505         if ( sanitize_key( $color_scheme ) !== $color_scheme ) {
    1506                 return;
    1507         }
    1508 
    1509         $suffix = SCRIPT_DEBUG ? '' : '.min';
    1510         $path   = "css/colors/{$color_scheme}/admin-bar{$suffix}.css";
    1511 
    1512         if ( ! file_exists( ABSPATH . 'wp-admin/' . $path ) ) {
     1513        $admin_bar_url = $_wp_admin_css_colors[ $color_scheme ]->admin_bar_url ?? '';
     1514        if ( ! $admin_bar_url ) {
    15131515                return;
    15141516        }
    15151517
    15161518        wp_enqueue_style(
    15171519                'admin-bar-color-scheme',
    1518                 admin_url( $path ),
     1520                $admin_bar_url,
    15191521                array( 'admin-bar' )
    15201522        );
    15211523}
  • src/wp-includes/general-template.php

    diff --git i/src/wp-includes/general-template.php w/src/wp-includes/general-template.php
    index 73178b9eca..6c0b24db24 100644
    i w function paginate_links( $args = '' ) {  
    51775177 *         '#07273E', '#14568A', '#D54E21', '#2683AE'
    51785178 *     ) );
    51795179 *
     5180 * Alternatively, the third argument can be an array of arguments:
     5181 *
     5182 *     wp_admin_css_color(
     5183 *         'classic',
     5184 *         __( 'Classic' ),
     5185 *         array(
     5186 *             'url'           => plugins_url( 'css/colors.css', __FILE__ ),
     5187 *             'admin_bar_url' => plugins_url( 'css/admin-bar.css', __FILE__ ),
     5188 *         ),
     5189 *         array( '#07273E', '#14568A', '#D54E21', '#2683AE' )
     5190 *     );
     5191 *
     5192 * To apply the color scheme to the admin bar on the front end, the color scheme
     5193 * must be registered on the front end too.
     5194 *
    51805195 * @since 2.5.0
     5196 * @since 7.2.0 The `$url` parameter can be an array of arguments.
    51815197 *
    51825198 * @global array $_wp_admin_css_colors
    51835199 *
    5184  * @param string $key    The unique key for this theme.
    5185  * @param string $name   The name of the theme.
    5186  * @param string $url    The URL of the CSS file containing the color scheme.
    5187  * @param array  $colors Optional. An array of CSS color definition strings which are used
    5188  *                       to give the user a feel for the theme.
    5189  * @param array  $icons {
     5200 * @param string       $key    The unique key for this theme.
     5201 * @param string       $name   The name of the theme.
     5202 * @param string|array $url    {
     5203 *     The URL of the CSS file containing the color scheme, or an array of arguments.
     5204 *
     5205 *     @type string $url           Optional. The URL of the CSS file containing the color scheme.
     5206 *     @type string $admin_bar_url Optional. The URL of the CSS file containing the color scheme
     5207 *                                 for the admin bar only, loaded on the front end. It should only
     5208 *                                 contain styles scoped to `#wpadminbar`.
     5209 * }
     5210 * @param array        $colors Optional. An array of CSS color definition strings which are used
     5211 *                             to give the user a feel for the theme.
     5212 * @param array        $icons {
    51905213 *     Optional. CSS color definitions used to color any SVG icons.
    51915214 *
    51925215 *     @type string $base    SVG icon base color.
    … … function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = arra  
    52015224                $_wp_admin_css_colors = array();
    52025225        }
    52035226
     5227        $args = wp_parse_args(
     5228                is_array( $url ) ? $url : array( 'url' => $url ),
     5229                array(
     5230                        'url'           => '',
     5231                        'admin_bar_url' => '',
     5232                )
     5233        );
     5234
    52045235        $_wp_admin_css_colors[ $key ] = (object) array(
    5205                 'name'        => $name,
    5206                 'url'         => $url,
    5207                 'colors'      => $colors,
    5208                 'icon_colors' => $icons,
     5236                'name'          => $name,
     5237                'url'           => $args['url'],
     5238                'admin_bar_url' => $args['admin_bar_url'],
     5239                'colors'        => $colors,
     5240                'icon_colors'   => $icons,
    52095241        );
    52105242}
    52115243
    … … function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = arra  
    52205252 * @since 3.0.0
    52215253 */
    52225254function register_admin_color_schemes() {
    5223         $suffix  = is_rtl() ? '-rtl' : '';
    5224         $suffix .= SCRIPT_DEBUG ? '' : '.min';
     5255        $min_suffix = SCRIPT_DEBUG ? '' : '.min';
     5256        $suffix     = ( is_rtl() ? '-rtl' : '' ) . $min_suffix;
    52255257
    52265258        wp_admin_css_color(
    52275259                'modern',
    52285260                _x( 'Default', 'admin color scheme' ),
    5229                 admin_url( "css/colors/modern/colors$suffix.css" ),
     5261                array(
     5262                        'url'           => admin_url( "css/colors/modern/colors$suffix.css" ),
     5263                        'admin_bar_url' => admin_url( "css/colors/modern/admin-bar$min_suffix.css" ),
     5264                ),
    52305265                array( '#1e1e1e', '#3858e9', '#7b90ff' ),
    52315266                array(
    52325267                        'base'    => '#f3f1f1',
    … … function register_admin_color_schemes() {  
    52505285        wp_admin_css_color(
    52515286                'light',
    52525287                _x( 'Light', 'admin color scheme' ),
    5253                 admin_url( "css/colors/light/colors$suffix.css" ),
     5288                array(
     5289                        'url'           => admin_url( "css/colors/light/colors$suffix.css" ),
     5290                        'admin_bar_url' => admin_url( "css/colors/light/admin-bar$min_suffix.css" ),
     5291                ),
    52545292                array( '#e5e5e5', '#6a6a6a', '#c64606', '#007cba' ),
    52555293                array(
    52565294                        'base'    => '#999',
    … … function register_admin_color_schemes() {  
    52625300        wp_admin_css_color(
    52635301                'blue',
    52645302                _x( 'Blue', 'admin color scheme' ),
    5265                 admin_url( "css/colors/blue/colors$suffix.css" ),
     5303                array(
     5304                        'url'           => admin_url( "css/colors/blue/colors$suffix.css" ),
     5305                        'admin_bar_url' => admin_url( "css/colors/blue/admin-bar$min_suffix.css" ),
     5306                ),
    52665307                array( '#183751', '#245278', '#437aa8', '#e1a948' ),
    52675308                array(
    52685309                        'base'    => '#e5f8ff',
    … … function register_admin_color_schemes() {  
    52745315        wp_admin_css_color(
    52755316                'midnight',
    52765317                _x( 'Midnight', 'admin color scheme' ),
    5277                 admin_url( "css/colors/midnight/colors$suffix.css" ),
     5318                array(
     5319                        'url'           => admin_url( "css/colors/midnight/colors$suffix.css" ),
     5320                        'admin_bar_url' => admin_url( "css/colors/midnight/admin-bar$min_suffix.css" ),
     5321                ),
    52785322                array( '#232a2e', '#333c42', '#69a8bb', '#cf4339' ),
    52795323                array(
    52805324                        'base'    => '#f1f2f3',
    … … function register_admin_color_schemes() {  
    52865330        wp_admin_css_color(
    52875331                'sunrise',
    52885332                _x( 'Sunrise', 'admin color scheme' ),
    5289                 admin_url( "css/colors/sunrise/colors$suffix.css" ),
     5333                array(
     5334                        'url'           => admin_url( "css/colors/sunrise/colors$suffix.css" ),
     5335                        'admin_bar_url' => admin_url( "css/colors/sunrise/admin-bar$min_suffix.css" ),
     5336                ),
    52905337                array( '#6f2724', '#8a312d', '#ad631e', '#ccaf0b' ),
    52915338                array(
    52925339                        'base'    => '#f3f1f1',
    … … function register_admin_color_schemes() {  
    52985345        wp_admin_css_color(
    52995346                'ectoplasm',
    53005347                _x( 'Ectoplasm', 'admin color scheme' ),
    5301                 admin_url( "css/colors/ectoplasm/colors$suffix.css" ),
     5348                array(
     5349                        'url'           => admin_url( "css/colors/ectoplasm/colors$suffix.css" ),
     5350                        'admin_bar_url' => admin_url( "css/colors/ectoplasm/admin-bar$min_suffix.css" ),
     5351                ),
    53025352                array( '#392751', '#4a3369', '#646c3e', '#d46f15' ),
    53035353                array(
    53045354                        'base'    => '#ece6f6',
    … … function register_admin_color_schemes() {  
    53105360        wp_admin_css_color(
    53115361                'ocean',
    53125362                _x( 'Ocean', 'admin color scheme' ),
    5313                 admin_url( "css/colors/ocean/colors$suffix.css" ),
     5363                array(
     5364                        'url'           => admin_url( "css/colors/ocean/colors$suffix.css" ),
     5365                        'admin_bar_url' => admin_url( "css/colors/ocean/admin-bar$min_suffix.css" ),
     5366                ),
    53145367                array( '#2b3f44', '#39535a', '#567958', '#aa9d88' ),
    53155368                array(
    53165369                        'base'    => '#f2fcff',
    … … function register_admin_color_schemes() {  
    53225375        wp_admin_css_color(
    53235376                'coffee',
    53245377                _x( 'Coffee', 'admin color scheme' ),
    5325                 admin_url( "css/colors/coffee/colors$suffix.css" ),
     5378                array(
     5379                        'url'           => admin_url( "css/colors/coffee/colors$suffix.css" ),
     5380                        'admin_bar_url' => admin_url( "css/colors/coffee/admin-bar$min_suffix.css" ),
     5381                ),
    53265382                array( '#382e27', '#5c4c40', '#916745', '#9ea476' ),
    53275383                array(
    53285384                        'base'    => '#f3f2f1',

</details>

Plugins would register the scheme at init as follows:

add_action(
        'init',
        function () {
                wp_admin_css_color(
                        'demo',
                        'Demo,
                        array(
                                'url'           => plugins_url( 'demo-admin-color-scheme/colors.css', __FILE__ ),
                                'admin_bar_url' => plugins_url( 'demo-admin-color-scheme/admin-bar.css', __FILE__ ),
                        ),
                        array( '#3b1f4f', '#2c173b', '#e05d9a', '#f2b134' ),
                        array(
                                'base'    => '#f2eef4',
                                'focus'   => '#ff9ccb',
                                'current' => '#fff',
                        )
                );
        }
);

This seems to work in my testing. But I think this should be another ticket.

​@fushar commented on ​PR #13806:


11 days ago
#93

I considered inline styles as well during my exploration. I think that's the most future-proof solution, considering that wp_admin_css_color proposal, however, it will add uncacheable inline CSS to every logged-in frontend request. I wonder if that's acceptable performance-wise?

​@wildworks commented on ​PR #13806:


11 days ago
#94

it will add uncacheable inline CSS to every logged-in frontend request. I wonder if that's acceptable performance-wise?

We might actually need to benchmark and compare these approaches. My guess is that the performance impact will be negligible. For reference, wp_maybe_inline_styles uses a similar approach to inject CSS inline.

​https://github.com/t-hamano/wordpress-develop/blob/f4350cd9e252a011db98a1b786975fbe2a544db5/src/wp-includes/script-loader.php#L3184

​@wildworks commented on ​PR #13806:


9 days ago
#95

There doesn't seem to be much difference, even though this report was generated by AI.

---

Setup

  • Local wordpress-develop environment (nginx, HTTP/1.1), front page, logged in as admin, modern color scheme.
  • Both variants use admin-bar.min.css (4,025 bytes).
  • A temporary mu-plugin switches between the variants with ?ab=file and ?ab=inline. The inline variant sets path data, so wp_maybe_inline_styles() inlines the stylesheet. The test checks that each variant outputs only <link> or only <style>.
  • Playwright (Chromium) with CDP throttling: Slow 4G (150ms latency, 1.6 Mbps down, 750 kbps up) and 4x CPU slowdown.
  • 30 runs per variant per theme. File and inline runs alternate, and their order is swapped on every iteration.
  • Cold: new browser context, empty cache. Warm: second load in the same context, so the browser cache is populated.

<details>
<summary>mu-plugin used for the A/B switch</summary>

<?php
add_action(
        'admin_bar_init',
        static function () {
                $styles = wp_styles();
                if ( ! isset( $styles->registered['admin-bar-color-scheme'], $_GET['ab'] ) ) {
                        return;
                }
                $style      = $styles->registered['admin-bar-color-scheme'];
                $style->src = str_replace( 'admin-bar.css', 'admin-bar.min.css', $style->src );
                if ( 'inline' === $_GET['ab'] ) {
                        $rel = substr( $style->src, strlen( admin_url() ) );
                        wp_style_add_data( 'admin-bar-color-scheme', 'path', ABSPATH . 'wp-admin/' . $rel );
                }
        },
        11
);

</details>

Results

Median ± median absolute deviation (ms). Diff = inline − file.

Theme Cache Metric File Inline Diff
Twenty Twenty-Five Cold FCP 1470 ± 6 1440 ± 8 −30
Twenty Twenty-Five Cold LCP 1544 ± 4 1512 ± 4 −32
Twenty Twenty-Five Warm FCP 424 ± 4 428 ± 2 +4
Twenty Twenty-Five Warm LCP 472 ± 4 492 ± 4 +20
Twenty Twenty-One Cold FCP 1924 ± 8 1914 ± 10 −10
Twenty Twenty-One Cold LCP 1924 ± 8 1914 ± 10 −10
Twenty Twenty-One Warm FCP 416 ± 8 396 ± 4 −20
Twenty Twenty-One Warm LCP 444 ± 8 460 ± 16 +16

With inlining, the HTML grows by about 4 KB on every page view (uncompressed in this local environment).

Takeaways

  • Cold cache: inline is 10–35ms faster (about 1–2%) because it removes one render-blocking request. This is larger than the run-to-run noise.
  • Warm cache: the differences are mixed in sign and about the same size as the noise, so neither variant is clearly faster. The file variant benefits from the browser cache, and the inline variant re-sends the CSS with every page. Both effects are small.

Caveats

  • The local environment uses HTTP/1.1 and may not compress responses. In production, with HTTP/2 and gzip/brotli, both the cost of the extra request and the extra inline bytes (about 1 KB compressed) are likely smaller, so the gap should shrink.
  • CDP throttling does not fully reproduce real network round-trip times.
  • Only Chromium was measured.

​@fushar commented on ​PR #13806:


9 days ago
#96

Thanks for the test @t-hamano, I'm contemplating and brainstorming another solution that combines both approaches. Give me a few hours...

​@fushar commented on ​PR #13806:


9 days ago
#97

All right, I have this other approach here: ​https://github.com/WordPress/wordpress-develop/pull/14011 which inlines CSS variables instead. My vision is to make the solution future-proof with https://core.trac.wordpress.org/ticket/65776 and align with the current "WPDS-fication" of classic PHP admin screens. I asked a question for @aduth in that ticket. If we want to make wp_admin_css_color() the source of truth for the seeds/colors, then I don't see any better approach. I'm happy to be wrong though!

Note: See TracTickets for help on using tickets.