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/dimensions.php +20 -12 2.9.02.13.1 View file →
@@ -62,9 +62,9 @@
62 62 ]
63 63 ];
64 64 }
65 65 public static function get_css( $attribute_value, $property = '', $device = '' ) {
66 - $attribute_value = wp_parse_args( $attribute_value, self::get_attribute_default_value( (bool) $device ) );
66 + $attribute_value = wp_parse_args( $attribute_value, $device ? self::responsive_defaults() : self::get_attribute_default_value( false ) );
67 67 $css = [];
68 68 $unit = self::get_unit( $attribute_value, $device );
69 69
70 70 if ( (bool) $attribute_value[ 'isLinked' . $device ] ) {
@@ -71,19 +71,27 @@
71 71 if ( '' !== $attribute_value[ 'common' . $device ] ) {
72 72 $css[ $property ] = $attribute_value[ 'common' . $device ] . $unit;
73 73 }
74 74 } else {
75 - if ( '' !== $attribute_value[ 'top' . $device ] ) {
76 - $css[ $property . '-top' ] = $attribute_value[ 'top' . $device ] . $unit;
77 - }
78 - if ( '' !== $attribute_value[ 'right' . $device ] ) {
79 - $css[ $property . '-right' ] = $attribute_value[ 'right' . $device ] . $unit;
80 - }
81 - if ( '' !== $attribute_value[ 'bottom' . $device ] ) {
82 - $css[ $property . '-bottom' ] = $attribute_value[ 'bottom' . $device ] . $unit;
83 - }
84 - if ( '' !== $attribute_value[ 'left' . $device ] ) {
85 - $css[ $property . '-left' ] = $attribute_value[ 'left' . $device ] . $unit;
75 + /*
76 + * A side may carry its own unit (`topUnit`, `rightUnit`, …), so an
77 + * author can mix e.g. `padding-top: 2rem` with `padding-left: 10px`.
78 + * Purely additive: a side that has never been given one falls back to
79 + * the group unit, so anything saved before this compiles
80 + * byte-for-byte as it did.
81 + */
82 + foreach ( [ 'top', 'right', 'bottom', 'left' ] as $side ) {
83 + if ( '' === $attribute_value[ $side . $device ] ) {
84 + continue;
85 + }
86 + $side_unit = self::device_member( $attribute_value, $side . 'Unit', $device );
87 + if ( '' === $side_unit ) {
88 + $side_unit = self::device_member( $attribute_value, $side . 'Unit' );
89 + }
90 + if ( '' === $side_unit ) {
91 + $side_unit = $unit;
92 + }
93 + $css[ $property . '-' . $side ] = $attribute_value[ $side . $device ] . $side_unit;
86 94 }
87 95 }
88 96 return $css;
89 97 }