Editor: Add missing `WP_Theme_JSON::process_blocks_custom_css()` method.

Follow up to [55192].

Props aristath, mamaduka, mukesh27, hellofromtonya.
Fixes #57621.

Built from https://develop.svn.wordpress.org/trunk@55216


git-svn-id: http://core.svn.wordpress.org/trunk@54749 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Felix Arntz 2023-02-03 18:25:22 +00:00
parent 203ba0cc28
commit 1856b98771
2 changed files with 24 additions and 2 deletions

View File

@ -1006,12 +1006,34 @@ class WP_Theme_JSON {
return $stylesheet; return $stylesheet;
} }
/**
* Processes the CSS, to apply nesting.
*
* @since 6.2.0
*
* @param string $css The CSS to process.
* @param string $selector The selector to nest.
* @return string The processed CSS.
*/
protected function process_blocks_custom_css( $css, $selector ) {
$processed_css = '';
// 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.
}
return $processed_css;
}
/** /**
* Returns the global styles custom css. * Returns the global styles custom css.
* *
* @since 6.2.0 * @since 6.2.0
* *
* @return string * @return string The global styles custom CSS.
*/ */
public function get_custom_css() { public function get_custom_css() {
// Add the global styles root CSS. // Add the global styles root CSS.

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.2-alpha-55215'; $wp_version = '6.2-alpha-55216';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.