PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.14.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.14.0
2.14.0 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 All 81 releases
← All changes | includes/controls/box-shadow.php +20 -5 2.9.1 → 2.14.0 View file →
@@ -5,8 +5,9 @@
5 5 exit;
6 6 }
7 7
8 8 use ABlocks\Classes\ControlBaseAbstract;
9 +use ABlocks\Controls\Color;
9 10
10 11 class BoxShadow extends ControlBaseAbstract {
11 12 public static function get_attribute_default_value( $is_responsive = false ) {
12 13 return [
@@ -42,9 +43,9 @@
42 43 $value = wp_parse_args( $attribute_value,
43 44 self::get_attribute_default_value( true )
44 45 );
45 46 $css = [];
46 - $color = $value['color'] ? $value['color'] : '#000000';
47 + $color = Color::get_css( $value['color'] ? $value['color'] : '#000000' );
47 48 if ( $value['shadowType'] !== 'default' && $value['shadowType'] === 'inner_shadow' ) {
48 49 if ( ! empty( $value['preset'] ) ) {
49 50 $css['box-shadow'] = 'inset ' . $value['horizontal'] . 'px ' . $value['vertical'] . 'px ' . $value['blur'] . 'px ' . $value['spread'] . 'px ' . $color;
50 51
@@ -53,14 +54,20 @@
53 54 if ( ! empty( $value['preset'] ) ) {
54 55 $css['box-shadow'] = $value['horizontal'] . 'px ' . $value['vertical'] . 'px ' . $value['blur'] . 'px ' . $value['spread'] . 'px ' . $color;
55 56 }
56 57 } else {
57 - if ( ! empty( $value['horizontal'] ) && ! empty( $value['vertical'] ) ) {
58 + // A 0 offset is a valid shadow (e.g. a centered glow); only an unset
59 + // value skips it, matching the editor's '' / undefined check.
60 + if ( self::is_offset_set( $value['horizontal'] ) && self::is_offset_set( $value['vertical'] ) ) {
58 61 $css['box-shadow'] = $value['horizontal'] . 'px ' . $value['vertical'] . 'px ' . $value['blur'] . 'px ' . $value['spread'] . 'px ' . $color;
59 62 }
60 63 }
61 64 if ( $value['transitionDuration'] ) {
62 - $css['transition'] = $property . ' ' . $value['transitionDuration'] . 's';
65 + // This control animates the box-shadow, so the transition property is
66 + // always "box-shadow". Previously it used $property, which callers
67 + // pass inconsistently (often the device string), producing invalid
68 + // CSS like "transition:Tablet 0.3s".
69 + $css['transition'] = 'box-shadow ' . $value['transitionDuration'] . 's';
63 70 }
64 71 return $css;
65 72 }
66 73
@@ -70,9 +77,9 @@
70 77 self::get_attribute_default_value( true ),
71 78 );
72 79
73 80 $css = [];
74 - $colorH = $value['colorH'] ? $value['colorH'] : '#000000';
81 + $colorH = Color::get_css( $value['colorH'] ? $value['colorH'] : '#000000' );
75 82 if ( $value['shadowTypeH'] !== 'default' && $value['shadowTypeH'] === 'inner_shadow' ) {
76 83 if ( ! empty( $value['presetH'] ) ) {
77 84 $css['box-shadow'] = 'inset ' . $value['horizontalH'] . 'px ' . $value['verticalH'] . 'px ' . $value['blurH'] . 'px ' . $value['spreadH'] . 'px ' . $colorH;
78 85 }
@@ -80,12 +87,20 @@
80 87 if ( ! empty( $value['presetH'] ) ) {
81 88 $css['box-shadow'] = $value['horizontalH'] . 'px ' . $value['verticalH'] . 'px ' . $value['blurH'] . 'px ' . $value['spreadH'] . 'px ' . $colorH;
82 89 }
83 90 } else {
84 - if ( ! empty( $value['horizontalH'] ) && ! empty( $value['verticalH'] ) ) {
91 + if ( self::is_offset_set( $value['horizontalH'] ) && self::is_offset_set( $value['verticalH'] ) ) {
85 92 $css['box-shadow'] = $value['horizontalH'] . 'px ' . $value['verticalH'] . 'px ' . $value['blurH'] . 'px ' . $value['spreadH'] . 'px ' . $colorH;
86 93 }
87 94 }
88 95 return $css;
96 + }
97 +
98 + /**
99 + * Whether a shadow offset is set. 0 / "0" count as set; only null and ''
100 + * mean "not configured".
101 + */
102 + private static function is_offset_set( $value ) {
103 + return null !== $value && '' !== $value;
89 104 }
90 105
91 106 }