wp_get_block_name_from_theme_json_path
函数
wp_get_block_name_from_theme_json_path ( $path )
- Access
- Private
- 参数
-
-
(array)
$path
An array of keys describing the path to a property in theme.json.- Required: 是
-
(array)
- 返回值
-
- (string) Identified block name, or empty string if none found.
- 定义位置
-
-
wp-includes/global-styles-and-settings.php
, line 344
-
wp-includes/global-styles-and-settings.php
- 引入
- 6.3.0
- 弃用
- –
从给定的 theme.json 路径中获取区块名称。
function wp_get_block_name_from_theme_json_path( $path ) {
// Block name is expected to be the third item after 'styles' and 'blocks'.
if (
count( $path ) >= 3
&& 'styles' === $path[0]
&& 'blocks' === $path[1]
&& str_contains( $path[2], '/' )
) {
return $path[2];
}
/*
* As fallback and for backward compatibility, allow any core block to be
* at any position.
*/
$result = array_values(
array_filter(
$path,
static function ( $item ) {
if ( str_contains( $item, 'core/' ) ) {
return true;
}
return false;
}
)
);
if ( isset( $result[0] ) ) {
return $result[0];
}
return '';
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。