Ignore:
Timestamp:
05/13/2026 03:28:14 AM (7 weeks ago)
Author:
audrasjb
Message:

Toolbar: Revert add CSS from admin color scheme on front-end.

The implementation issues a server-side HTTP request on every front-end page load and extracts the toolbar CSS via fragile substring matching. Alternatives are too large to land this late in the release cycle, so the fix is deferred to a future release.

Reverts [62025].

Reviewed by audrasjb, wildworks.
Merges [62349] to the 7.0 branch.
Props desrosj, jorbin, mukesh27, sabernhardt, wildworks.
See #64762.

Location:
branches/7.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/7.0

  • branches/7.0/src/wp-includes/admin-bar.php

    r62323 r62354  
    14671467        return 'true' === $pref;
    14681468}
    1469 
    1470 /**
    1471  * Adds CSS from the administration color scheme stylesheet on the front end.
    1472  *
    1473  * @since 7.0.0
    1474  *
    1475  * @global array $_wp_admin_css_colors Registered administration color schemes.
    1476  */
    1477 function wp_admin_bar_add_color_scheme_to_front_end() {
    1478         if ( is_admin() ) {
    1479                 return;
    1480         }
    1481 
    1482         global $_wp_admin_css_colors;
    1483 
    1484         if ( empty( $_wp_admin_css_colors ) ) {
    1485                 register_admin_color_schemes();
    1486         }
    1487 
    1488         $color_scheme = get_user_option( 'admin_color' );
    1489 
    1490         if ( empty( $color_scheme ) || ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) {
    1491                 $color_scheme = 'modern';
    1492         }
    1493 
    1494         $color = $_wp_admin_css_colors[ $color_scheme ] ?? null;
    1495         $url   = $color->url ?? '';
    1496 
    1497         if ( $url ) {
    1498                 $response = wp_remote_get( $url );
    1499                 if ( ! is_wp_error( $response ) ) {
    1500                         $css = $response['body'];
    1501                         if ( is_string( $css ) && str_contains( $css, '#wpadminbar' ) ) {
    1502                                 $start_position = strpos( $css, '#wpadminbar' );
    1503                                 $end_position   = strpos( $css, '.wp-pointer' );
    1504                                 if ( false !== $end_position && $end_position > $start_position ) {
    1505                                         $css = substr( $css, $start_position, $end_position - $start_position );
    1506                                         if ( SCRIPT_DEBUG ) {
    1507                                                 $css = str_replace( '/* Pointers */', '', $css );
    1508                                         }
    1509                                 }
    1510                                 wp_add_inline_style( 'admin-bar', $css );
    1511                         }
    1512                 }
    1513         }
    1514 }
Note: See TracChangeset for help on using the changeset viewer.