Skip to content

Commit f5f2c48

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

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,27 @@ public function initialize() {
7272
wp_enqueue_script( 'admin-bar' );
7373
wp_enqueue_style( 'admin-bar' );
7474

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

0 commit comments

Comments
 (0)