Skip to content

Commit 8a7542d

Browse files
committed
Introduce a separate admin_bar_url property for registered colour schemes that uses the extracted admin toolbar styles.
1 parent 3700f88 commit 8a7542d

11 files changed

Lines changed: 110 additions & 36 deletions

File tree

Gruntfile.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ module.exports = function(grunt) {
165165
cwd: WORKING_DIR,
166166
dest: WORKING_DIR,
167167
src: [
168-
'wp-admin/css/colors/*/colors.css'
168+
'wp-admin/css/colors/*/colors.css',
169+
'wp-admin/css/colors/*/admin-bar.css'
169170
]
170171
}
171172
},
@@ -696,7 +697,10 @@ module.exports = function(grunt) {
696697
cwd: SOURCE_DIR,
697698
dest: WORKING_DIR,
698699
ext: '.css',
699-
src: ['wp-admin/css/colors/*/colors.scss'],
700+
src: [
701+
'wp-admin/css/colors/*/colors.scss',
702+
'wp-admin/css/colors/*/admin-bar.scss'
703+
],
700704
options: {
701705
implementation: sass
702706
}
@@ -849,7 +853,8 @@ module.exports = function(grunt) {
849853
dest: WORKING_DIR,
850854
ext: '-rtl.css',
851855
src: [
852-
'wp-admin/css/colors/*/colors.css'
856+
'wp-admin/css/colors/*/colors.css',
857+
'wp-admin/css/colors/*/admin-bar.css'
853858
]
854859
},
855860
dynamic: {
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@use "../_admin-bar.scss" as admin-bar with (
2+
$base-color: #52accc,
3+
$icon-color: #e5f8ff,
4+
$highlight-color: #096484,
5+
$menu-submenu-text: #e2ecf1,
6+
$menu-submenu-focus-text: #fff,
7+
$menu-submenu-background: #4796b3,
8+
);
9+
10+
@include admin-bar.styles();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@use "../_admin-bar.scss" as admin-bar with (
2+
$base-color: #59524c,
3+
$highlight-color: #c7a589,
4+
);
5+
6+
@include admin-bar.styles();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@use "../_admin-bar.scss" as admin-bar with (
2+
$base-color: #523f6d,
3+
$icon-color: #ece6f6,
4+
$highlight-color: #a3b745,
5+
);
6+
7+
@include admin-bar.styles();
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@use "../_admin-bar.scss" as admin-bar with (
2+
$base-color: #e5e5e5,
3+
$icon-color: #999,
4+
$text-color: #333,
5+
$highlight-color: #04a4cc,
6+
$menu-submenu-background: #fff,
7+
);
8+
9+
@include admin-bar.styles();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@use "../_admin-bar.scss" as admin-bar with (
2+
$base-color: #363b3f,
3+
$highlight-color: #e14d43,
4+
);
5+
6+
@include admin-bar.styles();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@use "../_admin-bar.scss" as admin-bar with (
2+
$base-color: #1e1e1e,
3+
$highlight-color: #3858e9,
4+
$menu-submenu-focus-text: #7b90ff,
5+
);
6+
7+
@include admin-bar.styles();
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@use "../_admin-bar.scss" as admin-bar with (
2+
$base-color: #738e96,
3+
$icon-color: #f2fcff,
4+
$highlight-color: #9ebaa0,
5+
);
6+
7+
@include admin-bar.styles();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@use "sass:color";
2+
3+
$highlight-color: #dd823b;
4+
5+
@use "../_admin-bar.scss" as admin-bar with (
6+
$base-color: #cf4944,
7+
$highlight-color: $highlight-color,
8+
$menu-submenu-focus-text: color.adjust($highlight-color, $lightness: 35%),
9+
);
10+
11+
@include admin-bar.styles();

src/wp-includes/admin-bar.php

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,7 +1439,7 @@ function _get_admin_bar_pref( $context = 'front', $user = 0 ) {
14391439
}
14401440

14411441
/**
1442-
* Adds CSS from the administration color scheme stylesheet on the front end.
1442+
* Enqueues the admin bar color scheme stylesheet on the front end.
14431443
*
14441444
* @since 7.0.0
14451445
*
@@ -1462,24 +1462,16 @@ function wp_admin_bar_add_color_scheme_to_front_end() {
14621462
$color_scheme = 'modern';
14631463
}
14641464

1465-
$color = $_wp_admin_css_colors[ $color_scheme ] ?? null;
1466-
$url = $color->url ?? '';
1467-
1468-
if ( $url ) {
1469-
$response = wp_remote_get( $url );
1470-
if ( ! is_wp_error( $response ) ) {
1471-
$css = $response['body'];
1472-
if ( is_string( $css ) && str_contains( $css, '#wpadminbar' ) ) {
1473-
$start_position = strpos( $css, '#wpadminbar' );
1474-
$end_position = strpos( $css, '.wp-pointer' );
1475-
if ( false !== $end_position && $end_position > $start_position ) {
1476-
$css = substr( $css, $start_position, $end_position - $start_position );
1477-
if ( SCRIPT_DEBUG ) {
1478-
$css = str_replace( '/* Pointers */', '', $css );
1479-
}
1480-
}
1481-
wp_add_inline_style( 'admin-bar', $css );
1482-
}
1483-
}
1465+
$admin_bar_url = $_wp_admin_css_colors[ $color_scheme ]->admin_bar_url ?? false;
1466+
1467+
if ( ! $admin_bar_url ) {
1468+
return;
14841469
}
1470+
1471+
wp_enqueue_style(
1472+
'admin-bar-color-scheme',
1473+
$admin_bar_url,
1474+
array( 'admin-bar' ),
1475+
false
1476+
);
14851477
}

0 commit comments

Comments
 (0)