PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.17
UiCore Elements – Free widgets and templates for Elementor v1.3.17
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
← All changes | includes/class-nested-widget-base.php +152 -142 1.2.41.3.17 View file →
@@ -1,5 +1,6 @@
1 1 <?php
2 +
2 3 namespace UiCoreElements;
3 4
4 5 use Elementor\Plugin;
5 6 use Elementor\Settings;
@@ -10,177 +11,186 @@
10 11 *
11 12 * @since 1.0.6
12 13 */
13 14
14 -abstract class UiCoreNestedWidget extends UiCoreWidget {
15 +abstract class UiCoreNestedWidget extends UiCoreWidget
16 +{
15 17
16 18 /**
17 - * Get default children elements structure.
18 - *
19 - * @return array
20 - */
21 - abstract protected function get_default_children_elements();
19 + * Get default children elements structure.
20 + *
21 + * @return array
22 + */
23 + abstract protected function get_default_children_elements();
22 24
23 - /**
24 - * Get repeater title setting key name.
25 - *
26 - * @return string
27 - */
28 - abstract protected function get_default_repeater_title_setting_key();
25 + /**
26 + * Get repeater title setting key name.
27 + *
28 + * @return string
29 + */
30 + abstract protected function get_default_repeater_title_setting_key();
29 31
30 - /**
31 - * Get default children title for the navigator, using `%d` as index in the format.
32 - *
33 - * @note The title in this method is used to set the default title for each created child in nested element.
34 - * for handling the children title for new created widget(s), use `get_default_children_elements()` method,
35 - * eg:
36 - * [
37 - * 'elType' => 'container',
38 - * 'settings' => [
39 - * '_title' => __( 'Tab #1', 'uicore-elements' ),
40 - * ],
41 - * ],
42 - * @return string
43 - */
44 - protected function get_default_children_title() {
32 + /**
33 + * Get default children title for the navigator, using `%d` as index in the format.
34 + *
35 + * @note The title in this method is used to set the default title for each created child in nested element.
36 + * for handling the children title for new created widget(s), use `get_default_children_elements()` method,
37 + * eg:
38 + * [
39 + * 'elType' => 'container',
40 + * 'settings' => [
41 + * '_title' => __( 'Tab #1', 'uicore-elements' ),
42 + * ],
43 + * ],
44 + * @return string
45 + */
46 + protected function get_default_children_title()
47 + {
45 48 /* translators: item number */
46 - return esc_html__( 'Item #%d', 'uicore-elements' );
47 - }
49 + return esc_html__('Item #%d', 'uicore-elements');
50 + }
48 51
49 - /**
50 - * Get default children placeholder selector, Empty string, means will be added at the end view.
51 - *
52 - * @return string
53 - */
54 - protected function get_default_children_placeholder_selector() {
55 - return '';
56 - }
52 + /**
53 + * Get default children placeholder selector, Empty string, means will be added at the end view.
54 + *
55 + * @return string
56 + */
57 + protected function get_default_children_placeholder_selector()
58 + {
59 + return '';
60 + }
57 61
58 - protected function get_default_children_container_placeholder_selector() {
59 - return '';
60 - }
62 + protected function get_default_children_container_placeholder_selector()
63 + {
64 + return '';
65 + }
61 66
62 - /**
63 - * @inheritDoc
64 - *
65 - * To support nesting.
66 - */
67 - protected function _get_default_child_type( array $element_data ) {
68 - return Plugin::$instance->elements_manager->get_element_types( $element_data['elType'] );
69 - }
67 + /**
68 + * @inheritDoc
69 + *
70 + * To support nesting.
71 + */
72 + protected function _get_default_child_type(array $element_data)
73 + {
74 + return Plugin::$instance->elements_manager->get_element_types($element_data['elType']);
75 + }
70 76
71 - /**
72 - * @inheritDoc
73 - *
74 - * Adding new 'defaults' config for handling children elements.
75 - */
76 - protected function get_initial_config() {
77 - return array_merge( parent::get_initial_config(), [
78 - 'defaults' => [
79 - 'elements' => $this->get_default_children_elements(),
80 - 'elements_title' => $this->get_default_children_title(),
81 - 'elements_placeholder_selector' => $this->get_default_children_placeholder_selector(),
82 - 'child_container_placeholder_selector' => $this->get_default_children_container_placeholder_selector(),
83 - 'repeater_title_setting' => $this->get_default_repeater_title_setting_key(),
84 - ],
85 - 'support_nesting' => true,
86 - ] );
87 - }
77 + /**
78 + * @inheritDoc
79 + *
80 + * Adding new 'defaults' config for handling children elements.
81 + */
82 + protected function get_initial_config()
83 + {
84 + return array_merge(parent::get_initial_config(), [
85 + 'defaults' => [
86 + 'elements' => $this->get_default_children_elements(),
87 + 'elements_title' => $this->get_default_children_title(),
88 + 'elements_placeholder_selector' => $this->get_default_children_placeholder_selector(),
89 + 'child_container_placeholder_selector' => $this->get_default_children_container_placeholder_selector(),
90 + 'repeater_title_setting' => $this->get_default_repeater_title_setting_key(),
91 + ],
92 + 'support_nesting' => true,
93 + ]);
94 + }
88 95
89 - /**
90 - * @inheritDoc
91 - *
92 - * Each element including its children elements.
93 - */
94 - public function get_raw_data( $with_html_content = false ) {
95 - $elements = [];
96 - $data = $this->get_data();
96 + /**
97 + * @inheritDoc
98 + *
99 + * Each element including its children elements.
100 + */
101 + public function get_raw_data($with_html_content = false)
102 + {
103 + $elements = [];
104 + $data = $this->get_data();
97 105
98 - $children = $this->get_children();
106 + $children = $this->get_children();
99 107
100 - foreach ( $children as $child ) {
101 - $child_raw_data = $child->get_raw_data( $with_html_content );
108 + foreach ($children as $child) {
109 + $child_raw_data = $child->get_raw_data($with_html_content);
102 110
103 - $elements[] = $child_raw_data;
104 - }
111 + $elements[] = $child_raw_data;
112 + }
105 113
106 - return [
107 - 'id' => $this->get_id(),
108 - 'elType' => $data['elType'],
109 - 'widgetType' => $data['widgetType'],
110 - 'settings' => $data['settings'],
111 - 'elements' => $elements,
112 - ];
113 - }
114 + return [
115 + 'id' => $this->get_id(),
116 + 'elType' => $data['elType'],
117 + 'widgetType' => $data['widgetType'],
118 + 'settings' => $data['settings'],
119 + 'elements' => $elements,
120 + ];
121 + }
114 122
115 - /**
116 - * Print child, helper method to print the child element.
117 - *
118 - * @param int $index
119 - */
120 - public function print_child( $index ) {
121 - $children = $this->get_children();
122 - // \error_log('print_child');
123 - // \error_log( print_r( $children, true ) );
124 - // \error_log( print_r( $index, true ) );
125 - if ( ! empty( $children[ $index ] ) ) {
126 - $children[ $index ]->print_element();
127 - }
128 - }
123 + /**
124 + * Print child, helper method to print the child element.
125 + *
126 + * @param int $index
127 + */
128 + public function print_child($index)
129 + {
130 + $children = $this->get_children();
131 + // \error_log('print_child');
132 + // \error_log( print_r( $children, true ) );
133 + // \error_log( print_r( $index, true ) );
134 + if (! empty($children[$index])) {
135 + $children[$index]->print_element();
136 + }
137 + }
129 138
130 - protected function content_template_single_repeater_item() {}
139 + protected function content_template_single_repeater_item() {}
131 140
132 - public function print_template() {
133 - parent::print_template();
134 - if ( $this->get_initial_config()['support_improved_repeaters'] ?? false ) {
135 - ?>
136 - <script type="text/html" id="tmpl-elementor-<?php echo esc_attr( $this->get_name() ); ?>-content-single">
137 - <?php $this->content_template_single_repeater_item(); ?>
138 - </script>
139 - <?php
140 - }
141 - }
141 + public function print_template()
142 + {
143 + parent::print_template();
144 + if ($this->get_initial_config()['support_improved_repeaters'] ?? false) {
145 +?>
146 + <script type="text/html" id="tmpl-elementor-<?php echo esc_attr($this->get_name()); ?>-content-single">
147 + <?php $this->content_template_single_repeater_item(); ?>
148 + </script>
149 +<?php
150 + }
151 + }
142 152
143 - /**
144 - * Displays fallback content for the nesting feature.
145 - *
146 - * @param string $type The type of fallback content. Can be `controls` or `text`. Default is `text`.
147 - * @return void
148 - * @since 1.0.6
149 - */
150 - public function nesting_fallback(string $type = 'text') {
153 + /**
154 + * Displays fallback content for the nesting feature.
155 + *
156 + * @param string $type The type of fallback content. Can be `controls` or `text`. Default is `text`.
157 + * @return void
158 + * @since 1.0.6
159 + */
160 + public function nesting_fallback(string $type = 'text')
161 + {
151 162
152 163 /* translators: 1: Opening anchor tag, 2: Closing anchor tag for the link to the Elementor settings page. */
153 164 $warning = sprintf(
154 165 /* translators: 1: opening url tags 2: closing url tag */
155 166 __('Please, %1$s click here %2$s and enable the Nested Elements experiment in Elementor settings', 'uicore-elements'),
156 - '<a href="' . esc_attr( Settings::get_settings_tab_url('experiments') ) . '" target="_blank">',
167 + '<a href="' . esc_attr(Settings::get_settings_tab_url('experiments')) . '" target="_blank">',
157 168 '</a>'
158 169 );
159 170
160 - if ( 'text' === $type ) {
171 + if ('text' === $type) {
161 172
162 - echo wp_kses_post($warning);
173 + echo wp_kses_post($warning);
174 + } else if ('controls' === $type) {
175 + $this->start_controls_section(
176 + 'section_tabs',
177 + [
178 + 'label' => esc_html__('Tabs', 'uicore-elements'),
179 + 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
180 + ]
181 + );
163 182
164 - } else if ('controls' === $type ){
165 - $this->start_controls_section(
166 - 'section_tabs',
167 - [
168 - 'label' => esc_html__( 'Tabs', 'uicore-elements' ),
169 - 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
170 - ]
171 - );
183 + $this->add_control(
184 + 'tabs_alert',
185 + [
186 + 'type' => \Elementor\Controls_Manager::ALERT,
187 + 'alert_type' => 'danger',
188 + 'heading' => esc_html__('Feature Disabled.', 'uicore-elements'),
189 + 'content' => wp_kses_post($warning)
190 + ]
191 + );
172 192
173 - $this->add_control(
174 - 'tabs_alert',
175 - [
176 - 'type' => \Elementor\Controls_Manager::ALERT,
177 - 'alert_type' => 'danger',
178 - 'heading' => esc_html__( 'Feature Disabled.', 'uicore-elements' ),
179 - 'content' => wp_kses_post($warning)
180 - ]
181 - );
182 -
183 - $this->end_controls_section();
184 - }
193 + $this->end_controls_section();
194 + }
185 195 }
186 196 }