PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.0-dev3
Elementor Website Builder – more than just a page builder v3.32.0-dev3
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 +50 -208 4.1.33.32.0-dev3 View file →
@@ -12,276 +12,118 @@
12 12 const UNIT_EM = 'em';
13 13 const UNIT_REM = 'rem';
14 14 const UNIT_VW = 'vw';
15 15 const UNIT_VH = 'vh';
16 - const UNIT_CH = 'ch';
17 - const UNIT_VMIN = 'vmin';
18 - const UNIT_VMAX = 'vmax';
16 + const UNIT_AUTO = 'auto';
17 + const UNIT_CUSTOM = 'custom';
19 18 const UNIT_SECOND = 's';
20 19 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';
20 + const UNIT_ANGLE_DEG = 'deg';
27 21
28 - const DEFAULT_UNIT = self::UNIT_PX;
29 -
30 - private const ORDER = [
22 + const LENGTH_UNITS = [
31 23 self::UNIT_PX,
32 - self::UNIT_PERCENT,
33 24 self::UNIT_EM,
34 25 self::UNIT_REM,
35 26 self::UNIT_VW,
36 27 self::UNIT_VH,
37 - 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 28 ];
49 29
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 - ];
30 + const TIME_UNITS = [ self::UNIT_SECOND, self::UNIT_MILLI_SECOND ];
31 + const EXTENDED_UNITS = [ self::UNIT_AUTO, self::UNIT_CUSTOM ];
32 + const VIEWPORT_MIN_MAX_UNITS = [ 'vmin', 'vmax' ];
33 + const ANGLE_UNITS = [ self::UNIT_ANGLE_DEG, 'rad', 'grad', 'turn' ];
58 34
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 )
35 + public static function all_supported_units(): array {
36 + return array_merge(
37 + self::all(),
38 + self::ANGLE_UNITS,
39 + self::TIME_UNITS,
40 + self::EXTENDED_UNITS,
41 + self::VIEWPORT_MIN_MAX_UNITS,
158 42 );
159 -
160 - return $units;
161 43 }
162 44
163 - public static function standard_units(): array {
164 - return self::sort_by_preferred_order( [
45 + public static function all(): array {
46 + return [
165 47 ...self::LENGTH_UNITS,
166 48 self::UNIT_PERCENT,
167 49 self::UNIT_AUTO,
168 - 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 50 ];
181 51 }
182 52
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 - ];
53 + private static function units_without_auto(): array {
54 + return [ ...self::LENGTH_UNITS, self::UNIT_PERCENT ];
190 55 }
191 56
192 - private static function by_group( string $group ): array {
193 - $groups = self::grouped_units();
194 -
195 - return $groups[ $group ] ?? [];
57 + public static function layout() {
58 + return self::units_without_auto();
196 59 }
197 60
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 - public static function layout(): array {
217 - return self::get_preset( 'layout' );
218 - }
219 -
220 - public static function spacing_margin(): array {
221 - return self::get_preset( 'spacing_margin' );
222 - }
223 -
224 61 public static function spacing(): array {
225 - return self::get_preset( 'spacing' );
62 + return self::units_without_auto();
226 63 }
227 64
228 65 public static function position(): array {
229 - return self::get_preset( 'position' );
66 + return self::units_without_auto();
230 67 }
231 68
232 - public static function anchor_offset(): array {
233 - return self::get_preset( 'anchor_offset' );
69 + public static function anchor_offset() {
70 + return self::LENGTH_UNITS;
234 71 }
235 72
236 73 public static function typography(): array {
237 - return self::get_preset( 'typography' );
74 + return self::units_without_auto();
238 75 }
239 76
240 - public static function stroke_width(): array {
241 - return self::get_preset( 'stroke_width' );
77 + public static function stroke_width() {
78 + return [
79 + self::UNIT_PX,
80 + self::UNIT_EM,
81 + self::UNIT_REM,
82 + ];
242 83 }
243 84
244 - public static function transition(): array {
245 - return self::get_preset( 'transition' );
85 + public static function transition() {
86 + return self::TIME_UNITS;
246 87 }
247 88
248 89 public static function border(): array {
249 - return self::get_preset( 'border' );
90 + return self::units_without_auto();
250 91 }
251 92
93 +
252 94 public static function opacity(): array {
253 - return self::get_preset( 'opacity' );
95 + return [ self::UNIT_PERCENT ];
254 96 }
255 97
256 98 public static function box_shadow(): array {
257 - return self::get_preset( 'box_shadow' );
99 + return self::units_without_auto();
258 100 }
259 101
260 102 public static function rotate(): array {
261 - return self::get_preset( 'rotate' );
103 + return self::ANGLE_UNITS;
262 104 }
263 105
264 106 public static function transform(): array {
265 - return self::get_preset( 'transform' );
107 + return self::units_without_auto();
266 108 }
267 109
268 - public static function drop_shadow(): array {
269 - return self::get_preset( 'drop_shadow' );
110 + public static function drop_shadow() {
111 + return self::LENGTH_UNITS;
270 112 }
271 113
272 - public static function blur_filter(): array {
273 - return self::get_preset( 'blur_filter' );
114 + public static function blur_filter() {
115 + return self::LENGTH_UNITS;
274 116 }
275 117
276 - public static function intensity_filter(): array {
277 - return self::get_preset( 'intensity_filter' );
118 + public static function intensity_filter() {
119 + return [ self::UNIT_PERCENT ];
278 120 }
279 121
280 - public static function color_tone_filter(): array {
281 - return self::get_preset( 'color_tone_filter' );
122 + public static function color_tone_filter() {
123 + return [ self::UNIT_PERCENT ];
282 124 }
283 125
284 - public static function hue_rotate_filter(): array {
285 - return self::get_preset( 'hue_rotate_filter' );
126 + public static function hue_rotate_filter() {
127 + return self::ANGLE_UNITS;
286 128 }
287 129 }