From 9aca87ef860ab1b9a13c3e2ff809cfea31401503 Mon Sep 17 00:00:00 2001 From: Aaron Robertshaw <60436221+aaronrobertshaw@users.noreply.github.com> Date: Wed, 10 Jan 2024 17:03:25 +1000 Subject: [PATCH] Reinstate processing of variation > block > elements in block node generation --- lib/class-wp-theme-json-gutenberg.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index db81335237683f..69ac5f15611e19 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -2466,6 +2466,26 @@ private static function get_block_nodes( $theme_json, $selectors = array() ) { } } + $variation_block_elements = $variation_block_node['elements'] ?? array(); + foreach ( $variation_block_elements as $variation_element => $variation_element_node ) { + $nodes[] = array( + 'path' => array( 'styles', 'blocks', $name, 'variations', $variation, 'blocks', $variation_block, 'elements', $variation_element ), + 'selector' => static::scope_selector( $variation_block_selector, static::ELEMENTS[ $variation_element ] ), + ); + + if ( isset( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $variation_element ] ) ) { + foreach ( static::VALID_ELEMENT_PSEUDO_SELECTORS[ $variation_element ] as $pseudo_selector ) { + if ( isset( $variation_element_node[ $pseudo_selector ] ) ) { + $pseudo_element_selector = static::append_to_selector( static::ELEMENTS[ $variation_element ], $pseudo_selector ); + $nodes[] = array( + 'path' => array( 'styles', 'blocks', $name, 'variations', $variation, 'blocks', $variation_block, 'elements', $variation_element ), + 'selector' => static::scope_selector( $variation_block_selector, $pseudo_element_selector ), + ); + } + } + } + } + $variation_nodes[] = array( 'name' => $variation_block, 'path' => array( 'styles', 'blocks', $name, 'variations', $variation, 'blocks', $variation_block ),