@@ -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