From 70b4a18c9745027e29d145f76db8742b5b84b17d Mon Sep 17 00:00:00 2001 From: ramonopoly Date: Tue, 19 Nov 2024 04:44:19 +0000 Subject: [PATCH] Theme JSON: include block style variations in path only output of get_block_nodes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An `$include_node_paths_only` option to `get_block_nodes()` was introduced to improve performance. When set to `true`, this option tells the function to only return paths, and not selectors, for consumers that only needed paths to style values. For one of the conditional blocks, block style variations wasn't included. This commit adds them to the array of paths following the existing model `$node[]['path' => [], 'variations' => ['path' => []]]`. Follow-up to [61858]. Props aaronrobertshaw, ramonopoly. Fixes #62399. Built from https://develop.svn.wordpress.org/trunk@59418 git-svn-id: http://core.svn.wordpress.org/trunk@58804 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-theme-json.php | 14 +++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php index f40fde9cf8..7885f27b42 100644 --- a/wp-includes/class-wp-theme-json.php +++ b/wp-includes/class-wp-theme-json.php @@ -2722,9 +2722,21 @@ class WP_Theme_JSON { 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'] ) ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index c159709d2a..4eb6cf8fac 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59417'; +$wp_version = '6.8-alpha-59418'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.