diff --git a/src/wp-includes/block-supports/block-style-variations.php b/src/wp-includes/block-supports/block-style-variations.php index 8312f5edcfa6a..a44ecdd396e18 100644 --- a/src/wp-includes/block-supports/block-style-variations.php +++ b/src/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 : _wp_to_kebab_case( $variation['title'] ); foreach ( $supported_blocks as $block_type ) { // Add block style variation data under current block type. @@ -409,6 +409,7 @@ function wp_enqueue_block_style_variation_styles() { * Registers any block style variations contained within the provided * theme.json data. * + * @since 6.6.0 * @access private * * @param array $variations Shared block style variations. @@ -468,6 +469,7 @@ function wp_register_block_style_variations_from_theme_json_data( $variations ) * - the theme's partials (standalone files in `/styles` that only define block style variations) * - the user's theme.json (for example, theme style variations the user selected) * + * @since 6.6.0 * @access private */ function wp_register_block_style_variations_from_theme() { diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php index 24c8123b2a5a7..8ce522c1490e2 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-controller.php @@ -231,6 +231,7 @@ public function update_item_permissions_check( $request ) { * * @since 5.9.0 * @since 6.2.0 Added validation of styles.css property. + * @since 6.6.0 Added registration of newly created style variations provided by the user. * * @param WP_REST_Request $request Request object. * @return stdClass|WP_Error Prepared item on success. WP_Error on when the custom CSS is not valid. @@ -264,14 +265,16 @@ protected function prepare_item_for_database( $request ) { $config['styles'] = $existing_config['styles']; } - // If the incoming request is going to create a new variation - // that is not yet registered, we register it here. - // This is because the variations are registered on init, - // but we want this endpoint to return the new variation immediately: - // if we don't register it, it'll be stripped out of the response - // just in this request (subsequent ones will be ok). - // Take the variations defined in styles.blocks.variations from the incoming request - // that are not part of the $exsting_config. + /* + * If the incoming request is going to create a new variation + * that is not yet registered, we register it here. + * This is because the variations are registered on init, + * but we want this endpoint to return the new variation immediately: + * if we don't register it, it'll be stripped out of the response + * just in this request (subsequent ones will be ok). + * Take the variations defined in styles.blocks.variations from the incoming request + * that are not part of the $exsting_config. + */ if ( isset( $request['styles']['blocks']['variations'] ) ) { $existing_variations = isset( $existing_config['styles']['blocks']['variations'] ) ? $existing_config['styles']['blocks']['variations'] : array(); $new_variations = array_diff_key( $request['styles']['blocks']['variations'], $existing_variations );