From 9eb2c2c63a9cc55efb11a1a9c0f43c2b224af38a Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Sun, 10 May 2026 01:11:08 +0900 Subject: [PATCH] Revert "Toolbar: add CSS from admin color scheme on front-end." This reverts commit 421ac3612c1d221bcb930c29ac3a9252ed25d328. --- src/wp-includes/admin-bar.php | 46 ------------------- src/wp-includes/default-filters.php | 1 - .../tests/dependencies/wpStyleLoaderSrc.php | 9 +--- 3 files changed, 2 insertions(+), 54 deletions(-) diff --git a/src/wp-includes/admin-bar.php b/src/wp-includes/admin-bar.php index 41b01c3c5cc68..50868b11a2870 100644 --- a/src/wp-includes/admin-bar.php +++ b/src/wp-includes/admin-bar.php @@ -1466,49 +1466,3 @@ function _get_admin_bar_pref( $context = 'front', $user = 0 ) { return 'true' === $pref; } - -/** - * Adds CSS from the administration color scheme stylesheet on the front end. - * - * @since 7.0.0 - * - * @global array $_wp_admin_css_colors Registered administration color schemes. - */ -function wp_admin_bar_add_color_scheme_to_front_end() { - if ( is_admin() ) { - return; - } - - global $_wp_admin_css_colors; - - if ( empty( $_wp_admin_css_colors ) ) { - register_admin_color_schemes(); - } - - $color_scheme = get_user_option( 'admin_color' ); - - if ( empty( $color_scheme ) || ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) { - $color_scheme = 'modern'; - } - - $color = $_wp_admin_css_colors[ $color_scheme ] ?? null; - $url = $color->url ?? ''; - - if ( $url ) { - $response = wp_remote_get( $url ); - if ( ! is_wp_error( $response ) ) { - $css = $response['body']; - 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 ) { - $css = substr( $css, $start_position, $end_position - $start_position ); - if ( SCRIPT_DEBUG ) { - $css = str_replace( '/* Pointers */', '', $css ); - } - } - wp_add_inline_style( 'admin-bar', $css ); - } - } - } -} diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 4b6d9de25fa11..5e29b5ded605b 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -700,7 +700,6 @@ add_action( 'wp_body_open', 'wp_admin_bar_render', 0 ); add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); // Back-compat for themes not using `wp_body_open`. add_action( 'in_admin_header', 'wp_admin_bar_render', 0 ); -add_action( 'admin_bar_init', 'wp_admin_bar_add_color_scheme_to_front_end', 0 ); // Former admin filters that can also be hooked on the front end. add_action( 'media_buttons', 'media_buttons' ); diff --git a/tests/phpunit/tests/dependencies/wpStyleLoaderSrc.php b/tests/phpunit/tests/dependencies/wpStyleLoaderSrc.php index 170129580a3e7..6155ab0d178c3 100644 --- a/tests/phpunit/tests/dependencies/wpStyleLoaderSrc.php +++ b/tests/phpunit/tests/dependencies/wpStyleLoaderSrc.php @@ -12,20 +12,15 @@ class Tests_Dependencies_wpStyleLoaderSrc extends WP_UnitTestCase { /** * Tests that PHP warnings are not thrown when wp_style_loader_src() is called - * before the `$_wp_admin_css_colors` global is set within the admin. + * before the `$_wp_admin_css_colors` global is set. * * The warnings that we should not see: * `Warning: Trying to access array offset on null`. * `Warning: Attempt to read property "url" on null`. * * @ticket 61302 - * @ticket 64762 */ public function test_without_wp_admin_css_colors_global() { - if ( is_admin() ) { - $this->assertFalse( wp_style_loader_src( '', 'colors' ) ); - } else { - $this->assertStringContainsString( '/colors.css', wp_style_loader_src( '', 'colors' ) ); - } + $this->assertFalse( wp_style_loader_src( '', 'colors' ) ); } }