wpseek.com
A WordPress-centric search engine for devs and theme authors



wp_get_global_styles › WordPress Function

Since5.9.0
Deprecatedn/a
wp_get_global_styles ( $path = array(), $context = array() )
Parameters: (2)
  • (array) $path Path to the specific style to retrieve. Optional. If empty, will return all styles.
    Required: No
    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: No
    Default: array()
Returns:
  • (array) The styles to retrieve.
Defined at:
Codex:

Function to get the styles resulting of merging core, theme, and user data.



Source

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 );
}