PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.1
Elementor Website Builder – more than just a page builder v4.3.1
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 4.0.8 All 454 releases
← All changes | modules/atomic-widgets/props-resolver/render-props-resolver.php +37 -1 4.2.0 → 4.3.1 View file →
@@ -5,8 +5,9 @@
5 5 use Elementor\Modules\AtomicWidgets\DynamicTags\Dynamic_Prop_Type;
6 6 use Elementor\Modules\AtomicWidgets\PropTypes\Base\Array_Prop_Type;
7 7 use Elementor\Modules\AtomicWidgets\PropTypes\Base\Object_Prop_Type;
8 8 use Elementor\Modules\AtomicWidgets\PropTypes\Contracts\Prop_Type;
9 +use Elementor\Modules\AtomicWidgets\PropTypes\Html_Prop_Type;
9 10 use Elementor\Modules\AtomicWidgets\PropTypes\Union_Prop_Type;
10 11 use Elementor\Plugin;
11 12 use Exception;
12 13
@@ -23,8 +24,9 @@
23 24 const TRANSFORM_DEPTH_LIMIT = 3;
24 25
25 26 const CONTEXT_SETTINGS = 'settings';
26 27 const CONTEXT_STYLES = 'styles';
28 + const CONTEXT_PLAIN = 'plain';
27 29
28 30 public static function for_styles(): self {
29 31 return static::instance( self::CONTEXT_STYLES );
30 32 }
@@ -32,8 +34,18 @@
32 34 public static function for_settings(): self {
33 35 return static::instance( self::CONTEXT_SETTINGS );
34 36 }
35 37
38 + public static function for_plain(): self {
39 + return static::instance( self::CONTEXT_PLAIN );
40 + }
41 +
42 + public function resolve_value( $value, Prop_Type $prop_type ) {
43 + $value = $this->get_validated_value( $prop_type, $value );
44 +
45 + return $this->resolve_item( $value, null, $prop_type );
46 + }
47 +
36 48 public function resolve( array $schema, array $props ): array {
37 49 $resolved = [];
38 50
39 51 foreach ( $schema as $key => $prop_type ) {
@@ -67,9 +79,9 @@
67 79 return null;
68 80 }
69 81
70 82 if ( ! $this->is_transformable( $value ) ) {
71 - return $value;
83 + return $this->sanitize_html_prop_value( $value, $prop_type );
72 84 }
73 85
74 86 if ( $depth >= self::TRANSFORM_DEPTH_LIMIT ) {
75 87 return null;
@@ -98,6 +110,30 @@
98 110 $tag_name = $prop_value['value']['name'] ?? null;
99 111 $tag = Plugin::$instance->dynamic_tags->get_tag_info( $tag_name );
100 112
101 113 return ! $tag ? $default : $prop_value;
114 + }
115 +
116 + private function sanitize_html_prop_value( $value, Prop_Type $prop_type ) {
117 + if ( ! is_string( $value ) || ! $this->requires_html_sanitization( $prop_type ) ) {
118 + return $value;
119 + }
120 +
121 + return Html_Prop_Type::sanitize_allowed_html( $value );
122 + }
123 +
124 + private function requires_html_sanitization( Prop_Type $prop_type ): bool {
125 + if ( $prop_type instanceof Html_Prop_Type ) {
126 + return true;
127 + }
128 +
129 + if ( $prop_type instanceof Union_Prop_Type ) {
130 + foreach ( $prop_type->get_prop_types() as $variant ) {
131 + if ( $this->requires_html_sanitization( $variant ) ) {
132 + return true;
133 + }
134 + }
135 + }
136 +
137 + return false;
102 138 }
103 139 }