PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.18
UiCore Elements – Free widgets and templates for Elementor v1.3.18
1.3.18 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 All 42 releases
← All changes | includes/widgets/newsletter.php +470 -514 1.2.3 → 1.3.18 View file →
@@ -1,10 +1,14 @@
1 1 <?php
2 +
2 3 namespace UiCoreElements;
3 4
4 5
5 -use UiCoreElements\Utils\Contact_Form_Service;
6 +use UiCoreElements\Utils\Contact_Form_Service as Form_Service;
7 +use UiCoreElements\Utils\Newsletter_Services;
6 8 use UiCoreElements\Utils\Form_Component;
9 +
10 +
7 11 use Elementor\Controls_Manager;
8 12 use Elementor\Icons_Manager;
9 13 use Elementor\Utils;
10 14
@@ -17,30 +21,35 @@
17 21 * @author Lucas Marini Falbo <[email protected]>
18 22 * @since 1.0.7
19 23 */
20 24
21 -class Newsletter extends UiCoreWidget {
25 +class Newsletter extends UiCoreWidget
26 +{
22 27
23 28 use Form_Component;
24 29
25 - public function get_name() {
26 - return 'uicore-newsletter';
27 - }
30 + public function get_name()
31 + {
32 + return 'uicore-newsletter';
33 + }
28 34
29 - public function get_title() {
30 - return __( 'Newsletter', 'uicore-elements' );
31 - }
35 + public function get_title()
36 + {
37 + return __('Newsletter', 'uicore-elements');
38 + }
32 39
33 - public function get_icon() {
34 - return 'eicon-form-horizontal ui-e-widget';
35 - }
40 + public function get_icon()
41 + {
42 + return 'eicon-form-horizontal ui-e-widget';
43 + }
36 44 public function get_categories()
37 45 {
38 46 return ['uicore'];
39 47 }
40 - public function get_keywords() {
41 - return [ 'form', 'forms', 'newsletter', 'news', 'subscribe', 'subscription', 'mailchimp' ];
42 - }
48 + public function get_keywords()
49 + {
50 + return ['form', 'forms', 'newsletter', 'news', 'subscribe', 'subscription', 'mailchimp'];
51 + }
43 52 public function get_styles()
44 53 {
45 54 return ['newsletter'];
46 55 }
@@ -55,16 +64,17 @@
55 64 'custom_condition' => $this->check_recaptcha_version('v3')
56 65 ]
57 66 ];
58 67 }
59 - public function has_widget_inner_wrapper(): bool {
60 - // TODO: remove after 3.30, when the full deprecation of widget innet wrapper is ready
61 - return ! \Elementor\Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
62 - }
68 + public function has_widget_inner_wrapper(): bool
69 + {
70 + // TODO: remove after Optmized Markup experiment is merged to the core
71 + return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup');
72 + }
63 73 function check_recaptcha_version($version)
64 74 {
65 75
66 - if( $this->is_edit_mode() ){
76 + if ($this->is_edit_mode()) {
67 77 return true;
68 78 }
69 79
70 80 return $version === $this->get_settings_for_display('recaptcha_version') ? true : false;
@@ -69,84 +79,86 @@
69 79
70 80 return $version === $this->get_settings_for_display('recaptcha_version') ? true : false;
71 81 }
72 82
73 - function form_fields_render_attributes( $i, $instance, $item ) {
74 - $this->add_render_attribute(
75 - [
76 - 'field-group' . $i => [
77 - 'class' => [
78 - 'ui-e-field-type-text',
79 - 'ui-e-field-group',
80 - 'elementor-column',
81 - ],
82 - ],
83 + function form_fields_render_attributes($i, $instance, $item)
84 + {
85 + $this->add_render_attribute(
86 + [
87 + 'field-group' . $i => [
88 + 'class' => [
89 + 'ui-e-field-type-text',
90 + 'ui-e-field-group',
91 + 'elementor-column',
92 + ],
93 + ],
83 94 'honeypot' => [
84 95 'class' => [
85 - 'ui-e-field-type-address',
86 - 'ui-e-field-group',
87 - 'elementor-column',
88 - ],
96 + 'ui-e-field-type-address',
97 + 'ui-e-field-group',
98 + 'elementor-column',
99 + ],
89 100 ],
90 101 'recaptcha' => [
91 102 'class' => [
92 - 'ui-e-field-type-recaptcha',
93 - 'ui-e-field-group',
94 - 'elementor-column',
103 + 'ui-e-field-type-recaptcha',
104 + 'ui-e-field-group',
105 + 'elementor-column',
95 106 'elementor-col-100'
96 - ],
107 + ],
97 108 ],
98 109 'recaptcha_v3' => [
99 110 'class' => [
100 - 'ui-e-field-type-recaptcha_v3',
101 - 'ui-e-field-group',
102 - 'elementor-column',
111 + 'ui-e-field-type-recaptcha_v3',
112 + 'ui-e-field-group',
113 + 'elementor-column',
103 114 'elementor-col-100'
104 - ],
115 + ],
105 116 ],
106 - 'input' . $i => [
107 - 'type' => 'text',
117 + 'input' . $i => [
118 + 'type' => $item === 'email' ? 'email' : 'text',
108 119 'size' => '1',
109 - 'name' => 'form_fields[' . $item . ']',
110 - 'id' => 'form-fields-' . $item,
111 - 'class' => [
112 - 'ui-e-field',
113 - empty( $instance[$item.'_css'] ) ? '' : esc_attr( $instance[$item.'_css'] ),
114 - ],
115 - ],
116 - 'label' . $i => [
117 - 'for' => 'form-field-' . $item,
118 - 'class' => 'ui-e-label',
119 - ],
120 - ]
121 - );
120 + 'name' => 'form_fields[' . $item . ']',
121 + 'id' => 'form-fields-' . $item,
122 + 'class' => [
123 + 'ui-e-field',
124 + empty($instance[$item . '_css']) ? '' : esc_attr($instance[$item . '_css']),
125 + ],
126 + ],
127 + 'label' . $i => [
128 + 'for' => 'form-field-' . $item,
129 + 'class' => 'ui-e-label',
130 + ],
131 + ]
132 + );
122 133
123 - if ( empty( $instance[$item . '_width'] ) ) {
124 - $item['width'] = '100';
125 - }
134 + if (empty($instance[$item . '_width'])) {
135 + $item['width'] = '100';
136 + }
126 137
127 - $this->add_render_attribute( 'field-group' . $i, 'class', 'elementor-col-' . $instance[$item . '_width'] );
138 + $this->add_render_attribute('field-group' . $i, 'class', 'elementor-col-' . $instance[$item . '_width']);
128 139
129 - if ( ! empty( $instance[$item . '_width_tablet'] ) ) {
130 - $this->add_render_attribute( 'field-group' . $i, 'class', 'elementor-md-' . $instance[$item . '_width_tablet'] );
131 - }
140 + if (! empty($instance[$item . '_width_tablet'])) {
141 + $this->add_render_attribute('field-group' . $i, 'class', 'elementor-md-' . $instance[$item . '_width_tablet']);
142 + }
132 143
133 - if ( ! empty( $instance[$item . '_width_mobile'] ) ) {
134 - $this->add_render_attribute( 'field-group' . $i, 'class', 'elementor-sm-' . $instance[$item . '_width_mobile'] );
135 - }
144 + if (! empty($instance[$item . '_width_mobile'])) {
145 + $this->add_render_attribute('field-group' . $i, 'class', 'elementor-sm-' . $instance[$item . '_width_mobile']);
146 + }
136 147
137 - // Allow zero as placeholder.
138 - if ( ! Utils::is_empty( $instance[$item . '_placeholder'] ) ) {
139 - $this->add_render_attribute( 'input' . $i, 'placeholder', $instance[$item . '_placeholder'] );
140 - }
148 + // Allow zero as placeholder.
149 + if (! Utils::is_empty($instance[$item . '_placeholder'])) {
150 + $this->add_render_attribute('input' . $i, 'placeholder', $instance[$item . '_placeholder']);
151 + }
141 152
142 - if ( ! $instance['show_labels'] ) {
143 - $this->add_render_attribute( 'label' . $i, 'class', 'elementor-screen-only' );
144 - }
153 + if (! $instance['show_labels']) {
154 + $this->add_render_attribute('label' . $i, 'class', 'elementor-screen-only');
155 + }
145 156
146 - if ( ! empty( $instance[$item . '_required'] ) ) {
147 - if ( ! empty( $instance['mark_required'] ) ) {
148 - $this->add_render_attribute( 'field-group' . $i,
157 + if (! empty($instance[$item . '_required'])) {
158 + if (! empty($instance['mark_required'])) {
159 + $this->add_render_attribute(
160 + 'field-group' . $i,
149 161 [
150 162 'class' => 'ui-e-required',
151 163 'required' => 'required',
152 164 ]
@@ -151,413 +163,357 @@
151 163 'required' => 'required',
152 164 ]
153 165 );
154 166 }
155 - }
156 - }
167 + }
168 + }
157 169
158 - protected function register_controls() {
170 + protected function register_controls()
171 + {
159 172
160 173 $this->start_controls_section(
161 174 'section_form_settings',
162 175 [
163 - 'label' => esc_html__( 'Form Settings', 'uicore-elements' ),
176 + 'label' => esc_html__('Form Settings', 'uicore-elements'),
164 177 ]
165 178 );
166 179
167 - $this->add_control(
168 - 'form_name',
169 - [
170 - 'label' => esc_html__( 'Form Name', 'uicore-elements' ),
171 - 'type' => Controls_Manager::TEXT,
172 - 'default' => esc_html__( 'New Form', 'uicore-elements' ),
173 - 'placeholder' => esc_html__( 'Form Name', 'uicore-elements' ),
174 - ]
175 - );
176 - $this->add_control(
177 - 'show_labels',
178 - [
179 - 'label' => esc_html__( 'Label', 'uicore-elements' ),
180 - 'type' => Controls_Manager::SWITCHER,
181 - 'label_on' => esc_html__( 'Show', 'uicore-elements' ),
182 - 'label_off' => esc_html__( 'Hide', 'uicore-elements' ),
183 - 'return_value' => 'true',
184 - 'default' => 'true',
185 - ]
186 - );
187 - $this->add_control(
188 - 'mark_required',
189 - [
190 - 'label' => esc_html__( 'Required Mark', 'uicore-elements' ),
191 - 'type' => Controls_Manager::SWITCHER,
192 - 'label_on' => esc_html__( 'Show', 'uicore-elements' ),
193 - 'label_off' => esc_html__( 'Hide', 'uicore-elements' ),
194 - 'default' => '',
195 - 'render_type' => 'template',
196 - 'condition' => [
197 - 'show_labels!' => '',
198 - ],
199 - ]
200 - );
180 + $this->add_control(
181 + 'form_name',
182 + [
183 + 'label' => esc_html__('Form Name', 'uicore-elements'),
184 + 'type' => Controls_Manager::TEXT,
185 + 'default' => esc_html__('New Form', 'uicore-elements'),
186 + 'placeholder' => esc_html__('Form Name', 'uicore-elements'),
187 + ]
188 + );
189 + $this->add_control(
190 + 'show_labels',
191 + [
192 + 'label' => esc_html__('Label', 'uicore-elements'),
193 + 'type' => Controls_Manager::SWITCHER,
194 + 'label_on' => esc_html__('Show', 'uicore-elements'),
195 + 'label_off' => esc_html__('Hide', 'uicore-elements'),
196 + 'return_value' => 'true',
197 + 'default' => 'true',
198 + ]
199 + );
200 + $this->add_control(
201 + 'mark_required',
202 + [
203 + 'label' => esc_html__('Required Mark', 'uicore-elements'),
204 + 'type' => Controls_Manager::SWITCHER,
205 + 'label_on' => esc_html__('Show', 'uicore-elements'),
206 + 'label_off' => esc_html__('Hide', 'uicore-elements'),
207 + 'default' => '',
208 + 'render_type' => 'template',
209 + 'condition' => [
210 + 'show_labels!' => '',
211 + ],
212 + ]
213 + );
201 214 $this->end_controls_section();
202 215
203 216 $this->start_controls_section(
204 217 'section_form_fields',
205 218 [
206 - 'label' => esc_html__( 'Fields', 'uicore-elements' ),
219 + 'label' => esc_html__('Fields', 'uicore-elements'),
207 220 ]
208 221 );
209 222
210 - $this->add_control(
211 - 'add_name',
212 - [
213 - 'label' => esc_html__( 'Name', 'uicore-elements' ),
214 - 'type' => Controls_Manager::SWITCHER,
215 - 'return_value' => 'true',
216 - 'default' => 'true',
217 - ]
218 - );
219 - $this->add_control(
220 - 'add_recaptcha',
221 - [
222 - 'label' => esc_html__( 'Recaptcha', 'uicore-elements' ),
223 - 'type' => Controls_Manager::SWITCHER,
224 - 'return_value' => 'true',
225 - ]
226 - );
227 - $this->add_control(
228 - 'add_honeypot',
229 - [
230 - 'label' => esc_html__( 'Honeypot', 'uicore-elements' ),
231 - 'type' => Controls_Manager::SWITCHER,
232 - 'description' => esc_html__('Adds a hidden field to trap and identify bots by capturing automated form submissions.', 'uicore-elements'),
233 - 'return_value' => 'true',
234 - 'default' => 'true',
235 - ]
236 - );
223 + $this->add_control(
224 + 'add_name',
225 + [
226 + 'label' => esc_html__('Name', 'uicore-elements'),
227 + 'type' => Controls_Manager::SWITCHER,
228 + 'return_value' => 'true',
229 + 'default' => 'true',
230 + ]
231 + );
232 + $this->add_control(
233 + 'add_recaptcha',
234 + [
235 + 'label' => esc_html__('Recaptcha', 'uicore-elements'),
236 + 'type' => Controls_Manager::SWITCHER,
237 + 'return_value' => 'true',
238 + ]
239 + );
240 + $this->add_control(
241 + 'add_honeypot',
242 + [
243 + 'label' => esc_html__('Honeypot', 'uicore-elements'),
244 + 'type' => Controls_Manager::SWITCHER,
245 + 'description' => esc_html__('Adds a hidden field to trap and identify bots by capturing automated form submissions.', 'uicore-elements'),
246 + 'return_value' => 'true',
247 + 'default' => 'true',
248 + ]
249 + );
237 250
238 - $this->start_controls_tabs( 'form_fields_tabs' );
251 + $this->start_controls_tabs('form_fields_tabs');
239 252
240 - $this->start_controls_tab(
241 - 'email_tab',
242 - [
243 - 'label' => esc_html__( 'E-mail', 'uicore-elements' ),
244 - ]
245 - );
253 + $this->start_controls_tab(
254 + 'email_tab',
255 + [
256 + 'label' => esc_html__('E-mail', 'uicore-elements'),
257 + ]
258 + );
246 259
247 - $this->add_control(
248 - 'email_label',
249 - [
250 - 'label' => esc_html__( 'Label', 'uicore-elements' ),
251 - 'type' => Controls_Manager::TEXT,
252 - 'default' => '',
253 - 'dynamic' => [
254 - 'active' => true,
255 - ],
256 - ]
257 - );
258 - $this->add_control(
259 - 'email_placeholder',
260 - [
261 - 'label' => esc_html__( 'Placeholder', 'uicore-elements' ),
262 - 'type' => Controls_Manager::TEXT,
263 - 'default' => esc_html__('Your e-mail', 'uicore-elements'),
264 - 'dynamic' => [
265 - 'active' => true,
266 - ],
267 - ]
268 - );
269 - $this->add_control(
270 - 'email_required',
271 - [
272 - 'label' => esc_html__( 'Required', 'uicore-elements' ),
273 - 'type' => Controls_Manager::SWITCHER,
274 - 'return_value' => 'true',
275 - 'default' => '',
276 - ]
277 - );
278 - $this->add_responsive_control(
279 - 'email_width',
280 - [
281 - 'label' => esc_html__( 'Column Width', 'uicore-elements' ),
282 - 'type' => Controls_Manager::SELECT,
283 - 'options' => $this->TRAIT_get_width_values(),
284 - 'default' => '40',
285 - ]
286 - );
287 - $this->add_control(
288 - 'email_css',
289 - [
290 - 'label' => esc_html__( 'Custom Class', 'uicore-elements' ),
291 - 'type' => Controls_Manager::TEXT,
292 - 'default' => '',
293 - 'ai' => [
294 - 'active' => false,
295 - ],
296 - 'separator' => 'before',
297 - 'placeholder' => esc_html__( 'e.g: my-class', 'uicore-elements' ),
298 - ]
299 - );
300 - $this->add_control(
301 - 'email_shortcode',
302 - [
303 - 'label' => esc_html__( 'Shortcode', 'uicore-elements' ),
304 - 'type' => Controls_Manager::RAW_HTML,
305 - 'classes' => 'forms-field-shortcode',
306 - 'raw' => '<input class="elementor-form-field-shortcode" value=\'[field id="email"]\' readonly />',
307 - ]
308 - );
260 + $this->add_control(
261 + 'email_label',
262 + [
263 + 'label' => esc_html__('Label', 'uicore-elements'),
264 + 'type' => Controls_Manager::TEXT,
265 + 'default' => '',
266 + 'dynamic' => [
267 + 'active' => true,
268 + ],
269 + ]
270 + );
271 + $this->add_control(
272 + 'email_placeholder',
273 + [
274 + 'label' => esc_html__('Placeholder', 'uicore-elements'),
275 + 'type' => Controls_Manager::TEXT,
276 + 'default' => esc_html__('Your e-mail', 'uicore-elements'),
277 + 'dynamic' => [
278 + 'active' => true,
279 + ],
280 + ]
281 + );
282 + $this->add_control(
283 + 'email_required',
284 + [
285 + 'label' => esc_html__('Required', 'uicore-elements'),
286 + 'type' => Controls_Manager::SWITCHER,
287 + 'return_value' => 'true',
288 + 'default' => '',
289 + ]
290 + );
291 + $this->add_responsive_control(
292 + 'email_width',
293 + [
294 + 'label' => esc_html__('Column Width', 'uicore-elements'),
295 + 'type' => Controls_Manager::SELECT,
296 + 'options' => $this->TRAIT_get_width_values(),
297 + 'default' => '40',
298 + ]
299 + );
300 + $this->add_control(
301 + 'email_css',
302 + [
303 + 'label' => esc_html__('Custom Class', 'uicore-elements'),
304 + 'type' => Controls_Manager::TEXT,
305 + 'default' => '',
306 + 'ai' => [
307 + 'active' => false,
308 + ],
309 + 'separator' => 'before',
310 + 'placeholder' => esc_html__('e.g: my-class', 'uicore-elements'),
311 + ]
312 + );
313 + $this->add_control(
314 + 'email_shortcode',
315 + [
316 + 'label' => esc_html__('Shortcode', 'uicore-elements'),
317 + 'type' => Controls_Manager::RAW_HTML,
318 + 'classes' => 'forms-field-shortcode',
319 + 'raw' => '<input class="elementor-form-field-shortcode" value=\'[field id="email"]\' readonly />',
320 + ]
321 + );
309 322
310 - $this->end_controls_tab();
323 + $this->end_controls_tab();
311 324
312 - $this->start_controls_tab(
313 - 'name_tab',
314 - [
315 - 'label' => esc_html__( 'Name', 'uicore-elements' ),
316 - 'condition' => [
317 - 'add_name' => 'true',
318 - ],
319 - ]
320 - );
325 + $this->start_controls_tab(
326 + 'name_tab',
327 + [
328 + 'label' => esc_html__('Name', 'uicore-elements'),
329 + 'condition' => [
330 + 'add_name' => 'true',
331 + ],
332 + ]
333 + );
321 334
322 - $this->add_control(
323 - 'name_label',
324 - [
325 - 'label' => esc_html__( 'Label', 'uicore-elements' ),
326 - 'type' => Controls_Manager::TEXT,
327 - 'default' => '',
328 - 'dynamic' => [
329 - 'active' => true,
330 - ],
331 - ]
332 - );
333 - $this->add_control(
334 - 'name_placeholder',
335 - [
336 - 'label' => esc_html__( 'Placeholder', 'uicore-elements' ),
337 - 'type' => Controls_Manager::TEXT,
338 - 'default' => esc_html__('Your name', 'uicore-elements'),
339 - 'dynamic' => [
340 - 'active' => true,
341 - ],
342 - ]
343 - );
344 - $this->add_control(
345 - 'name_required',
346 - [
347 - 'label' => esc_html__( 'Required', 'uicore-elements' ),
348 - 'type' => Controls_Manager::SWITCHER,
349 - 'return_value' => 'true',
350 - 'default' => '',
351 - ]
352 - );
353 - $this->add_responsive_control(
354 - 'name_width',
355 - [
356 - 'label' => esc_html__( 'Column Width', 'uicore-elements' ),
357 - 'type' => Controls_Manager::SELECT,
358 - 'options' => $this->TRAIT_get_width_values(),
359 - 'default' => '40',
360 - ]
361 - );
362 - $this->add_control(
363 - 'name_css',
364 - [
365 - 'label' => esc_html__( 'Custom Class', 'uicore-elements' ),
366 - 'type' => Controls_Manager::TEXT,
367 - 'default' => '',
368 - 'ai' => [
369 - 'active' => false,
370 - ],
371 - 'separator' => 'before',
372 - 'placeholder' => esc_html__( 'e.g: my-class', 'uicore-elements' ),
373 - ]
374 - );
375 - $this->add_control(
376 - 'name_shortcode',
377 - [
378 - 'label' => esc_html__( 'Shortcode', 'uicore-elements' ),
379 - 'type' => Controls_Manager::RAW_HTML,
380 - 'classes' => 'forms-field-shortcode',
381 - 'raw' => '<input class="elementor-form-field-shortcode" value=\'[field id="name"]\' readonly />',
382 - ]
383 - );
384 -
385 - $this->end_controls_tab();
386 -
387 - $this->start_controls_tab(
388 - 'recaptcha_tab',
389 - [
390 - 'label' => esc_html__( 'Recaptcha', 'uicore-elements' ),
391 - 'condition' => [
392 - 'add_recaptcha' => 'true',
393 - ],
394 - ]
395 - );
396 -
397 - $this->add_control(
398 - 'recaptcha_version',
399 - [
400 - 'label' => esc_html__( 'Recaptcha Version', 'uicore-elements' ),
401 - 'type' => Controls_Manager::SELECT,
402 - 'options' => [
403 - 'v2' => 'V2',
404 - 'v3' => 'V3',
405 - ],
406 - 'default' => 'v2',
407 - ]
408 - );
409 - $this->add_control(
410 - 'recaptcha_hide',
411 - [
412 - 'label' => esc_html__( 'Badge', 'uicore-elements' ),
413 - 'type' => Controls_Manager::SELECT,
414 - 'default' => 'hidden',
415 - 'options' => [
416 - 'hidden' => esc_html__( 'Hidden', 'uicore-elements' ),
417 - 'visible' => esc_html__( 'Visible', 'uicore-elements' )
418 - ],
419 - 'condition' => [
420 - 'recaptcha_version' => 'v3',
421 - ],
422 - 'selectors' => [
423 - '.grecaptcha-badge' => 'visibility: {{VALUE}};',
424 - ],
425 - ]
426 - );
427 - $recaptcha_keys = (!get_option('uicore_elements_recaptcha_secret_key') && !get_option('uicore_elements_recaptcha_site_key')) ? true : false; // Check if recaptcha API keys were set
428 - $this->add_control(
429 - 'recaptcha_warning',
430 - [
431 - 'type' => Controls_Manager::ALERT,
432 - 'alert_type' => 'warning',
433 - 'dismissible' => false,
434 - 'heading' => esc_html__("You haven't set your reCAPTCHA API keys yet.", 'uicore-elements'),
435 - 'content' => Helper::get_admin_settings_url( esc_html__("Click here to configure your API keys.", 'uicore-elements' ) ),
436 - 'condition' => [
437 - 'add_recaptcha' => $recaptcha_keys ? 'true' : [],
438 - ]
439 - ]
440 - );
441 -
442 - $this->end_controls_tab();
443 -
444 - $this->end_controls_tabs();
445 -
446 - $this->end_controls_section();
447 -
448 - $this->start_controls_section(
449 - 'section_buttons',
335 + $this->add_control(
336 + 'name_label',
450 337 [
451 - 'label' => esc_html__( 'Button', 'uicore-elements' ),
338 + 'label' => esc_html__('Label', 'uicore-elements'),
339 + 'type' => Controls_Manager::TEXT,
340 + 'default' => '',
341 + 'dynamic' => [
342 + 'active' => true,
343 + ],
452 344 ]
453 345 );
454 -
455 - $this->TRAIT_register_button_controls('Subscribe');
456 -
457 - $this->end_controls_section();
458 -
459 - $this->start_controls_section(
460 - 'section_actions',
346 + $this->add_control(
347 + 'name_placeholder',
461 348 [
462 - 'label' => esc_html__( 'Actions After Submit', 'uicore-elements' ),
349 + 'label' => esc_html__('Placeholder', 'uicore-elements'),
350 + 'type' => Controls_Manager::TEXT,
351 + 'default' => esc_html__('Your name', 'uicore-elements'),
352 + 'dynamic' => [
353 + 'active' => true,
354 + ],
463 355 ]
464 356 );
357 + $this->add_control(
358 + 'name_required',
359 + [
360 + 'label' => esc_html__('Required', 'uicore-elements'),
361 + 'type' => Controls_Manager::SWITCHER,
362 + 'return_value' => 'true',
363 + 'default' => '',
364 + ]
365 + );
366 + $this->add_responsive_control(
367 + 'name_width',
368 + [
369 + 'label' => esc_html__('Column Width', 'uicore-elements'),
370 + 'type' => Controls_Manager::SELECT,
371 + 'options' => $this->TRAIT_get_width_values(),
372 + 'default' => '40',
373 + ]
374 + );
375 + $this->add_control(
376 + 'name_css',
377 + [
378 + 'label' => esc_html__('Custom Class', 'uicore-elements'),
379 + 'type' => Controls_Manager::TEXT,
380 + 'default' => '',
381 + 'ai' => [
382 + 'active' => false,
383 + ],
384 + 'separator' => 'before',
385 + 'placeholder' => esc_html__('e.g: my-class', 'uicore-elements'),
386 + ]
387 + );
388 + $this->add_control(
389 + 'name_shortcode',
390 + [
391 + 'label' => esc_html__('Shortcode', 'uicore-elements'),
392 + 'type' => Controls_Manager::RAW_HTML,
393 + 'classes' => 'forms-field-shortcode',
394 + 'raw' => '<input class="elementor-form-field-shortcode" value=\'[field id="name"]\' readonly />',
395 + ]
396 + );
465 397
466 - $this->add_control(
467 - 'submit_actions',
468 - [
469 - 'label' => esc_html__( 'Submit Actions', 'uicore-elements' ),
470 - 'type' => Controls_Manager::SELECT2,
471 - 'label_block' => true,
472 - 'multiple' => true,
473 - 'options' => [
474 - 'email' => esc_html__( 'Email', 'uicore-elements' ),
475 - 'email_2' => esc_html__( 'Email 2', 'uicore-elements' ),
476 - 'redirect' => esc_html__( 'Redirect', 'uicore-elements' ),
477 - 'mailchimp' => esc_html__( 'MailChimp', 'uicore-elements' ),
478 - ],
479 - 'default' => [ 'email' ],
480 - ]
481 - );
398 + $this->end_controls_tab();
482 399
483 - $this->end_controls_section();
484 -
485 - // Submit sections
486 - $this->start_controls_section(
487 - 'section_email',
400 + $this->start_controls_tab(
401 + 'recaptcha_tab',
488 402 [
489 - 'label' => esc_html__( 'Email', 'uicore-elements' ),
403 + 'label' => esc_html__('Recaptcha', 'uicore-elements'),
490 404 'condition' => [
491 - 'submit_actions' => 'email',
405 + 'add_recaptcha' => 'true',
492 406 ],
493 407 ]
494 408 );
495 409
496 - $this->TRAIT_register_submit_email_controls($this);
497 -
498 - $this->end_controls_section();
499 -
500 - $this->start_controls_section(
501 - 'section_email_2',
410 + $this->add_control(
411 + 'recaptcha_version',
502 412 [
503 - 'label' => esc_html__( 'Email 2', 'uicore-elements' ),
413 + 'label' => esc_html__('Recaptcha Version', 'uicore-elements'),
414 + 'type' => Controls_Manager::SELECT,
415 + 'options' => [
416 + 'v2' => 'V2',
417 + 'v3' => 'V3',
418 + ],
419 + 'default' => 'v2',
420 + ]
421 + );
422 + $this->add_control(
423 + 'recaptcha_hide',
424 + [
425 + 'label' => esc_html__('Badge', 'uicore-elements'),
426 + 'type' => Controls_Manager::SELECT,
427 + 'default' => 'hidden',
428 + 'options' => [
429 + 'hidden' => esc_html__('Hidden', 'uicore-elements'),
430 + 'visible' => esc_html__('Visible', 'uicore-elements')
431 + ],
504 432 'condition' => [
505 - 'submit_actions' => 'email_2',
433 + 'recaptcha_version' => 'v3',
506 434 ],
435 + 'selectors' => [
436 + '.grecaptcha-badge' => 'visibility: {{VALUE}};',
437 + ],
507 438 ]
508 439 );
440 + $recaptcha_keys = (!get_option('uicore_elements_recaptcha_secret_key') && !get_option('uicore_elements_recaptcha_site_key')) ? true : false; // Check if recaptcha API keys were set
441 + $this->add_control(
442 + 'recaptcha_warning',
443 + [
444 + 'type' => Controls_Manager::ALERT,
445 + 'alert_type' => 'warning',
446 + 'dismissible' => false,
447 + 'heading' => esc_html__("You haven't set your reCAPTCHA API keys yet.", 'uicore-elements'),
448 + 'content' => Helper::get_admin_settings_url(esc_html__("Click here to configure your API keys.", 'uicore-elements')),
449 + 'condition' => [
450 + 'add_recaptcha' => $recaptcha_keys ? 'true' : [],
451 + ]
452 + ]
453 + );
509 454
510 - $this->TRAIT_register_submit_email_controls($this, '_2');
455 + $this->end_controls_tab();
511 456
457 + $this->end_controls_tabs();
458 +
512 459 $this->end_controls_section();
513 460
514 461 $this->start_controls_section(
515 - 'section_redirect',
462 + 'section_buttons',
516 463 [
517 - 'label' => esc_html__( 'Redirect', 'uicore-elements' ),
518 - 'condition' => [
519 - 'submit_actions' => 'redirect',
520 - ],
464 + 'label' => esc_html__('Button', 'uicore-elements'),
521 465 ]
522 466 );
523 467
524 - $this->TRAIT_register_submit_redirect_controls();
468 + $this->TRAIT_register_button_controls('Subscribe');
525 469
526 470 $this->end_controls_section();
527 471
472 + $this->TRAIT_register_submit_actions_controls(Form_Service::get_form_submit_options());
473 +
474 + // Submit sections
528 475 $this->start_controls_section(
529 - 'mailchimp_redirect',
476 + 'section_email',
530 477 [
531 - 'label' => esc_html__( 'Mailchimp', 'uicore-elements' ),
478 + 'label' => esc_html__('Email', 'uicore-elements'),
532 479 'condition' => [
533 - 'submit_actions' => 'mailchimp',
480 + 'submit_actions' => 'email',
534 481 ],
535 482 ]
536 483 );
537 484
538 - $this->TRAIT_register_submit_mailchimp_controls();
485 + $this->TRAIT_register_submit_email_controls($this);
539 486
540 487 $this->end_controls_section();
541 488
542 489 $this->start_controls_section(
543 - 'section_form_options',
490 + 'section_email_2',
544 491 [
545 - 'label' => esc_html__( 'Additional Options', 'uicore-elements' ),
546 - 'tab' => Controls_Manager::TAB_CONTENT,
492 + 'label' => esc_html__('Email 2', 'uicore-elements'),
493 + 'condition' => [
494 + 'submit_actions' => 'email_2',
495 + ],
547 496 ]
548 497 );
549 498
550 - $this->TRAIT_register_additional_controls( Contact_Form_Service::get_default_messages() );
499 + $this->TRAIT_register_submit_email_controls($this, '_2');
551 500
552 501 $this->end_controls_section();
553 502
503 + $this->TRAIT_register_submit_redirect_controls();
504 + $this->TRAIT_register_submit_popup_controls($this);
505 + $this->TRAIT_register_submit_webhook_controls();
506 + $this->TRAIT_register_submit_newsletter_services_controls(Newsletter_Services::get_services_list('keys'));
507 + $this->TRAIT_register_additional_controls(Form_Service::get_default_messages());
508 +
554 509 $this->TRAIT_register_all_form_style_controls();
555 - }
510 + }
556 511
557 - protected function render() {
512 + protected function render()
513 + {
558 514
559 - $instance = $this->get_settings_for_display();
515 + $instance = $this->get_settings_for_display();
560 516 $is_recaptcha_required = false;
561 517
562 518 // Save widget settings so form API can retrieve them
563 519 set_transient('ui_e_form_widget_settings_' . $this->get_id(), $instance, DAY_IN_SECONDS);
@@ -562,159 +518,159 @@
562 518 // Save widget settings so form API can retrieve them
563 519 set_transient('ui_e_form_widget_settings_' . $this->get_id(), $instance, DAY_IN_SECONDS);
564 520
565 521 // Render Form and Fields Atts
566 - $this->add_render_attribute(
567 - [
568 - 'wrapper' => [
569 - 'class' => [
570 - 'ui-e-fields-wrp',
571 - ],
572 - ],
573 - 'submit-group' => [
574 - 'class' => [
575 - 'ui-e-field-group',
576 - 'elementor-column',
577 - 'ui-e-field-type-submit',
578 - ],
579 - ],
580 - 'button' => [
581 - 'class' => 'elementor-button',
582 - ],
583 - 'icon-align' => [
584 - 'class' => [
585 - empty( $instance['button_icon_align'] ) ? '' : 'ui-e-icon ui-e-align-' . $instance['button_icon_align'],
586 - ],
587 - ],
588 - ]
589 - );
590 - if($instance['add_name'] == 'true') {
591 - $this->form_fields_render_attributes( '_name', $instance, 'name' );
522 + $this->add_render_attribute(
523 + [
524 + 'wrapper' => [
525 + 'class' => [
526 + 'ui-e-fields-wrp',
527 + ],
528 + ],
529 + 'submit-group' => [
530 + 'class' => [
531 + 'ui-e-field-group',
532 + 'elementor-column',
533 + 'ui-e-field-type-submit',
534 + ],
535 + ],
536 + 'button' => [
537 + 'class' => 'elementor-button',
538 + ],
539 + 'icon-align' => [
540 + 'class' => [
541 + empty($instance['button_icon_align']) ? '' : 'ui-e-icon ui-e-align-' . $instance['button_icon_align'],
542 + ],
543 + ],
544 + ]
545 + );
546 + if ($instance['add_name'] == 'true') {
547 + $this->form_fields_render_attributes('_name', $instance, 'name');
592 548 }
593 - $this->form_fields_render_attributes( '_email', $instance, 'email' );
549 + $this->form_fields_render_attributes('_email', $instance, 'email');
594 550
595 551 // Fallback for empty control values
596 - if ( empty( $instance['button_width'] ) ) {
597 - $instance['button_width'] = '100';
598 - }
552 + if (empty($instance['button_width'])) {
553 + $instance['button_width'] = '100';
554 + }
599 555
600 - // Button atts
601 - $this->add_render_attribute( 'submit-group', 'class', 'elementor-col-' . $instance['button_width'] . ' e-form__buttons' );
556 + // Button atts
557 + $this->add_render_attribute('submit-group', 'class', 'elementor-col-' . $instance['button_width'] . ' e-form__buttons');
602 558
603 - if ( ! empty( $instance['button_width_tablet'] ) ) {
604 - $this->add_render_attribute( 'submit-group', 'class', 'elementor-md-' . $instance['button_width_tablet'] );
605 - }
606 - if ( ! empty( $instance['button_width_mobile'] ) ) {
607 - $this->add_render_attribute( 'submit-group', 'class', 'elementor-sm-' . $instance['button_width_mobile'] );
608 - }
609 - if ( $instance['button_hover_animation'] ) {
610 - $this->add_render_attribute( 'button', 'class', 'elementor-animation-' . $instance['button_hover_animation'] );
611 - }
559 + if (! empty($instance['button_width_tablet'])) {
560 + $this->add_render_attribute('submit-group', 'class', 'elementor-md-' . $instance['button_width_tablet']);
561 + }
562 + if (! empty($instance['button_width_mobile'])) {
563 + $this->add_render_attribute('submit-group', 'class', 'elementor-sm-' . $instance['button_width_mobile']);
564 + }
565 + if ($instance['button_hover_animation']) {
566 + $this->add_render_attribute('button', 'class', 'elementor-animation-' . $instance['button_hover_animation']);
567 + }
612 568
613 - // Form atts
614 - if ( ! empty( $instance['form_id'] ) ) {
615 - $this->add_render_attribute( 'form', 'id', $instance['form_id'] );
616 - }
617 - if ( ! empty( $instance['form_name'] ) ) {
618 - $this->add_render_attribute( 'form', 'name', $instance['form_name'] );
619 - }
620 - if ( 'no' === $instance['form_validation'] ) {
621 - $this->add_render_attribute( 'form', 'novalidate' );
622 - }
623 - if ( ! empty( $instance['button_css_id'] ) ) {
624 - $this->add_render_attribute( 'button', 'id', $instance['button_css_id'] );
625 - }
569 + // Form atts
570 + if (! empty($instance['form_id'])) {
571 + $this->add_render_attribute('form', 'id', $instance['form_id']);
572 + }
573 + if (! empty($instance['form_name'])) {
574 + $this->add_render_attribute('form', 'name', $instance['form_name']);
575 + }
576 + if ('no' === $instance['form_validation']) {
577 + $this->add_render_attribute('form', 'novalidate');
578 + }
579 + if (! empty($instance['button_css_id'])) {
580 + $this->add_render_attribute('button', 'id', $instance['button_css_id']);
581 + }
626 582
627 583 // Basic settings
628 584 $print_label = $instance['show_labels'] == 'true';
629 - ?>
585 +?>
630 586
631 - <form class="ui-e-form" method="post" <?php $this->print_render_attribute_string( 'form' ); ?>>
587 + <form class="ui-e-form" method="post" <?php $this->print_render_attribute_string('form'); ?>>
632 588
633 - <input type="hidden" name="widget_id" value="<?php echo esc_attr( $this->get_id() ); ?>"/>
589 + <input type="hidden" name="widget_id" value="<?php echo esc_attr($this->get_id()); ?>" />
634 590 <input type="hidden" name="widget_type" value="newsletter">
635 591
636 - <div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
592 + <div <?php $this->print_render_attribute_string('wrapper'); ?>>
637 593
638 - <?php if($instance['add_name'] == 'true') : ?>
639 - <div <?php $this->print_render_attribute_string( 'field-group_name'); ?>>
640 - <?php if ( $print_label && $instance['name_label'] ) : ?>
641 - <label <?php $this->print_render_attribute_string( 'label_name' ); ?>>
642 - <?php echo esc_html($instance['name_label']);?>
594 + <?php if ($instance['add_name'] == 'true') : ?>
595 + <div <?php $this->print_render_attribute_string('field-group_name'); ?>>
596 + <?php if ($print_label && $instance['name_label']) : ?>
597 + <label <?php $this->print_render_attribute_string('label_name'); ?>>
598 + <?php echo esc_html($instance['name_label']); ?>
643 599 </label>
644 600 <?php endif; ?>
645 - <input <?php $this->print_render_attribute_string( 'input_name'); ?>>
601 + <input <?php $this->print_render_attribute_string('input_name'); ?>>
646 602 </div>
647 603 <?php endif; ?>
648 604
649 - <div <?php $this->print_render_attribute_string( 'field-group_email'); ?>>
650 - <?php if ( $print_label && $instance['email_label'] ) : ?>
651 - <label <?php $this->print_render_attribute_string( 'label_email' ); ?>>
652 - <?php echo esc_html($instance['email_label']);?>
605 + <div <?php $this->print_render_attribute_string('field-group_email'); ?>>
606 + <?php if ($print_label && $instance['email_label']) : ?>
607 + <label <?php $this->print_render_attribute_string('label_email'); ?>>
608 + <?php echo esc_html($instance['email_label']); ?>
653 609 </label>
654 610 <?php endif; ?>
655 - <input <?php $this->print_render_attribute_string( 'input_email'); ?>>
611 + <input <?php $this->print_render_attribute_string('input_email'); ?>>
656 612 </div>
657 613
658 - <?php if($instance['add_honeypot'] == 'true') : ?>
659 - <div <?php $this->print_render_attribute_string( 'honeypot'); ?>>
614 + <?php if ($instance['add_honeypot'] == 'true') : ?>
615 + <div <?php $this->print_render_attribute_string('honeypot'); ?>>
660 616 <label for="form-field-address" class="ui-e-label">
661 - <?php echo esc_html__( 'Address', 'uicore-elements' ); ?>
617 + <?php echo esc_html__('Address', 'uicore-elements'); ?>
662 618 </label>
663 619 <input class="ui-e-field ui-e-h-p" name="ui-e-h-p" id="ui-e-h-p" tabindex="-1" autocomplete="off">
664 620 </div>
665 621 <?php endif; ?>
666 622
667 - <div <?php $this->print_render_attribute_string( 'submit-group' ); ?>>
668 - <button type="submit" <?php $this->print_render_attribute_string( 'button' ); ?>>
669 - <span <?php $this->print_render_attribute_string( 'content-wrapper' ); ?>>
670 - <?php if ( ! empty( $instance['button_icon'] ) || ! empty( $instance['selected_button_icon'] ) ) : ?>
671 - <span <?php $this->print_render_attribute_string( 'icon-align' ); ?>>
672 - <?php Icons_Manager::render_icon( $instance['selected_button_icon'], [ 'aria-hidden' => 'true' ] ); ?>
673 - <?php if ( empty( $instance['button_text'] ) ) : ?>
674 - <span class="elementor-screen-only"><?php echo esc_html__( 'Submit', 'uicore-elements' ); ?></span>
675 - <?php endif; ?>
676 - </span>
677 - <?php endif; ?>
678 - <?php if ( ! empty( $instance['button_text'] ) ) : ?>
679 - <span class="ui-e-text"><?php $this->print_unescaped_setting( 'button_text' ); ?></span>
680 - <?php endif; ?>
681 - </span>
682 - </button>
683 - </div>
623 + <div <?php $this->print_render_attribute_string('submit-group'); ?>>
624 + <button type="submit" <?php $this->print_render_attribute_string('button'); ?>>
625 + <span <?php $this->print_render_attribute_string('content-wrapper'); ?>>
626 + <?php if (! empty($instance['button_icon']) || ! empty($instance['selected_button_icon'])) : ?>
627 + <span <?php $this->print_render_attribute_string('icon-align'); ?>>
628 + <?php Icons_Manager::render_icon($instance['selected_button_icon'], ['aria-hidden' => 'true']); ?>
629 + <?php if (empty($instance['button_text'])) : ?>
630 + <span class="elementor-screen-only"><?php echo esc_html__('Submit', 'uicore-elements'); ?></span>
631 + <?php endif; ?>
632 + </span>
633 + <?php endif; ?>
634 + <?php if (! empty($instance['button_text'])) : ?>
635 + <span class="ui-e-text"><?php $this->print_unescaped_setting('button_text'); ?></span>
636 + <?php endif; ?>
637 + </span>
638 + </button>
639 + </div>
684 640
685 641 <?php
686 - if($instance['add_recaptcha'] == 'true') :
687 - $recaptcha_type = $instance['recaptcha_version'] === 'v2' ? 'recaptcha' : 'recaptcha_v3';
688 - $is_recaptcha_required = true;
642 + if ($instance['add_recaptcha'] == 'true') :
643 + $recaptcha_type = $instance['recaptcha_version'] === 'v2' ? 'recaptcha' : 'recaptcha_v3';
644 + $is_recaptcha_required = true;
689 645 ?>
690 646 <div <?php $this->print_render_attribute_string($recaptcha_type); ?>>
691 - <input type="hidden" name="<?php echo esc_attr($recaptcha_type);?>">
692 - <?php if($instance['recaptcha_version'] == 'v2') : ?>
693 - <div id="ui-e-recaptcha-<?php echo esc_attr( $this->get_ID() ); ?>"></div>
647 + <input type="hidden" name="<?php echo esc_attr($recaptcha_type); ?>">
648 + <?php if ($instance['recaptcha_version'] == 'v2') : ?>
649 + <div id="ui-e-recaptcha-<?php echo esc_attr($this->get_ID()); ?>"></div>
694 650 <?php endif; ?>
695 651 </div>
696 652 <?php endif; ?>
697 653
698 - </div>
654 + </div>
699 655
700 656 <div class="ui-e-message <?php echo $this->is_edit_mode() ? 'elementor-hidden' : ''; ?>">
701 - <?php if($this->is_edit_mode()) :
657 + <?php if ($this->is_edit_mode()) :
702 658 // Get custom messages if set, else use default
703 - $messages = Contact_Form_Service::get_default_messages();
659 + $messages = Form_Service::get_default_messages();
704 660 $success = isset($instance['success_message']) ? $instance['success_message'] : $messages['success'];
705 661 $error = isset($instance['error_message']) ? $instance['error_message'] : $messages['error'];
706 - ?>
707 - <span class="success"> <?php echo esc_html($success);?> </span> <br>
708 - <span class="error"> <?php echo esc_html($error);?> </span>
709 - <?php endif; ?>
662 + ?>
663 + <span class="success"> <?php echo esc_html($success); ?> </span> <br>
664 + <span class="error"> <?php echo esc_html($error); ?> </span>
665 + <?php endif; ?>
710 666 </div>
711 - </form>
712 - <?php
667 + </form>
668 +<?php
713 669
714 670 //add js to footer if recaptcha is enabled
715 - if($is_recaptcha_required){
671 + if ($is_recaptcha_required) {
716 672 add_action('wp_footer', [$this, 'TRAIT_recaptcha_key_js'], 999);
717 673 }
718 - }
674 + }
719 675 }
720 -\Elementor\Plugin::instance()->widgets_manager->register(new Newsletter());
676 +\Elementor\Plugin::instance()->widgets_manager->register(new Newsletter());