Automattic\WooCommerce\EmailEditor\Integrations\Utils

Styles_Helper::resolve_color_from_palette │ public static │ WC 1.0

Resolve a color slug against the palette.

Searches every origin, highest priority first: a slug the user defined in the email's own global styles (custom) beats the theme's, which beats core's.

A slug no origin defines returns an empty string, so callers omit the declaration and the block keeps the surrounding color. A literal color passes through.

Метод класса: Styles_Helper{}

Хуков нет.

Возвращает

string. The color value, or an empty string for a slug the palette does not define.

Использование

$result = Styles_Helper::resolve_color_from_palette( $settings, $color_slug ): string;
$settings(массив) (обязательный)
Theme settings array, as WP_Theme_JSON::get_settings() returns it.
$color_slug(строка) (обязательный)
Color slug, or a literal color.

Код Styles_Helper::resolve_color_from_palette() WC 11.3.0

public static function resolve_color_from_palette( array $settings, string $color_slug ): string {
	foreach ( self::palette_definitions( $settings ) as $color_definition ) {
		if ( $color_definition['slug'] === $color_slug ) {
			return strtolower( (string) $color_definition['color'] );
		}
	}

	// Not lowercased the way a palette color is: a custom property name inside `var()` is
	// case-sensitive.
	return self::is_color_literal( $color_slug ) ? trim( $color_slug ) : '';
}