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
This commit is contained in:
oandregal 2024-06-14 09:05:11 +00:00
parent 8e7728a1ad
commit d2ebe7d776
3 changed files with 5 additions and 4 deletions

View File

@ -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 ) {

View File

@ -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.

View File

@ -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.