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