WordPress.org

Make WordPress Core

Changeset 51167


Ignore:
Timestamp:
06/15/2021 09:36:07 PM (4 months ago)
Author:
SergeyBiryukov
Message:

Editor: Check if supports metadata key is defined before migrating typography keys.

This avoids an "Undefined index" PHP notice on blocks without a supports key in block.json.

Follow-up to [51089], [51153], [51159].

Props walbo.
Fixes #53416.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r51160 r51167  
    987987 */
    988988function wp_migrate_old_typography_shape( $metadata ) {
     989    if ( ! isset( $metadata['supports'] ) ) {
     990        return $metadata;
     991    }
     992
    989993    $typography_keys = array(
    990994        '__experimentalFontFamily',
     
    9971001        'lineHeight',
    9981002    );
     1003
    9991004    foreach ( $typography_keys as $typography_key ) {
    10001005        $support_for_key = _wp_array_get( $metadata['supports'], array( $typography_key ), null );
     1006
    10011007        if ( null !== $support_for_key ) {
    10021008            _doing_it_wrong(
     
    10131019                '5.8.0'
    10141020            );
     1021
    10151022            _wp_array_set( $metadata['supports'], array( 'typography', $typography_key ), $support_for_key );
    10161023            unset( $metadata['supports'][ $typography_key ] );
    10171024        }
    10181025    }
     1026
    10191027    return $metadata;
    10201028}
Note: See TracChangeset for help on using the changeset viewer.