Changeset 58987 for branches/6.6/src/wp-includes/class-wp-theme-json.php
- Timestamp:
- 09/04/2024 02:22:16 PM (5 months ago)
- Location:
- branches/6.6
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.6
-
branches/6.6/src/wp-includes/class-wp-theme-json.php
r58986 r58987 1440 1440 $processed_css = ''; 1441 1441 1442 if ( empty( $css ) ) { 1443 return $processed_css; 1444 } 1445 1442 1446 // Split CSS nested rules. 1443 1447 $parts = explode( '&', $css ); 1444 1448 foreach ( $parts as $part ) { 1449 if ( empty( $part ) ) { 1450 continue; 1451 } 1445 1452 $is_root_css = ( ! str_contains( $part, '{' ) ); 1446 1453 if ( $is_root_css ) { … … 1455 1462 $nested_selector = $part[0]; 1456 1463 $css_value = $part[1]; 1457 $part_selector = str_starts_with( $nested_selector, ' ' ) 1464 1465 /* 1466 * Handle pseudo elements such as ::before, ::after etc. Regex will also 1467 * capture any leading combinator such as >, +, or ~, as well as spaces. 1468 * This allows pseudo elements as descendants e.g. `.parent ::before`. 1469 */ 1470 $matches = array(); 1471 $has_pseudo_element = preg_match( '/([>+~\s]*::[a-zA-Z-]+)/', $nested_selector, $matches ); 1472 $pseudo_part = $has_pseudo_element ? $matches[1] : ''; 1473 $nested_selector = $has_pseudo_element ? str_replace( $pseudo_part, '', $nested_selector ) : $nested_selector; 1474 1475 // Finalize selector and re-append pseudo element if required. 1476 $part_selector = str_starts_with( $nested_selector, ' ' ) 1458 1477 ? static::scope_selector( $selector, $nested_selector ) 1459 1478 : static::append_to_selector( $selector, $nested_selector ); 1460 $final_selector = ":root :where($part_selector)"; 1461 $processed_css .= $final_selector . '{' . trim( $css_value ) . '}';} 1479 $final_selector = ":root :where($part_selector)$pseudo_part"; 1480 1481 $processed_css .= $final_selector . '{' . trim( $css_value ) . '}'; 1482 } 1462 1483 } 1463 1484 return $processed_css;
Note: See TracChangeset
for help on using the changeset viewer.