Skip to content

Commit 239a3fe

Browse files
Toolbar: Enqueue admin color scheme CSS on the frontend admin bar.
1 parent 826b024 commit 239a3fe

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class WP_Admin_Bar {
3232
* Initializes the admin bar.
3333
*
3434
* @since 3.1.0
35+
* @since 7.0.0 Enqueues the admin color scheme stylesheet on the front end.
36+
*
37+
* @global array $_wp_admin_css_colors Registered admin CSS color schemes.
3538
*/
3639
public function initialize() {
3740
$this->user = new stdClass();
@@ -72,6 +75,27 @@ public function initialize() {
7275
wp_enqueue_script( 'admin-bar' );
7376
wp_enqueue_style( 'admin-bar' );
7477

78+
if ( ! is_admin() ) {
79+
global $_wp_admin_css_colors;
80+
81+
if ( empty( $_wp_admin_css_colors ) ) {
82+
register_admin_color_schemes();
83+
}
84+
85+
$color_scheme = get_user_option( 'admin_color' );
86+
87+
if ( empty( $color_scheme ) || ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) {
88+
$color_scheme = 'modern';
89+
}
90+
91+
$color = $_wp_admin_css_colors[ $color_scheme ] ?? null;
92+
$url = $color->url ?? '';
93+
94+
if ( $url ) {
95+
wp_enqueue_style( 'admin-bar-colors', $url, array( 'admin-bar' ) );
96+
}
97+
}
98+
7599
/**
76100
* Fires after WP_Admin_Bar is initialized.
77101
*

0 commit comments

Comments
 (0)