Skip to content

Commit

Permalink
Theme JSON: include block style variations in path only output of get…
Browse files Browse the repository at this point in the history
…_block_nodes (#66948)

Follow up to WordPress/gutenberg#66002
Including variations in the nodes array when 'include_node_paths_only' => true

Co-authored-by: ramonjd <[email protected]>
Co-authored-by: aaronrobertshaw <[email protected]>

Source: WordPress/gutenberg@d0a190b
  • Loading branch information
ramonjd committed Nov 13, 2024
1 parent 2f7702b commit bf97579
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

Expand Down
14 changes: 13 additions & 1 deletion lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ) ) {
Expand Down

0 comments on commit bf97579

Please sign in to comment.