Automattic\WooCommerce\Blocks\Utils

StyleAttributesUtils::get_padding_class_and_style()public staticWC 1.0

Get class and style for padding from attributes.

Method of the class: StyleAttributesUtils{}

No Hooks.

Return

Array.

Usage

$result = StyleAttributesUtils::get_padding_class_and_style( $attributes );
$attributes(array) (required)
Block attributes.

StyleAttributesUtils::get_padding_class_and_style() code WC 9.4.2

public static function get_padding_class_and_style( $attributes ) {
	$padding = $attributes['style']['spacing']['padding'] ?? null;

	if ( ! $padding ) {
		return self::EMPTY_STYLE;
	}

	$spacing_values_css = '';

	foreach ( $padding as $padding_side => $padding_value ) {
		$spacing_values_css .= 'padding-' . $padding_side . ':' . self::get_spacing_value( $padding_value ) . ';';
	}

	return array(
		'class' => null,
		'style' => $spacing_values_css,
	);
}