mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-16 19:46:21 +00:00
Editor: fix incorrect block custom CSS output.
Fixes output of block custom CSS when multiple rules require a descendant selector. Props wildworks, mikachan. Fixes #59499. Built from https://develop.svn.wordpress.org/trunk@56812 git-svn-id: http://core.svn.wordpress.org/trunk@56324 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
61658a27a3
commit
5951111cba
@ -1146,9 +1146,23 @@ class WP_Theme_JSON {
|
||||
// Split CSS nested rules.
|
||||
$parts = explode( '&', $css );
|
||||
foreach ( $parts as $part ) {
|
||||
$processed_css .= ( ! str_contains( $part, '{' ) )
|
||||
? trim( $selector ) . '{' . trim( $part ) . '}' // If the part doesn't contain braces, it applies to the root level.
|
||||
: trim( $selector . $part ); // Prepend the selector, which effectively replaces the "&" character.
|
||||
$is_root_css = ( ! str_contains( $part, '{' ) );
|
||||
if ( $is_root_css ) {
|
||||
// If the part doesn't contain braces, it applies to the root level.
|
||||
$processed_css .= trim( $selector ) . '{' . trim( $part ) . '}';
|
||||
} else {
|
||||
// If the part contains braces, it's a nested CSS rule.
|
||||
$part = explode( '{', str_replace( '}', '', $part ) );
|
||||
if ( count( $part ) !== 2 ) {
|
||||
continue;
|
||||
}
|
||||
$nested_selector = $part[0];
|
||||
$css_value = $part[1];
|
||||
$part_selector = str_starts_with( $nested_selector, ' ' )
|
||||
? static::scope_selector( $selector, $nested_selector )
|
||||
: static::append_to_selector( $selector, $nested_selector );
|
||||
$processed_css .= $part_selector . '{' . trim( $css_value ) . '}';
|
||||
}
|
||||
}
|
||||
return $processed_css;
|
||||
}
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.4-beta2-56811';
|
||||
$wp_version = '6.4-beta2-56812';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
x
Reference in New Issue
Block a user