wp_migrate_old_typography_shape
函数
wp_migrate_old_typography_shape ( $metadata )
- 参数
-
-
(array)
$metadata
Metadata for registering a block type.- Required: 是
-
(array)
- 返回值
-
- (array) Filtered metadata for registering a block type.
- 定义位置
-
-
wp-includes/blocks.php
, line 1194
-
wp-includes/blocks.php
- 引入
- 5.8.0
- 弃用
- –
Converts typography keys declared under `supports.*` to `supports.typography.*`.
Displays a `_doing_it_wrong()` notice when a block using the older format is detected.
function wp_migrate_old_typography_shape( $metadata ) { if ( ! isset( $metadata['supports'] ) ) { return $metadata; } $typography_keys = array( '__experimentalFontFamily', '__experimentalFontStyle', '__experimentalFontWeight', '__experimentalLetterSpacing', '__experimentalTextDecoration', '__experimentalTextTransform', '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()', sprintf( /* translators: 1: Block type, 2: Typography supports key, e.g: fontSize, lineHeight, etc. 3: block.json, 4: Old metadata key, 5: New metadata key. */ __( 'Block "%1$s" is declaring %2$s support in %3$s file under %4$s. %2$s support is now declared under %5$s.' ), $metadata['name'], "$typography_key
", 'block.json
', "supports.$typography_key
", "supports.typography.$typography_key
" ), '5.8.0' ); _wp_array_set( $metadata['supports'], array( 'typography', $typography_key ), $support_for_key ); unset( $metadata['supports'][ $typography_key ] ); } } return $metadata; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。