WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\Utils

StyleAttributesUtils::get_classes_and_styles_by_attributes() public WC 1.0

Get classes and styles from attributes.

{} It's a method of the class: StyleAttributesUtils{}

No Hooks.

Return

Array.

Usage

$result = StyleAttributesUtils::get_classes_and_styles_by_attributes( $attributes, $properties );
$attributes(array) (required)
Block attributes.
$properties(array)
Properties to get classes/styles from.
Default: array()

Code of StyleAttributesUtils::get_classes_and_styles_by_attributes() WC 6.1.0

public static function get_classes_and_styles_by_attributes( $attributes, $properties = array() ) {
	$classes_and_styles = array(
		'line_height' => self::get_line_height_class_and_style( $attributes ),
		'text_color'  => self::get_text_color_class_and_style( $attributes ),
		'font_size'   => self::get_font_size_class_and_style( $attributes ),
		'link_color'  => self::get_link_color_class_and_style( $attributes ),
	);

	if ( ! empty( $properties ) ) {
		foreach ( $classes_and_styles as $key => $value ) {
			if ( ! in_array( $key, $properties, true ) ) {
				unset( $classes_and_styles[ $key ] );
			}
		}
	}

	$classes_and_styles = array_filter( $classes_and_styles );

	$classes = array_map(
		function( $item ) {
			return $item['class'];
		},
		$classes_and_styles
	);

	$styles = array_map(
		function( $item ) {
			return $item['style'];
		},
		$classes_and_styles
	);

	$classes = array_filter( $classes );
	$styles  = array_filter( $styles );

	return array(
		'classes' => implode( ' ', $classes ),
		'styles'  => implode( ' ', $styles ),
	);
}