PluginProbe
Elementor Website Builder – more than just a page builder / 4.3.0-beta3
Elementor Website Builder – more than just a page builder v4.3.0-beta3
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/atomic-widgets/elements/base/has-atomic-base.php +59 -13 4.2.04.3.0-beta3 View file →
@@ -6,8 +6,9 @@
6 6 use Elementor\Modules\AtomicWidgets\Controls\Base\Atomic_Control_Base;
7 7 use Elementor\Modules\AtomicWidgets\Controls\Section;
8 8 use Elementor\Modules\AtomicWidgets\Elements\Atomic_Form\Atomic_Form;
9 9 use Elementor\Modules\AtomicWidgets\Elements\Loader\Frontend_Assets_Loader;
10 +use Elementor\Modules\AtomicWidgets\Logger\Logger;
10 11 use Elementor\Modules\AtomicWidgets\PropsResolver\Render_Props_Resolver;
11 12 use Elementor\Modules\AtomicWidgets\PropTypes\Contracts\Prop_Type;
12 13 use Elementor\Modules\AtomicWidgets\Styles\Style_Schema;
13 14 use Elementor\Modules\AtomicWidgets\Parsers\Props_Parser;
@@ -15,8 +16,9 @@
15 16 use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type;
16 17 use Elementor\Modules\AtomicWidgets\PropTypes\Key_Value_Prop_Type;
17 18 use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type;
18 19 use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type;
20 +use Elementor\Modules\AtomicWidgets\PropTypes\Prop_Duplication_Behavior;
19 21 use Elementor\Utils;
20 22 use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type;
21 23 use Elementor\Modules\AtomicWidgets\Styles\Atomic_Widget_Styles;
22 24
@@ -30,8 +32,18 @@
30 32 trait Has_Atomic_Base {
31 33 use Has_Base_Styles;
32 34 use Has_Base_Settings;
33 35
36 + public static function html_tag_follows_link(): bool {
37 + return true;
38 + }
39 +
40 + public static function get_computed_html_tag( array $settings ): string {
41 + return Html_Tag_Computer::compute( $settings, 'div', [
42 + Html_Tag_Computer::FOLLOW_LINK_OPTION => static::html_tag_follows_link(),
43 + ] );
44 + }
45 +
34 46 public function has_widget_inner_wrapper(): bool {
35 47 return false;
36 48 }
37 49
@@ -88,22 +100,29 @@
88 100
89 101 private function parse_atomic_styles( array $data ): array {
90 102 $styles = $data['styles'] ?? [];
91 103 $style_parser = Style_Parser::make( Style_Schema::get() );
104 + $validated_styles = [];
92 105
93 106 foreach ( $styles as $style_id => $style ) {
94 107 $result = $style_parser->parse( $style );
95 108
96 109 if ( ! $result->is_valid() ) {
97 - throw new \Exception(
98 - esc_html( $this->format_styles_validation_error_message( $style_id, $data, $style, $result->errors()->to_string() ) )
110 + Logger::warning(
111 + $this->format_styles_validation_error_message(
112 + $style_id,
113 + $data,
114 + $style,
115 + $result->errors()->to_string()
116 + )
99 117 );
118 + continue;
100 119 }
101 120
102 - $styles[ $style_id ] = $result->unwrap();
121 + $validated_styles[ $style_id ] = $result->unwrap();
103 122 }
104 123
105 - return $styles;
124 + return $validated_styles;
106 125 }
107 126
108 127 private function format_styles_validation_error_message(
109 128 string $style_id,
@@ -228,18 +247,43 @@
228 247 final public function get_data_for_save() {
229 248 $data = parent::get_data_for_save();
230 249
231 250 $data['version'] = $this->version;
232 - $data['settings'] = $this->parse_atomic_settings( $data['settings'] );
233 - $data['styles'] = $this->parse_atomic_styles( $data );
234 - $data['editor_settings'] = $this->parse_editor_settings( $data['editor_settings'] );
235 251
236 - if ( isset( $data['interactions'] ) && ! empty( $data['interactions'] ) ) {
237 - $data['interactions'] = $this->transform_interactions_for_save( $data['interactions'] );
238 - } else {
239 - $data['interactions'] = [];
252 + $this->set_data_field_for_save(
253 + $data,
254 + 'settings',
255 + $this->parse_atomic_settings( $data['settings'] ?? [] )
256 + );
257 +
258 + $this->set_data_field_for_save(
259 + $data,
260 + 'styles',
261 + $this->parse_atomic_styles( $data )
262 + );
263 +
264 + $this->set_data_field_for_save(
265 + $data,
266 + 'editor_settings',
267 + $this->parse_editor_settings( $data['editor_settings'] ?? [] )
268 + );
269 +
270 + $this->set_data_field_for_save(
271 + $data,
272 + 'interactions',
273 + $this->transform_interactions_for_save( $data['interactions'] ?? [] )
274 + );
275 +
276 + return $data;
277 + }
278 +
279 + private function set_data_field_for_save( array &$data, string $key, $value ): void {
280 + if ( ! empty( $value ) ) {
281 + $data[ $key ] = $value;
282 + return;
240 283 }
241 - return $data;
284 +
285 + unset( $data[ $key ] );
242 286 }
243 287
244 288 private function transform_interactions_for_save( $interactions ) {
245 289 $decoded = $this->decode_interactions_data( $interactions );
@@ -359,9 +403,11 @@
359 403 public static function get_props_schema(): array {
360 404 $schema = static::define_props_schema();
361 405
362 406 if ( ! isset( $schema['_cssid'] ) ) {
363 - $schema['_cssid'] = String_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() );
407 + $schema['_cssid'] = String_Prop_Type::make()
408 + ->meta( Overridable_Prop_Type::ignore() )
409 + ->meta( Prop_Duplication_Behavior::clear() );
364 410 }
365 411
366 412 return apply_filters(
367 413 'elementor/atomic-widgets/props-schema',