PluginProbe
Elementor Website Builder – more than just a page builder / 3.9.0
Elementor Website Builder – more than just a page builder v3.9.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 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | modules/kit-elements-defaults/utils/settings-sanitizer.php +14 -76 4.2.13.9.0 View file →
@@ -1,12 +1,11 @@
1 1 <?php
2 2 namespace Elementor\Modules\KitElementsDefaults\Utils;
3 3
4 -use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
5 4 use Elementor\Element_Base;
6 5 use Elementor\Elements_Manager;
7 6 use Elementor\Core\Base\Document;
8 -use Elementor\Utils;
7 +use Elementor\Core\Utils\Collection;
9 8
10 9 if ( ! defined( 'ABSPATH' ) ) {
11 10 exit; // Exit if accessed directly.
12 11 }
@@ -39,9 +38,9 @@
39 38 private $pending_settings = null;
40 39
41 40 /**
42 41 * @param Elements_Manager $elements_manager
43 - * @param array $widget_types
42 + * @param array $widget_types
44 43 */
45 44 public function __construct( Elements_Manager $elements_manager, array $widget_types = [] ) {
46 45 $this->elements_manager = $elements_manager;
47 46 $this->widget_types = $widget_types;
@@ -93,28 +92,21 @@
93 92 if ( ! $this->is_prepared() ) {
94 93 return $this;
95 94 }
96 95
97 - $valid_settings_keys = $this->get_valid_settings_keys(
98 - $this->pending_element->get_controls()
99 - );
96 + $controls = $this->pending_element->get_controls();
100 97
101 - $this->pending_settings = $this->filter_invalid_settings(
102 - $this->pending_settings,
103 - array_merge( $valid_settings_keys, self::SPECIAL_SETTINGS )
104 - );
98 + $this->pending_settings = ( new Collection( $this->pending_settings ) )
99 + ->only( array_merge( array_keys( $controls ), static::SPECIAL_SETTINGS ) )
100 + ->map( function ( $value, $key ) use ( $controls ) {
101 + if ( ! in_array( $key, static::SPECIAL_SETTINGS, true ) ) {
102 + return $value;
103 + }
105 104
106 - foreach ( self::SPECIAL_SETTINGS as $special_setting ) {
107 - if ( ! isset( $this->pending_settings[ $special_setting ] ) ) {
108 - continue;
109 - }
105 + return array_intersect_key( $value, $controls );
106 + } )
107 + ->all();
110 108
111 - $this->pending_settings[ $special_setting ] = $this->filter_invalid_settings(
112 - $this->pending_settings[ $special_setting ],
113 - $valid_settings_keys
114 - );
115 - }
116 -
117 109 return $this;
118 110 }
119 111
120 112 public function kses_deep() {
@@ -121,9 +113,9 @@
121 113 if ( ! $this->is_prepared() ) {
122 114 return $this;
123 115 }
124 116
125 - $this->pending_settings = Utils::kses_post_deep( $this->pending_settings );
117 + $this->pending_settings = wp_kses_post_deep( $this->pending_settings );
126 118
127 119 return $this;
128 120 }
129 121
@@ -161,8 +153,9 @@
161 153 }
162 154
163 155 /**
164 156 * @param string $type
157 + * @param array $settings
165 158 *
166 159 * @return Element_Base|null
167 160 */
168 161 private function create_element( $type ) {
@@ -214,61 +207,6 @@
214 207
215 208 $this->pending_settings = $result['settings'];
216 209
217 210 return $this;
218 - }
219 -
220 - /**
221 - * Get all the available settings of a specific element, including responsive settings.
222 - *
223 - * @param array $controls
224 - *
225 - * @return array
226 - */
227 - private function get_valid_settings_keys( $controls ) {
228 - if ( ! $controls ) {
229 - return [];
230 - }
231 -
232 - $control_keys = array_keys( $controls );
233 -
234 - $optional_responsive_keys = [
235 - Breakpoints_Manager::BREAKPOINT_KEY_MOBILE,
236 - Breakpoints_Manager::BREAKPOINT_KEY_MOBILE_EXTRA,
237 - Breakpoints_Manager::BREAKPOINT_KEY_TABLET,
238 - Breakpoints_Manager::BREAKPOINT_KEY_TABLET_EXTRA,
239 - Breakpoints_Manager::BREAKPOINT_KEY_LAPTOP,
240 - Breakpoints_Manager::BREAKPOINT_KEY_WIDESCREEN,
241 - ];
242 -
243 - $settings = [];
244 -
245 - foreach ( $control_keys as $control_key ) {
246 - // Add the responsive settings.
247 - foreach ( $optional_responsive_keys as $responsive_key ) {
248 - $settings[] = "{$control_key}_{$responsive_key}";
249 - }
250 - // Add the setting itself (not responsive).
251 - $settings[] = $control_key;
252 - }
253 -
254 - return $settings;
255 - }
256 -
257 - /**
258 - * Remove invalid settings.
259 - *
260 - * @param $settings
261 - * @param $valid_settings_keys
262 - *
263 - * @return array
264 - */
265 - private function filter_invalid_settings( $settings, $valid_settings_keys ) {
266 - return array_filter(
267 - $settings,
268 - function ( $setting_key ) use ( $valid_settings_keys ) {
269 - return in_array( $setting_key, $valid_settings_keys, true );
270 - },
271 - ARRAY_FILTER_USE_KEY
272 - );
273 211 }
274 212 }