PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.1
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
← All changes | includes/controls/width.php +37 -27 2.9.12.13.1 View file →
@@ -5,8 +5,9 @@
5 5 exit();
6 6 }
7 7
8 8 use ABlocks\Classes\ControlBaseAbstract;
9 +use ABlocks\Helper;
9 10
10 11 class Width extends ControlBaseAbstract {
11 12
12 13 public static function get_attribute_default_value( $is_responsive = false ) {
@@ -56,39 +57,48 @@
56 57 $attribute_value = wp_parse_args(
57 58 $attribute_value,
58 59 self::get_attribute_default_value( (bool) $device )
59 60 );
61 +
60 62 $css = [];
61 - if ( ! empty( $attribute_value[ 'widthType' . $device ] ) ) {
62 - if ( $attribute_value[ 'widthType' . $device ] === 'full' ) {
63 +
64 + // Width type (uses responsive fallback)
65 + $width_type = Helper::get_responsive_value(
66 + $attribute_value,
67 + 'widthType',
68 + $device,
69 + self::get_attribute_default_value()
70 + );
71 +
72 + if ( ! empty( $width_type ) ) {
73 + if ( $width_type === 'full' ) {
63 74 $css[ $property ] = '100%';
64 - } elseif ( $attribute_value[ 'widthType' . $device ] === 'auto' ) {
75 + } elseif ( $width_type === 'auto' ) {
65 76 $css[ $property ] = 'auto';
66 - $css['display'] = 'inline-block';
67 - } elseif ( $attribute_value[ 'widthType' . $device ] === 'custom' ) {
68 - $css[ $property ] =
69 - $attribute_value[ 'customWidth' . $device ] .
70 - self::get_unit(
71 - [
72 - 'unit' => ! empty(
73 - $attribute_value['customWidthUnit']
74 - )
75 - ? $attribute_value['customWidthUnit']
76 - : '',
77 - 'unitTablet' => ! empty(
78 - $attribute_value['customWidthUnitTablet']
79 - )
80 - ? $attribute_value['customWidthUnitTablet']
81 - : '',
82 - 'unitMobile' => ! empty(
83 - $attribute_value['customWidthUnitTablet']
84 - )
85 - ? $attribute_value['customWidthUnitTablet']
86 - : '',
87 - ],
88 - $device
89 - ) . '!important';
77 + $css['display'] = 'inline-block';
78 + } elseif ( $width_type === 'custom' ) {
79 + // Get custom width with responsive fallback
80 + $custom_width = Helper::get_responsive_value(
81 + $attribute_value,
82 + 'customWidth',
83 + $device,
84 + self::get_attribute_default_value()
85 + );
86 +
87 + // Get responsive unit (delegates to your get_unit function)
88 + $unit = self::get_unit(
89 + [
90 + 'unit' => Helper::get_responsive_value( $attribute_value, 'customWidthUnit', 'Desktop' ),
91 + 'unitTablet' => Helper::get_responsive_value( $attribute_value, 'customWidthUnit', 'Tablet' ),
92 + 'unitMobile' => Helper::get_responsive_value( $attribute_value, 'customWidthUnit', 'Mobile' ),
93 + ],
94 + $device
95 + );
96 +
97 + $css[ $property ] = $custom_width . $unit;
90 98 }//end if
91 99 }//end if
100 +
92 101 return $css;
93 102 }
103 +
94 104 }