Automattic\WooCommerce\Blocks\Utils

StyleAttributesUtils::get_font_size_class_and_style()public staticWC 1.0

Get class and style for font-size from attributes.

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

Хуков нет.

Возвращает

Массив.

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

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

Код StyleAttributesUtils::get_font_size_class_and_style() WC 8.7.0

public static function get_font_size_class_and_style( $attributes ) {

	$font_size = $attributes['fontSize'] ?? '';

	$custom_font_size = $attributes['style']['typography']['fontSize'] ?? '';

	if ( ! $font_size && '' === $custom_font_size ) {
		return self::EMPTY_STYLE;
	}

	if ( $font_size ) {
		return array(
			'class' => sprintf( 'has-font-size has-%s-font-size', $font_size ),
			'style' => null,
		);
	} elseif ( '' !== $custom_font_size ) {
		return array(
			'class' => null,
			'style' => sprintf( 'font-size: %s;', $custom_font_size ),
		);
	}

	return self::EMPTY_STYLE;
}