Automattic\WooCommerce\Blocks\Utils

StyleAttributesUtils::get_link_color_class_and_style()public staticWC 1.0

Get class and style for link-color from attributes.

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

Хуков нет.

Возвращает

Массив.

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

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

Код StyleAttributesUtils::get_link_color_class_and_style() WC 8.7.0

public static function get_link_color_class_and_style( $attributes ) {
	$link_color = self::array_get_value_by_path( $attributes, 'style.elements.link.color.text' );

	if ( empty( $link_color ) ) {
		return self::EMPTY_STYLE;
	}

	// If the link color is selected from the theme color picker, the value of $link_color is var:preset|color|slug.
	// If the link color is selected from the core color picker, the value of $link_color is an hex value.
	// When the link color is a string var:preset|color|slug we parsed it for get the slug, otherwise we use the hex value.
	if ( strstr( $link_color, '|' ) ) {
		$link_color_parts = explode( '|', $link_color );
		$link_color       = self::get_preset_value( end( $link_color_parts ) );
	}

	return array(
		'class' => 'has-link-color',
		'style' => sprintf( 'color: %s;', $link_color ),
		'value' => $link_color,
	);
}