Automattic\WooCommerce\Blocks\Utils
StyleAttributesUtils::get_font_size_class_and_style()
Get class and style for font-size from attributes.
Method of the class: StyleAttributesUtils{}
No Hooks.
Return
Array
.
Usage
$result = StyleAttributesUtils::get_font_size_class_and_style( $attributes );
- $attributes(array) (required)
- Block attributes.
StyleAttributesUtils::get_font_size_class_and_style() StyleAttributesUtils::get font size class and style code WC 9.4.2
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; }