PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.0.14
UiCore Elements – Free widgets and templates for Elementor v1.0.14
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
uicore-elements / includes / utils / form-component.php

form-component.php in UiCore Elements – Free widgets and templates for Elementor 1.0.14, at includes/utils/form-component.php

1,221 lines 43.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace UiCoreElements\Utils;
3
4 use UiCoreElements\Helper;
5 use Elementor\Controls_Manager;
6 use Elementor\Group_Control_Typography;
7 use Elementor\Group_Control_Border;
8 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
9 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
10
11 defined('ABSPATH') || exit();
12
13 /**
14 * Register some Form Widgets controls and methods.
15 */
16
17 trait Form_Component {
18
19 // Submission Controls
20 function TRAIT_register_submit_email_controls($instance, $slug = '')
21 {
22 $instance->add_control(
23 'email_to' . $slug,
24 [
25 'label' => esc_html__( 'To', 'uicore-elements' ),
26 'type' => Controls_Manager::TEXT,
27 'default' => get_option( 'admin_email' ),
28 'ai' => [
29 'active' => false,
30 ],
31 'placeholder' => get_option( 'admin_email' ),
32 'label_block' => true,
33 'title' => esc_html__( 'Separate emails with commas', 'uicore-elements' ),
34 'render_type' => 'none',
35 'dynamic' => [
36 'active' => true,
37 ],
38 ]
39 );
40
41 /* translators: %s: Site title. */
42 $default_message = sprintf( html_entity_decode( esc_html__( 'New message from "%s"', 'uicore-elements' ) ), get_option( 'blogname' ) );
43
44 $instance->add_control(
45 'email_subject' . $slug,
46 [
47 'label' => esc_html__( 'Subject', 'uicore-elements' ),
48 'type' => Controls_Manager::TEXT,
49 'default' => $default_message,
50 'ai' => [
51 'active' => false,
52 ],
53 'placeholder' => $default_message,
54 'label_block' => true,
55 'render_type' => 'none',
56 'dynamic' => [
57 'active' => true,
58 ],
59 ]
60 );
61
62 $instance->add_control(
63 'email_content' . $slug,
64 [
65 'label' => esc_html__( 'Message', 'uicore-elements' ),
66 'type' => Controls_Manager::TEXTAREA,
67 'default' => '[all-fields]',
68 'ai' => [
69 'active' => false,
70 ],
71 'placeholder' => '[all-fields]',
72 'description' => sprintf(
73 /* translators: %s: The [all-fields] shortcode. */
74 esc_html__( 'By default, all form fields are sent via %s shortcode. To customize sent fields, copy the shortcode that appears inside each field and paste it above.', 'uicore-elements' ),
75 '<code>[all-fields]</code>'
76 ),
77 'render_type' => 'none',
78 'dynamic' => [
79 'active' => true,
80 ],
81 ]
82 );
83
84 $site_domain = Helper::get_site_domain();
85
86 $instance->add_control(
87 'email_from' . $slug,
88 [
89 'label' => esc_html__( 'From Email', 'uicore-elements' ),
90 'type' => Controls_Manager::TEXT,
91 'default' => 'email@' . $site_domain,
92 'ai' => [
93 'active' => false,
94 ],
95 'render_type' => 'none',
96 'dynamic' => [
97 'active' => true,
98 ],
99 ]
100 );
101
102 $instance->add_control(
103 'email_from_name' . $slug,
104 [
105 'label' => esc_html__( 'From Name', 'uicore-elements' ),
106 'type' => Controls_Manager::TEXT,
107 'default' => get_bloginfo( 'name' ),
108 'ai' => [
109 'active' => false,
110 ],
111 'render_type' => 'none',
112 'dynamic' => [
113 'active' => true,
114 ],
115 ]
116 );
117
118 $instance->add_control(
119 'email_reply_to' . $slug,
120 [
121 'label' => esc_html__( 'Reply-To', 'uicore-elements' ),
122 'type' => Controls_Manager::TEXT,
123 'options' => [
124 '' => '',
125 ],
126 'default' => 'noreply@' . Helper::get_site_domain(),
127 'render_type' => 'none',
128 ]
129 );
130
131 $instance->add_control(
132 'email_to_cc' . $slug,
133 [
134 'label' => esc_html__( 'Cc', 'uicore-elements' ),
135 'type' => Controls_Manager::TEXT,
136 'default' => '',
137 'ai' => [
138 'active' => false,
139 ],
140 'title' => esc_html__( 'Separate emails with commas', 'uicore-elements' ),
141 'render_type' => 'none',
142 'dynamic' => [
143 'active' => true,
144 ],
145 ]
146 );
147
148 $instance->add_control(
149 'email_to_bcc' . $slug,
150 [
151 'label' => esc_html__( 'Bcc', 'uicore-elements' ),
152 'type' => Controls_Manager::TEXT,
153 'default' => '',
154 'ai' => [
155 'active' => false,
156 ],
157 'title' => esc_html__( 'Separate emails with commas', 'uicore-elements' ),
158 'render_type' => 'none',
159 'dynamic' => [
160 'active' => true,
161 ],
162 ]
163 );
164
165 $instance->add_control(
166 'form_metadata' . $slug,
167 [
168 'label' => esc_html__( 'Meta Data', 'uicore-elements' ),
169 'type' => Controls_Manager::SELECT2,
170 'multiple' => true,
171 'label_block' => true,
172 'separator' => 'before',
173 'default' => [
174 'date',
175 'time',
176 'page_url',
177 'user_agent',
178 'remote_ip',
179 ],
180 'options' => [
181 'date' => esc_html__( 'Date', 'uicore-elements' ),
182 'time' => esc_html__( 'Time', 'uicore-elements' ),
183 'page_url' => esc_html__( 'Page URL', 'uicore-elements' ),
184 'user_agent' => esc_html__( 'User Agent', 'uicore-elements' ),
185 'remote_ip' => esc_html__( 'Remote IP', 'uicore-elements' ),
186 ],
187 'render_type' => 'none',
188 ]
189 );
190
191 $instance->add_control(
192 'email_content_type' . $slug,
193 [
194 'label' => esc_html__( 'Send As', 'uicore-elements' ),
195 'type' => Controls_Manager::SELECT,
196 'default' => 'html',
197 'render_type' => 'none',
198 'options' => [
199 'html' => esc_html__( 'HTML', 'uicore-elements' ),
200 'plain' => esc_html__( 'Plain', 'uicore-elements' ),
201 ],
202 ]
203 );
204 }
205 function TRAIT_register_submit_redirect_controls()
206 {
207 $this->add_control(
208 'redirect_to',
209 [
210 'label' => esc_html__( 'Redirect To', 'uicore-elements' ),
211 'type' => Controls_Manager::TEXT,
212 'placeholder' => esc_html__( 'https://your-link.com', 'uicore-elements' ),
213 'ai' => [
214 'active' => false,
215 ],
216 'dynamic' => [
217 'active' => true,
218 'categories' => [
219 'url',
220 ],
221 ],
222 'label_block' => true,
223 'render_type' => 'none',
224 ]
225 );
226 }
227 /**
228 * Register MailChimp controls for the submit action.
229 *
230 * @param $instance - The widget instance. Required if $has_repeaters is true.
231 * @param bool $has_repeaters - Enable Field Mapping control if the widget has dynamic fields widh repeaters.
232 *
233 * @return void
234 */
235 function TRAIT_register_submit_mailchimp_controls($instance = null, bool $has_repeaters = false)
236 {
237
238 if( !get_option('uicore_elements_mailchimp_secret_key') ) {
239 $this->add_control(
240 'mailchimp_warning',
241 [
242 'type' => Controls_Manager::ALERT,
243 'alert_type' => 'warning',
244 'dismissible' => false,
245 'heading' => esc_html__("You haven't set your Mailchimp API key yet.", 'uicore-elements'),
246 'content' => Helper::get_admin_settings_url(esc_html__("Click here to configure your API keys.", 'uicore-elements' )),
247 ]
248 );
249 }
250
251 $this->add_control(
252 'mailchimp_audience_id',
253 [
254 'label' => esc_html__( 'Audience ID', 'uicore-elements' ),
255 'type' => Controls_Manager::TEXT,
256 'description' => esc_html__( 'Enter the Audience ID to subscribe the user to.', 'uicore-elements' ),
257 'ai' => [
258 'active' => false,
259 ],
260 'dynamic' => [
261 'active' => true,
262 ],
263 'label_block' => true,
264 'render_type' => 'none',
265 ]
266 );
267
268 // If repeaters, than we need the field mapping controls
269 if($has_repeaters) {
270 $this->add_control(
271 'mailchimp_map_description',
272 [
273 'label' => esc_html__( 'Field Mapping', 'uicore-elements' ),
274 'type' => Controls_Manager::RAW_HTML,
275 'raw' => esc_html__( 'You need to set the "ID" of the field you want to map.', 'uicore-elements' ),
276 'content_classes' => 'elementor-control-field-description',
277 'separator' => 'before',
278 ]
279 );
280 $this->add_control(
281 'mailchimp_email_id',
282 [
283 'label' => esc_html__( 'Email*', 'uicore-elements' ),
284 'type' => Controls_Manager::TEXT,
285 'ai' => [
286 'active' => false,
287 ],
288 'render_type' => 'none',
289 ]
290 );
291 $this->add_control(
292 'mailchimp_birthday_id',
293 [
294 'label' => esc_html__( 'Birthday', 'uicore-elements' ),
295 'type' => Controls_Manager::TEXT,
296 'description' => esc_html__( 'Expects the format MM/DD.', 'uicore-elements' ),
297 'ai' => [
298 'active' => false,
299 ],
300 'render_type' => 'none',
301 ]
302 );
303 $this->add_control(
304 'mailchimp_fname_id',
305 [
306 'label' => esc_html__( 'First Name', 'uicore-elements' ),
307 'type' => Controls_Manager::TEXT,
308 'ai' => [
309 'active' => false,
310 ],
311 'render_type' => 'none',
312 ]
313 );
314 $this->add_control(
315 'mailchimp_lname_id',
316 [
317 'label' => esc_html__( 'Last Name', 'uicore-elements' ),
318 'type' => Controls_Manager::TEXT,
319 'ai' => [
320 'active' => false,
321 ],
322 'render_type' => 'none',
323 ]
324 );
325 $this->add_control(
326 'mailchimp_phone_id',
327 [
328 'label' => esc_html__( 'Phone', 'uicore-elements' ),
329 'type' => Controls_Manager::TEXT,
330 'ai' => [
331 'active' => false,
332 ],
333 'render_type' => 'none',
334 ]
335 );
336
337 }
338 }
339
340 // Settings and Content Controls
341 function TRAIT_register_additional_controls($messages)
342 {
343 $this->add_control(
344 'form_id',
345 [
346 'label' => esc_html__( 'Form ID', 'uicore-elements' ),
347 'type' => Controls_Manager::TEXT,
348 'ai' => [
349 'active' => false,
350 ],
351 'placeholder' => 'new_form_id',
352 'description' => esc_html__( 'Please make sure the ID is unique and not used elsewhere on the page this form is displayed. This field allows `A-z 0-9` & underscore chars without spaces.', 'uicore-elements' ),
353 'separator' => 'after',
354 'dynamic' => [
355 'active' => true,
356 ],
357 ]
358 );
359 $this->add_control(
360 'form_validation',
361 [
362 'label' => esc_html__( 'Form Validation', 'uicore-elements' ),
363 'type' => Controls_Manager::SELECT,
364 'options' => [
365 '' => esc_html__( 'Browser Default', 'uicore-elements' ),
366 'no' => esc_html__( 'No validation', 'uicore-elements' ),
367 ],
368 'default' => '',
369 ]
370 );
371 $this->add_control(
372 'custom_messages',
373 [
374 'label' => esc_html__( 'Custom Messages', 'uicore-elements' ),
375 'type' => Controls_Manager::SWITCHER,
376 'default' => '',
377 'separator' => 'before',
378 'render_type' => 'none',
379 ]
380 );
381 $this->add_control(
382 'success_message',
383 [
384 'label' => esc_html__( 'Success Message', 'uicore-elements' ),
385 'type' => Controls_Manager::TEXT,
386 'default' => $messages['success'],
387 'placeholder' => $messages['success'],
388 'label_block' => true,
389 'condition' => [
390 'custom_messages!' => '',
391 ],
392 'render_type' => 'none',
393 'dynamic' => [
394 'active' => true,
395 ],
396 ]
397 );
398 $this->add_control(
399 'error_message',
400 [
401 'label' => esc_html__( 'Form Error', 'uicore-elements' ),
402 'type' => Controls_Manager::TEXT,
403 'default' => $messages['error'],
404 'placeholder' => $messages['error'],
405 'label_block' => true,
406 'condition' => [
407 'custom_messages!' => '',
408 ],
409 'render_type' => 'none',
410 'dynamic' => [
411 'active' => true,
412 ],
413 ]
414 );
415 $this->add_control(
416 'mail_error_message',
417 [
418 'label' => esc_html__( 'Email Sending Error', 'uicore-elements' ),
419 'type' => Controls_Manager::TEXT,
420 'default' => $messages['mail_error'],
421 'placeholder' => $messages['mail_error'],
422 'label_block' => true,
423 'condition' => [
424 'custom_messages!' => '',
425 ],
426 'render_type' => 'none',
427 'dynamic' => [
428 'active' => true,
429 ],
430 ]
431 );
432 $this->add_control(
433 'redirect_message',
434 [
435 'label' => esc_html__( 'Sucessfull Redirect', 'uicore-elements' ),
436 'type' => Controls_Manager::TEXT,
437 'default' => $messages['redirect'],
438 'placeholder' => $messages['redirect'],
439 'label_block' => true,
440 'conditions' => [
441 'terms' => [
442 [
443 'name' => 'custom_messages',
444 'operator' => '!=',
445 'value' => '',
446 ],
447 [
448 'name' => 'submit_actions',
449 'operator' => 'contains',
450 'value' => 'redirect',
451 ]
452 ],
453 ],
454 'render_type' => 'none',
455 'dynamic' => [
456 'active' => true,
457 ],
458 ]
459 );
460 }
461 function TRAIT_register_button_controls(string $submit_text = 'send')
462 {
463 $this->add_responsive_control(
464 'button_width',
465 [
466 'label' => esc_html__( 'Column Width', 'uicore-elements' ),
467 'type' => Controls_Manager::SELECT,
468 'options' => $this->TRAIT_get_width_values(),
469 'default' => '20',
470 ]
471 );
472 $this->add_responsive_control(
473 'button_align',
474 [
475 'label' => esc_html__( 'Alignment', 'uicore-elements' ),
476 'type' => Controls_Manager::CHOOSE,
477 'options' => [
478 'left' => [
479 'title' => esc_html__( 'Left', 'uicore-elements' ),
480 'icon' => 'eicon-text-align-left',
481 ],
482 'center' => [
483 'title' => esc_html__( 'Center', 'uicore-elements' ),
484 'icon' => 'eicon-text-align-center',
485 ],
486 'right' => [
487 'title' => esc_html__( 'Right', 'uicore-elements' ),
488 'icon' => 'eicon-text-align-right',
489 ],
490 'stretch' => [
491 'title' => esc_html__( 'Justified', 'uicore-elements' ),
492 'icon' => 'eicon-text-align-justify',
493 ],
494 ],
495 'default' => 'stretch',
496 'prefix_class' => 'ui-e-submit-align-',
497 ]
498 );
499 $this->add_control(
500 'button_text',
501 [
502 'label' => esc_html__( 'Submit', 'uicore-elements' ),
503 'type' => Controls_Manager::TEXT,
504 'default' => esc_html__( $submit_text, 'uicore-elements' ),
505 'placeholder' => esc_html__( $submit_text, 'uicore-elements' ),
506 'dynamic' => [
507 'active' => true,
508 ],
509 'ai' => [
510 'active' => false,
511 ],
512 ]
513 );
514 $this->add_control(
515 'selected_button_icon',
516 [
517 'label' => esc_html__( 'Icon', 'uicore-elements' ),
518 'type' => Controls_Manager::ICONS,
519 'skin' => 'inline',
520 'label_block' => false,
521 ]
522 );
523 $this->add_control(
524 'button_icon_align',
525 [
526 'label' => esc_html__( 'Icon Position', 'uicore-elements' ),
527 'type' => Controls_Manager::SELECT,
528 'default' => 'left',
529 'options' => [
530 'left' => esc_html__( 'Before', 'uicore-elements' ),
531 'right' => esc_html__( 'After', 'uicore-elements' ),
532 ],
533 'condition' => [
534 'selected_button_icon[value]!' => '',
535 ],
536 ]
537 );
538 $this->add_control(
539 'button_icon_indent',
540 [
541 'label' => esc_html__( 'Icon Spacing', 'uicore-elements' ),
542 'type' => Controls_Manager::SLIDER,
543 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
544 'range' => [
545 'px' => [
546 'max' => 100,
547 ],
548 'em' => [
549 'max' => 10,
550 ],
551 'rem' => [
552 'max' => 10,
553 ],
554 ],
555 'condition' => [
556 'selected_button_icon[value]!' => '',
557 ],
558 'selectors' => [
559 '{{WRAPPER}} .elementor-button .ui-e-align-right' => 'margin-left: {{SIZE}}{{UNIT}};',
560 '{{WRAPPER}} .elementor-button .ui-e-align-left' => 'margin-right: {{SIZE}}{{UNIT}};',
561 ],
562 ]
563 );
564 $this->add_control(
565 'button_css_id',
566 [
567 'label' => esc_html__( 'Button ID', 'uicore-elements' ),
568 'type' => Controls_Manager::TEXT,
569 'default' => '',
570 'ai' => [
571 'active' => false,
572 ],
573 'title' => esc_html__( 'Add your custom id WITHOUT the Pound key. e.g: my-id', 'uicore-elements' ),
574 'description' => esc_html__( 'Please make sure the ID is unique and not used elsewhere on the page this form is displayed. This field allows `A-z 0-9` & underscore chars without spaces.', 'uicore-elements' ),
575 'separator' => 'before',
576 'dynamic' => [
577 'active' => true,
578 ],
579 ]
580 );
581 }
582
583 // Style Controls
584 function TRAIT_register_form_style_controls($section = true)
585 {
586 if($section){
587 $this->start_controls_section(
588 'section_form_style',
589 [
590 'label' => esc_html__( 'Form', 'uicore-elements' ),
591 'tab' => Controls_Manager::TAB_STYLE,
592 ]
593 );
594 }
595 $this->add_control(
596 'column_gap',
597 [
598 'label' => esc_html__( 'Columns Gap', 'uicore-elements' ),
599 'type' => Controls_Manager::SLIDER,
600 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
601 'default' => [
602 'size' => 10,
603 ],
604 'range' => [
605 'px' => [
606 'max' => 60,
607 ],
608 'em' => [
609 'max' => 6,
610 ],
611 'rem' => [
612 'max' => 6,
613 ],
614 ],
615 'selectors' => [
616 '{{WRAPPER}} .ui-e-field-group' => 'padding-right: calc( {{SIZE}}{{UNIT}}/2 ); padding-left: calc( {{SIZE}}{{UNIT}}/2 );',
617 '{{WRAPPER}} .ui-e-fields-wrp' => 'margin-left: calc( -{{SIZE}}{{UNIT}}/2 ); margin-right: calc( -{{SIZE}}{{UNIT}}/2 );',
618 ],
619 ]
620 );
621 $this->add_control(
622 'row_gap',
623 [
624 'label' => esc_html__( 'Rows Gap', 'uicore-elements' ),
625 'type' => Controls_Manager::SLIDER,
626 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
627 'default' => [
628 'size' => 10,
629 ],
630 'range' => [
631 'px' => [
632 'max' => 60,
633 ],
634 'em' => [
635 'max' => 6,
636 ],
637 'rem' => [
638 'max' => 6,
639 ],
640 ],
641 'selectors' => [
642 '{{WRAPPER}} .ui-e-field-group' => 'margin-bottom: {{SIZE}}{{UNIT}};',
643 '{{WRAPPER}} .ui-e-fields-wrp' => 'margin-bottom: -{{SIZE}}{{UNIT}};',
644 ],
645 ]
646 );
647 $this->add_control(
648 'heading_label',
649 [
650 'label' => esc_html__( 'Label', 'uicore-elements' ),
651 'type' => Controls_Manager::HEADING,
652 'separator' => 'before',
653 ]
654 );
655 $this->add_control(
656 'label_spacing',
657 [
658 'label' => esc_html__( 'Spacing', 'uicore-elements' ),
659 'type' => Controls_Manager::SLIDER,
660 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
661 'default' => [
662 'size' => 0,
663 ],
664 'range' => [
665 'px' => [
666 'max' => 60,
667 ],
668 'em' => [
669 'max' => 6,
670 ],
671 'rem' => [
672 'max' => 6,
673 ],
674 ],
675 'selectors' => [
676 'body {{WRAPPER}} .ui-e-field-group > label' => 'padding-bottom: {{SIZE}}{{UNIT}};',
677 ],
678 ]
679 );
680 $this->add_control(
681 'label_color',
682 [
683 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
684 'type' => Controls_Manager::COLOR,
685 'selectors' => [
686 '{{WRAPPER}} .ui-e-field-group > label, {{WRAPPER}} .ui-e-field-subgroup label' => 'color: {{VALUE}};',
687 ],
688 'global' => [
689 'default' => Global_Colors::COLOR_TEXT,
690 ],
691 ]
692 );
693 $this->add_control(
694 'mark_required_color',
695 [
696 'label' => esc_html__( 'Mark Color', 'uicore-elements' ),
697 'type' => Controls_Manager::COLOR,
698 'default' => '',
699 'selectors' => [
700 '{{WRAPPER}} .ui-e-required .ui-e-label:after' => 'color: {{COLOR}};',
701 ],
702 'condition' => [
703 'mark_required' => 'yes',
704 ],
705 ]
706 );
707 $this->add_group_control(
708 Group_Control_Typography::get_type(),
709 [
710 'name' => 'label_typography',
711 'selector' => '{{WRAPPER}} .ui-e-field-group > label',
712 'global' => [
713 'default' => Global_Typography::TYPOGRAPHY_TEXT,
714 ],
715 ]
716 );
717 if($section){
718 $this->end_controls_section();
719 }
720 }
721 function TRAIT_register_fields_style_controls($section = true)
722 {
723 if($section){
724 $this->start_controls_section(
725 'section_field_style',
726 [
727 'label' => esc_html__( 'Fields', 'uicore-elements' ),
728 'tab' => Controls_Manager::TAB_STYLE,
729 ]
730 );
731 }
732
733 $this->start_controls_tabs(
734 'field_style_tabs'
735 );
736
737 $this->start_controls_tab(
738 'field_normal_tab',
739 [
740 'label' => esc_html__( 'Normal', 'uicore-elements' ),
741 ]
742 );
743
744 $this->add_group_control(
745 Group_Control_Typography::get_type(),
746 [
747 'name' => 'field_typography',
748 'selector' => '{{WRAPPER}} .ui-e-field-group .ui-e-field, {{WRAPPER}} .ui-e-field-subgroup label',
749 'global' => [
750 'default' => Global_Typography::TYPOGRAPHY_TEXT,
751 ],
752 ]
753 );
754 $this->add_control(
755 'field_text_color',
756 [
757 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
758 'type' => Controls_Manager::COLOR,
759 'selectors' => [
760 '{{WRAPPER}} .ui-e-field-group .ui-e-field' => 'color: {{VALUE}};',
761 ],
762 'global' => [
763 'default' => Global_Colors::COLOR_TEXT,
764 ],
765 ]
766 );
767 $this->add_control(
768 'field_placeholder_color',
769 [
770 'label' => esc_html__( 'Placeholder Color', 'uicore-elements' ),
771 'type' => Controls_Manager::COLOR,
772 'selectors' => [
773 '{{WRAPPER}} .ui-e-field-group .ui-e-field::placeholder' => 'color: {{VALUE}};',
774 ],
775 'global' => [
776 'default' => Global_Colors::COLOR_TEXT,
777 ],
778 ]
779 );
780 $this->add_control(
781 'field_background_color',
782 [
783 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
784 'type' => Controls_Manager::COLOR,
785 'default' => '#ffffff',
786 'selectors' => [
787 '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'background-color: {{VALUE}};',
788 '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'background-color: {{VALUE}};',
789 ],
790 ]
791 );
792 $this->add_group_control(
793 Group_Control_Border::get_type(),
794 [
795 'name' => 'field_border',
796 'selector' =>
797 '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select),
798 {{WRAPPER}} .ui-e-field-group .ui-e-field-select select',
799 ]
800 );
801
802 $this->end_controls_tab();
803
804 $this->start_controls_tab(
805 'field_hover_tab',
806 [
807 'label' => esc_html__( 'Hover', 'uicore-elements' ),
808 ]
809 );
810
811 $this->add_control(
812 'field_text_hover_color',
813 [
814 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
815 'type' => Controls_Manager::COLOR,
816 'selectors' => [
817 '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field' => 'color: {{VALUE}};',
818 ],
819 'global' => [
820 'default' => Global_Colors::COLOR_TEXT,
821 ],
822 ]
823 );
824 $this->add_control(
825 'field_placeholder_hover_color',
826 [
827 'label' => esc_html__( 'Placeholder Color', 'uicore-elements' ),
828 'type' => Controls_Manager::COLOR,
829 'selectors' => [
830 '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field::placeholder' => 'color: {{VALUE}};',
831 ],
832 'global' => [
833 'default' => Global_Colors::COLOR_TEXT,
834 ],
835 ]
836 );
837 $this->add_control(
838 'field_background_hover_color',
839 [
840 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
841 'type' => Controls_Manager::COLOR,
842 'default' => '#ffffff',
843 'selectors' => [
844 '{{WRAPPER}} .ui-e-field-group:hover:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'background-color: {{VALUE}};',
845 '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field-select select' => 'background-color: {{VALUE}};',
846 ],
847 ]
848 );
849 $this->add_group_control(
850 Group_Control_Border::get_type(),
851 [
852 'name' => 'field_hover_border',
853 'selector' =>
854 '{{WRAPPER}} .ui-e-field-group:hover:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select),
855 {{WRAPPER}} .ui-e-field-group:hover .ui-e-field-select select',
856 ]
857 );
858
859 $this->end_controls_tab();
860
861 $this->start_controls_tab(
862 'field_active_tab',
863 [
864 'label' => esc_html__( 'Active', 'uicore-elements' ),
865 ]
866 );
867
868 $this->add_control(
869 'field_text_active_color',
870 [
871 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
872 'type' => Controls_Manager::COLOR,
873 'selectors' => [
874 '{{WRAPPER}} .ui-e-field-group .ui-e-field:focus' => 'color: {{VALUE}};',
875 ],
876 'global' => [
877 'default' => Global_Colors::COLOR_TEXT,
878 ],
879 ]
880 );
881 $this->add_control(
882 'field_background_active_color',
883 [
884 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
885 'type' => Controls_Manager::COLOR,
886 'default' => '#ffffff',
887 'selectors' => [
888 '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:focus:not(.ui-e-field-select)' => 'background-color: {{VALUE}};',
889 '{{WRAPPER}} .ui-e-field-group .ui-e-field-select:focus select' => 'background-color: {{VALUE}};',
890 ],
891 ]
892 );
893 $this->add_group_control(
894 Group_Control_Border::get_type(),
895 [
896 'name' => 'field_active_border',
897 'selector' =>
898 '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:focus:not(.ui-e-field-select),
899 {{WRAPPER}} .ui-e-field-group .ui-e-field-select:focus select',
900 ]
901 );
902
903 $this->end_controls_tab();
904
905 $this->end_controls_tabs();
906
907 $this->add_control(
908 'field_border_radius',
909 [
910 'label' => esc_html__( 'Border Radius', 'uicore-elements' ),
911 'type' => Controls_Manager::DIMENSIONS,
912 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
913 'selectors' => [
914 '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
915 '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
916 ],
917 'separator' => 'before'
918 ]
919 );
920 $this->add_responsive_control(
921 'field_padding',
922 [
923 'label' => esc_html__( 'Padding', 'uicore-elements' ),
924 'type' => Controls_Manager::DIMENSIONS,
925 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
926 'selectors' => [
927 '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
928 '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
929 ],
930 ]
931 );
932 if($section){
933 $this->end_controls_section();
934 }
935 }
936 function TRAIT_register_button_style_controls($section = true)
937 {
938 if($section){
939 $this->start_controls_section(
940 'section_button_style',
941 [
942 'label' => esc_html__( 'Button', 'uicore-elements' ),
943 'tab' => Controls_Manager::TAB_STYLE,
944 ]
945 );
946 }
947
948 $this->add_group_control(
949 Group_Control_Typography::get_type(),
950 [
951 'name' => 'button_typography',
952 'global' => [
953 'default' => Global_Typography::TYPOGRAPHY_ACCENT,
954 ],
955 'selector' => '{{WRAPPER}} .elementor-button',
956 ]
957 );
958 $this->add_group_control(
959 Group_Control_Border::get_type(), [
960 'name' => 'button_border',
961 'selector' => '{{WRAPPER}} .elementor-button',
962 'exclude' => [
963 'color',
964 ],
965 ]
966 );
967
968 $this->start_controls_tabs( 'tabs_button_style' );
969
970 $this->start_controls_tab(
971 'tab_button_normal',
972 [
973 'label' => esc_html__( 'Normal', 'uicore-elements' ),
974 ]
975 );
976
977 $this->add_control(
978 'button_background_color',
979 [
980 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
981 'type' => Controls_Manager::COLOR,
982 'global' => [
983 'default' => Global_Colors::COLOR_ACCENT,
984 ],
985 'selectors' => [
986 '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'background-color: {{VALUE}};',
987 '{{WRAPPER}} .elementor-button[type="submit"]' => 'background-color: {{VALUE}};',
988 ],
989 ]
990 );
991 $this->add_control(
992 'button_text_color',
993 [
994 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
995 'type' => Controls_Manager::COLOR,
996 'default' => '#ffffff',
997 'selectors' => [
998 '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'color: {{VALUE}};',
999 '{{WRAPPER}} .elementor-button[type="submit"]' => 'color: {{VALUE}};',
1000 '{{WRAPPER}} .elementor-button[type="submit"] svg *' => 'fill: {{VALUE}};',
1001 ],
1002 ]
1003 );
1004 $this->add_control(
1005 'button_border_color',
1006 [
1007 'label' => esc_html__( 'Border Color', 'uicore-elements' ),
1008 'type' => Controls_Manager::COLOR,
1009 'default' => '',
1010 'selectors' => [
1011 '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'border-color: {{VALUE}};',
1012 '{{WRAPPER}} .elementor-button[type="submit"]' => 'border-color: {{VALUE}};',
1013 ],
1014 'condition' => [
1015 'button_border_border!' => '',
1016 ],
1017 ]
1018 );
1019
1020 $this->end_controls_tab();
1021
1022 $this->start_controls_tab(
1023 'tab_button_hover',
1024 [
1025 'label' => esc_html__( 'Hover', 'uicore-elements' ),
1026 ]
1027 );
1028
1029 $this->add_control(
1030 'button_background_hover_color',
1031 [
1032 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
1033 'type' => Controls_Manager::COLOR,
1034 'default' => '',
1035 'selectors' => [
1036 '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'background-color: {{VALUE}};',
1037 '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'background-color: {{VALUE}};',
1038 ],
1039 ]
1040 );
1041 $this->add_control(
1042 'button_hover_color',
1043 [
1044 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
1045 'type' => Controls_Manager::COLOR,
1046 'default' => '#ffffff',
1047 'selectors' => [
1048 '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'color: {{VALUE}};',
1049 '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'color: {{VALUE}};',
1050 '{{WRAPPER}} .elementor-button[type="submit"]:hover svg *' => 'fill: {{VALUE}};',
1051 ],
1052 ]
1053 );
1054 $this->add_control(
1055 'button_hover_border_color',
1056 [
1057 'label' => esc_html__( 'Border Color', 'uicore-elements' ),
1058 'type' => Controls_Manager::COLOR,
1059 'default' => '',
1060 'selectors' => [
1061 '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'border-color: {{VALUE}};',
1062 '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'border-color: {{VALUE}};',
1063 ],
1064 'condition' => [
1065 'button_border_border!' => '',
1066 ],
1067 ]
1068 );
1069 $this->add_control(
1070 'hover_transition_duration',
1071 [
1072 'label' => esc_html__( 'Transition Duration', 'uicore-elements' ),
1073 'type' => Controls_Manager::SLIDER,
1074 'size_units' => [ 's', 'ms', 'custom' ],
1075 'default' => [
1076 'unit' => 'ms',
1077 ],
1078 'selectors' => [
1079 '{{WRAPPER}} .e-form__buttons__wrapper__button-previous' => 'transition-duration: {{SIZE}}{{UNIT}};',
1080 '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'transition-duration: {{SIZE}}{{UNIT}};',
1081 '{{WRAPPER}} .elementor-button[type="submit"] svg *' => 'transition-duration: {{SIZE}}{{UNIT}};',
1082 '{{WRAPPER}} .elementor-button[type="submit"]' => 'transition-duration: {{SIZE}}{{UNIT}};',
1083 ],
1084 ]
1085 );
1086 $this->add_control(
1087 'button_hover_animation',
1088 [
1089 'label' => esc_html__( 'Animation', 'uicore-elements' ),
1090 'type' => Controls_Manager::HOVER_ANIMATION,
1091 ]
1092 );
1093
1094 $this->end_controls_tab();
1095
1096 $this->end_controls_tabs();
1097
1098 $this->add_control(
1099 'button_border_radius',
1100 [
1101 'label' => esc_html__( 'Border Radius', 'uicore-elements' ),
1102 'type' => Controls_Manager::DIMENSIONS,
1103 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
1104 'selectors' => [
1105 '{{WRAPPER}} .elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1106 ],
1107 'separator' => 'before',
1108 ]
1109 );
1110
1111 $this->add_control(
1112 'button_text_padding',
1113 [
1114 'label' => esc_html__( 'Text Padding', 'uicore-elements' ),
1115 'type' => Controls_Manager::DIMENSIONS,
1116 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
1117 'selectors' => [
1118 '{{WRAPPER}} .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1119 ],
1120 ]
1121 );
1122
1123 if($section){
1124 $this->end_controls_section();
1125 }
1126 }
1127 function TRAIT_register_messages_style_controls($section = true)
1128 {
1129 if($section){
1130 $this->start_controls_section(
1131 'section_messages_style',
1132 [
1133 'label' => esc_html__( 'Messages', 'uicore-elements' ),
1134 'tab' => Controls_Manager::TAB_STYLE,
1135 ]
1136 );
1137 }
1138
1139 $this->add_control(
1140 'show_messages',
1141 [
1142 'label' => esc_html__( 'Show/Hide messages', 'uicore-elements' ),
1143 'type' => Controls_Manager::BUTTON,
1144 'separator' => 'before',
1145 'text' => esc_html__( 'Toggle', 'uicore-elements' ),
1146 'event' => 'ui-e-form-show-messages',
1147 ]
1148 );
1149 $this->add_group_control(
1150 Group_Control_Typography::get_type(),
1151 [
1152 'name' => 'message_typography',
1153 'global' => [
1154 'default' => Global_Typography::TYPOGRAPHY_TEXT,
1155 ],
1156 'selector' => '{{WRAPPER}} .ui-e-message',
1157 ]
1158 );
1159 $this->add_control(
1160 'success_message_color',
1161 [
1162 'label' => esc_html__( 'Success Message Color', 'uicore-elements' ),
1163 'type' => Controls_Manager::COLOR,
1164 'default' => '#4CAF50',
1165 'selectors' => [
1166 '{{WRAPPER}} .ui-e-message span.success' => 'color: {{COLOR}};',
1167 ],
1168 ]
1169 );
1170 $this->add_control(
1171 'error_message_color',
1172 [
1173 'label' => esc_html__( 'Error Message Color', 'uicore-elements' ),
1174 'type' => Controls_Manager::COLOR,
1175 'default' => '#F44336',
1176 'selectors' => [
1177 '{{WRAPPER}} .ui-e-message span.error' => 'color: {{COLOR}};',
1178 ],
1179 ]
1180 );
1181
1182 if($section){
1183 $this->end_controls_section();
1184 }
1185 }
1186 function TRAIT_register_all_form_style_controls()
1187 {
1188 $this->TRAIT_register_form_style_controls();
1189 $this->TRAIT_register_fields_style_controls();
1190 $this->TRAIT_register_button_style_controls();
1191 $this->TRAIT_register_messages_style_controls();
1192 }
1193
1194 // Helper and Utility Functions
1195 function TRAIT_get_width_values()
1196 {
1197 return [
1198 '' => esc_html__( 'Default', 'uicore-elements' ),
1199 '100' => '100%',
1200 '80' => '80%',
1201 '75' => '75%',
1202 '70' => '70%',
1203 '66' => '66%',
1204 '60' => '60%',
1205 '50' => '50%',
1206 '40' => '40%',
1207 '33' => '33%',
1208 '30' => '30%',
1209 '25' => '25%',
1210 '20' => '20%',
1211 ];
1212 }
1213 function TRAIT_recaptcha_key_js()
1214 {
1215 ?>
1216 <script>
1217 window.uicore_elements_recaptcha = '<?php echo get_option('uicore_elements_recaptcha_site_key'); ?>';
1218 </script>
1219 <?php
1220 }
1221 }