diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index bbdf0d76ac44b7..8cd83e007f37c9 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -2743,9 +2743,11 @@ private static function get_block_nodes( $theme_json, $selectors = array(), $opt return $nodes; } + $include_variations = $options['include_block_style_variations'] ?? false; + $include_node_paths_only = $options['include_node_paths_only'] ?? false; + foreach ( $theme_json['styles']['blocks'] as $name => $node ) { - $include_node_paths_only = $options['include_node_paths_only'] ?? false; - $node_path = array( 'styles', 'blocks', $name ); + $node_path = array( 'styles', 'blocks', $name ); if ( $include_node_paths_only ) { $nodes[] = array( 'path' => $node_path, @@ -2767,7 +2769,7 @@ private static function get_block_nodes( $theme_json, $selectors = array(), $opt } $variation_selectors = array(); - $include_variations = $options['include_block_style_variations'] ?? false; + if ( $include_variations && isset( $node['variations'] ) ) { foreach ( $node['variations'] as $variation => $node ) { $variation_selectors[] = array(