Automattic\WooCommerce\Blocks\Utils

StyleAttributesUtils::get_text_align_class_and_style()public staticWC 1.0

Get class and style for text align from attributes.

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

Хуков нет.

Возвращает

(Массив. | null)

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

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

Код StyleAttributesUtils::get_text_align_class_and_style() WC 7.3.0

public static function get_text_align_class_and_style( $attributes ) {

	$text_align_attribute = $attributes['textAlign'] ?? null;

	if ( ! $text_align_attribute ) {
		return null;
	}

	if ( 'left' === $text_align_attribute ) {
		return array(
			'class' => 'has-text-align-left',
			'style' => null,
		);
	}

	if ( 'center' === $text_align_attribute ) {
		return array(
			'class' => 'has-text-align-center',
			'style' => null,
		);
	}

	if ( 'right' === $text_align_attribute ) {
		return array(
			'class' => 'has-text-align-right',
			'style' => null,
		);
	}

	return null;
}