Toolbar: Enqueue admin color scheme CSS on the frontend admin bar.#11183
Toolbar: Enqueue admin color scheme CSS on the frontend admin bar.#11183huzaifaalmesbah wants to merge 1 commit intoWordPress:trunkfrom
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
f5f2c48 to
838292e
Compare
838292e to
239a3fe
Compare
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Huzaifa-20260306105243.mp4 |
amesplant
left a comment
There was a problem hiding this comment.
Overall, I think. this looks like a great, and. made a few comments around:
- Adding
is_admin_bar_showing()guard - Confirming safe usage of
register_admin_color_schemes()on the front end - Verifying 'modern' fallback behavior
| wp_enqueue_script( 'admin-bar' ); | ||
| wp_enqueue_style( 'admin-bar' ); | ||
|
|
||
| if ( ! is_admin() ) { |
There was a problem hiding this comment.
May also want to include && is_admin_bar_showing()
| $color_scheme = get_user_option( 'admin_color' ); | ||
|
|
||
| if ( empty( $color_scheme ) || ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) { | ||
| $color_scheme = 'modern'; |
There was a problem hiding this comment.
The defensive handling around missing color schemes looks great. Is 'modern' guaranteed to exist once register_admin_color_schemes() runs? Just want to double-check since this is hard-coded here.
| wp_enqueue_script( 'admin-bar' ); | ||
| wp_enqueue_style( 'admin-bar' ); | ||
|
|
||
| if ( ! is_admin() ) { |
There was a problem hiding this comment.
Let's also add && is_admin_bar_showing() to this
| global $_wp_admin_css_colors; | ||
|
|
||
| if ( empty( $_wp_admin_css_colors ) ) { | ||
| register_admin_color_schemes(); |
There was a problem hiding this comment.
register_admin_color_schemes() is primarily intended for admin installation, calling it on the front end may introduce unexpected behavior if future code assumes admin context.
Enqueue the user's selected admin color scheme CSS for the toolbar on the front end to ensure visual consistency with the admin dashboard.
Trac: https://core.trac.wordpress.org/ticket/64762
Changes
admin-baras its sole dependency.Testing Instructions