From d2ebe7d776c15dd9b4f66047e5f1a3e02aaa365e Mon Sep 17 00:00:00 2001 From: oandregal Date: Fri, 14 Jun 2024 09:05:11 +0000 Subject: [PATCH] Section styles: add slug to override non-kebab-cased variations. Props aaronrobertshaw, oandregal. Fixes #61440. Built from https://develop.svn.wordpress.org/trunk@58413 git-svn-id: http://core.svn.wordpress.org/trunk@57862 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/block-supports/block-style-variations.php | 4 ++-- wp-includes/class-wp-theme-json.php | 3 ++- wp-includes/version.php | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/wp-includes/block-supports/block-style-variations.php b/wp-includes/block-supports/block-style-variations.php index a44ecdd396..8e84292ac0 100644 --- a/wp-includes/block-supports/block-style-variations.php +++ b/wp-includes/block-supports/block-style-variations.php @@ -249,7 +249,7 @@ function wp_resolve_block_style_variations( $variations ) { * Block style variations read in via standalone theme.json partials * need to have their name set to the kebab case version of their title. */ - $variation_name = $have_named_variations ? $key : _wp_to_kebab_case( $variation['title'] ); + $variation_name = $have_named_variations ? $key : ( $variation['slug'] ?? _wp_to_kebab_case( $variation['title'] ) ); foreach ( $supported_blocks as $block_type ) { // Add block style variation data under current block type. @@ -441,7 +441,7 @@ function wp_register_block_style_variations_from_theme_json_data( $variations ) * Block style variations read in via standalone theme.json partials * need to have their name set to the kebab case version of their title. */ - $variation_name = $have_named_variations ? $key : _wp_to_kebab_case( $variation['title'] ); + $variation_name = $have_named_variations ? $key : ( $variation['slug'] ?? _wp_to_kebab_case( $variation['title'] ) ); $variation_label = $variation['title'] ?? $variation_name; foreach ( $supported_blocks as $block_type ) { diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php index 957434de7f..05f5e7b9e7 100644 --- a/wp-includes/class-wp-theme-json.php +++ b/wp-includes/class-wp-theme-json.php @@ -358,6 +358,7 @@ class WP_Theme_JSON { 'description', 'patterns', 'settings', + 'slug', 'styles', 'templateParts', 'title', @@ -3244,7 +3245,7 @@ class WP_Theme_JSON { * @since 6.3.2 Preserves global styles block variations when securing styles. * @since 6.6.0 Updated to allow variation element styles and $origin parameter. * - * @param array $theme_json Structure to sanitize. + * @param array $theme_json Structure to sanitize. * @param string $origin Optional. What source of data this object represents. * One of 'blocks', 'default', 'theme', or 'custom'. Default 'theme'. * @return array Sanitized structure. diff --git a/wp-includes/version.php b/wp-includes/version.php index 97ec6777a0..3541f7230b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-beta2-58412'; +$wp_version = '6.6-beta2-58413'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.