← All changes
|
modules/atomic-widgets/elements/base/has-atomic-base.php
+47
-9
4.2.3
→
4.3.2
View file →
| @@ -16,8 +16,9 @@ | ||
| 16 | 16 | use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; |
| 17 | 17 | use Elementor\Modules\AtomicWidgets\PropTypes\Key_Value_Prop_Type; |
| 18 | 18 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 19 | 19 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 20 | +use Elementor\Modules\AtomicWidgets\PropTypes\Prop_Duplication_Behavior; | |
| 20 | 21 | use Elementor\Utils; |
| 21 | 22 | use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type; |
| 22 | 23 | use Elementor\Modules\AtomicWidgets\Styles\Atomic_Widget_Styles; |
| 23 | 24 | |
| @@ -31,8 +32,18 @@ | ||
| 31 | 32 | trait Has_Atomic_Base { |
| 32 | 33 | use Has_Base_Styles; |
| 33 | 34 | use Has_Base_Settings; |
| 34 | 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 | + | |
| 35 | 46 | public function has_widget_inner_wrapper(): bool { |
| 36 | 47 | return false; |
| 37 | 48 | } |
| 38 | 49 | |
| @@ -236,18 +247,43 @@ | ||
| 236 | 247 | final public function get_data_for_save() { |
| 237 | 248 | $data = parent::get_data_for_save(); |
| 238 | 249 | |
| 239 | 250 | $data['version'] = $this->version; |
| 240 | - $data['settings'] = $this->parse_atomic_settings( $data['settings'] ); | |
| 241 | - $data['styles'] = $this->parse_atomic_styles( $data ); | |
| 242 | - $data['editor_settings'] = $this->parse_editor_settings( $data['editor_settings'] ); | |
| 243 | 251 | |
| 244 | - if ( isset( $data['interactions'] ) && ! empty( $data['interactions'] ) ) { | |
| 245 | - $data['interactions'] = $this->transform_interactions_for_save( $data['interactions'] ); | |
| 246 | - } else { | |
| 247 | - $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; | |
| 248 | 283 | } |
| 249 | - return $data; | |
| 284 | + | |
| 285 | + unset( $data[ $key ] ); | |
| 250 | 286 | } |
| 251 | 287 | |
| 252 | 288 | private function transform_interactions_for_save( $interactions ) { |
| 253 | 289 | $decoded = $this->decode_interactions_data( $interactions ); |
| @@ -367,9 +403,11 @@ | ||
| 367 | 403 | public static function get_props_schema(): array { |
| 368 | 404 | $schema = static::define_props_schema(); |
| 369 | 405 | |
| 370 | 406 | if ( ! isset( $schema['_cssid'] ) ) { |
| 371 | - $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() ); | |
| 372 | 410 | } |
| 373 | 411 | |
| 374 | 412 | return apply_filters( |
| 375 | 413 | 'elementor/atomic-widgets/props-schema', |