wp_get_global_styles
函数
wp_get_global_styles ( $path = array(), $context = array() )
- 参数
-
-
(array)
$path
Path to the specific style to retrieve. Optional. If empty, will return all styles.- Required: 否
- Default: array()
-
(array)
$context
{ Metadata to know where to retrieve the $path from. Optional. @type string $block_name Which block to retrieve the styles from. If empty, it’ll return the styles for the global context. @type string $origin Which origin to take data from. Valid values are ‘all’ (core, theme, and user) or ‘base’ (core and theme). If empty or unknown, ‘all’ is used. }- Required: 否
- Default: array()
-
(array)
- 返回值
-
- (array) The styles to retrieve.
- 定义位置
-
-
wp-includes/global-styles-and-settings.php
, line 59
-
wp-includes/global-styles-and-settings.php
- 引入
- 5.9.0
- 弃用
- –
获取合并核心、主题和用户数据后的样式。
function wp_get_global_styles( $path = array(), $context = array() ) { if ( ! empty( $context['block_name'] ) ) { $path = array_merge( array( 'blocks', $context['block_name'] ), $path ); } $origin = 'custom'; if ( isset( $context['origin'] ) && 'base' === $context['origin'] ) { $origin = 'theme'; } $styles = WP_Theme_JSON_Resolver::get_merged_data( $origin )->get_raw_data()['styles']; return _wp_array_get( $styles, $path, $styles ); }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。