Changeset 62025
- Timestamp:
- 03/14/2026 07:53:29 AM (15 hours ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
src/wp-includes/admin-bar.php (modified) (1 diff)
-
src/wp-includes/default-filters.php (modified) (1 diff)
-
tests/phpunit/tests/dependencies/wpStyleLoaderSrc.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/admin-bar.php
r61979 r62025 1438 1438 return 'true' === $pref; 1439 1439 } 1440 1441 /** 1442 * Adds CSS from the administration color scheme stylesheet on the front end. 1443 * 1444 * @since 7.0.0 1445 * 1446 * @global array $_wp_admin_css_colors Registered administration color schemes. 1447 */ 1448 function wp_admin_bar_add_color_scheme_to_front_end() { 1449 if ( is_admin() ) { 1450 return; 1451 } 1452 1453 global $_wp_admin_css_colors; 1454 1455 if ( empty( $_wp_admin_css_colors ) ) { 1456 register_admin_color_schemes(); 1457 } 1458 1459 $color_scheme = get_user_option( 'admin_color' ); 1460 1461 if ( empty( $color_scheme ) || ! isset( $_wp_admin_css_colors[ $color_scheme ] ) ) { 1462 $color_scheme = 'modern'; 1463 } 1464 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 } 1484 } 1485 } -
trunk/src/wp-includes/default-filters.php
r61985 r62025 709 709 add_action( 'wp_footer', 'wp_admin_bar_render', 1000 ); // Back-compat for themes not using `wp_body_open`. 710 710 add_action( 'in_admin_header', 'wp_admin_bar_render', 0 ); 711 add_action( 'admin_bar_init', 'wp_admin_bar_add_color_scheme_to_front_end', 0 ); 711 712 712 713 // Former admin filters that can also be hooked on the front end. -
trunk/tests/phpunit/tests/dependencies/wpStyleLoaderSrc.php
r61388 r62025 13 13 /** 14 14 * Tests that PHP warnings are not thrown when wp_style_loader_src() is called 15 * before the `$_wp_admin_css_colors` global is set .15 * before the `$_wp_admin_css_colors` global is set within the admin. 16 16 * 17 17 * The warnings that we should not see: … … 20 20 * 21 21 * @ticket 61302 22 * @ticket 64762 22 23 */ 23 24 public function test_without_wp_admin_css_colors_global() { 24 $this->assertFalse( wp_style_loader_src( '', 'colors' ) ); 25 if ( is_admin() ) { 26 $this->assertFalse( wp_style_loader_src( '', 'colors' ) ); 27 } else { 28 $this->assertStringContainsString( '/colors.css', wp_style_loader_src( '', 'colors' ) ); 29 } 25 30 } 26 31 }
Note: See TracChangeset
for help on using the changeset viewer.