← All changes
|
modules/atomic-widgets/props-resolver/render-props-resolver.php
+1
-37
4.3.0-beta3
→
3.35.8
View file →
| @@ -5,9 +5,8 @@ | ||
| 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; | |
| 10 | 9 | use Elementor\Modules\AtomicWidgets\PropTypes\Union_Prop_Type; |
| 11 | 10 | use Elementor\Plugin; |
| 12 | 11 | use Exception; |
| 13 | 12 | |
| @@ -24,9 +23,8 @@ | ||
| 24 | 23 | const TRANSFORM_DEPTH_LIMIT = 3; |
| 25 | 24 | |
| 26 | 25 | const CONTEXT_SETTINGS = 'settings'; |
| 27 | 26 | const CONTEXT_STYLES = 'styles'; |
| 28 | - const CONTEXT_PLAIN = 'plain'; | |
| 29 | 27 | |
| 30 | 28 | public static function for_styles(): self { |
| 31 | 29 | return static::instance( self::CONTEXT_STYLES ); |
| 32 | 30 | } |
| @@ -34,18 +32,8 @@ | ||
| 34 | 32 | public static function for_settings(): self { |
| 35 | 33 | return static::instance( self::CONTEXT_SETTINGS ); |
| 36 | 34 | } |
| 37 | 35 | |
| 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 | - | |
| 48 | 36 | public function resolve( array $schema, array $props ): array { |
| 49 | 37 | $resolved = []; |
| 50 | 38 | |
| 51 | 39 | foreach ( $schema as $key => $prop_type ) { |
| @@ -79,9 +67,9 @@ | ||
| 79 | 67 | return null; |
| 80 | 68 | } |
| 81 | 69 | |
| 82 | 70 | if ( ! $this->is_transformable( $value ) ) { |
| 83 | - return $this->sanitize_html_prop_value( $value, $prop_type ); | |
| 71 | + return $value; | |
| 84 | 72 | } |
| 85 | 73 | |
| 86 | 74 | if ( $depth >= self::TRANSFORM_DEPTH_LIMIT ) { |
| 87 | 75 | return null; |
| @@ -110,30 +98,6 @@ | ||
| 110 | 98 | $tag_name = $prop_value['value']['name'] ?? null; |
| 111 | 99 | $tag = Plugin::$instance->dynamic_tags->get_tag_info( $tag_name ); |
| 112 | 100 | |
| 113 | 101 | 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; | |
| 138 | 102 | } |
| 139 | 103 | } |