From bf97579fb3388aca77f8cf5db5d142f07a23a8e8 Mon Sep 17 00:00:00 2001 From: Ramon Date: Thu, 14 Nov 2024 09:59:02 +1100 Subject: [PATCH] Theme JSON: include block style variations in path only output of get_block_nodes (#66948) Follow up to https://github.com/WordPress/gutenberg/pull/66002 Including variations in the nodes array when 'include_node_paths_only' => true Co-authored-by: ramonjd Co-authored-by: aaronrobertshaw Source: https://github.com/WordPress/gutenberg/commit/d0a190b65cebe27652e1a4d8d38a714d624e54ad --- gutenberg.php | 2 +- lib/class-wp-theme-json-gutenberg.php | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gutenberg.php b/gutenberg.php index f5fb8c43..6c018c27 100644 --- a/gutenberg.php +++ b/gutenberg.php @@ -14,7 +14,7 @@ ### BEGIN AUTO-GENERATED DEFINES define( 'GUTENBERG_VERSION', '19.7.0' ); -define( 'GUTENBERG_GIT_COMMIT', 'ee5aee9263474836b54b1399fdd1342cb3ffa175' ); +define( 'GUTENBERG_GIT_COMMIT', 'd0a190b65cebe27652e1a4d8d38a714d624e54ad' ); ### END AUTO-GENERATED DEFINES defined( 'GUTENBERG_MINIMUM_WP_VERSION' ) or define( 'GUTENBERG_MINIMUM_WP_VERSION', '6.5' ); diff --git a/lib/class-wp-theme-json-gutenberg.php b/lib/class-wp-theme-json-gutenberg.php index d5059164..10f80c3f 100644 --- a/lib/class-wp-theme-json-gutenberg.php +++ b/lib/class-wp-theme-json-gutenberg.php @@ -2749,9 +2749,21 @@ private static function get_block_nodes( $theme_json, $selectors = array(), $opt foreach ( $theme_json['styles']['blocks'] as $name => $node ) { $node_path = array( 'styles', 'blocks', $name ); if ( $include_node_paths_only ) { - $nodes[] = array( + $variation_paths = array(); + if ( $include_variations && isset( $node['variations'] ) ) { + foreach ( $node['variations'] as $variation => $variation_node ) { + $variation_paths[] = array( + 'path' => array( 'styles', 'blocks', $name, 'variations', $variation ), + ); + } + } + $node = array( 'path' => $node_path, ); + if ( ! empty( $variation_paths ) ) { + $node['variations'] = $variation_paths; + } + $nodes[] = $node; } else { $selector = null; if ( isset( $selectors[ $name ]['selector'] ) ) {