PluginProbe
Elementor Website Builder – more than just a page builder / trunk
Elementor Website Builder – more than just a page builder vtrunk
4.3.3 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 All 456 releases
elementor / modules / mcp / abilities / appliers / v3 / v3-non-style-allowlist.php

v3-non-style-allowlist.php in Elementor Website Builder – more than just a page builder trunk, at modules/mcp/abilities/appliers/v3/v3-non-style-allowlist.php

67 lines 1.6 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 * Validates V3 element_config settings against the per-widget non-style allowlist.
11 */
12 class V3_Non_Style_Allowlist {
13
14 /**
15 * @param string $widget_type
16 * @param array<string, mixed> $settings
17 * @return array{allowed: array<string, mixed>, rejected: string[], error: \WP_Error|null}
18 */
19 public static function filter( string $widget_type, array $settings ): array {
20 $allowed_keys = V3_Widget_Bridge_Registry::get_non_style_keys( $widget_type );
21 $allowed_lookup = array_fill_keys( $allowed_keys, true );
22
23 $allowed = [];
24 $rejected = [];
25
26 foreach ( $settings as $key => $value ) {
27 if ( ! is_string( $key ) || '' === $key ) {
28 continue;
29 }
30
31 if ( ! isset( $allowed_lookup[ $key ] ) ) {
32 $rejected[] = $key;
33 continue;
34 }
35
36 $allowed[ $key ] = $value;
37 }
38
39 if ( empty( $rejected ) ) {
40 return [
41 'allowed' => $allowed,
42 'rejected' => [],
43 'error' => null,
44 ];
45 }
46
47 $available = empty( $allowed_keys )
48 ? '(none — this V3 widget has no settable behavior keys; use style for visuals)'
49 : implode( ', ', $allowed_keys );
50
51 return [
52 'allowed' => $allowed,
53 'rejected' => $rejected,
54 'error' => new \WP_Error(
55 'elementor_invalid_settings',
56 sprintf(
57 'V3 widget "%s" does not allow settings: %s. Allowed non-style keys: %s. Visual styling must go through the style (CSS) input.',
58 $widget_type,
59 implode( ', ', $rejected ),
60 $available
61 ),
62 [ 'status' => \WP_Http::BAD_REQUEST ]
63 ),
64 ];
65 }
66 }
67