mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-31 13:37:51 +01:00
Editor: fix custom CSS output for block style variations.
Adds custom CSS to the block style variation rules output by `get_styles_for_block` in class `WP_Theme_JSON`. Props isabel_brison, aaronrobertshaw. Fixes #61425. Built from https://develop.svn.wordpress.org/trunk@58421 git-svn-id: http://core.svn.wordpress.org/trunk@57870 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ac8829da47
commit
93177aa249
@ -2647,6 +2647,7 @@ class WP_Theme_JSON {
|
||||
* @since 6.1.0
|
||||
* @since 6.6.0 Setting a min-height of HTML when root styles have a background gradient or image.
|
||||
* Updated general global styles specificity to 0-1-0.
|
||||
* Fixed custom CSS output in block style variations.
|
||||
*
|
||||
* @param array $block_metadata Metadata about the block to get styles for.
|
||||
*
|
||||
@ -2662,6 +2663,7 @@ class WP_Theme_JSON {
|
||||
|
||||
// If there are style variations, generate the declarations for them, including any feature selectors the block may have.
|
||||
$style_variation_declarations = array();
|
||||
$style_variation_custom_css = array();
|
||||
if ( ! empty( $block_metadata['variations'] ) ) {
|
||||
foreach ( $block_metadata['variations'] as $style_variation ) {
|
||||
$style_variation_node = _wp_array_get( $this->theme_json, $style_variation['path'], array() );
|
||||
@ -2691,6 +2693,10 @@ class WP_Theme_JSON {
|
||||
|
||||
// Compute declarations for remaining styles not covered by feature level selectors.
|
||||
$style_variation_declarations[ $style_variation['selector'] ] = static::compute_style_properties( $style_variation_node, $settings, null, $this->theme_json );
|
||||
// Store custom CSS for the style variation.
|
||||
if ( isset( $style_variation_node['css'] ) ) {
|
||||
$style_variation_custom_css[ $style_variation['selector'] ] = $this->process_blocks_custom_css( $style_variation_node['css'], $style_variation['selector'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -2819,6 +2825,14 @@ class WP_Theme_JSON {
|
||||
// 6. Generate and append the style variation rulesets.
|
||||
foreach ( $style_variation_declarations as $style_variation_selector => $individual_style_variation_declarations ) {
|
||||
$block_rules .= static::to_ruleset( ":root :where($style_variation_selector)", $individual_style_variation_declarations );
|
||||
if ( isset( $style_variation_custom_css[ $style_variation_selector ] ) ) {
|
||||
$block_rules .= $style_variation_custom_css[ $style_variation_selector ];
|
||||
}
|
||||
}
|
||||
|
||||
// 7. Generate and append any custom CSS rules pertaining to nested block style variations.
|
||||
if ( isset( $node['css'] ) && ! $is_root_selector ) {
|
||||
$block_rules .= $this->process_blocks_custom_css( $node['css'], $selector );
|
||||
}
|
||||
|
||||
return $block_rules;
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.6-beta2-58420';
|
||||
$wp_version = '6.6-beta2-58421';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user