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