W3cubDocs

/WordPress

WP_Duotone::get_global_styles_presets( array $sources ): string

Get the CSS for global styles.

Description

Example output: body{–wp–preset–duotone–blue-orange:url(‘#wp-duotone-blue-orange’);}

Parameters

$sourcesarrayrequired
The duotone presets.

Return

string The CSS for global styles.

Source

private static function get_global_styles_presets( $sources ) {
	$css = WP_Theme_JSON::ROOT_CSS_PROPERTIES_SELECTOR . '{';
	foreach ( $sources as $filter_id => $filter_data ) {
		$slug              = $filter_data['slug'];
		$colors            = $filter_data['colors'];
		$css_property_name = self::get_css_custom_property_name( $slug );
		$declaration_value = is_string( $colors ) ? $colors : self::get_filter_url( $filter_id );
		$css              .= "$css_property_name:$declaration_value;";
	}
	$css .= '}';
	return $css;
}

Changelog

Version Description
6.6.0 Replaced body selector with WP_Theme_JSON::ROOT_CSS_PROPERTIES_SELECTOR.
6.3.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_duotone/get_global_styles_presets