wp_get_global_styles() – Gets the styles resulting of merging core, theme, and user data.
You appear to be a bot. Output may be restricted
Description
Gets the styles resulting of merging core, theme, and user data.
Usage
$mixed = wp_get_global_styles( $path, $context );
Parameters
- $path
- ( array ) optional – Path to the specific style to retrieve. Optional. If empty, will return all styles.
- $context
- ( array ) optional – { Metadata to know where to retrieve the $path from. Optional.
- $block_name
- ( string ) optional – Which block to retrieve the styles from. If empty, it'll return the styles for the global context.
- $origin
- ( string ) optional – 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.
- $transforms
- ( array ) optional – Which transformation(s) to apply. Valid value is array( 'resolve-variables' ). If defined, variables are resolved to their value in the styles. }
Returns
mixed The styles array or individual style value to retrieve.
Source
File name: wordpress/wp-includes/global-styles-and-settings.php
Lines:
1 to 22 of 22
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'; } $resolve_variables = isset( $context['transforms'] ) && is_array( $context['transforms'] ) && in_array( 'resolve-variables', $context['transforms'], true ); $merged_data = WP_Theme_JSON_Resolver::get_merged_data( $origin ); if ( $resolve_variables ) { $merged_data = WP_Theme_JSON::resolve_variables( $merged_data ); } $styles = $merged_data->get_raw_data()['styles']; return _wp_array_get( $styles, $path, $styles ); }