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(), $block_name = '', $origin = 'all' )
Parameters: (3)
  • (array) $path Path to the specific style to retrieve. Optional. If empty, will return all styles.
    Required: No
    Default: array()
  • (string) $block_name Which block to retrieve the styles from. Optional. If empty, it'll return the styles for the global context.
    Required: No
    Default: (empty)
  • (string) $origin Which origin to take data from. Optional. It can be 'all' (core, theme, and user) or 'base' (core and theme). If empty or unknown, 'all' is used.
    Required: No
    Default: 'all'
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(), $block_name = '', $origin = 'all' ) {
	if ( '' !== $block_name ) {
		$path = array_merge( array( 'blocks', $block_name ), $path );
	}

	if ( 'base' === $origin ) {
		$origin = 'theme';
	} else {
		$origin = 'user';
	}

	$styles = WP_Theme_JSON_Resolver::get_merged_data( $origin )->get_raw_data()['styles'];

	return _wp_array_get( $styles, $path, $styles );
}