Automattic\WooCommerce\Blocks\Utils

StyleAttributesUtils::get_border_width_class_and_style()public staticWC 1.0

Get class and style for border width from attributes.

Метод класса: StyleAttributesUtils{}

Хуков нет.

Возвращает

Массив.

Использование

$result = StyleAttributesUtils::get_border_width_class_and_style( $attributes );
$attributes(массив) (обязательный)
Block attributes.

Код StyleAttributesUtils::get_border_width_class_and_style() WC 8.7.0

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,
	);
}