PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.2
Elementor Website Builder – more than just a page builder v4.3.2
4.3.2 4.3.1 4.3.0 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 All 455 releases
elementor / modules / mcp / abilities / appliers / v3 / v3-widget-bridge-registry.php

v3-widget-bridge-registry.php in Elementor Website Builder – more than just a page builder 4.3.2, at modules/mcp/abilities/appliers/v3/v3-widget-bridge-registry.php

347 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Elementor\Modules\Mcp\Abilities\Appliers\V3;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 /**
10 * Per-widget allowlists and CSS→legacy-setting overrides for MCP-allowlisted V3 widgets.
11 *
12 * Entry shape:
13 * [
14 * 'non_style_keys' => string[],
15 * 'style_overrides' => [
16 * // Match key: "css-property" or "css-property@pseudo" (pseudo: hover|focus|active)
17 * 'color' => [
18 * 'setting' => 'title_color', // single setting key
19 * 'resolver' => 'color', // V3_Value_Resolvers::resolve name
20 * 'responsive' => true, // write _tablet/_mobile suffix when breakpoint != desktop
21 * ],
22 * 'font-size' => [
23 * 'typography_prefix' => 'typography', // expands via resolve_typography_group
24 * ],
25 * 'border' => [
26 * 'border_prefix' => 'image_border', // expands via resolve_border_shorthand
27 * ],
28 * 'box-shadow' => [
29 * 'setting' => 'image_box_shadow', // writes box_shadow_type + box_shadow under this prefix
30 * 'resolver' => 'box_shadow',
31 * ],
32 * ],
33 * ]
34 */
35 class V3_Widget_Bridge_Registry {
36
37 /**
38 * @return array{non_style_keys: string[], style_overrides: array<string, array>, description?: string}|null
39 */
40 public static function get( string $widget_type ): ?array {
41 $entries = self::entries();
42
43 return $entries[ $widget_type ] ?? null;
44 }
45
46 /**
47 * @return string[]
48 */
49 public static function get_non_style_keys( string $widget_type ): array {
50 $entry = self::get( $widget_type );
51
52 return $entry['non_style_keys'] ?? [];
53 }
54
55 /**
56 * @return array<string, array>
57 */
58 public static function get_style_overrides( string $widget_type ): array {
59 $entry = self::get( $widget_type );
60
61 return $entry['style_overrides'] ?? [];
62 }
63
64 public static function get_description( string $widget_type ): ?string {
65 $entry = self::get( $widget_type );
66 $description = $entry['description'] ?? null;
67
68 return is_string( $description ) && '' !== $description ? $description : null;
69 }
70
71 /**
72 * @return array<string, array{non_style_keys: string[], style_overrides: array<string, array>}>
73 */
74 private static function entries(): array {
75 return [
76 'nav-menu' => self::nav_menu(),
77 'theme-post-content' => self::theme_post_content(),
78 'theme-post-title' => self::theme_post_title(),
79 'theme-post-featured-image' => self::theme_post_featured_image(),
80 'theme-post-excerpt' => self::theme_post_excerpt(),
81 'theme-archive-title' => self::theme_archive_title(),
82 ];
83 }
84
85 private static function nav_menu(): array {
86 return [
87 'non_style_keys' => [
88 'menu_name',
89 'menu',
90 'layout',
91 'align_items',
92 'pointer',
93 'animation_line',
94 'animation_framed',
95 'animation_background',
96 'animation_text',
97 'submenu_icon',
98 'dropdown',
99 'full_width',
100 'text_align',
101 'toggle',
102 'toggle_icon_normal',
103 'toggle_icon_hover_animation',
104 'toggle_icon_active',
105 'toggle_align',
106 ],
107 'style_overrides' => array_merge(
108 self::typography_overrides( 'dropdown_typography' ),
109 self::typography_overrides( 'menu_typography' ),
110 [
111 'color' => [
112 'setting' => 'color_menu_item',
113 'resolver' => 'color',
114 ],
115 'color@hover' => [
116 'setting' => 'color_menu_item_hover',
117 'resolver' => 'color',
118 ],
119 'color@active' => [
120 'setting' => 'color_menu_item_active',
121 'resolver' => 'color',
122 ],
123 'background-color@hover' => [
124 'setting' => 'pointer_color_menu_item_hover',
125 'resolver' => 'color',
126 ],
127 'background-color@active' => [
128 'setting' => 'pointer_color_menu_item_active',
129 'resolver' => 'color',
130 ],
131 'padding-left' => [
132 'setting' => 'padding_horizontal_menu_item',
133 'resolver' => 'dimension',
134 'responsive' => true,
135 ],
136 'padding-right' => [
137 'setting' => 'padding_horizontal_menu_item',
138 'resolver' => 'dimension',
139 'responsive' => true,
140 ],
141 'padding-top' => [
142 'setting' => 'padding_vertical_menu_item',
143 'resolver' => 'dimension',
144 'responsive' => true,
145 ],
146 'padding-bottom' => [
147 'setting' => 'padding_vertical_menu_item',
148 'resolver' => 'dimension',
149 'responsive' => true,
150 ],
151 ]
152 ),
153 ];
154 }
155
156 private static function theme_post_content(): array {
157 return [
158 'description' => 'Single-template body slot only. Exactly one per single template, wrapped in an `e-div-block`. Do NOT place inside loop items, archives, headers, footers, or components — the loop already repeats the article body.',
159 'non_style_keys' => [],
160 'style_overrides' => array_merge(
161 self::typography_overrides( 'typography' ),
162 [
163 'color' => [
164 'setting' => 'text_color',
165 'resolver' => 'color',
166 ],
167 'text-align' => [
168 'setting' => 'align',
169 'resolver' => 'text',
170 ],
171 ]
172 ),
173 ];
174 }
175
176 private static function theme_post_title(): array {
177 return [
178 'description' => 'Prefer `e-heading` with a `post-title` dynamic tag. Use this V3 widget only when the V4 equivalent is not viable.',
179 'non_style_keys' => [
180 'title',
181 'link',
182 'size',
183 'header_size',
184 ],
185 'style_overrides' => self::heading_style_overrides(),
186 ];
187 }
188
189 private static function theme_archive_title(): array {
190 return [
191 'non_style_keys' => [
192 'title',
193 'link',
194 'size',
195 'header_size',
196 ],
197 'style_overrides' => self::heading_style_overrides(),
198 ];
199 }
200
201 private static function theme_post_excerpt(): array {
202 return [
203 'description' => 'Prefer `e-heading` or `e-paragraph` with a `post-excerpt` dynamic tag.',
204 'non_style_keys' => [
205 'excerpt',
206 ],
207 'style_overrides' => array_merge(
208 self::typography_overrides( 'typography' ),
209 [
210 'color' => [
211 'setting' => 'title_color',
212 'resolver' => 'color',
213 ],
214 'text-align' => [
215 'setting' => 'align',
216 'resolver' => 'text',
217 ],
218 'margin-bottom' => [
219 'setting' => 'paragraph_spacing',
220 'resolver' => 'dimension',
221 'responsive' => true,
222 ],
223 ]
224 ),
225 ];
226 }
227
228 private static function theme_post_featured_image(): array {
229 return [
230 'description' => 'Prefer `e-image` with a `featured-image` dynamic tag on `src`. Use this V3 widget only when the V4 equivalent is not viable.',
231 'non_style_keys' => [
232 'image',
233 'image_size',
234 'image_custom_dimension',
235 'caption_source',
236 'caption',
237 'link_to',
238 'link',
239 'open_lightbox',
240 ],
241 'style_overrides' => array_merge(
242 self::typography_overrides( 'caption_typography' ),
243 [
244 'text-align' => [
245 'setting' => 'align',
246 'resolver' => 'text',
247 ],
248 'width' => [
249 'setting' => 'width',
250 'resolver' => 'dimension',
251 'responsive' => true,
252 ],
253 'max-width' => [
254 'setting' => 'space',
255 'resolver' => 'dimension',
256 'responsive' => true,
257 ],
258 'height' => [
259 'setting' => 'height',
260 'resolver' => 'dimension',
261 'responsive' => true,
262 ],
263 'object-fit' => [
264 'setting' => 'object_fit',
265 'resolver' => 'text',
266 ],
267 'object-position' => [
268 'setting' => 'object_position',
269 'resolver' => 'text',
270 ],
271 'opacity' => [
272 'setting' => 'opacity',
273 'resolver' => 'text',
274 ],
275 'opacity@hover' => [
276 'setting' => 'opacity_hover',
277 'resolver' => 'text',
278 ],
279 'border-radius' => [
280 'setting' => 'image_border_radius',
281 'resolver' => 'sides',
282 'responsive' => true,
283 ],
284 'border' => [ 'border_prefix' => 'image_border' ],
285 'box-shadow' => [ 'box_shadow_prefix' => 'image_box_shadow' ],
286 ]
287 ),
288 ];
289 }
290
291 /**
292 * Shared heading-style overrides for theme-post-title / theme-archive-title.
293 *
294 * @return array<string, array>
295 */
296 private static function heading_style_overrides(): array {
297 return array_merge(
298 self::typography_overrides( 'typography' ),
299 [
300 'color' => [
301 'setting' => 'title_color',
302 'resolver' => 'color',
303 ],
304 'color@hover' => [
305 'setting' => 'title_hover_color',
306 'resolver' => 'color',
307 ],
308 'text-align' => [
309 'setting' => 'align',
310 'resolver' => 'text',
311 ],
312 'mix-blend-mode' => [
313 'setting' => 'blend_mode',
314 'resolver' => 'text',
315 ],
316 ]
317 );
318 }
319
320 /**
321 * @return array<string, array{typography_prefix: string, responsive?: bool}>
322 */
323 private static function typography_overrides( string $prefix ): array {
324 $props = [
325 'font-family',
326 'font-weight',
327 'font-style',
328 'text-transform',
329 'text-decoration',
330 'font-size',
331 'line-height',
332 'letter-spacing',
333 'word-spacing',
334 ];
335
336 $overrides = [];
337 foreach ( $props as $prop ) {
338 $overrides[ $prop ] = [
339 'typography_prefix' => $prefix,
340 'responsive' => in_array( $prop, [ 'font-size', 'line-height', 'letter-spacing', 'word-spacing' ], true ),
341 ];
342 }
343
344 return $overrides;
345 }
346 }
347