[wp-trac] [WordPress Trac] #64762: Frontend admin toolbar not using updated admin color scheme
WordPress Trac
noreply at wordpress.org
Sat Mar 14 18:42:05 UTC 2026
#64762: Frontend admin toolbar not using updated admin color scheme
-------------------------------------------------+-------------------------
Reporter: huzaifaalmesbah | Owner: audrasjb
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 7.0
Component: Toolbar | Version: trunk
Severity: normal | Resolution:
Keywords: has-screenshots admin-reskin has- | Focuses: ui, css
patch has-unit-tests commit changes-requested |
-------------------------------------------------+-------------------------
Changes (by westonruter):
* keywords: has-screenshots admin-reskin has-patch has-unit-tests commit
=>
has-screenshots admin-reskin has-patch has-unit-tests commit changes-
requested
* status: closed => reopened
* resolution: fixed =>
Comment:
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:
{{{#!diff
diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php
index b9c7872d0c..be623baf9f 100644
--- a/src/wp-includes/admin-bar.php
+++ b/src/wp-includes/admin-bar.php
@@ -1472,7 +1472,7 @@ function
wp_admin_bar_add_color_scheme_to_front_end() {
if ( is_string( $css ) && str_contains( $css,
'#wpadminbar' ) ) {
$start_position = strpos( $css,
'#wpadminbar' );
$end_position = strpos( $css, '.wp-
pointer' );
- if ( false !== $end_position &&
$end_position > $start_position ) {
+ if ( false !== $start_position && false
!== $end_position && $end_position > $start_position ) {
$css = substr( $css,
$start_position, $end_position - $start_position );
if ( SCRIPT_DEBUG ) {
$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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64762#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list