From e1877c1c42478cb90d6d44a434d6b73de199cf80 Mon Sep 17 00:00:00 2001 From: audrasjb Date: Tue, 4 Feb 2025 08:42:25 +0000 Subject: [PATCH] Editor: Add a fallback to `WP_Block_Styles_Registry` if the label is missing. Both `name` and `label` properties are required when registering a block style. If the label is missing, assign `name` as the value for the `label`, to ensure the property is defined. This avoids a PHP warning in such case. Props poena, Rahmohn, aaronrobertshaw, audrasjb, rinkalpagdar. Fixes #52592. Built from https://develop.svn.wordpress.org/trunk@59760 git-svn-id: http://core.svn.wordpress.org/trunk@59102 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-block-styles-registry.php | 5 +++++ wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-block-styles-registry.php b/wp-includes/class-wp-block-styles-registry.php index 2d16e0e034..9a990173b4 100644 --- a/wp-includes/class-wp-block-styles-registry.php +++ b/wp-includes/class-wp-block-styles-registry.php @@ -93,6 +93,11 @@ final class WP_Block_Styles_Registry { $block_style_name = $style_properties['name']; $block_names = is_string( $block_name ) ? array( $block_name ) : $block_name; + // Ensure there is a label defined. + if ( empty( $style_properties['label'] ) ) { + $style_properties['label'] = $block_style_name; + } + foreach ( $block_names as $name ) { if ( ! isset( $this->registered_block_styles[ $name ] ) ) { $this->registered_block_styles[ $name ] = array(); diff --git a/wp-includes/version.php b/wp-includes/version.php index bcc9713c98..082d043fbf 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-alpha-59756'; +$wp_version = '6.8-alpha-59760'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.