PluginProbe
Elementor Website Builder – more than just a page builder / 3.35.7
Elementor Website Builder – more than just a page builder v3.35.7
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/atomic-element-base.php +31 -36 4.1.33.35.7 View file →
@@ -2,8 +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\Elements\Loader\Frontend_Assets_Loader;
6 7 use Elementor\Modules\AtomicWidgets\PropDependencies\Manager as Dependency_Manager;
7 8 use Elementor\Modules\AtomicWidgets\PropTypes\Contracts\Prop_Type;
8 9 use Elementor\Modules\AtomicWidgets\PropTypes\Concerns\Has_Meta;
9 10 use Elementor\Plugin;
@@ -20,9 +21,8 @@
20 21 protected $version = '0.0';
21 22 protected $styles = [];
22 23 protected $interactions = [];
23 24 protected $editor_settings = [];
24 - protected $origin_id = null;
25 25
26 26 public static $widget_description = null;
27 27
28 28
@@ -32,14 +32,12 @@
32 32 $this->version = $data['version'] ?? '0.0';
33 33 $this->styles = $data['styles'] ?? [];
34 34 $this->interactions = $this->parse_atomic_interactions( $data['interactions'] ?? [] );
35 35 $this->editor_settings = $data['editor_settings'] ?? [];
36 -
36 + $this->add_script_depends( Frontend_Assets_Loader::ATOMIC_WIDGETS_HANDLER );
37 37 if ( static::$widget_description ) {
38 38 $this->description( static::$widget_description );
39 39 }
40 -
41 - $this->origin_id = $data['origin_id'] ?? null;
42 40 }
43 41
44 42 private function parse_atomic_interactions( $interactions ) {
45 43 if ( empty( $interactions ) ) {
@@ -59,8 +57,28 @@
59 57
60 58 return $interactions;
61 59 }
62 60
61 + private function convert_prop_type_interactions_to_legacy_for_runtime( $interactions ) {
62 + $legacy_items = [];
63 +
64 + foreach ( $interactions['items'] as $item ) {
65 + if ( isset( $item['$$type'] ) && 'interaction-item' === $item['$$type'] ) {
66 + $legacy_item = $this->extract_legacy_interaction_from_prop_type( $item );
67 + if ( $legacy_item ) {
68 + $legacy_items[] = $legacy_item;
69 + }
70 + } else {
71 + $legacy_items[] = $item;
72 + }
73 + }
74 +
75 + return [
76 + 'version' => $interactions['version'] ?? 1,
77 + 'items' => $legacy_items,
78 + ];
79 + }
80 +
63 81 abstract protected function define_atomic_controls(): array;
64 82
65 83 protected function define_atomic_style_states(): array {
66 84 return [];
@@ -65,30 +83,24 @@
65 83 protected function define_atomic_style_states(): array {
66 84 return [];
67 85 }
68 86
69 - protected function define_atomic_pseudo_states(): array {
70 - return [];
71 - }
72 -
73 87 public function get_global_scripts() {
74 88 return [];
75 89 }
76 90
77 - protected function get_initial_config() {
91 + final public function get_initial_config() {
78 92 $config = parent::get_initial_config();
79 93 $props_schema = static::get_props_schema();
80 94
81 - $config['atomic'] = true;
82 95 $config['atomic_controls'] = $this->get_atomic_controls();
83 96 $config['atomic_props_schema'] = $props_schema;
84 97 $config['atomic_style_states'] = $this->define_atomic_style_states();
85 - $config['atomic_pseudo_states'] = $this->define_atomic_pseudo_states();
86 98 $config['dependencies_per_target_mapping'] = Dependency_Manager::get_source_to_dependents( $props_schema );
87 99 $config['base_styles'] = $this->get_base_styles();
88 100 $config['version'] = $this->version;
89 101 $config['show_in_panel'] = $this->should_show_in_panel();
90 - $config['categories'] = $this->define_panel_categories();
102 + $config['categories'] = [ 'v4-elements' ];
91 103 $config['hide_on_search'] = false;
92 104 $config['controls'] = [];
93 105 $config['keywords'] = $this->get_keywords();
94 106 $config['default_children'] = $this->define_default_children();
@@ -95,9 +107,8 @@
95 107 $config['initial_attributes'] = $this->define_initial_attributes();
96 108 $config['include_in_widgets_config'] = true;
97 109 $config['default_html_tag'] = $this->define_default_html_tag();
98 110 $config['meta'] = $this->get_meta();
99 - $config['allowed_child_types'] = $this->define_allowed_child_types();
100 111
101 112 return $config;
102 113 }
103 114
@@ -104,12 +115,8 @@
104 115 protected function should_show_in_panel() {
105 116 return true;
106 117 }
107 118
108 - protected function define_panel_categories(): array {
109 - return [ 'v4-elements' ];
110 - }
111 -
112 119 protected function define_default_children() {
113 120 return [];
114 121 }
115 122
@@ -120,20 +127,17 @@
120 127 protected function define_initial_attributes() {
121 128 return [];
122 129 }
123 130
124 - protected function define_allowed_child_types() {
125 - return [];
126 - }
127 -
128 - protected function get_interaction_id() {
129 - return $this->origin_id ?? $this->get_id();
130 - }
131 -
132 131 protected function add_render_attributes() {
133 132 parent::add_render_attributes();
134 133
135 - $this->add_render_attribute( '_wrapper', 'data-interaction-id', $this->get_interaction_id() );
134 + $interaction_ids = $this->get_interactions_ids();
135 +
136 + if ( ! empty( $interaction_ids ) ) {
137 + $this->add_render_attribute( '_wrapper', 'data-interaction-id', $this->get_id() );
138 + $this->add_render_attribute( '_wrapper', 'data-interactions', json_encode( $interaction_ids ) );
139 + }
136 140 }
137 141
138 142 /**
139 143 * Get Element keywords.
@@ -162,13 +166,9 @@
162 166 protected function get_html_tag(): string {
163 167 $settings = $this->get_atomic_settings();
164 168 $default_html_tag = $this->define_default_html_tag();
165 169
166 - if ( ! empty( $settings['link']['tag'] ) ) {
167 - return $settings['link']['tag'];
168 - }
169 -
170 - return $settings['tag'] ?? $default_html_tag;
170 + return ! empty( $settings['link']['href'] ) ? $settings['link']['tag'] : ( $settings['tag'] ?? $default_html_tag );
171 171 }
172 172
173 173 /**
174 174 * Print safe HTML tag for the element based on the element settings.
@@ -187,13 +187,8 @@
187 187 */
188 188 protected function print_custom_attributes() {
189 189 $settings = $this->get_atomic_settings();
190 190 $attributes = $settings['attributes'] ?? '';
191 -
192 - if ( isset( $settings['link']['attributes'] ) ) {
193 - $attributes .= ' ' . ( $settings['link']['attributes'] ?? '' );
194 - }
195 -
196 191 if ( ! empty( $attributes ) && is_string( $attributes ) ) {
197 192 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
198 193 echo ' ' . $attributes;
199 194 }