Automattic\WooCommerce\Blocks\Utils
StyleAttributesUtils::get_border_width_class_and_style
Get class and style for border width from attributes.
Method of the class: StyleAttributesUtils{}
No Hooks.
Returns
Array.
Usage
$result = StyleAttributesUtils::get_border_width_class_and_style( $attributes );
- $attributes(array) (required)
- Block attributes.
StyleAttributesUtils::get_border_width_class_and_style() StyleAttributesUtils::get border width class and style code WC 10.8.1
public static function get_border_width_class_and_style( $attributes ) {
$custom_border = $attributes['style']['border'] ?? '';
if ( '' === $custom_border ) {
return self::EMPTY_STYLE;
}
$style = '';
if ( array_key_exists( 'width', ( $custom_border ) ) && ! empty( $custom_border['width'] ) ) {
// Linked sides.
$style = 'border-width:' . $custom_border['width'] . ';';
} else {
// Unlinked sides.
foreach ( $custom_border as $border_width_side => $border_width_value ) {
if ( isset( $border_width_value['width'] ) ) {
$style .= 'border-' . $border_width_side . '-width:' . $border_width_value['width'] . ';';
}
}
}
return array(
'class' => null,
'style' => $style,
);
}