Automattic\WooCommerce\Blocks\Utils
StyleAttributesUtils::get_text_align_class_and_style
Get class and style for text align from attributes.
Method of the class: StyleAttributesUtils{}
No Hooks.
Returns
Array.
Usage
$result = StyleAttributesUtils::get_text_align_class_and_style( $attributes );
- $attributes(array) (required)
- Block attributes.
StyleAttributesUtils::get_text_align_class_and_style() StyleAttributesUtils::get text align class and style code WC 10.8.1
public static function get_text_align_class_and_style( $attributes ) {
// Check if the text align is set in the attributes manually (legacy) or in the global styles.
$text_align = $attributes['textAlign'] ?? $attributes['style']['typography']['textAlign'] ?? null;
if ( $text_align ) {
return array(
'class' => 'has-text-align-' . $text_align,
'style' => null,
);
}
return self::EMPTY_STYLE;
}