Automattic\WooCommerce\Blocks\Utils

StyleAttributesUtils::get_text_color_class_and_style()public staticWC 1.0

Get class and style for text-color from attributes.

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

Хуков нет.

Возвращает

Массив.

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

$result = StyleAttributesUtils::get_text_color_class_and_style( $attributes );
$attributes(массив) (обязательный)
Block attributes.

Код StyleAttributesUtils::get_text_color_class_and_style() WC 8.7.0

public static function get_text_color_class_and_style( $attributes ) {

	$text_color = $attributes['textColor'] ?? '';

	$custom_text_color = $attributes['style']['color']['text'] ?? '';

	if ( ! $text_color && ! $custom_text_color ) {
		return self::EMPTY_STYLE;
	}

	if ( $text_color ) {
		return array(
			'class' => sprintf( 'has-text-color has-%s-color', $text_color ),
			'style' => null,
			'value' => self::get_preset_value( $text_color ),
		);
	} elseif ( $custom_text_color ) {
		return array(
			'class' => null,
			'style' => sprintf( 'color: %s;', $custom_text_color ),
			'value' => $custom_text_color,
		);
	}

	return self::EMPTY_STYLE;
}