Skip to content

Commit 39b293e

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@59760 602fd350-edb4-49c9-b593-d223f7449a82
1 parent bce13fd commit 39b293e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/wp-includes/class-wp-block-styles-registry.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ public function register( $block_name, $style_properties ) {
9393
$block_style_name = $style_properties['name'];
9494
$block_names = is_string( $block_name ) ? array( $block_name ) : $block_name;
9595

96+
// Ensure there is a label defined.
97+
if ( empty( $style_properties['label'] ) ) {
98+
$style_properties['label'] = $block_style_name;
99+
}
100+
96101
foreach ( $block_names as $name ) {
97102
if ( ! isset( $this->registered_block_styles[ $name ] ) ) {
98103
$this->registered_block_styles[ $name ] = array();

0 commit comments

Comments
 (0)