← All changes
|
modules/atomic-widgets/elements/base/atomic-element-base.php
+13
-50
4.3.0-beta3
→
4.0.9
View file →
| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\AtomicWidgets\Elements\Base; |
| 4 | 4 | |
| 5 | 5 | use Elementor\Element_Base; |
| 6 | -use Elementor\Modules\AtomicWidgets\ChildrenDependencies\Child_Dependency; | |
| 6 | +use Elementor\Modules\AtomicWidgets\Elements\Loader\Frontend_Assets_Loader; | |
| 7 | 7 | use Elementor\Modules\AtomicWidgets\PropDependencies\Manager as Dependency_Manager; |
| 8 | 8 | use Elementor\Modules\AtomicWidgets\PropTypes\Contracts\Prop_Type; |
| 9 | 9 | use Elementor\Modules\AtomicWidgets\PropTypes\Concerns\Has_Meta; |
| 10 | 10 | use Elementor\Plugin; |
| @@ -17,20 +17,8 @@ | ||
| 17 | 17 | abstract class Atomic_Element_Base extends Element_Base { |
| 18 | 18 | use Has_Atomic_Base; |
| 19 | 19 | use Has_Meta; |
| 20 | 20 | |
| 21 | - /** | |
| 22 | - * Maps atomic element type → the minor version when the "New" badge expires. | |
| 23 | - * Format: 'element-type' => 'major.minor' (patch is ignored during comparison). | |
| 24 | - * | |
| 25 | - * @var array<string, string> | |
| 26 | - */ | |
| 27 | - private const NEW_ATOMIC_ELEMENTS = [ | |
| 28 | - 'e-background-video' => '4.3', | |
| 29 | - 'e-accordion' => '4.3', | |
| 30 | - 'e-list' => '4.3', | |
| 31 | - ]; | |
| 32 | - | |
| 33 | 21 | protected $version = '0.0'; |
| 34 | 22 | protected $styles = []; |
| 35 | 23 | protected $interactions = []; |
| 36 | 24 | protected $editor_settings = []; |
| @@ -45,13 +33,12 @@ | ||
| 45 | 33 | $this->version = $data['version'] ?? '0.0'; |
| 46 | 34 | $this->styles = $data['styles'] ?? []; |
| 47 | 35 | $this->interactions = $this->parse_atomic_interactions( $data['interactions'] ?? [] ); |
| 48 | 36 | $this->editor_settings = $data['editor_settings'] ?? []; |
| 49 | - | |
| 37 | + $this->add_script_depends( Frontend_Assets_Loader::ATOMIC_WIDGETS_HANDLER ); | |
| 50 | 38 | if ( static::$widget_description ) { |
| 51 | 39 | $this->description( static::$widget_description ); |
| 52 | 40 | } |
| 53 | - | |
| 54 | 41 | $this->origin_id = $data['origin_id'] ?? null; |
| 55 | 42 | } |
| 56 | 43 | |
| 57 | 44 | private function parse_atomic_interactions( $interactions ) { |
| @@ -97,9 +84,8 @@ | ||
| 97 | 84 | $config['atomic_style_states'] = $this->define_atomic_style_states(); |
| 98 | 85 | $config['atomic_pseudo_states'] = $this->define_atomic_pseudo_states(); |
| 99 | 86 | $config['dependencies_per_target_mapping'] = Dependency_Manager::get_source_to_dependents( $props_schema ); |
| 100 | 87 | $config['base_styles'] = $this->get_base_styles(); |
| 101 | - $config['base_settings'] = $this->get_base_settings(); | |
| 102 | 88 | $config['version'] = $this->version; |
| 103 | 89 | $config['show_in_panel'] = $this->should_show_in_panel(); |
| 104 | 90 | $config['categories'] = $this->define_panel_categories(); |
| 105 | 91 | $config['hide_on_search'] = false; |
| @@ -105,16 +91,13 @@ | ||
| 105 | 91 | $config['hide_on_search'] = false; |
| 106 | 92 | $config['controls'] = []; |
| 107 | 93 | $config['keywords'] = $this->get_keywords(); |
| 108 | 94 | $config['default_children'] = $this->define_default_children(); |
| 109 | - $config['children_dependencies'] = $this->get_children_dependencies_config(); | |
| 110 | 95 | $config['initial_attributes'] = $this->define_initial_attributes(); |
| 111 | 96 | $config['include_in_widgets_config'] = true; |
| 112 | - $config['default_html_tag'] = static::get_computed_html_tag( [] ); | |
| 113 | - $config['html_tag_follows_link'] = static::html_tag_follows_link(); | |
| 97 | + $config['default_html_tag'] = $this->define_default_html_tag(); | |
| 114 | 98 | $config['meta'] = $this->get_meta(); |
| 115 | 99 | $config['allowed_child_types'] = $this->define_allowed_child_types(); |
| 116 | - $config['new_until_version'] = self::NEW_ATOMIC_ELEMENTS[ $this->get_name() ] ?? ''; | |
| 117 | 100 | |
| 118 | 101 | return $config; |
| 119 | 102 | } |
| 120 | 103 | |
| @@ -129,39 +112,12 @@ | ||
| 129 | 112 | protected function define_default_children() { |
| 130 | 113 | return []; |
| 131 | 114 | } |
| 132 | 115 | |
| 133 | - /** | |
| 134 | - * Declare settings→children reconcile rules for this element. | |
| 135 | - * | |
| 136 | - * Each rule ties a `Dependency_Manager` condition on this element's | |
| 137 | - * settings to the presence of a specific child element type. The generic | |
| 138 | - * client-side reconciler (`@elementor/editor-elements/children-dependencies`) | |
| 139 | - * attaches / detaches the child at the model layer as the condition flips, | |
| 140 | - * without per-widget v1 hooks. | |
| 141 | - * | |
| 142 | - * @return Child_Dependency[] | |
| 143 | - */ | |
| 144 | - protected function define_children_dependencies(): array { | |
| 145 | - return []; | |
| 116 | + protected function define_default_html_tag() { | |
| 117 | + return 'div'; | |
| 146 | 118 | } |
| 147 | 119 | |
| 148 | - private function get_children_dependencies_config(): array { | |
| 149 | - $config = []; | |
| 150 | - | |
| 151 | - foreach ( $this->define_children_dependencies() as $dependency ) { | |
| 152 | - if ( ! $dependency instanceof Child_Dependency ) { | |
| 153 | - throw new \InvalidArgumentException( | |
| 154 | - esc_html( static::class . '::define_children_dependencies() must return Child_Dependency instances.' ) | |
| 155 | - ); | |
| 156 | - } | |
| 157 | - | |
| 158 | - $config[] = $dependency->build(); | |
| 159 | - } | |
| 160 | - | |
| 161 | - return $config; | |
| 162 | - } | |
| 163 | - | |
| 164 | 120 | protected function define_initial_attributes() { |
| 165 | 121 | return []; |
| 166 | 122 | } |
| 167 | 123 | |
| @@ -203,9 +159,16 @@ | ||
| 203 | 159 | * |
| 204 | 160 | * @return string |
| 205 | 161 | */ |
| 206 | 162 | protected function get_html_tag(): string { |
| 207 | - return static::get_computed_html_tag( $this->get_atomic_settings() ); | |
| 163 | + $settings = $this->get_atomic_settings(); | |
| 164 | + $default_html_tag = $this->define_default_html_tag(); | |
| 165 | + | |
| 166 | + if ( ! empty( $settings['link']['tag'] ) ) { | |
| 167 | + return $settings['link']['tag']; | |
| 168 | + } | |
| 169 | + | |
| 170 | + return $settings['tag'] ?? $default_html_tag; | |
| 208 | 171 | } |
| 209 | 172 | |
| 210 | 173 | /** |
| 211 | 174 | * Print safe HTML tag for the element based on the element settings. |