Make WordPress Core

Changeset 59760


Ignore:
Timestamp:
02/04/2025 08:40:40 AM (5 months ago)
Author:
audrasjb
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-block-styles-registry.php

    r58247 r59760  
    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 ] ) ) {
Note: See TracChangeset for help on using the changeset viewer.