wpseek.com
WordPress开发者和主题制作者的搜索引擎
wp_get_block_name_from_theme_json_path is private and should not be used in themes or plugins directly.
wp_get_block_name_from_theme_json_path › WordPress Function
Since6.3.0
已弃用n/a
› wp_get_block_name_from_theme_json_path ( $path )
| 访问: |
|
| 参数: |
|
| 返回: |
|
| 定义在: |
|
| 文档: |
Gets the block name from a given theme.json path.
源码
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;
}
)
);
return $result[0] ?? '';
}