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. Built from https://develop.svn.wordpress.org/trunk@51167 git-svn-id: http://core.svn.wordpress.org/trunk@50776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d32aa67e80
commit
5ffd5d6e9b
|
@ -986,6 +986,10 @@ function block_has_support( $block_type, $feature, $default = false ) {
|
|||
* @return array Filtered metadata for registering a block type.
|
||||
*/
|
||||
function wp_migrate_old_typography_shape( $metadata ) {
|
||||
if ( ! isset( $metadata['supports'] ) ) {
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
$typography_keys = array(
|
||||
'__experimentalFontFamily',
|
||||
'__experimentalFontStyle',
|
||||
|
@ -996,8 +1000,10 @@ function wp_migrate_old_typography_shape( $metadata ) {
|
|||
'fontSize',
|
||||
'lineHeight',
|
||||
);
|
||||
|
||||
foreach ( $typography_keys as $typography_key ) {
|
||||
$support_for_key = _wp_array_get( $metadata['supports'], array( $typography_key ), null );
|
||||
|
||||
if ( null !== $support_for_key ) {
|
||||
_doing_it_wrong(
|
||||
'register_block_type_from_metadata()',
|
||||
|
@ -1012,10 +1018,12 @@ function wp_migrate_old_typography_shape( $metadata ) {
|
|||
),
|
||||
'5.8.0'
|
||||
);
|
||||
|
||||
_wp_array_set( $metadata['supports'], array( 'typography', $typography_key ), $support_for_key );
|
||||
unset( $metadata['supports'][ $typography_key ] );
|
||||
}
|
||||
}
|
||||
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.8-beta2-51166';
|
||||
$wp_version = '5.8-beta2-51167';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue