PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.7
Elementor Website Builder – more than just a page builder v3.35.7
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | modules/atomic-widgets/styles/size-constants.php +44 -192 4.1.33.35.7 View file →
@@ -13,275 +13,127 @@
13 13 const UNIT_REM = 'rem';
14 14 const UNIT_VW = 'vw';
15 15 const UNIT_VH = 'vh';
16 16 const UNIT_CH = 'ch';
17 - const UNIT_VMIN = 'vmin';
18 - const UNIT_VMAX = 'vmax';
17 + const UNIT_AUTO = 'auto';
18 + const UNIT_CUSTOM = 'custom';
19 19 const UNIT_SECOND = 's';
20 20 const UNIT_MILLI_SECOND = 'ms';
21 - const UNIT_DEG = 'deg';
22 - const UNIT_RAD = 'rad';
23 - const UNIT_GRAD = 'grad';
24 - const UNIT_TURN = 'turn';
25 - const UNIT_AUTO = 'auto';
26 - const UNIT_CUSTOM = 'custom';
21 + const UNIT_ANGLE_DEG = 'deg';
27 22
28 23 const DEFAULT_UNIT = self::UNIT_PX;
29 24
30 - private const ORDER = [
25 + const LENGTH_UNITS = [
31 26 self::UNIT_PX,
32 - self::UNIT_PERCENT,
33 27 self::UNIT_EM,
34 28 self::UNIT_REM,
35 29 self::UNIT_VW,
36 30 self::UNIT_VH,
37 31 self::UNIT_CH,
38 - self::UNIT_VMIN,
39 - self::UNIT_VMAX,
40 - self::UNIT_DEG,
41 - self::UNIT_RAD,
42 - self::UNIT_GRAD,
43 - self::UNIT_TURN,
44 - self::UNIT_SECOND,
45 - self::UNIT_MILLI_SECOND,
46 - self::UNIT_AUTO,
47 - self::UNIT_CUSTOM,
48 32 ];
49 33
50 - private const LENGTH_UNITS = [
51 - self::UNIT_PX,
52 - self::UNIT_EM,
53 - self::UNIT_REM,
54 - self::UNIT_VW,
55 - self::UNIT_VH,
56 - self::UNIT_CH,
57 - ];
34 + const TIME_UNITS = [ self::UNIT_SECOND, self::UNIT_MILLI_SECOND ];
35 + const EXTENDED_UNITS = [ self::UNIT_AUTO, self::UNIT_CUSTOM ];
36 + const VIEWPORT_MIN_MAX_UNITS = [ 'vmin', 'vmax' ];
37 + const ANGLE_UNITS = [ self::UNIT_ANGLE_DEG, 'rad', 'grad', 'turn' ];
58 38
59 - private const TIME_UNITS = [
60 - self::UNIT_MILLI_SECOND,
61 - self::UNIT_SECOND,
62 - ];
63 -
64 - private const ANGLE_UNITS = [
65 - self::UNIT_DEG,
66 - self::UNIT_RAD,
67 - self::UNIT_GRAD,
68 - self::UNIT_TURN,
69 - ];
70 -
71 - private const EXTENDED_UNITS = [
72 - self::UNIT_AUTO,
73 - self::UNIT_CUSTOM,
74 - ];
75 -
76 - private const VIEWPORT_MIN_MAX_UNITS = [
77 - self::UNIT_VMIN,
78 - self::UNIT_VMAX,
79 - ];
80 -
81 - private const NUMERIC_UNITS = [
82 - ...self::LENGTH_UNITS,
83 - self::UNIT_PERCENT,
84 - self::UNIT_CUSTOM,
85 - ];
86 -
87 - private static function presets(): array {
88 - return [
89 - 'layout' => self::sort_by_preferred_order( self::NUMERIC_UNITS ),
90 - 'spacing' => self::sort_by_preferred_order( self::NUMERIC_UNITS ),
91 - 'position' => self::NUMERIC_UNITS,
92 - 'typography' => self::NUMERIC_UNITS,
93 - 'border' => self::NUMERIC_UNITS,
94 - 'box_shadow' => self::NUMERIC_UNITS,
95 - 'transform' => self::NUMERIC_UNITS,
96 -
97 - 'spacing_margin' => self::standard_units(),
98 -
99 - 'anchor_offset' => [
100 - ...self::LENGTH_UNITS,
101 - self::UNIT_CUSTOM,
102 - ],
103 -
104 - 'stroke_width' => [
105 - self::UNIT_PX,
106 - self::UNIT_EM,
107 - self::UNIT_REM,
108 - self::UNIT_CUSTOM,
109 - ],
110 -
111 - 'transition' => [
112 - ...self::TIME_UNITS,
113 - self::UNIT_CUSTOM,
114 - ],
115 -
116 - 'opacity' => [
117 - self::UNIT_PERCENT,
118 - self::UNIT_CUSTOM,
119 - ],
120 -
121 - 'rotate' => [
122 - ...self::ANGLE_UNITS,
123 - self::UNIT_CUSTOM,
124 - ],
125 -
126 - 'drop_shadow' => [
127 - ...self::LENGTH_UNITS,
128 - self::UNIT_CUSTOM,
129 - ],
130 -
131 - 'blur_filter' => [
132 - ...self::LENGTH_UNITS,
133 - self::UNIT_CUSTOM,
134 - ],
135 -
136 - 'intensity_filter' => [
137 - self::UNIT_PERCENT,
138 - self::UNIT_CUSTOM,
139 - ],
140 -
141 - 'color_tone_filter' => [
142 - self::UNIT_PERCENT,
143 - self::UNIT_CUSTOM,
144 - ],
145 -
146 - 'hue_rotate_filter' => [
147 - ...self::ANGLE_UNITS,
148 - self::UNIT_CUSTOM,
149 - ],
150 - ];
151 - }
152 -
153 - private static function sort_by_preferred_order( array $units ): array {
154 - $index = array_flip( self::ORDER );
155 -
156 - usort( $units, fn( $a, $b ) =>
157 - ( $index[ $a ] ?? PHP_INT_MAX ) <=> ( $index[ $b ] ?? PHP_INT_MAX )
39 + public static function all_supported_units(): array {
40 + return array_merge(
41 + self::all(),
42 + self::ANGLE_UNITS,
43 + self::TIME_UNITS,
44 + self::EXTENDED_UNITS,
45 + self::VIEWPORT_MIN_MAX_UNITS,
158 46 );
159 -
160 - return $units;
161 47 }
162 48
163 - public static function standard_units(): array {
164 - return self::sort_by_preferred_order( [
49 + public static function all(): array {
50 + return [
165 51 ...self::LENGTH_UNITS,
166 52 self::UNIT_PERCENT,
167 53 self::UNIT_AUTO,
168 54 self::UNIT_CUSTOM,
169 - ] );
170 - }
171 -
172 - public static function all_supported_units(): array {
173 - return [
174 - ...self::LENGTH_UNITS,
175 - ...self::TIME_UNITS,
176 - ...self::ANGLE_UNITS,
177 - ...self::EXTENDED_UNITS,
178 - ...self::VIEWPORT_MIN_MAX_UNITS,
179 - self::UNIT_PERCENT,
180 55 ];
181 56 }
182 57
183 - public static function grouped_units(): array {
184 - return [
185 - 'length' => self::LENGTH_UNITS,
186 - 'angle' => self::ANGLE_UNITS,
187 - 'time' => self::TIME_UNITS,
188 - 'extended_units' => self::EXTENDED_UNITS,
189 - ];
58 + private static function units_without_auto(): array {
59 + return [ ...self::LENGTH_UNITS, self::UNIT_PERCENT, self::UNIT_CUSTOM ];
190 60 }
191 61
192 - private static function by_group( string $group ): array {
193 - $groups = self::grouped_units();
194 -
195 - return $groups[ $group ] ?? [];
196 - }
197 -
198 - public static function get_preset( string $name ): array {
199 - $presets = self::presets();
200 -
201 - return $presets[ $name ] ?? [];
202 - }
203 -
204 - public static function length(): array {
205 - return self::by_group( 'length' );
206 - }
207 -
208 - public static function time(): array {
209 - return self::by_group( 'time' );
210 - }
211 -
212 - public static function angle(): array {
213 - return self::by_group( 'angle' );
214 - }
215 -
216 62 public static function layout(): array {
217 - return self::get_preset( 'layout' );
63 + return self::units_without_auto();
218 64 }
219 65
220 - public static function spacing_margin(): array {
221 - return self::get_preset( 'spacing_margin' );
66 + public static function spacing_margin() {
67 + return self::all();
222 68 }
223 69
224 70 public static function spacing(): array {
225 - return self::get_preset( 'spacing' );
71 + return self::units_without_auto();
226 72 }
227 73
228 74 public static function position(): array {
229 - return self::get_preset( 'position' );
75 + return self::units_without_auto();
230 76 }
231 77
232 78 public static function anchor_offset(): array {
233 - return self::get_preset( 'anchor_offset' );
79 + return [ ...self::LENGTH_UNITS, self::UNIT_CUSTOM ];
234 80 }
235 81
236 82 public static function typography(): array {
237 - return self::get_preset( 'typography' );
83 + return self::units_without_auto();
238 84 }
239 85
240 86 public static function stroke_width(): array {
241 - return self::get_preset( 'stroke_width' );
87 + return [
88 + self::UNIT_PX,
89 + self::UNIT_EM,
90 + self::UNIT_REM,
91 + self::UNIT_CUSTOM,
92 + ];
242 93 }
243 94
244 95 public static function transition(): array {
245 - return self::get_preset( 'transition' );
96 + return [ ...self::TIME_UNITS, self::UNIT_CUSTOM ];
246 97 }
247 98
248 99 public static function border(): array {
249 - return self::get_preset( 'border' );
100 + return self::units_without_auto();
250 101 }
251 102
103 +
252 104 public static function opacity(): array {
253 - return self::get_preset( 'opacity' );
105 + return [ self::UNIT_PERCENT, self::UNIT_CUSTOM ];
254 106 }
255 107
256 108 public static function box_shadow(): array {
257 - return self::get_preset( 'box_shadow' );
109 + return self::units_without_auto();
258 110 }
259 111
260 112 public static function rotate(): array {
261 - return self::get_preset( 'rotate' );
113 + return [ ...self::ANGLE_UNITS, self::UNIT_CUSTOM ];
262 114 }
263 115
264 116 public static function transform(): array {
265 - return self::get_preset( 'transform' );
117 + return self::units_without_auto();
266 118 }
267 119
268 120 public static function drop_shadow(): array {
269 - return self::get_preset( 'drop_shadow' );
121 + return [ ...self::LENGTH_UNITS, self::UNIT_CUSTOM ];
270 122 }
271 123
272 124 public static function blur_filter(): array {
273 - return self::get_preset( 'blur_filter' );
125 + return [ ...self::LENGTH_UNITS, self::UNIT_CUSTOM ];
274 126 }
275 127
276 128 public static function intensity_filter(): array {
277 - return self::get_preset( 'intensity_filter' );
129 + return [ self::UNIT_PERCENT, self::UNIT_CUSTOM ];
278 130 }
279 131
280 132 public static function color_tone_filter(): array {
281 - return self::get_preset( 'color_tone_filter' );
133 + return [ self::UNIT_PERCENT, self::UNIT_CUSTOM ];
282 134 }
283 135
284 136 public static function hue_rotate_filter(): array {
285 - return self::get_preset( 'hue_rotate_filter' );
137 + return [ ...self::ANGLE_UNITS, self::UNIT_CUSTOM ];
286 138 }
287 139 }