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/contact-form.php +1400 -2460 1.0.10 → 1.3.18 View file →
@@ -1,2460 +1,1400 @@
1 -<?php
2 -namespace UiCoreElements;
3 -
4 -use UiCoreElements\Helper;
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 -use Elementor\Repeater;
11 -use Elementor\Group_Control_Typography;
12 -use Elementor\Group_Control_Border;
13 -use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
14 -use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
15 -
16 -
17 -defined('ABSPATH') || exit();
18 -
19 -/**
20 - * Contact Form
21 - *
22 - * @author Lucas Marini Falbo <[email protected]>
23 - * @since 1.0.5
24 - */
25 -
26 -class ContactForm extends UiCoreWidget {
27 -
28 - use Form_Component;
29 -
30 - public function get_name() {
31 - return 'uicore-contact-form';
32 - }
33 -
34 - public function get_title() {
35 - return __( 'Contact Form', 'uicore-elements' );
36 - }
37 -
38 - public function get_icon() {
39 - return 'eicon-form-horizontal ui-e-widget';
40 - }
41 - public function get_categories()
42 - {
43 - return ['uicore'];
44 - }
45 - public function get_keywords() {
46 - return [ 'form', 'forms', 'contact', 'mail', 'send', 'field', 'button', 'recaptcha', ];
47 - }
48 - public function get_styles()
49 - {
50 - return ['contact-form'];
51 - }
52 - public function get_scripts()
53 - {
54 - return [
55 - 'contact-form',
56 - 'recaptcha' => [
57 - 'custom_condition' => $this->check_recaptcha_version('v2')
58 - ],
59 - 'recaptcha-v3' => [
60 - 'custom_condition' => $this->check_recaptcha_version('v3')
61 - ],
62 - 'repeater-custom-key' => [
63 - 'custom_condition' => $this->is_edit_mode()
64 - ]
65 - ];
66 - }
67 - function check_recaptcha_version($version)
68 - {
69 -
70 - if($this->is_edit_mode()){
71 - return true;
72 - }
73 - $settings = $this->get_settings_for_display();
74 - foreach ($settings['form_fields'] as $field) {
75 - $version_to_check = $version === 'v2' ? 'recaptcha' : 'recaptcha_v3';
76 - if($field['field_type'] === $version_to_check){
77 - return true;
78 - }
79 - }
80 - return false;
81 - }
82 -
83 - // Helper Functions
84 - function get_field_types()
85 - {
86 - return [
87 - 'text' => esc_html__( 'Text', 'uicore-elements' ),
88 - 'email' => esc_html__( 'Email', 'uicore-elements' ),
89 - 'textarea' => esc_html__( 'Textarea', 'uicore-elements' ),
90 - 'url' => esc_html__( 'URL', 'uicore-elements' ),
91 - 'tel' => esc_html__( 'Tel', 'uicore-elements' ),
92 - 'radio' => esc_html__( 'Radio', 'uicore-elements' ),
93 - 'select' => esc_html__( 'Select', 'uicore-elements' ),
94 - 'checkbox' => esc_html__( 'Checkbox', 'uicore-elements' ),
95 - 'acceptance' => esc_html__( 'Acceptance', 'uicore-elements' ),
96 - 'number' => esc_html__( 'Number', 'uicore-elements' ),
97 - 'date' => esc_html__( 'Date', 'uicore-elements' ),
98 - 'time' => esc_html__( 'Time', 'uicore-elements' ),
99 - 'file' => esc_html__( 'File Upload', 'uicore-elements' ),
100 - 'password' => esc_html__( 'Password', 'uicore-elements' ),
101 - 'address' => esc_html__( 'Honeypot', 'uicore-elements' ),
102 - 'recaptcha' => esc_html__( 'reCAPTCHA', 'uicore-elements' ),
103 - 'recaptcha_v3' => esc_html__( 'reCAPTCHA V3', 'uicore-elements' ),
104 - 'html' => esc_html__( 'HTML', 'uicore-elements' ),
105 - 'hidden' => esc_html__( 'Hidden', 'uicore-elements' ),
106 - ];
107 - }
108 -
109 - function get_attribute_name( $item ) {
110 - return "form_fields[{$item['custom_id']}]";
111 - }
112 - function get_attribute_id( $item ) {
113 - return 'form-field-' . $item['custom_id'];
114 - }
115 - function add_required_attribute( $element ) {
116 - $this->add_render_attribute( $element, 'required', 'required' );
117 - $this->add_render_attribute( $element, 'aria-required', 'true' );
118 - }
119 -
120 - // Control Render Functions
121 - function register_submit_email_controls($instance, $slug = '') {
122 - $instance->add_control(
123 - 'email_to' . $slug,
124 - [
125 - 'label' => esc_html__( 'To', 'uicore-elements' ),
126 - 'type' => Controls_Manager::TEXT,
127 - 'default' => get_option( 'admin_email' ),
128 - 'ai' => [
129 - 'active' => false,
130 - ],
131 - 'placeholder' => get_option( 'admin_email' ),
132 - 'label_block' => true,
133 - 'title' => esc_html__( 'Separate emails with commas', 'uicore-elements' ),
134 - 'render_type' => 'none',
135 - 'dynamic' => [
136 - 'active' => true,
137 - ],
138 - ]
139 - );
140 -
141 - /* translators: %s: Site title. */
142 - $default_message = sprintf( html_entity_decode( esc_html__( 'New message from "%s"', 'uicore-elements' ) ), get_option( 'blogname' ) );
143 -
144 - $instance->add_control(
145 - 'email_subject' . $slug,
146 - [
147 - 'label' => esc_html__( 'Subject', 'uicore-elements' ),
148 - 'type' => Controls_Manager::TEXT,
149 - 'default' => $default_message,
150 - 'ai' => [
151 - 'active' => false,
152 - ],
153 - 'placeholder' => $default_message,
154 - 'label_block' => true,
155 - 'render_type' => 'none',
156 - 'dynamic' => [
157 - 'active' => true,
158 - ],
159 - ]
160 - );
161 -
162 - $instance->add_control(
163 - 'email_content' . $slug,
164 - [
165 - 'label' => esc_html__( 'Message', 'uicore-elements' ),
166 - 'type' => Controls_Manager::TEXTAREA,
167 - 'default' => '[all-fields]',
168 - 'ai' => [
169 - 'active' => false,
170 - ],
171 - 'placeholder' => '[all-fields]',
172 - 'description' => sprintf(
173 - /* translators: %s: The [all-fields] shortcode. */
174 - 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' ),
175 - '<code>[all-fields]</code>'
176 - ),
177 - 'render_type' => 'none',
178 - 'dynamic' => [
179 - 'active' => true,
180 - ],
181 - ]
182 - );
183 -
184 - $site_domain = Helper::get_site_domain();
185 -
186 - $instance->add_control(
187 - 'email_from' . $slug,
188 - [
189 - 'label' => esc_html__( 'From Email', 'uicore-elements' ),
190 - 'type' => Controls_Manager::TEXT,
191 - 'default' => 'email@' . $site_domain,
192 - 'ai' => [
193 - 'active' => false,
194 - ],
195 - 'render_type' => 'none',
196 - 'dynamic' => [
197 - 'active' => true,
198 - ],
199 - ]
200 - );
201 -
202 - $instance->add_control(
203 - 'email_from_name' . $slug,
204 - [
205 - 'label' => esc_html__( 'From Name', 'uicore-elements' ),
206 - 'type' => Controls_Manager::TEXT,
207 - 'default' => get_bloginfo( 'name' ),
208 - 'ai' => [
209 - 'active' => false,
210 - ],
211 - 'render_type' => 'none',
212 - 'dynamic' => [
213 - 'active' => true,
214 - ],
215 - ]
216 - );
217 -
218 - $instance->add_control(
219 - 'email_reply_to' . $slug,
220 - [
221 - 'label' => esc_html__( 'Reply-To', 'uicore-elements' ),
222 - 'type' => Controls_Manager::TEXT,
223 - 'options' => [
224 - '' => '',
225 - ],
226 - 'default' => 'noreply@' . Helper::get_site_domain(),
227 - 'render_type' => 'none',
228 - ]
229 - );
230 -
231 - $instance->add_control(
232 - 'email_to_cc' . $slug,
233 - [
234 - 'label' => esc_html__( 'Cc', 'uicore-elements' ),
235 - 'type' => Controls_Manager::TEXT,
236 - 'default' => '',
237 - 'ai' => [
238 - 'active' => false,
239 - ],
240 - 'title' => esc_html__( 'Separate emails with commas', 'uicore-elements' ),
241 - 'render_type' => 'none',
242 - 'dynamic' => [
243 - 'active' => true,
244 - ],
245 - ]
246 - );
247 -
248 - $instance->add_control(
249 - 'email_to_bcc' . $slug,
250 - [
251 - 'label' => esc_html__( 'Bcc', 'uicore-elements' ),
252 - 'type' => Controls_Manager::TEXT,
253 - 'default' => '',
254 - 'ai' => [
255 - 'active' => false,
256 - ],
257 - 'title' => esc_html__( 'Separate emails with commas', 'uicore-elements' ),
258 - 'render_type' => 'none',
259 - 'dynamic' => [
260 - 'active' => true,
261 - ],
262 - ]
263 - );
264 -
265 - $instance->add_control(
266 - 'form_metadata' . $slug,
267 - [
268 - 'label' => esc_html__( 'Meta Data', 'uicore-elements' ),
269 - 'type' => Controls_Manager::SELECT2,
270 - 'multiple' => true,
271 - 'label_block' => true,
272 - 'separator' => 'before',
273 - 'default' => [
274 - 'date',
275 - 'time',
276 - 'page_url',
277 - 'user_agent',
278 - 'remote_ip',
279 - ],
280 - 'options' => [
281 - 'date' => esc_html__( 'Date', 'uicore-elements' ),
282 - 'time' => esc_html__( 'Time', 'uicore-elements' ),
283 - 'page_url' => esc_html__( 'Page URL', 'uicore-elements' ),
284 - 'user_agent' => esc_html__( 'User Agent', 'uicore-elements' ),
285 - 'remote_ip' => esc_html__( 'Remote IP', 'uicore-elements' ),
286 - ],
287 - 'render_type' => 'none',
288 - ]
289 - );
290 -
291 - $instance->add_control(
292 - 'email_content_type' . $slug,
293 - [
294 - 'label' => esc_html__( 'Send As', 'uicore-elements' ),
295 - 'type' => Controls_Manager::SELECT,
296 - 'default' => 'html',
297 - 'render_type' => 'none',
298 - 'options' => [
299 - 'html' => esc_html__( 'HTML', 'uicore-elements' ),
300 - 'plain' => esc_html__( 'Plain', 'uicore-elements' ),
301 - ],
302 - ]
303 - );
304 - }
305 -
306 - // Field Render Functions
307 - function build_honeypot_field( $item, $item_index ) {
308 - $this->add_render_attribute( 'honeypot' . $item_index, [
309 - 'class' => [
310 - 'ui-e-field',
311 - 'ui-e-h-p',
312 - esc_attr( $item['css_classes'] ),
313 - ],
314 - 'name' => 'ui-e-h-p',
315 - 'id' => 'ui-e-h-p',
316 - 'autocomplete' => 'off',
317 - ] );
318 -
319 - if ( $item['placeholder'] ) {
320 - $this->add_render_attribute( 'honeypot' . $item_index, 'placeholder', $item['placeholder'] );
321 - }
322 -
323 - if ( $item['required'] ) {
324 - $this->add_required_attribute( 'honeypot' . $item_index );
325 - }
326 -
327 - $value = empty( $item['field_value'] ) ? '' : $item['field_value'];
328 -
329 - return '<input ' . $this->get_render_attribute_string( 'honeypot' . $item_index ) . ' tabindex="-1">' . $value . '</input>';
330 - }
331 - function build_textarea_field( $item, $item_index ) {
332 - $this->add_render_attribute( 'textarea' . $item_index, [
333 - 'class' => [
334 - 'ui-e-field',
335 - esc_attr( $item['css_classes'] ),
336 - ],
337 - 'name' => $this->get_attribute_name( $item ),
338 - 'id' => $this->get_attribute_id( $item ),
339 - 'rows' => $item['rows'],
340 - ] );
341 -
342 - if ( $item['placeholder'] ) {
343 - $this->add_render_attribute( 'textarea' . $item_index, 'placeholder', $item['placeholder'] );
344 - }
345 -
346 - if ( $item['required'] ) {
347 - $this->add_required_attribute( 'textarea' . $item_index );
348 - }
349 -
350 - $value = empty( $item['field_value'] ) ? '' : $item['field_value'];
351 -
352 - return '<textarea ' . $this->get_render_attribute_string( 'textarea' . $item_index ) . '>' . $value . '</textarea>';
353 - }
354 - function build_select_field( $item, $i ) {
355 - $this->add_render_attribute(
356 - [
357 - 'select-wrapper' . $i => [
358 - 'class' => [
359 - 'ui-e-field',
360 - 'ui-e-field-select',
361 - 'ui-e-field-subgroup',
362 - esc_attr( $item['css_classes'] ),
363 - ],
364 - ],
365 - 'select' . $i => [
366 - 'name' => $this->get_attribute_name( $item ) . ( ! empty( $item['allow_multiple'] ) ? '[]' : '' ),
367 - 'id' => $this->get_attribute_id( $item ),
368 - 'class' => [
369 - 'ui-e-field-textual',
370 - ],
371 - ],
372 - ]
373 - );
374 -
375 - if ( $item['required'] ) {
376 - $this->add_required_attribute( 'select' . $i );
377 - }
378 -
379 - if ( $item['allow_multiple'] ) {
380 - $this->add_render_attribute( 'select' . $i, 'multiple' );
381 - if ( ! empty( $item['select_size'] ) ) {
382 - $this->add_render_attribute( 'select' . $i, 'size', $item['select_size'] );
383 - }
384 - }
385 -
386 - $options = preg_split( "/\\r\\n|\\r|\\n/", $item['field_options'] );
387 -
388 - if ( ! $options ) {
389 - return '';
390 - }
391 -
392 - ob_start();
393 - ?>
394 - <div <?php $this->print_render_attribute_string( 'select-wrapper' . $i ); ?>>
395 - <select <?php $this->print_render_attribute_string( 'select' . $i ); ?>>
396 - <?php
397 - foreach ( $options as $key => $option ) {
398 - $option_id = $item['custom_id'] . $key;
399 - $option_value = esc_attr( $option );
400 - $option_label = esc_html( $option );
401 -
402 - if ( false !== strpos( $option, '|' ) ) {
403 - list( $label, $value ) = explode( '|', $option );
404 - $option_value = esc_attr( $value );
405 - $option_label = esc_html( $label );
406 - }
407 -
408 - $this->add_render_attribute( $option_id, 'value', $option_value );
409 -
410 - // Support multiple selected values
411 - if ( ! empty( $item['field_value'] ) && in_array( $option_value, explode( ',', $item['field_value'] ) ) ) {
412 - $this->add_render_attribute( $option_id, 'selected', 'selected' );
413 - } ?>
414 - <option <?php $this->print_render_attribute_string( $option_id ); ?>><?php
415 - // PHPCS - $option_label is already escaped
416 - echo $option_label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></option>
417 - <?php } ?>
418 - </select>
419 - </div>
420 - <?php
421 -
422 - $select = ob_get_clean();
423 - return $select;
424 - }
425 - function build_radio_checkbox_field( $item, $item_index, $type ) {
426 - $options = preg_split( "/\\r\\n|\\r|\\n/", $item['field_options'] );
427 - $html = '';
428 - if ( $options ) {
429 - $html .= '<div class="ui-e-field-subgroup ' . esc_attr( $item['css_classes'] ) . ' ' . $item['inline_list'] . '">';
430 - foreach ( $options as $key => $option ) {
431 - $element_id = $item['custom_id'] . $key;
432 - $html_id = $this->get_attribute_id( $item ) . '-' . $key;
433 - $option_label = $option;
434 - $option_value = $option;
435 - if ( false !== strpos( $option, '|' ) ) {
436 - list( $option_label, $option_value ) = explode( '|', $option );
437 - }
438 -
439 - $this->add_render_attribute(
440 - $element_id,
441 - [
442 - 'type' => $type,
443 - 'value' => $option_value,
444 - 'id' => $html_id,
445 - 'name' => $this->get_attribute_name( $item ) . ( ( 'checkbox' === $type && count( $options ) > 1 ) ? '[]' : '' ),
446 - ]
447 - );
448 -
449 - if ( ! empty( $item['field_value'] ) && $option_value === $item['field_value'] ) {
450 - $this->add_render_attribute( $element_id, 'checked', 'checked' );
451 - }
452 -
453 - if ( $item['required'] && 'radio' === $type ) {
454 - $this->add_required_attribute( $element_id );
455 - }
456 -
457 - $html .= '<span class="ui-e-field-option"><input ' . $this->get_render_attribute_string( $element_id ) . '> <label for="' . $html_id . '">' . $option_label . '</label></span>';
458 - }
459 - $html .= '</div>';
460 - }
461 -
462 - return $html;
463 - }
464 - function build_acceptance_field($item, $item_index) {
465 - $text = '';
466 - $this->add_render_attribute( 'input' . $item_index, 'class', 'ui-e-acceptance-field' );
467 - $this->add_render_attribute( 'input' . $item_index, 'type', 'checkbox', true );
468 -
469 - if ( ! empty( $item['acceptance_text'] ) ) {
470 - $text = '<label for="' . $this->get_attribute_id( $item ) . '">' . $item['acceptance_text'] . '</label>';
471 - }
472 -
473 - if ( ! empty( $item['checked_by_default'] ) ) {
474 - $this->add_render_attribute( 'input' . $item_index, 'checked', 'checked' );
475 - }
476 -
477 - ?>
478 - <div class="ui-e-field-subgroup <?php echo esc_attr( $item['css_classes'] );?>">
479 - <input <?php $this->print_render_attribute_string( 'input' . $item_index ); ?>>
480 - <?php // PHPCS - the variables $text is safe.
481 - echo $text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
482 - </div>
483 - <?php
484 - }
485 - function form_fields_render_attributes( $i, $instance, $item ) {
486 - $this->add_render_attribute(
487 - [
488 - 'field-group' . $i => [
489 - 'class' => [
490 - 'ui-e-field-type-' . $item['field_type'],
491 - 'ui-e-field-group',
492 - 'elementor-column',
493 - 'ui-e-field-group-' . $item['custom_id'],
494 - ],
495 - ],
496 - 'input' . $i => [
497 - 'type' => $item['field_type'],
498 - 'name' => $this->get_attribute_name( $item ),
499 - 'id' => $this->get_attribute_id( $item ),
500 - 'class' => [
501 - 'ui-e-field',
502 - empty( $item['css_classes'] ) ? '' : esc_attr( $item['css_classes'] ),
503 - ],
504 - ],
505 - 'label' . $i => [
506 - 'for' => $this->get_attribute_id( $item ),
507 - 'class' => 'ui-e-label',
508 - ],
509 - ]
510 - );
511 -
512 - if ( empty( $item['width'] ) ) {
513 - $item['width'] = '100';
514 - }
515 -
516 - $this->add_render_attribute( 'field-group' . $i, 'class', 'elementor-col-' . $item['width'] );
517 -
518 - if ( ! empty( $item['width_tablet'] ) ) {
519 - $this->add_render_attribute( 'field-group' . $i, 'class', 'elementor-md-' . $item['width_tablet'] );
520 - }
521 -
522 - if ( $item['allow_multiple'] ) {
523 - $this->add_render_attribute( 'field-group' . $i, 'class', 'ui-e-field-type-' . $item['field_type'] . '-multiple' );
524 - }
525 -
526 - if ( ! empty( $item['width_mobile'] ) ) {
527 - $this->add_render_attribute( 'field-group' . $i, 'class', 'elementor-sm-' . $item['width_mobile'] );
528 - }
529 -
530 - // Allow zero as placeholder.
531 - if ( ! Utils::is_empty( $item['placeholder'] ) ) {
532 - $this->add_render_attribute( 'input' . $i, 'placeholder', $item['placeholder'] );
533 - }
534 -
535 - if ( ! empty( $item['field_value'] ) ) {
536 - $this->add_render_attribute( 'input' . $i, 'value', $item['field_value'] );
537 - }
538 -
539 - if ( ! $instance['show_labels'] ) {
540 - $this->add_render_attribute( 'label' . $i, 'class', 'elementor-screen-only' );
541 - }
542 -
543 - if ( ! empty( $item['required'] ) ) {
544 - $class = '';
545 - if ( ! empty( $instance['mark_required'] ) ) {
546 - $class .= ' ui-e-required';
547 - }
548 - $this->add_render_attribute( 'field-group' . $i, 'class', $class );
549 - $this->add_required_attribute( 'input' . $i );
550 - }
551 - }
552 -
553 - protected function register_controls() {
554 -
555 - // Content Controls
556 - // Repeater Controls used by `form_fields` control
557 - $repeater = new Repeater();
558 - $repeater->start_controls_tabs( 'form_fields_tabs' );
559 -
560 - $repeater->start_controls_tab(
561 - 'form_fields_content_tab',
562 - [
563 - 'label' => esc_html__( 'Content', 'uicore-elements' ),
564 - ]
565 - );
566 -
567 - $repeater->add_control(
568 - 'field_type',
569 - [
570 - 'label' => esc_html__( 'Type', 'uicore-elements' ),
571 - 'type' => Controls_Manager::SELECT,
572 - 'options' => $this->get_field_types(),
573 - 'default' => 'text',
574 - ]
575 - );
576 - $repeater->add_control(
577 - 'field_label',
578 - [
579 - 'label' => esc_html__( 'Label', 'uicore-elements' ),
580 - 'type' => Controls_Manager::TEXT,
581 - 'default' => '',
582 - 'dynamic' => [
583 - 'active' => true,
584 - ],
585 - ]
586 - );
587 - $repeater->add_control(
588 - 'placeholder',
589 - [
590 - 'label' => esc_html__( 'Placeholder', 'uicore-elements' ),
591 - 'type' => Controls_Manager::TEXT,
592 - 'default' => '',
593 - 'conditions' => [
594 - 'terms' => [
595 - [
596 - 'name' => 'field_type',
597 - 'operator' => 'in',
598 - 'value' => [
599 - 'tel',
600 - 'text',
601 - 'email',
602 - 'textarea',
603 - 'number',
604 - 'url',
605 - 'password',
606 - ],
607 - ],
608 - ],
609 - ],
610 - 'dynamic' => [
611 - 'active' => true,
612 - ],
613 - ]
614 - );
615 - $repeater->add_control(
616 - 'required',
617 - [
618 - 'label' => esc_html__( 'Required', 'uicore-elements' ),
619 - 'type' => Controls_Manager::SWITCHER,
620 - 'return_value' => 'true',
621 - 'default' => '',
622 - 'conditions' => [
623 - 'terms' => [
624 - [
625 - 'name' => 'field_type',
626 - 'operator' => '!in',
627 - 'value' => [
628 - 'checkbox',
629 - 'recaptcha',
630 - 'recaptcha_v3',
631 - 'hidden',
632 - 'html',
633 - ],
634 - ],
635 - ],
636 - ],
637 - ]
638 - );
639 - $repeater->add_control(
640 - 'field_options',
641 - [
642 - 'label' => esc_html__( 'Options', 'uicore-elements' ),
643 - 'type' => Controls_Manager::TEXTAREA,
644 - 'default' => '',
645 - 'description' => esc_html__( 'Enter each option in a separate line. To differentiate between label and value, separate them with a pipe char ("|"). For example: First Name|f_name', 'uicore-elements' ),
646 - 'conditions' => [
647 - 'terms' => [
648 - [
649 - 'name' => 'field_type',
650 - 'operator' => 'in',
651 - 'value' => [
652 - 'select',
653 - 'checkbox',
654 - 'radio',
655 - ],
656 - ],
657 - ],
658 - ],
659 - ]
660 - );
661 - $repeater->add_control(
662 - 'allow_multiple',
663 - [
664 - 'label' => esc_html__( 'Multiple Selection', 'uicore-elements' ),
665 - 'type' => Controls_Manager::SWITCHER,
666 - 'return_value' => 'true',
667 - 'conditions' => [
668 - 'terms' => [
669 - [
670 - 'name' => 'field_type',
671 - 'value' => 'select',
672 - ],
673 - ],
674 - ],
675 - ]
676 - );
677 - $repeater->add_control(
678 - 'select_size',
679 - [
680 - 'label' => esc_html__( 'Rows', 'uicore-elements' ),
681 - 'type' => Controls_Manager::NUMBER,
682 - 'min' => 2,
683 - 'step' => 1,
684 - 'conditions' => [
685 - 'terms' => [
686 - [
687 - 'name' => 'field_type',
688 - 'value' => 'select',
689 - ],
690 - [
691 - 'name' => 'allow_multiple',
692 - 'value' => 'true',
693 - ],
694 - ],
695 - ],
696 - ]
697 - );
698 - $repeater->add_control(
699 - 'inline_list',
700 - [
701 - 'label' => esc_html__( 'Inline List', 'uicore-elements' ),
702 - 'type' => Controls_Manager::SWITCHER,
703 - 'return_value' => 'ui-e-subgroup-inline',
704 - 'default' => '',
705 - 'conditions' => [
706 - 'terms' => [
707 - [
708 - 'name' => 'field_type',
709 - 'operator' => 'in',
710 - 'value' => [
711 - 'checkbox',
712 - 'radio',
713 - ],
714 - ],
715 - ],
716 - ],
717 - ]
718 - );
719 - $repeater->add_control(
720 - 'field_html',
721 - [
722 - 'label' => esc_html__( 'HTML', 'uicore-elements' ),
723 - 'type' => Controls_Manager::TEXTAREA,
724 - 'dynamic' => [
725 - 'active' => true,
726 - ],
727 - 'conditions' => [
728 - 'terms' => [
729 - [
730 - 'name' => 'field_type',
731 - 'value' => 'html',
732 - ],
733 - ],
734 - ],
735 - ]
736 - );
737 - $repeater->add_control(
738 - 'acceptance_text',
739 - [
740 - 'label' => esc_html__( 'Acceptance Text', 'uicore-elements' ),
741 - 'type' => Controls_Manager::TEXTAREA,
742 - 'condition' => [
743 - 'field_type' => 'acceptance',
744 - ],
745 - ],
746 - );
747 - $repeater->add_control(
748 - 'checked_by_default',
749 - [
750 - 'label' => esc_html__( 'Checked by Default', 'uicore-elements' ),
751 - 'type' => Controls_Manager::SWITCHER,
752 - 'condition' => [
753 - 'field_type' => 'acceptance',
754 - ],
755 - ],
756 - );
757 - $repeater->add_responsive_control(
758 - 'width',
759 - [
760 - 'label' => esc_html__( 'Column Width', 'uicore-elements' ),
761 - 'type' => Controls_Manager::SELECT,
762 - 'options' => [
763 - '' => esc_html__( 'Default', 'uicore-elements' ),
764 - '100' => '100%',
765 - '80' => '80%',
766 - '75' => '75%',
767 - '70' => '70%',
768 - '66' => '66%',
769 - '60' => '60%',
770 - '50' => '50%',
771 - '40' => '40%',
772 - '33' => '33%',
773 - '30' => '30%',
774 - '25' => '25%',
775 - '20' => '20%',
776 - ],
777 - 'default' => '100',
778 - 'conditions' => [
779 - 'terms' => [
780 - [
781 - 'name' => 'field_type',
782 - 'operator' => '!in',
783 - 'value' => [
784 - 'hidden',
785 - 'recaptcha',
786 - 'recaptcha_v3'
787 - ],
788 - ],
789 - ],
790 - ],
791 - ]
792 - );
793 - $repeater->add_control(
794 - 'rows',
795 - [
796 - 'label' => esc_html__( 'Rows', 'uicore-elements' ),
797 - 'type' => Controls_Manager::NUMBER,
798 - 'default' => 4,
799 - 'conditions' => [
800 - 'terms' => [
801 - [
802 - 'name' => 'field_type',
803 - 'value' => 'textarea',
804 - ],
805 - ],
806 - ],
807 - ]
808 - );
809 - $repeater->add_control(
810 - 'recaptcha_hide',
811 - [
812 - 'label' => esc_html__( 'Badge', 'uicore-elements' ),
813 - 'type' => Controls_Manager::SELECT,
814 - 'default' => 'hidden',
815 - 'options' => [
816 - 'hidden' => esc_html__( 'Hidden', 'uicore-elements' ),
817 - 'visible' => esc_html__( 'Visible', 'uicore-elements' )
818 - ],
819 - 'condition' => [
820 - 'field_type' => 'recaptcha_v3',
821 - ],
822 - 'selectors' => [
823 - '.grecaptcha-badge' => 'visibility: {{VALUE}};',
824 - ],
825 - ]
826 - );
827 - $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
828 - $repeater->add_control(
829 - 'recaptcha_warning',
830 - [
831 - 'type' => Controls_Manager::ALERT,
832 - 'alert_type' => 'warning',
833 - 'dismissible' => false,
834 - 'heading' => esc_html__("You haven't set your reCAPTCHA API keys yet.", 'uicore-elements'),
835 - 'content' => Helper::get_admin_settings_url(esc_html__("Click here to configure your API keys.", 'uicore-elements' )),
836 - 'condition' => [
837 - 'field_type' => $recaptcha_keys ? ['recaptcha', 'recaptcha_v3'] : [],
838 - ]
839 - ]
840 - );
841 -
842 - $repeater->end_controls_tab();
843 -
844 - $repeater->start_controls_tab(
845 - 'form_fields_advanced_tab',
846 - [
847 - 'label' => esc_html__( 'Advanced', 'uicore-elements' ),
848 - 'condition' => [
849 - 'field_type!' => ['html', 'address' ],
850 - ],
851 - ]
852 - );
853 -
854 - $repeater->add_control(
855 - 'field_value',
856 - [
857 - 'label' => esc_html__( 'Default Value', 'uicore-elements' ),
858 - 'type' => Controls_Manager::TEXT,
859 - 'default' => '',
860 - 'dynamic' => [
861 - 'active' => true,
862 - ],
863 - 'ai' => [
864 - 'active' => false,
865 - ],
866 - 'conditions' => [
867 - 'terms' => [
868 - [
869 - 'name' => 'field_type',
870 - 'operator' => 'in',
871 - 'value' => [
872 - 'text',
873 - 'email',
874 - 'textarea',
875 - 'url',
876 - 'tel',
877 - 'radio',
878 - 'select',
879 - 'number',
880 - 'date',
881 - 'time',
882 - 'hidden',
883 - ],
884 - ],
885 - ],
886 - ],
887 - ]
888 - );
889 - $repeater->add_control(
890 - 'custom_id',
891 - [
892 - 'label' => esc_html__( 'ID', 'uicore-elements' ),
893 - 'type' => Controls_Manager::TEXT,
894 - 'description' => esc_html__( 'Please make sure the ID is unique and not used elsewhere in this form. This field allows `A-z 0-9` & underscore chars without spaces.', 'uicore-elements' ),
895 - 'render_type' => 'none',
896 - 'required' => true,
897 - 'dynamic' => [
898 - 'active' => true,
899 - ],
900 - 'ai' => [
901 - 'active' => false,
902 - ],
903 - ]
904 - );
905 - $repeater->add_control(
906 - 'css_classes',
907 - [
908 - 'label' => esc_html__( 'Custom Class', 'uicore-elements' ),
909 - 'type' => Controls_Manager::TEXT,
910 - 'default' => '',
911 - 'ai' => [
912 - 'active' => false,
913 - ],
914 - 'placeholder' => esc_html__( 'e.g: my-class', 'uicore-elements' ),
915 - ]
916 - );
917 - $shortcode_template = '{{ view.container.settings.get( \'custom_id\' ) }}';
918 - $repeater->add_control(
919 - 'shortcode',
920 - [
921 - 'label' => esc_html__( 'Shortcode', 'uicore-elements' ),
922 - 'type' => Controls_Manager::RAW_HTML,
923 - 'classes' => 'forms-field-shortcode',
924 - 'raw' => '<input class="elementor-form-field-shortcode" value=\'[field id="' . $shortcode_template . '"]\' readonly />',
925 - 'label_block' => false,
926 - ]
927 - );
928 -
929 - $repeater->end_controls_tab();
930 -
931 - $repeater->end_controls_tabs();
932 -
933 - $this->start_controls_section(
934 - 'section_form_fields',
935 - [
936 - 'label' => esc_html__( 'Form Fields', 'uicore-elements' ),
937 - ]
938 - );
939 -
940 -
941 - $this->add_control(
942 - 'form_name',
943 - [
944 - 'label' => esc_html__( 'Form Name', 'uicore-elements' ),
945 - 'type' => Controls_Manager::TEXT,
946 - 'default' => esc_html__( 'New Form', 'uicore-elements' ),
947 - 'placeholder' => esc_html__( 'Form Name', 'uicore-elements' ),
948 - ]
949 - );
950 - $this->add_control(
951 - 'form_fields',
952 - [
953 - 'type' => Controls_Manager::REPEATER,
954 - 'fields' => $repeater->get_controls(),
955 - 'default' => [
956 - [
957 - 'custom_id' => 'name',
958 - 'field_type' => 'text',
959 - 'field_label' => esc_html__( 'Name', 'uicore-elements' ),
960 - 'placeholder' => esc_html__( 'Name', 'uicore-elements' ),
961 - 'width' => '100',
962 - 'dynamic' => [
963 - 'active' => true,
964 - ],
965 - ],
966 - [
967 - 'custom_id' => 'email',
968 - 'field_type' => 'email',
969 - 'required' => 'true',
970 - 'field_label' => esc_html__( 'Email', 'uicore-elements' ),
971 - 'placeholder' => esc_html__( 'Email', 'uicore-elements' ),
972 - 'width' => '100',
973 - ],
974 - [
975 - 'custom_id' => 'address',
976 - 'field_type' => 'address',
977 - 'field_label' => esc_html__( 'address (honeypot)', 'uicore-elements' ),
978 - 'placeholder' => esc_html__( 'address', 'uicore-elements' ),
979 - 'width' => '100',
980 - ],
981 - [
982 - 'custom_id' => 'message',
983 - 'field_type' => 'textarea',
984 - 'field_label' => esc_html__( 'Message', 'uicore-elements' ),
985 - 'placeholder' => esc_html__( 'Message', 'uicore-elements' ),
986 - 'width' => '100',
987 - ],
988 - ],
989 - 'title_field' => '{{{ field_label }}}',
990 - ]
991 - );
992 - $this->add_control(
993 - 'show_labels',
994 - [
995 - 'label' => esc_html__( 'Label', 'uicore-elements' ),
996 - 'type' => Controls_Manager::SWITCHER,
997 - 'label_on' => esc_html__( 'Show', 'uicore-elements' ),
998 - 'label_off' => esc_html__( 'Hide', 'uicore-elements' ),
999 - 'return_value' => 'true',
1000 - 'default' => 'true',
1001 - 'separator' => 'before',
1002 - ]
1003 - );
1004 - $this->add_control(
1005 - 'mark_required',
1006 - [
1007 - 'label' => esc_html__( 'Required Mark', 'uicore-elements' ),
1008 - 'type' => Controls_Manager::SWITCHER,
1009 - 'label_on' => esc_html__( 'Show', 'uicore-elements' ),
1010 - 'label_off' => esc_html__( 'Hide', 'uicore-elements' ),
1011 - 'default' => '',
1012 - 'render_type' => 'template',
1013 - 'condition' => [
1014 - 'show_labels!' => '',
1015 - ],
1016 - ]
1017 - );
1018 -
1019 - $this->end_controls_section();
1020 -
1021 - $this->start_controls_section(
1022 - 'section_buttons',
1023 - [
1024 - 'label' => esc_html__( 'Button', 'uicore-elements' ),
1025 - ]
1026 - );
1027 -
1028 - $this->add_responsive_control(
1029 - 'button_width',
1030 - [
1031 - 'label' => esc_html__( 'Column Width', 'uicore-elements' ),
1032 - 'type' => Controls_Manager::SELECT,
1033 - 'options' => [
1034 - '' => esc_html__( 'Default', 'uicore-elements' ),
1035 - '100' => '100%',
1036 - '80' => '80%',
1037 - '75' => '75%',
1038 - '70' => '70%',
1039 - '66' => '66%',
1040 - '60' => '60%',
1041 - '50' => '50%',
1042 - '40' => '40%',
1043 - '33' => '33%',
1044 - '30' => '30%',
1045 - '25' => '25%',
1046 - '20' => '20%',
1047 - ],
1048 - 'default' => '100',
1049 - ]
1050 - );
1051 - $this->add_responsive_control(
1052 - 'button_align',
1053 - [
1054 - 'label' => esc_html__( 'Alignment', 'uicore-elements' ),
1055 - 'type' => Controls_Manager::CHOOSE,
1056 - 'options' => [
1057 - 'left' => [
1058 - 'title' => esc_html__( 'Left', 'uicore-elements' ),
1059 - 'icon' => 'eicon-text-align-left',
1060 - ],
1061 - 'center' => [
1062 - 'title' => esc_html__( 'Center', 'uicore-elements' ),
1063 - 'icon' => 'eicon-text-align-center',
1064 - ],
1065 - 'right' => [
1066 - 'title' => esc_html__( 'Right', 'uicore-elements' ),
1067 - 'icon' => 'eicon-text-align-right',
1068 - ],
1069 - 'stretch' => [
1070 - 'title' => esc_html__( 'Justified', 'uicore-elements' ),
1071 - 'icon' => 'eicon-text-align-justify',
1072 - ],
1073 - ],
1074 - 'default' => 'stretch',
1075 - 'prefix_class' => 'ui-e-submit-align-',
1076 - ]
1077 - );
1078 - $this->add_control(
1079 - 'button_text',
1080 - [
1081 - 'label' => esc_html__( 'Submit', 'uicore-elements' ),
1082 - 'type' => Controls_Manager::TEXT,
1083 - 'default' => esc_html__( 'Send', 'uicore-elements' ),
1084 - 'placeholder' => esc_html__( 'Send', 'uicore-elements' ),
1085 - 'dynamic' => [
1086 - 'active' => true,
1087 - ],
1088 - 'ai' => [
1089 - 'active' => false,
1090 - ],
1091 - ]
1092 - );
1093 - $this->add_control(
1094 - 'selected_button_icon',
1095 - [
1096 - 'label' => esc_html__( 'Icon', 'uicore-elements' ),
1097 - 'type' => Controls_Manager::ICONS,
1098 - 'skin' => 'inline',
1099 - 'label_block' => false,
1100 - ]
1101 - );
1102 - $this->add_control(
1103 - 'button_icon_align',
1104 - [
1105 - 'label' => esc_html__( 'Icon Position', 'uicore-elements' ),
1106 - 'type' => Controls_Manager::SELECT,
1107 - 'default' => 'left',
1108 - 'options' => [
1109 - 'left' => esc_html__( 'Before', 'uicore-elements' ),
1110 - 'right' => esc_html__( 'After', 'uicore-elements' ),
1111 - ],
1112 - 'condition' => [
1113 - 'selected_button_icon[value]!' => '',
1114 - ],
1115 - ]
1116 - );
1117 - $this->add_control(
1118 - 'button_icon_indent',
1119 - [
1120 - 'label' => esc_html__( 'Icon Spacing', 'uicore-elements' ),
1121 - 'type' => Controls_Manager::SLIDER,
1122 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
1123 - 'range' => [
1124 - 'px' => [
1125 - 'max' => 100,
1126 - ],
1127 - 'em' => [
1128 - 'max' => 10,
1129 - ],
1130 - 'rem' => [
1131 - 'max' => 10,
1132 - ],
1133 - ],
1134 - 'condition' => [
1135 - 'selected_button_icon[value]!' => '',
1136 - ],
1137 - 'selectors' => [
1138 - '{{WRAPPER}} .elementor-button .ui-e-align-right' => 'margin-left: {{SIZE}}{{UNIT}};',
1139 - '{{WRAPPER}} .elementor-button .ui-e-align-left' => 'margin-right: {{SIZE}}{{UNIT}};',
1140 - ],
1141 - ]
1142 - );
1143 - $this->add_control(
1144 - 'button_css_id',
1145 - [
1146 - 'label' => esc_html__( 'Button ID', 'uicore-elements' ),
1147 - 'type' => Controls_Manager::TEXT,
1148 - 'default' => '',
1149 - 'ai' => [
1150 - 'active' => false,
1151 - ],
1152 - 'title' => esc_html__( 'Add your custom id WITHOUT the Pound key. e.g: my-id', 'uicore-elements' ),
1153 - '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' ),
1154 - 'separator' => 'before',
1155 - 'dynamic' => [
1156 - 'active' => true,
1157 - ],
1158 - ]
1159 - );
1160 -
1161 -
1162 - $this->end_controls_section();
1163 -
1164 - $this->start_controls_section(
1165 - 'section_actions',
1166 - [
1167 - 'label' => esc_html__( 'Actions After Submit', 'uicore-elements' ),
1168 - ]
1169 - );
1170 -
1171 - $this->add_control(
1172 - 'submit_actions',
1173 - [
1174 - 'label' => esc_html__( 'Submit Actions', 'uicore-elements' ),
1175 - 'type' => Controls_Manager::SELECT2,
1176 - 'label_block' => true,
1177 - 'multiple' => true,
1178 - 'options' => [
1179 - 'email' => esc_html__( 'Email', 'uicore-elements' ),
1180 - 'email_2' => esc_html__( 'Email 2', 'uicore-elements' ),
1181 - 'redirect' => esc_html__( 'Redirect', 'uicore-elements' ),
1182 - 'mailchimp' => esc_html__( 'MailChimp', 'uicore-elements' ),
1183 - ],
1184 - 'default' => [ 'email' ],
1185 - ]
1186 - );
1187 -
1188 - $this->end_controls_section();
1189 -
1190 - // Submit sections
1191 - $this->start_controls_section(
1192 - 'section_email',
1193 - [
1194 - 'label' => esc_html__( 'Email', 'uicore-elements' ),
1195 - 'condition' => [
1196 - 'submit_actions' => 'email',
1197 - ],
1198 - ]
1199 - );
1200 -
1201 - $this->register_submit_email_controls($this);
1202 -
1203 - $this->end_controls_section();
1204 -
1205 - $this->start_controls_section(
1206 - 'section_email_2',
1207 - [
1208 - 'label' => esc_html__( 'Email 2', 'uicore-elements' ),
1209 - 'condition' => [
1210 - 'submit_actions' => 'email_2',
1211 - ],
1212 - ]
1213 - );
1214 -
1215 - $this->register_submit_email_controls($this, '_2');
1216 -
1217 - $this->end_controls_section();
1218 -
1219 - $this->start_controls_section(
1220 - 'section_redirect',
1221 - [
1222 - 'label' => esc_html__( 'Redirect', 'uicore-elements' ),
1223 - 'condition' => [
1224 - 'submit_actions' => 'redirect',
1225 - ],
1226 - ]
1227 - );
1228 -
1229 - $this->add_control(
1230 - 'redirect_to',
1231 - [
1232 - 'label' => esc_html__( 'Redirect To', 'uicore-elements' ),
1233 - 'type' => Controls_Manager::TEXT,
1234 - 'placeholder' => esc_html__( 'https://your-link.com', 'uicore-elements' ),
1235 - 'ai' => [
1236 - 'active' => false,
1237 - ],
1238 - 'dynamic' => [
1239 - 'active' => true,
1240 - 'categories' => [
1241 - 'url',
1242 - ],
1243 - ],
1244 - 'label_block' => true,
1245 - 'render_type' => 'none',
1246 - ]
1247 - );
1248 -
1249 - $this->end_controls_section();
1250 -
1251 - $this->start_controls_section(
1252 - 'mailchimp_redirect',
1253 - [
1254 - 'label' => esc_html__( 'Mailchimp', 'uicore-elements' ),
1255 - 'condition' => [
1256 - 'submit_actions' => 'mailchimp',
1257 - ],
1258 - ]
1259 - );
1260 -
1261 - $this->TRAIT_register_submit_mailchimp_controls($this, true);
1262 -
1263 - $this->end_controls_section();
1264 -
1265 - $default_messages = Contact_Form_Service::get_default_messages();
1266 - $this->start_controls_section(
1267 - 'section_form_options',
1268 - [
1269 - 'label' => esc_html__( 'Additional Options', 'uicore-elements' ),
1270 - 'tab' => Controls_Manager::TAB_CONTENT,
1271 - ]
1272 - );
1273 -
1274 - $this->add_control(
1275 - 'form_id',
1276 - [
1277 - 'label' => esc_html__( 'Form ID', 'uicore-elements' ),
1278 - 'type' => Controls_Manager::TEXT,
1279 - 'ai' => [
1280 - 'active' => false,
1281 - ],
1282 - 'placeholder' => 'new_form_id',
1283 - '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' ),
1284 - 'separator' => 'after',
1285 - 'dynamic' => [
1286 - 'active' => true,
1287 - ],
1288 - ]
1289 - );
1290 - $this->add_control(
1291 - 'form_validation',
1292 - [
1293 - 'label' => esc_html__( 'Form Validation', 'uicore-elements' ),
1294 - 'type' => Controls_Manager::SELECT,
1295 - 'options' => [
1296 - '' => esc_html__( 'Browser Default', 'uicore-elements' ),
1297 - 'no' => esc_html__( 'No validation', 'uicore-elements' ),
1298 - ],
1299 - 'default' => '',
1300 - ]
1301 - );
1302 - $this->add_control(
1303 - 'custom_messages',
1304 - [
1305 - 'label' => esc_html__( 'Custom Messages', 'uicore-elements' ),
1306 - 'type' => Controls_Manager::SWITCHER,
1307 - 'default' => '',
1308 - 'separator' => 'before',
1309 - 'render_type' => 'none',
1310 - ]
1311 - );
1312 - $this->add_control(
1313 - 'success_message',
1314 - [
1315 - 'label' => esc_html__( 'Success Message', 'uicore-elements' ),
1316 - 'type' => Controls_Manager::TEXT,
1317 - 'default' => $default_messages['success'],
1318 - 'placeholder' => $default_messages['success'],
1319 - 'label_block' => true,
1320 - 'condition' => [
1321 - 'custom_messages!' => '',
1322 - ],
1323 - 'render_type' => 'none',
1324 - 'dynamic' => [
1325 - 'active' => true,
1326 - ],
1327 - ]
1328 - );
1329 - $this->add_control(
1330 - 'error_message',
1331 - [
1332 - 'label' => esc_html__( 'Form Error', 'uicore-elements' ),
1333 - 'type' => Controls_Manager::TEXT,
1334 - 'default' => $default_messages['error'],
1335 - 'placeholder' => $default_messages['error'],
1336 - 'label_block' => true,
1337 - 'condition' => [
1338 - 'custom_messages!' => '',
1339 - ],
1340 - 'render_type' => 'none',
1341 - 'dynamic' => [
1342 - 'active' => true,
1343 - ],
1344 - ]
1345 - );
1346 - $this->add_control(
1347 - 'mail_error_message',
1348 - [
1349 - 'label' => esc_html__( 'Email Sending Error', 'uicore-elements' ),
1350 - 'type' => Controls_Manager::TEXT,
1351 - 'default' => $default_messages['mail_error'],
1352 - 'placeholder' => $default_messages['mail_error'],
1353 - 'label_block' => true,
1354 - 'condition' => [
1355 - 'custom_messages!' => '',
1356 - ],
1357 - 'render_type' => 'none',
1358 - 'dynamic' => [
1359 - 'active' => true,
1360 - ],
1361 - ]
1362 - );
1363 - $this->add_control(
1364 - 'redirect_message',
1365 - [
1366 - 'label' => esc_html__( 'Sucessfull Redirect', 'uicore-elements' ),
1367 - 'type' => Controls_Manager::TEXT,
1368 - 'default' => $default_messages['redirect'],
1369 - 'placeholder' => $default_messages['redirect'],
1370 - 'label_block' => true,
1371 - 'conditions' => [
1372 - 'terms' => [
1373 - [
1374 - 'name' => 'custom_messages',
1375 - 'operator' => '!=',
1376 - 'value' => '',
1377 - ],
1378 - [
1379 - 'name' => 'submit_actions',
1380 - 'operator' => 'contains',
1381 - 'value' => 'redirect',
1382 - ]
1383 - ],
1384 - ],
1385 - 'render_type' => 'none',
1386 - 'dynamic' => [
1387 - 'active' => true,
1388 - ],
1389 - ]
1390 - );
1391 -
1392 - $this->end_controls_section();
1393 -
1394 - $this->start_controls_section(
1395 - 'section_form_style',
1396 - [
1397 - 'label' => esc_html__( 'Form', 'uicore-elements' ),
1398 - 'tab' => Controls_Manager::TAB_STYLE,
1399 - ]
1400 - );
1401 -
1402 - $this->add_control(
1403 - 'column_gap',
1404 - [
1405 - 'label' => esc_html__( 'Columns Gap', 'uicore-elements' ),
1406 - 'type' => Controls_Manager::SLIDER,
1407 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
1408 - 'default' => [
1409 - 'size' => 10,
1410 - ],
1411 - 'range' => [
1412 - 'px' => [
1413 - 'max' => 60,
1414 - ],
1415 - 'em' => [
1416 - 'max' => 6,
1417 - ],
1418 - 'rem' => [
1419 - 'max' => 6,
1420 - ],
1421 - ],
1422 - 'selectors' => [
1423 - '{{WRAPPER}} .ui-e-field-group' => 'padding-right: calc( {{SIZE}}{{UNIT}}/2 ); padding-left: calc( {{SIZE}}{{UNIT}}/2 );',
1424 - '{{WRAPPER}} .ui-e-fields-wrp' => 'margin-left: calc( -{{SIZE}}{{UNIT}}/2 ); margin-right: calc( -{{SIZE}}{{UNIT}}/2 );',
1425 - ],
1426 - ]
1427 - );
1428 - $this->add_control(
1429 - 'row_gap',
1430 - [
1431 - 'label' => esc_html__( 'Rows Gap', 'uicore-elements' ),
1432 - 'type' => Controls_Manager::SLIDER,
1433 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
1434 - 'default' => [
1435 - 'size' => 10,
1436 - ],
1437 - 'range' => [
1438 - 'px' => [
1439 - 'max' => 60,
1440 - ],
1441 - 'em' => [
1442 - 'max' => 6,
1443 - ],
1444 - 'rem' => [
1445 - 'max' => 6,
1446 - ],
1447 - ],
1448 - 'selectors' => [
1449 - '{{WRAPPER}} .ui-e-field-group' => 'margin-bottom: {{SIZE}}{{UNIT}};',
1450 - '{{WRAPPER}} .ui-e-fields-wrp' => 'margin-bottom: -{{SIZE}}{{UNIT}};',
1451 - ],
1452 - ]
1453 - );
1454 - $this->add_control(
1455 - 'heading_label',
1456 - [
1457 - 'label' => esc_html__( 'Label', 'uicore-elements' ),
1458 - 'type' => Controls_Manager::HEADING,
1459 - 'separator' => 'before',
1460 - ]
1461 - );
1462 - $this->add_control(
1463 - 'label_spacing',
1464 - [
1465 - 'label' => esc_html__( 'Spacing', 'uicore-elements' ),
1466 - 'type' => Controls_Manager::SLIDER,
1467 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
1468 - 'default' => [
1469 - 'size' => 0,
1470 - ],
1471 - 'range' => [
1472 - 'px' => [
1473 - 'max' => 60,
1474 - ],
1475 - 'em' => [
1476 - 'max' => 6,
1477 - ],
1478 - 'rem' => [
1479 - 'max' => 6,
1480 - ],
1481 - ],
1482 - 'selectors' => [
1483 - 'body {{WRAPPER}} .ui-e-field-group > label' => 'padding-bottom: {{SIZE}}{{UNIT}};',
1484 - ],
1485 - ]
1486 - );
1487 - $this->add_control(
1488 - 'label_color',
1489 - [
1490 - 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
1491 - 'type' => Controls_Manager::COLOR,
1492 - 'selectors' => [
1493 - '{{WRAPPER}} .ui-e-field-group > label, {{WRAPPER}} .ui-e-field-subgroup label' => 'color: {{VALUE}};',
1494 - ],
1495 - 'global' => [
1496 - 'default' => Global_Colors::COLOR_TEXT,
1497 - ],
1498 - ]
1499 - );
1500 - $this->add_control(
1501 - 'mark_required_color',
1502 - [
1503 - 'label' => esc_html__( 'Mark Color', 'uicore-elements' ),
1504 - 'type' => Controls_Manager::COLOR,
1505 - 'default' => '',
1506 - 'selectors' => [
1507 - '{{WRAPPER}} .ui-e-required .ui-e-label:after' => 'color: {{COLOR}};',
1508 - ],
1509 - 'condition' => [
1510 - 'mark_required' => 'yes',
1511 - ],
1512 - ]
1513 - );
1514 - $this->add_group_control(
1515 - Group_Control_Typography::get_type(),
1516 - [
1517 - 'name' => 'label_typography',
1518 - 'selector' => '{{WRAPPER}} .ui-e-field-group > label',
1519 - 'global' => [
1520 - 'default' => Global_Typography::TYPOGRAPHY_TEXT,
1521 - ],
1522 - ]
1523 - );
1524 - $this->add_control(
1525 - 'heading_html',
1526 - [
1527 - 'label' => esc_html__( 'HTML Field', 'uicore-elements' ),
1528 - 'type' => Controls_Manager::HEADING,
1529 - 'separator' => 'before',
1530 - ]
1531 - );
1532 - $this->add_control(
1533 - 'html_spacing',
1534 - [
1535 - 'label' => esc_html__( 'Spacing', 'uicore-elements' ),
1536 - 'type' => Controls_Manager::SLIDER,
1537 - 'size_units' => [ 'px', 'em', 'rem', 'custom' ],
1538 - 'default' => [
1539 - 'size' => 0,
1540 - ],
1541 - 'range' => [
1542 - 'px' => [
1543 - 'max' => 60,
1544 - ],
1545 - 'em' => [
1546 - 'max' => 6,
1547 - ],
1548 - 'rem' => [
1549 - 'max' => 6,
1550 - ],
1551 - ],
1552 - 'selectors' => [
1553 - '{{WRAPPER}} .ui-e-field-type-html' => 'padding-bottom: {{SIZE}}{{UNIT}};',
1554 - ],
1555 - ]
1556 - );
1557 - $this->add_control(
1558 - 'html_color',
1559 - [
1560 - 'label' => esc_html__( 'Color', 'uicore-elements' ),
1561 - 'type' => Controls_Manager::COLOR,
1562 - 'selectors' => [
1563 - '{{WRAPPER}} .ui-e-field-type-html' => 'color: {{VALUE}};',
1564 - ],
1565 - 'global' => [
1566 - 'default' => Global_Colors::COLOR_TEXT,
1567 - ],
1568 - ]
1569 - );
1570 - $this->add_group_control(
1571 - Group_Control_Typography::get_type(),
1572 - [
1573 - 'name' => 'html_typography',
1574 - 'selector' => '{{WRAPPER}} .ui-e-field-type-html',
1575 - 'global' => [
1576 - 'default' => Global_Typography::TYPOGRAPHY_TEXT,
1577 - ],
1578 - ]
1579 - );
1580 -
1581 - $this->end_controls_section();
1582 -
1583 - $this->start_controls_section(
1584 - 'section_field_style',
1585 - [
1586 - 'label' => esc_html__( 'Fields', 'uicore-elements' ),
1587 - 'tab' => Controls_Manager::TAB_STYLE,
1588 - ]
1589 - );
1590 -
1591 - $this->start_controls_tabs(
1592 - 'field_style_tabs'
1593 - );
1594 -
1595 - $this->start_controls_tab(
1596 - 'field_normal_tab',
1597 - [
1598 - 'label' => esc_html__( 'Normal', 'uicore-elements' ),
1599 - ]
1600 - );
1601 -
1602 - $this->add_group_control(
1603 - Group_Control_Typography::get_type(),
1604 - [
1605 - 'name' => 'field_typography',
1606 - 'selector' => '{{WRAPPER}} .ui-e-field-group .ui-e-field, {{WRAPPER}} .ui-e-field-subgroup label',
1607 - 'global' => [
1608 - 'default' => Global_Typography::TYPOGRAPHY_TEXT,
1609 - ],
1610 - ]
1611 - );
1612 - $this->add_control(
1613 - 'field_text_color',
1614 - [
1615 - 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
1616 - 'type' => Controls_Manager::COLOR,
1617 - 'selectors' => [
1618 - '{{WRAPPER}} .ui-e-field-group .ui-e-field' => 'color: {{VALUE}};',
1619 - ],
1620 - 'global' => [
1621 - 'default' => Global_Colors::COLOR_TEXT,
1622 - ],
1623 - ]
1624 - );
1625 - $this->add_control(
1626 - 'field_placeholder_color',
1627 - [
1628 - 'label' => esc_html__( 'Placeholder Color', 'uicore-elements' ),
1629 - 'type' => Controls_Manager::COLOR,
1630 - 'selectors' => [
1631 - '{{WRAPPER}} .ui-e-field-group .ui-e-field::placeholder' => 'color: {{VALUE}};',
1632 - ],
1633 - 'global' => [
1634 - 'default' => Global_Colors::COLOR_TEXT,
1635 - ],
1636 - ]
1637 - );
1638 - $this->add_control(
1639 - 'field_background_color',
1640 - [
1641 - 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
1642 - 'type' => Controls_Manager::COLOR,
1643 - 'default' => '#ffffff',
1644 - 'selectors' => [
1645 - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'background-color: {{VALUE}};',
1646 - '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'background-color: {{VALUE}};',
1647 - ],
1648 - ]
1649 - );
1650 - $this->add_group_control(
1651 - Group_Control_Border::get_type(),
1652 - [
1653 - 'name' => 'field_border',
1654 - 'selector' =>
1655 - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select),
1656 - {{WRAPPER}} .ui-e-field-group .ui-e-field-select select',
1657 - ]
1658 - );
1659 -
1660 - $this->end_controls_tab();
1661 -
1662 - $this->start_controls_tab(
1663 - 'field_hover_tab',
1664 - [
1665 - 'label' => esc_html__( 'Hover', 'uicore-elements' ),
1666 - ]
1667 - );
1668 -
1669 - $this->add_control(
1670 - 'field_text_hover_color',
1671 - [
1672 - 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
1673 - 'type' => Controls_Manager::COLOR,
1674 - 'selectors' => [
1675 - '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field' => 'color: {{VALUE}};',
1676 - ],
1677 - 'global' => [
1678 - 'default' => Global_Colors::COLOR_TEXT,
1679 - ],
1680 - ]
1681 - );
1682 - $this->add_control(
1683 - 'field_placeholder_hover_color',
1684 - [
1685 - 'label' => esc_html__( 'Placeholder Color', 'uicore-elements' ),
1686 - 'type' => Controls_Manager::COLOR,
1687 - 'selectors' => [
1688 - '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field::placeholder' => 'color: {{VALUE}};',
1689 - ],
1690 - 'global' => [
1691 - 'default' => Global_Colors::COLOR_TEXT,
1692 - ],
1693 - ]
1694 - );
1695 - $this->add_control(
1696 - 'field_background_hover_color',
1697 - [
1698 - 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
1699 - 'type' => Controls_Manager::COLOR,
1700 - 'default' => '#ffffff',
1701 - 'selectors' => [
1702 - '{{WRAPPER}} .ui-e-field-group:hover:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select)' => 'background-color: {{VALUE}};',
1703 - '{{WRAPPER}} .ui-e-field-group:hover .ui-e-field-select select' => 'background-color: {{VALUE}};',
1704 - ],
1705 - ]
1706 - );
1707 - $this->add_group_control(
1708 - Group_Control_Border::get_type(),
1709 - [
1710 - 'name' => 'field_hover_border',
1711 - 'selector' =>
1712 - '{{WRAPPER}} .ui-e-field-group:hover:not(.ui-e-field-type-file) .ui-e-field:not(.ui-e-field-select),
1713 - {{WRAPPER}} .ui-e-field-group:hover .ui-e-field-select select',
1714 - ]
1715 - );
1716 -
1717 - $this->end_controls_tab();
1718 -
1719 - $this->start_controls_tab(
1720 - 'field_active_tab',
1721 - [
1722 - 'label' => esc_html__( 'Active', 'uicore-elements' ),
1723 - ]
1724 - );
1725 -
1726 - $this->add_control(
1727 - 'field_text_active_color',
1728 - [
1729 - 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
1730 - 'type' => Controls_Manager::COLOR,
1731 - 'selectors' => [
1732 - '{{WRAPPER}} .ui-e-field-group .ui-e-field:focus' => 'color: {{VALUE}};',
1733 - ],
1734 - 'global' => [
1735 - 'default' => Global_Colors::COLOR_TEXT,
1736 - ],
1737 - ]
1738 - );
1739 - $this->add_control(
1740 - 'field_background_active_color',
1741 - [
1742 - 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
1743 - 'type' => Controls_Manager::COLOR,
1744 - 'default' => '#ffffff',
1745 - 'selectors' => [
1746 - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:focus:not(.ui-e-field-select)' => 'background-color: {{VALUE}};',
1747 - '{{WRAPPER}} .ui-e-field-group .ui-e-field-select:focus select' => 'background-color: {{VALUE}};',
1748 - ],
1749 - ]
1750 - );
1751 - $this->add_group_control(
1752 - Group_Control_Border::get_type(),
1753 - [
1754 - 'name' => 'field_active_border',
1755 - 'selector' =>
1756 - '{{WRAPPER}} .ui-e-field-group:not(.ui-e-field-type-file) .ui-e-field:focus:not(.ui-e-field-select),
1757 - {{WRAPPER}} .ui-e-field-group .ui-e-field-select:focus select',
1758 - ]
1759 - );
1760 -
1761 - $this->end_controls_tab();
1762 -
1763 - $this->end_controls_tabs();
1764 -
1765 - $this->add_control(
1766 - 'field_border_radius',
1767 - [
1768 - 'label' => esc_html__( 'Border Radius', 'uicore-elements' ),
1769 - 'type' => Controls_Manager::DIMENSIONS,
1770 - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
1771 - 'selectors' => [
1772 - '{{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}};',
1773 - '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1774 - ],
1775 - 'separator' => 'before'
1776 - ]
1777 - );
1778 - $this->add_control(
1779 - 'field_padding',
1780 - [
1781 - 'label' => esc_html__( 'Padding', 'uicore-elements' ),
1782 - 'type' => Controls_Manager::DIMENSIONS,
1783 - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
1784 - 'selectors' => [
1785 - '{{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}};',
1786 - '{{WRAPPER}} .ui-e-field-group .ui-e-field-select select' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1787 - ],
1788 - ]
1789 - );
1790 -
1791 - $this->end_controls_section();
1792 -
1793 - $this->start_controls_section(
1794 - 'section_button_style',
1795 - [
1796 - 'label' => esc_html__( 'Button', 'uicore-elements' ),
1797 - 'tab' => Controls_Manager::TAB_STYLE,
1798 - ]
1799 - );
1800 -
1801 - $this->add_group_control(
1802 - Group_Control_Typography::get_type(),
1803 - [
1804 - 'name' => 'button_typography',
1805 - 'global' => [
1806 - 'default' => Global_Typography::TYPOGRAPHY_ACCENT,
1807 - ],
1808 - 'selector' => '{{WRAPPER}} .elementor-button',
1809 - ]
1810 - );
1811 - $this->add_group_control(
1812 - Group_Control_Border::get_type(), [
1813 - 'name' => 'button_border',
1814 - 'selector' => '{{WRAPPER}} .elementor-button',
1815 - 'exclude' => [
1816 - 'color',
1817 - ],
1818 - ]
1819 - );
1820 -
1821 - $this->start_controls_tabs( 'tabs_button_style' );
1822 -
1823 - $this->start_controls_tab(
1824 - 'tab_button_normal',
1825 - [
1826 - 'label' => esc_html__( 'Normal', 'uicore-elements' ),
1827 - ]
1828 - );
1829 -
1830 - $this->add_control(
1831 - 'button_background_color',
1832 - [
1833 - 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
1834 - 'type' => Controls_Manager::COLOR,
1835 - 'global' => [
1836 - 'default' => Global_Colors::COLOR_ACCENT,
1837 - ],
1838 - 'selectors' => [
1839 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'background-color: {{VALUE}};',
1840 - '{{WRAPPER}} .elementor-button[type="submit"]' => 'background-color: {{VALUE}};',
1841 - ],
1842 - ]
1843 - );
1844 - $this->add_control(
1845 - 'button_text_color',
1846 - [
1847 - 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
1848 - 'type' => Controls_Manager::COLOR,
1849 - 'default' => '#ffffff',
1850 - 'selectors' => [
1851 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'color: {{VALUE}};',
1852 - '{{WRAPPER}} .elementor-button[type="submit"]' => 'color: {{VALUE}};',
1853 - '{{WRAPPER}} .elementor-button[type="submit"] svg *' => 'fill: {{VALUE}};',
1854 - ],
1855 - ]
1856 - );
1857 - $this->add_control(
1858 - 'button_border_color',
1859 - [
1860 - 'label' => esc_html__( 'Border Color', 'uicore-elements' ),
1861 - 'type' => Controls_Manager::COLOR,
1862 - 'default' => '',
1863 - 'selectors' => [
1864 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'border-color: {{VALUE}};',
1865 - '{{WRAPPER}} .elementor-button[type="submit"]' => 'border-color: {{VALUE}};',
1866 - ],
1867 - 'condition' => [
1868 - 'button_border_border!' => '',
1869 - ],
1870 - ]
1871 - );
1872 -
1873 - $this->end_controls_tab();
1874 -
1875 - $this->start_controls_tab(
1876 - 'tab_button_hover',
1877 - [
1878 - 'label' => esc_html__( 'Hover', 'uicore-elements' ),
1879 - ]
1880 - );
1881 -
1882 - $this->add_control(
1883 - 'button_background_hover_color',
1884 - [
1885 - 'label' => esc_html__( 'Background Color', 'uicore-elements' ),
1886 - 'type' => Controls_Manager::COLOR,
1887 - 'default' => '',
1888 - 'selectors' => [
1889 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'background-color: {{VALUE}};',
1890 - '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'background-color: {{VALUE}};',
1891 - ],
1892 - ]
1893 - );
1894 - $this->add_control(
1895 - 'button_hover_color',
1896 - [
1897 - 'label' => esc_html__( 'Text Color', 'uicore-elements' ),
1898 - 'type' => Controls_Manager::COLOR,
1899 - 'default' => '#ffffff',
1900 - 'selectors' => [
1901 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'color: {{VALUE}};',
1902 - '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'color: {{VALUE}};',
1903 - '{{WRAPPER}} .elementor-button[type="submit"]:hover svg *' => 'fill: {{VALUE}};',
1904 - ],
1905 - ]
1906 - );
1907 - $this->add_control(
1908 - 'button_hover_border_color',
1909 - [
1910 - 'label' => esc_html__( 'Border Color', 'uicore-elements' ),
1911 - 'type' => Controls_Manager::COLOR,
1912 - 'default' => '',
1913 - 'selectors' => [
1914 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next:hover' => 'border-color: {{VALUE}};',
1915 - '{{WRAPPER}} .elementor-button[type="submit"]:hover' => 'border-color: {{VALUE}};',
1916 - ],
1917 - 'condition' => [
1918 - 'button_border_border!' => '',
1919 - ],
1920 - ]
1921 - );
1922 - $this->add_control(
1923 - 'hover_transition_duration',
1924 - [
1925 - 'label' => esc_html__( 'Transition Duration', 'uicore-elements' ),
1926 - 'type' => Controls_Manager::SLIDER,
1927 - 'size_units' => [ 's', 'ms', 'custom' ],
1928 - 'default' => [
1929 - 'unit' => 'ms',
1930 - ],
1931 - 'selectors' => [
1932 - '{{WRAPPER}} .e-form__buttons__wrapper__button-previous' => 'transition-duration: {{SIZE}}{{UNIT}};',
1933 - '{{WRAPPER}} .e-form__buttons__wrapper__button-next' => 'transition-duration: {{SIZE}}{{UNIT}};',
1934 - '{{WRAPPER}} .elementor-button[type="submit"] svg *' => 'transition-duration: {{SIZE}}{{UNIT}};',
1935 - '{{WRAPPER}} .elementor-button[type="submit"]' => 'transition-duration: {{SIZE}}{{UNIT}};',
1936 - ],
1937 - ]
1938 - );
1939 - $this->add_control(
1940 - 'button_hover_animation',
1941 - [
1942 - 'label' => esc_html__( 'Animation', 'uicore-elements' ),
1943 - 'type' => Controls_Manager::HOVER_ANIMATION,
1944 - ]
1945 - );
1946 -
1947 - $this->end_controls_tab();
1948 -
1949 - $this->end_controls_tabs();
1950 -
1951 - $this->add_control(
1952 - 'button_border_radius',
1953 - [
1954 - 'label' => esc_html__( 'Border Radius', 'uicore-elements' ),
1955 - 'type' => Controls_Manager::DIMENSIONS,
1956 - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
1957 - 'selectors' => [
1958 - '{{WRAPPER}} .elementor-button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1959 - ],
1960 - 'separator' => 'before',
1961 - ]
1962 - );
1963 -
1964 - $this->add_control(
1965 - 'button_text_padding',
1966 - [
1967 - 'label' => esc_html__( 'Text Padding', 'uicore-elements' ),
1968 - 'type' => Controls_Manager::DIMENSIONS,
1969 - 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
1970 - 'selectors' => [
1971 - '{{WRAPPER}} .elementor-button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1972 - ],
1973 - ]
1974 - );
1975 -
1976 - $this->end_controls_section();
1977 -
1978 - $this->start_controls_section(
1979 - 'section_messages_style',
1980 - [
1981 - 'label' => esc_html__( 'Messages', 'uicore-elements' ),
1982 - 'tab' => Controls_Manager::TAB_STYLE,
1983 - ]
1984 - );
1985 -
1986 - $this->add_control(
1987 - 'show_messages',
1988 - [
1989 - 'label' => esc_html__( 'Show/Hide messages', 'uicore-elements' ),
1990 - 'type' => Controls_Manager::BUTTON,
1991 - 'separator' => 'before',
1992 - 'text' => esc_html__( 'Toggle', 'uicore-elements' ),
1993 - 'event' => 'ui-e-form-show-messages',
1994 - ]
1995 - );
1996 - $this->add_group_control(
1997 - Group_Control_Typography::get_type(),
1998 - [
1999 - 'name' => 'message_typography',
2000 - 'global' => [
2001 - 'default' => Global_Typography::TYPOGRAPHY_TEXT,
2002 - ],
2003 - 'selector' => '{{WRAPPER}} .ui-e-message',
2004 - ]
2005 - );
2006 - $this->add_control(
2007 - 'success_message_color',
2008 - [
2009 - 'label' => esc_html__( 'Success Message Color', 'uicore-elements' ),
2010 - 'type' => Controls_Manager::COLOR,
2011 - 'default' => '#4CAF50',
2012 - 'selectors' => [
2013 - '{{WRAPPER}} .ui-e-message span.success' => 'color: {{COLOR}};',
2014 - ],
2015 - ]
2016 - );
2017 - $this->add_control(
2018 - 'error_message_color',
2019 - [
2020 - 'label' => esc_html__( 'Error Message Color', 'uicore-elements' ),
2021 - 'type' => Controls_Manager::COLOR,
2022 - 'default' => '#F44336',
2023 - 'selectors' => [
2024 - '{{WRAPPER}} .ui-e-message span.error' => 'color: {{COLOR}};',
2025 - ],
2026 - ]
2027 - );
2028 -
2029 - $this->end_controls_section();
2030 - }
2031 - function recaptcha_js()
2032 - {
2033 - ?>
2034 - <script>
2035 - window.uicore_elements_recaptcha = '<?php echo get_option('uicore_elements_recaptcha_site_key'); ?>';
2036 - </script>
2037 - <?php
2038 - }
2039 -
2040 - protected function render() {
2041 -
2042 - $instance = $this->get_settings_for_display();
2043 - $is_recaptcha_required = false;
2044 -
2045 - // Render Form Atts
2046 - $this->add_render_attribute(
2047 - [
2048 - 'wrapper' => [
2049 - 'class' => [
2050 - 'ui-e-fields-wrp',
2051 - ],
2052 - ],
2053 - 'submit-group' => [
2054 - 'class' => [
2055 - 'ui-e-field-group',
2056 - 'elementor-column',
2057 - 'ui-e-field-type-submit',
2058 - ],
2059 - ],
2060 - 'button' => [
2061 - 'class' => 'elementor-button',
2062 - ],
2063 - 'icon-align' => [
2064 - 'class' => [
2065 - empty( $instance['button_icon_align'] ) ? '' : 'ui-e-icon ui-e-align-' . $instance['button_icon_align'],
2066 - ],
2067 - ],
2068 - ]
2069 - );
2070 -
2071 - // Fallback for empty control values
2072 - if ( empty( $instance['button_width'] ) ) {
2073 - $instance['button_width'] = '100';
2074 - }
2075 -
2076 - // Button atts
2077 - $this->add_render_attribute( 'submit-group', 'class', 'elementor-col-' . $instance['button_width'] . ' e-form__buttons' );
2078 -
2079 - if ( ! empty( $instance['button_width_tablet'] ) ) {
2080 - $this->add_render_attribute( 'submit-group', 'class', 'elementor-md-' . $instance['button_width_tablet'] );
2081 - }
2082 - if ( ! empty( $instance['button_width_mobile'] ) ) {
2083 - $this->add_render_attribute( 'submit-group', 'class', 'elementor-sm-' . $instance['button_width_mobile'] );
2084 - }
2085 - if ( $instance['button_hover_animation'] ) {
2086 - $this->add_render_attribute( 'button', 'class', 'elementor-animation-' . $instance['button_hover_animation'] );
2087 - }
2088 -
2089 - // Form atts
2090 - if ( ! empty( $instance['form_id'] ) ) {
2091 - $this->add_render_attribute( 'form', 'id', $instance['form_id'] );
2092 - }
2093 - if ( ! empty( $instance['form_name'] ) ) {
2094 - $this->add_render_attribute( 'form', 'name', $instance['form_name'] );
2095 - }
2096 - if ( 'no' === $instance['form_validation'] ) {
2097 - $this->add_render_attribute( 'form', 'novalidate' );
2098 - }
2099 - if ( ! empty( $instance['button_css_id'] ) ) {
2100 - $this->add_render_attribute( 'button', 'id', $instance['button_css_id'] );
2101 - }
2102 -
2103 - $referer_title = trim( wp_title( '', false ) );
2104 - if ( ! $referer_title && is_home() ) {
2105 - $referer_title = get_option( 'blogname' );
2106 - }
2107 -
2108 - ?>
2109 -
2110 - <form class="ui-e-form" method="post" <?php $this->print_render_attribute_string( 'form' ); ?>>
2111 -
2112 - <input type="hidden" name="post_id" value="<?php echo esc_attr( get_the_ID()); ?>"/>
2113 - <input type="hidden" name="widget_type" value="contact-form">
2114 -
2115 - <div <?php $this->print_render_attribute_string( 'wrapper' ); ?>>
2116 - <?php
2117 - foreach ( $instance['form_fields'] as $item_index => $item ) :
2118 - $this->form_fields_render_attributes( $item_index, $instance, $item );
2119 -
2120 - $field_type = $item['field_type'];
2121 -
2122 - if( $field_type === 'recaptcha' || $field_type === 'recaptcha_v3' ){
2123 - $is_recaptcha_required = true;
2124 - }
2125 -
2126 - $print_label = ! in_array( $item['field_type'], [ 'hidden', 'html' ], true );
2127 - ?>
2128 -
2129 - <div <?php $this->print_render_attribute_string( 'field-group' . $item_index ); ?>>
2130 - <?php
2131 - // Print label (excepts if recaptcha)
2132 - if ( $print_label && $item['field_label'] && $item['field_type'] !== 'recaptcha' && $item['field_type'] !== 'recaptcha_v3' ){
2133 - ?>
2134 - <label <?php $this->print_render_attribute_string( 'label' . $item_index ); ?>>
2135 - <?php // PHPCS - the variable $item['field_label'] is safe.
2136 - echo $item['field_label']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
2137 - </label>
2138 - <?php
2139 - }
2140 -
2141 - // Print field
2142 - switch ( $item['field_type'] ) :
2143 - case 'html':
2144 - echo do_shortcode( $item['field_html'] );
2145 - break;
2146 -
2147 - case 'textarea':
2148 - // PHPCS - the method build_textarea_field is safe.
2149 - echo $this->build_textarea_field( $item, $item_index ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2150 - break;
2151 -
2152 - case 'select':
2153 - // PHPCS - the method build_select_field is safe.
2154 - echo $this->build_select_field( $item, $item_index ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2155 - break;
2156 -
2157 - case 'acceptance':
2158 - // PHPCS - the method build_select_field is safe.
2159 - echo $this->build_acceptance_field( $item, $item_index); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2160 - break;
2161 -
2162 - case 'radio':
2163 - case 'checkbox':
2164 - // PHPCS - the method build_radio_checkbox_field is safe.
2165 - echo $this->build_radio_checkbox_field( $item, $item_index, $item['field_type'] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2166 - break;
2167 -
2168 - case 'address': // is actually honeypot
2169 - // PHPCS - the method build_honeypot_field is safe.
2170 - echo $this->build_honeypot_field( $item, $item_index ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2171 - break;
2172 -
2173 - case 'recaptcha':
2174 - // get widget ID
2175 - echo '<input type="hidden" name="recaptcha"/> <div id="ui-e-recaptcha-'.esc_attr($this->get_ID()).'"></div>';
2176 - break;
2177 -
2178 - case 'recaptcha_v3':
2179 - echo '<input type="hidden" name="recaptcha_v3"/>';
2180 - break;
2181 -
2182 - // All other cases are covered by the add_render_atribute()
2183 - default:
2184 - $this->add_render_attribute('input' . $item_index, 'class', 'ui-e-field-textual');
2185 - ?>
2186 - <input size="1" <?php $this->print_render_attribute_string( 'input' . $item_index ); ?>>
2187 - <?php
2188 - break;
2189 -
2190 - endswitch;
2191 - ?>
2192 - </div>
2193 -
2194 - <?php endforeach; ?>
2195 -
2196 - <div <?php $this->print_render_attribute_string( 'submit-group' ); ?>>
2197 - <button type="submit" <?php $this->print_render_attribute_string( 'button' ); ?>>
2198 - <span <?php $this->print_render_attribute_string( 'content-wrapper' ); ?>>
2199 - <?php if ( ! empty( $instance['button_icon'] ) || ! empty( $instance['selected_button_icon'] ) ) : ?>
2200 - <span <?php $this->print_render_attribute_string( 'icon-align' ); ?>>
2201 - <?php Icons_Manager::render_icon( $instance['selected_button_icon'], [ 'aria-hidden' => 'true' ] ); ?>
2202 - <?php if ( empty( $instance['button_text'] ) ) : ?>
2203 - <span class="elementor-screen-only"><?php echo esc_html__( 'Submit', 'uicore-elements' ); ?></span>
2204 - <?php endif; ?>
2205 - </span>
2206 - <?php endif; ?>
2207 - <?php if ( ! empty( $instance['button_text'] ) ) : ?>
2208 - <span class="ui-e-text"><?php $this->print_unescaped_setting( 'button_text' ); ?></span>
2209 - <?php endif; ?>
2210 - </span>
2211 - </button>
2212 - </div>
2213 -
2214 - </div>
2215 -
2216 - <div class="ui-e-message <?php echo $this->is_edit_mode() ? 'elementor-hidden' : ''; ?>">
2217 - <?php if($this->is_edit_mode()) :
2218 - // Get custom messages if set, else use default
2219 - $messages = Contact_Form_Service::get_default_messages();
2220 - $success = isset($instance['success_message']) ? $instance['success_message'] : $messages['success'];
2221 - $error = isset($instance['error_message']) ? $instance['error_message'] : $messages['error'];
2222 - ?>
2223 - <span class="success"> <?php echo esc_html($success);?> </span> <br>
2224 - <span class="error"> <?php echo esc_html($error);?> </span>
2225 - <?php endif; ?>
2226 - </div>
2227 - </form>
2228 - <?php
2229 -
2230 - //add js to footer if recaptcha is enabled
2231 - if($is_recaptcha_required){
2232 - add_action('wp_footer', [$this, 'recaptcha_js'], 999);
2233 - }
2234 - }
2235 - protected function content_template() {
2236 - ?>
2237 - <#
2238 - view.addRenderAttribute(
2239 - 'form',
2240 - {
2241 - 'id': settings.form_id,
2242 - 'name': settings.form_name,
2243 - }
2244 - );
2245 - if ( 'no' === settings.form_validation ) {
2246 - view.addRenderAttribute( 'form', 'novalidate' );
2247 - }
2248 - #>
2249 - <form class="ui-e-form" {{{ view.getRenderAttributeString( 'form' ) }}}>
2250 - <div class="ui-e-fields-wrp">
2251 - <#
2252 - for ( var i in settings.form_fields ) {
2253 - var item = settings.form_fields[ i ];
2254 - item.field_type = _.escape( item.field_type );
2255 - item.field_value = _.escape( item.field_value );
2256 -
2257 - var options = item.field_options ? item.field_options.split( '\n' ) : [],
2258 - itemClasses = _.escape( item.css_classes ),
2259 - labelVisibility = '',
2260 - placeholder = '',
2261 - required = '',
2262 - checked_by_default = '',
2263 - inputField = '',
2264 - multiple = '',
2265 - fieldGroupClasses = 'ui-e-field-group elementor-column ui-e-field-type-' + item.field_type,
2266 - printLabel = settings.show_labels && ! [ 'hidden', 'html', 'recaptcha', 'recaptcha_v3' ].includes( item.field_type );
2267 -
2268 - fieldGroupClasses += ' elementor-col-' + ( ( '' !== item.width ) ? item.width : '100' );
2269 -
2270 - if ( item.width_tablet ) {
2271 - fieldGroupClasses += ' elementor-md-' + item.width_tablet;
2272 - }
2273 -
2274 - if ( item.width_mobile ) {
2275 - fieldGroupClasses += ' elementor-sm-' + item.width_mobile;
2276 - }
2277 -
2278 - if ( item.required ) {
2279 - required = 'required';
2280 - fieldGroupClasses += ' ui-e-field-required';
2281 -
2282 - if ( settings.mark_required ) {
2283 - fieldGroupClasses += ' ui-e-required';
2284 - }
2285 - }
2286 -
2287 - if ( item.placeholder ) {
2288 - placeholder = 'placeholder="' + _.escape( item.placeholder ) + '"';
2289 - }
2290 -
2291 - if ( item.allow_multiple ) {
2292 - multiple = ' multiple';
2293 - fieldGroupClasses += ' ui-e-field-type-' + item.field_type + '-multiple';
2294 - }
2295 -
2296 - switch ( item.field_type ) {
2297 - case 'html':
2298 - inputField = item.field_html;
2299 - break;
2300 -
2301 - case 'textarea':
2302 - inputField = '<textarea class="ui-e-field ui-e-field-textual elementor-size-' + settings.input_size + ' ' + itemClasses + '" name="form_field_' + i + '" id="form_field_' + i + '" rows="' + item.rows + '" ' + required + ' ' + placeholder + '>' + item.field_value + '</textarea>';
2303 - break;
2304 -
2305 - case 'select':
2306 - if ( options ) {
2307 - var size = '';
2308 - if ( item.allow_multiple && item.select_size ) {
2309 - size = ' size="' + item.select_size + '"';
2310 - }
2311 - inputField = '<div class="ui-e-field ui-e-field-select ui-e-field-subgroup' + itemClasses + '">';
2312 - inputField += '<select class="ui-e-field-textual" name="form_field_' + i + '" id="form_field_' + i + '" ' + required + multiple + size + ' >';
2313 - for ( var x in options ) {
2314 - var option_value = options[ x ];
2315 - var option_label = options[ x ];
2316 - var option_id = 'form_field_option' + i + x;
2317 -
2318 - if ( options[ x ].indexOf( '|' ) > -1 ) {
2319 - var label_value = options[ x ].split( '|' );
2320 - option_label = label_value[0];
2321 - option_value = label_value[1];
2322 - }
2323 -
2324 - view.addRenderAttribute( option_id, 'value', option_value );
2325 - if ( item.field_value.split( ',' ) .indexOf( option_value ) ) {
2326 - view.addRenderAttribute( option_id, 'selected', 'selected' );
2327 - }
2328 - inputField += '<option ' + view.getRenderAttributeString( option_id ) + '>' + option_label + '</option>';
2329 - }
2330 - inputField += '</select></div>';
2331 - }
2332 - break;
2333 -
2334 - case 'radio':
2335 - case 'checkbox':
2336 - if ( options ) {
2337 - var multiple = '';
2338 -
2339 - if ( 'checkbox' === item.field_type && options.length > 1 ) {
2340 - multiple = '[]';
2341 - }
2342 -
2343 - inputField = '<div class="ui-e-field-subgroup ' + itemClasses + ' ' + _.escape( item.inline_list ) + '">';
2344 -
2345 - for ( var x in options ) {
2346 - var option_value = options[ x ];
2347 - var option_label = options[ x ];
2348 - var option_id = 'form_field_' + item.field_type + i + x;
2349 - if ( options[x].indexOf( '|' ) > -1 ) {
2350 - var label_value = options[x].split( '|' );
2351 - option_label = label_value[0];
2352 - option_value = label_value[1];
2353 - }
2354 -
2355 - view.addRenderAttribute( option_id, {
2356 - value: option_value,
2357 - type: item.field_type,
2358 - id: 'form_field_' + i + '-' + x,
2359 - name: 'form_field_' + i + multiple
2360 - } );
2361 -
2362 - if ( option_value === item.field_value ) {
2363 - view.addRenderAttribute( option_id, 'checked', 'checked' );
2364 - }
2365 -
2366 - inputField += '<span class="ui-e-field-option"><input ' + view.getRenderAttributeString( option_id ) + ' ' + required + '> ';
2367 - inputField += '<label for="form_field_' + i + '-' + x + '">' + option_label + '</label></span>';
2368 -
2369 - }
2370 -
2371 - inputField += '</div>';
2372 - }
2373 - break;
2374 -
2375 - case 'acceptance' :
2376 - var checked = '';
2377 - if(item.checked_by_default == 'yes') {
2378 - checked = ' checked';
2379 - }
2380 - inputField += '<div class="ui-e-field-subgroup">';
2381 - inputField += '<input type="checkbox" class="ui-e-field ui-e-acceptance-field" name="form_field_' + i + '" id="form_field_' + i + '" ' + required + checked + '>';
2382 - inputField += '<label for="form_field_' + i + '">' + item.acceptance_text + '</label>';
2383 - inputField += '</div>';
2384 - break;
2385 -
2386 - case 'recaptcha' :
2387 - case 'recaptcha_v3' :
2388 - inputField = '<input type="hidden" name="recaptcha"/> <div id="ui-e-recaptcha"></div>';
2389 - break;
2390 -
2391 - default:
2392 - itemClasses = 'ui-e-field-textual ' + itemClasses;
2393 - inputField = '<input size="1" type="' + item.field_type + '" value="' + item.field_value + '" class="ui-e-field elementor-size-' + settings.input_size + ' ' + itemClasses + '" name="form_field_' + i + '" id="form_field_' + i + '" ' + required + ' ' + placeholder + ' >';
2394 - break;
2395 - }
2396 -
2397 - if ( inputField ) {
2398 - #>
2399 - <div class="{{ fieldGroupClasses }}">
2400 -
2401 - <# if ( printLabel && item.field_label ) { #>
2402 - <label class="ui-e-field-label" for="form_field_{{ i }}" {{{ labelVisibility }}}>{{{ item.field_label }}}</label>
2403 - <# } #>
2404 -
2405 - {{{ inputField }}}
2406 - </div>
2407 - <#
2408 - }
2409 - }
2410 -
2411 -
2412 - var buttonClasses = 'ui-e-field-group elementor-column ui-e-field-type-submit e-form__buttons';
2413 -
2414 - buttonClasses += ' elementor-col-' + ( ( '' !== settings.button_width ) ? settings.button_width : '100' );
2415 -
2416 - if ( settings.button_width_tablet ) {
2417 - buttonClasses += ' elementor-md-' + settings.button_width_tablet;
2418 - }
2419 -
2420 - if ( settings.button_width_mobile ) {
2421 - buttonClasses += ' elementor-sm-' + settings.button_width_mobile;
2422 - }
2423 -
2424 - var iconHTML = elementor.helpers.renderIcon( view, settings.selected_button_icon, { 'aria-hidden': true }, 'i' , 'object' )
2425 - #>
2426 -
2427 - <div class="{{ buttonClasses }}">
2428 - <button id="{{ settings.button_css_id }}" type="submit" class="elementor-button elementor-animation-{{ settings.button_hover_animation }}">
2429 - <span>
2430 - <# if ( settings.button_icon || settings.selected_button_icon ) { #>
2431 - <span class="ui-e-icon ui-e-align-{{ settings.button_icon_align }}">
2432 - <# if ( iconHTML && iconHTML.rendered && ( ! settings.button_icon ) ) { #>
2433 - {{{ iconHTML.value }}}
2434 - <# } else { #>
2435 - <i class="{{ settings.button_icon }}" aria-hidden="true"></i>
2436 - <# } #>
2437 - <span class="elementor-screen-only"><?php echo esc_html__( 'Submit', 'uicore-elements' ); ?></span>
2438 - </span>
2439 - <# } #>
2440 -
2441 - <# if ( settings.button_text ) { #>
2442 - <span class="ui-e-text">{{{ settings.button_text }}}</span>
2443 - <# } #>
2444 - </span>
2445 - </button>
2446 - </div>
2447 - </div>
2448 - <div class="ui-e-message elementor-hidden">
2449 - <#
2450 - const success = settings.success_message;
2451 - const error = settings.error_message;
2452 - #>
2453 - <span class="success">{{{ success }}}</span> <br>
2454 - <span class="error">{{{ error }}}</span>
2455 - </div>
2456 - </form>
2457 - <?php
2458 - }
2459 -}
2460 -\Elementor\Plugin::instance()->widgets_manager->register(new ContactForm());
1 +<?php
2 +
3 +namespace UiCoreElements;
4 +
5 +use UiCoreElements\Helper;
6 +use UiCoreElements\Utils\Contact_Form_Service;
7 +use UiCoreElements\Utils\Form_Component;
8 +use UiCoreElements\Utils\Newsletter_Services;
9 +
10 +use Elementor\Controls_Manager;
11 +use Elementor\Icons_Manager;
12 +use Elementor\Utils;
13 +use Elementor\Repeater;
14 +use Elementor\Group_Control_Typography;
15 +use Elementor\Group_Control_Border;
16 +use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
17 +use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
18 +
19 +
20 +defined('ABSPATH') || exit();
21 +
22 +/**
23 + * Contact Form
24 + *
25 + * @author Lucas Marini Falbo <[email protected]>
26 + * @since 1.0.5
27 + */
28 +
29 +class ContactForm extends UiCoreWidget
30 +{
31 +
32 + use Form_Component;
33 +
34 + public function get_name()
35 + {
36 + return 'uicore-contact-form';
37 + }
38 +
39 + public function get_title()
40 + {
41 + return __('Contact Form', 'uicore-elements');
42 + }
43 +
44 + public function get_icon()
45 + {
46 + return 'eicon-form-horizontal ui-e-widget';
47 + }
48 + public function get_categories()
49 + {
50 + return ['uicore'];
51 + }
52 + public function get_keywords()
53 + {
54 + return ['form', 'forms', 'contact', 'mail', 'send', 'field', 'button', 'recaptcha',];
55 + }
56 + public function get_styles()
57 + {
58 + return ['contact-form'];
59 + }
60 + public function get_scripts()
61 + {
62 + return [
63 + 'contact-form',
64 + 'recaptcha' => [
65 + 'custom_condition' => $this->check_recaptcha_version('v2')
66 + ],
67 + 'recaptcha-v3' => [
68 + 'custom_condition' => $this->check_recaptcha_version('v3')
69 + ],
70 + 'repeater-custom-key' => [
71 + 'custom_condition' => $this->is_edit_mode()
72 + ]
73 + ];
74 + }
75 + public function has_widget_inner_wrapper(): bool
76 + {
77 + // TODO: remove after Optmized Markup experiment is merged to the core
78 + return ! \Elementor\Plugin::$instance->experiments->is_feature_active('e_optimized_markup');;
79 + }
80 + function check_recaptcha_version($version)
81 + {
82 +
83 + if ($this->is_edit_mode()) {
84 + return true;
85 + }
86 + $settings = $this->get_settings_for_display();
87 + foreach ($settings['form_fields'] as $field) {
88 + $version_to_check = $version === 'v2' ? 'recaptcha' : 'recaptcha_v3';
89 + if ($field['field_type'] === $version_to_check) {
90 + return true;
91 + }
92 + }
93 + return false;
94 + }
95 +
96 + // Helper Functions
97 + function get_field_types()
98 + {
99 + return [
100 + 'text' => esc_html__('Text', 'uicore-elements'),
101 + 'email' => esc_html__('Email', 'uicore-elements'),
102 + 'textarea' => esc_html__('Textarea', 'uicore-elements'),
103 + 'url' => esc_html__('URL', 'uicore-elements'),
104 + 'tel' => esc_html__('Tel', 'uicore-elements'),
105 + 'radio' => esc_html__('Radio', 'uicore-elements'),
106 + 'select' => esc_html__('Select', 'uicore-elements'),
107 + 'checkbox' => esc_html__('Checkbox', 'uicore-elements'),
108 + 'acceptance' => esc_html__('Acceptance', 'uicore-elements'),
109 + 'number' => esc_html__('Number', 'uicore-elements'),
110 + 'date' => esc_html__('Date', 'uicore-elements'),
111 + 'time' => esc_html__('Time', 'uicore-elements'),
112 + 'file' => esc_html__('File Upload', 'uicore-elements'),
113 + 'password' => esc_html__('Password', 'uicore-elements'),
114 + 'address' => esc_html__('Honeypot', 'uicore-elements'),
115 + 'recaptcha' => esc_html__('reCAPTCHA', 'uicore-elements'),
116 + 'recaptcha_v3' => esc_html__('reCAPTCHA V3', 'uicore-elements'),
117 + 'html' => esc_html__('HTML', 'uicore-elements'),
118 + 'hidden' => esc_html__('Hidden', 'uicore-elements'),
119 + ];
120 + }
121 +
122 + function get_attribute_name($item)
123 + {
124 + return "form_fields[{$item['custom_id']}]";
125 + }
126 + function get_attribute_id($item)
127 + {
128 + return 'form-field-' . $item['custom_id'];
129 + }
130 + function add_required_attribute($element, $js_verication = false)
131 + {
132 +
133 + // Used for elements (eg: checkbox) that aren't natively supported by the browsers validations
134 + if ($js_verication) {
135 + $this->add_render_attribute($element, 'data-ui-e-required', 'true');
136 + return;
137 + }
138 +
139 + // Default method
140 + $this->add_render_attribute($element, 'required', 'required');
141 + $this->add_render_attribute($element, 'aria-required', 'true');
142 + }
143 +
144 + // Field Render Functions
145 + function build_honeypot_field($item, $item_index)
146 + {
147 + $this->add_render_attribute('honeypot' . $item_index, [
148 + 'class' => [
149 + 'ui-e-field',
150 + 'ui-e-h-p',
151 + esc_attr($item['css_classes']),
152 + ],
153 + 'name' => 'ui-e-h-p',
154 + 'id' => 'ui-e-h-p',
155 + 'autocomplete' => 'off',
156 + ]);
157 +
158 + if ($item['placeholder']) {
159 + $this->add_render_attribute('honeypot' . $item_index, 'placeholder', $item['placeholder']);
160 + }
161 +
162 + if ($item['required']) {
163 + $this->add_required_attribute('honeypot' . $item_index);
164 + }
165 +
166 + $value = empty($item['field_value']) ? '' : $item['field_value'];
167 +
168 + return '<input ' . $this->get_render_attribute_string('honeypot' . $item_index) . ' tabindex="-1">' . esc_html($value) . '</input>';
169 + }
170 + function build_textarea_field($item, $item_index)
171 + {
172 + $this->add_render_attribute('textarea' . $item_index, [
173 + 'class' => [
174 + 'ui-e-field',
175 + esc_attr($item['css_classes']),
176 + ],
177 + 'name' => $this->get_attribute_name($item),
178 + 'id' => $this->get_attribute_id($item),
179 + 'rows' => $item['rows'],
180 + ]);
181 +
182 + if ($item['placeholder']) {
183 + $this->add_render_attribute('textarea' . $item_index, 'placeholder', $item['placeholder']);
184 + }
185 +
186 + if ($item['required']) {
187 + $this->add_required_attribute('textarea' . $item_index);
188 + }
189 +
190 + $value = empty($item['field_value']) ? '' : $item['field_value'];
191 +
192 + return '<textarea ' . $this->get_render_attribute_string('textarea' . $item_index) . '>' . esc_textarea($value) . '</textarea>';
193 + }
194 + function build_select_field($item, $i)
195 + {
196 + $this->add_render_attribute(
197 + [
198 + 'select-wrapper' . $i => [
199 + 'class' => [
200 + 'ui-e-field',
201 + 'ui-e-field-select',
202 + 'ui-e-field-subgroup',
203 + esc_attr($item['css_classes']),
204 + ],
205 + ],
206 + 'select' . $i => [
207 + 'name' => $this->get_attribute_name($item) . (! empty($item['allow_multiple']) ? '[]' : ''),
208 + 'id' => $this->get_attribute_id($item),
209 + 'class' => [
210 + 'ui-e-field-textual',
211 + ],
212 + ],
213 + ]
214 + );
215 +
216 + if ($item['required']) {
217 + $this->add_required_attribute('select' . $i);
218 + }
219 +
220 + if ($item['allow_multiple']) {
221 + $this->add_render_attribute('select' . $i, 'multiple');
222 + if (! empty($item['select_size'])) {
223 + $this->add_render_attribute('select' . $i, 'size', $item['select_size']);
224 + }
225 + }
226 +
227 + $options = preg_split("/\\r\\n|\\r|\\n/", $item['field_options']);
228 +
229 + if (! $options) {
230 + return '';
231 + }
232 +
233 + ob_start();
234 +?>
235 + <div <?php $this->print_render_attribute_string('select-wrapper' . $i); ?>>
236 + <select <?php $this->print_render_attribute_string('select' . $i); ?>>
237 + <?php
238 + foreach ($options as $key => $option) {
239 + $option_id = $item['custom_id'] . $key;
240 + $option_value = esc_attr($option);
241 + $option_label = esc_html($option);
242 +
243 + if (false !== strpos($option, '|')) {
244 + list($label, $value) = explode('|', $option);
245 + $option_value = esc_attr($value);
246 + $option_label = esc_html($label);
247 + }
248 +
249 + $this->add_render_attribute($option_id, 'value', $option_value);
250 +
251 + // Support multiple selected values
252 + if (! empty($item['field_value']) && in_array($option_value, explode(',', $item['field_value']))) {
253 + $this->add_render_attribute($option_id, 'selected', 'selected');
254 + } ?>
255 + <option <?php $this->print_render_attribute_string($option_id); ?>><?php
256 + // PHPCS - $option_label is already escaped
257 + echo $option_label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
258 + ?></option>
259 + <?php } ?>
260 + </select>
261 + </div>
262 + <?php
263 +
264 + $select = ob_get_clean();
265 + return $select;
266 + }
267 + function build_radio_checkbox_field($item, $item_index, $type)
268 + {
269 + $options = preg_split("/\\r\\n|\\r|\\n/", $item['field_options']);
270 + $html = '';
271 + if ($options) {
272 + $html .= '<div class="ui-e-field-subgroup ' . esc_attr($item['css_classes']) . ' ' . esc_attr($item['inline_list']) . '">';
273 + foreach ($options as $key => $option) {
274 + $element_id = $item['custom_id'] . $key;
275 + $html_id = $this->get_attribute_id($item) . '-' . $key;
276 + $option_label = $option;
277 + $option_value = $option;
278 + if (false !== strpos($option, '|')) {
279 + list($option_label, $option_value) = explode('|', $option);
280 + }
281 +
282 + $this->add_render_attribute(
283 + $element_id,
284 + [
285 + 'type' => $type,
286 + 'value' => $option_value,
287 + 'id' => $html_id,
288 + 'name' => $this->get_attribute_name($item) . (('checkbox' === $type && count($options) > 1) ? '[]' : ''),
289 + ]
290 + );
291 +
292 + if ($item['required']) {
293 + $this->add_required_attribute($element_id, true);
294 + }
295 +
296 + if (! empty($item['field_value']) && $option_value === $item['field_value']) {
297 + $this->add_render_attribute($element_id, 'checked', 'checked');
298 + }
299 +
300 + if ($item['required'] && 'radio' === $type) {
301 + $this->add_required_attribute($element_id);
302 + }
303 +
304 + $html .= '<span class="ui-e-field-option">';
305 + $html .= '<input ' . $this->get_render_attribute_string($element_id) . '>';
306 + $html .= '<label for="' . $html_id . '">';
307 + $html .= esc_html($option_label);
308 + $html .= '</label></span>';
309 + }
310 + $html .= '</div>';
311 + }
312 +
313 + return $html;
314 + }
315 + function build_acceptance_field($item, $item_index)
316 + {
317 + $text = '';
318 + $this->add_render_attribute('input' . $item_index, 'class', 'ui-e-acceptance-field');
319 + $this->add_render_attribute('input' . $item_index, 'type', 'checkbox', true);
320 +
321 + if (! empty($item['acceptance_text'])) {
322 + $text = '<label for="' . $this->get_attribute_id($item) . '">' . Helper::esc_string($item['acceptance_text']) . '</label>';
323 + }
324 +
325 + if (! empty($item['checked_by_default'])) {
326 + $this->add_render_attribute('input' . $item_index, 'checked', 'checked');
327 + }
328 +
329 + ?>
330 + <div class="ui-e-field-subgroup <?php echo esc_attr($item['css_classes']); ?>">
331 + <input <?php $this->print_render_attribute_string('input' . $item_index); ?>>
332 + <?php // PHPCS - the variables $text is safe.
333 + echo $text; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
334 + ?>
335 + </div>
336 + <?php
337 + }
338 + function form_fields_render_attributes($i, $instance, $item)
339 + {
340 + $this->add_render_attribute(
341 + [
342 + 'field-group' . $i => [
343 + 'class' => [
344 + 'ui-e-field-type-' . $item['field_type'],
345 + 'ui-e-field-group',
346 + 'elementor-column',
347 + 'ui-e-field-group-' . $item['custom_id'],
348 + ],
349 + ],
350 + 'input' . $i => [
351 + 'type' => $item['field_type'],
352 + 'name' => $this->get_attribute_name($item),
353 + 'id' => $this->get_attribute_id($item),
354 + 'class' => [
355 + 'ui-e-field',
356 + empty($item['css_classes']) ? '' : esc_attr($item['css_classes']),
357 + ],
358 + ],
359 + 'label' . $i => [
360 + 'for' => $this->get_attribute_id($item),
361 + 'class' => 'ui-e-label',
362 + ],
363 + ]
364 + );
365 +
366 + if (empty($item['width'])) {
367 + $item['width'] = '100';
368 + }
369 +
370 + $this->add_render_attribute('field-group' . $i, 'class', 'elementor-col-' . $item['width']);
371 +
372 + if (! empty($item['width_tablet'])) {
373 + $this->add_render_attribute('field-group' . $i, 'class', 'elementor-md-' . $item['width_tablet']);
374 + }
375 +
376 + if ($item['allow_multiple']) {
377 + $this->add_render_attribute('field-group' . $i, 'class', 'ui-e-field-type-' . $item['field_type'] . '-multiple');
378 + }
379 +
380 + if (! empty($item['width_mobile'])) {
381 + $this->add_render_attribute('field-group' . $i, 'class', 'elementor-sm-' . $item['width_mobile']);
382 + }
383 +
384 + // Allow zero as placeholder.
385 + if (! Utils::is_empty($item['placeholder'])) {
386 + $this->add_render_attribute('input' . $i, 'placeholder', $item['placeholder']);
387 + }
388 +
389 + if (! empty($item['field_value'])) {
390 + $this->add_render_attribute('input' . $i, 'value', $item['field_value']);
391 + }
392 +
393 + if (! $instance['show_labels']) {
394 + $this->add_render_attribute('label' . $i, 'class', 'elementor-screen-only');
395 + }
396 +
397 + if (! empty($item['required'])) {
398 + $class = '';
399 + if (! empty($instance['mark_required'])) {
400 + $class .= ' ui-e-required';
401 + }
402 + $this->add_render_attribute('field-group' . $i, 'class', $class);
403 + $this->add_required_attribute('input' . $i);
404 + }
405 + }
406 +
407 + protected function register_controls()
408 + {
409 +
410 + // Content Controls
411 + // Repeater Controls used by `form_fields` control
412 + $repeater = new Repeater();
413 + $repeater->start_controls_tabs('form_fields_tabs');
414 +
415 + $repeater->start_controls_tab(
416 + 'form_fields_content_tab',
417 + [
418 + 'label' => esc_html__('Content', 'uicore-elements'),
419 + ]
420 + );
421 +
422 + $repeater->add_control(
423 + 'field_type',
424 + [
425 + 'label' => esc_html__('Type', 'uicore-elements'),
426 + 'type' => Controls_Manager::SELECT,
427 + 'options' => $this->get_field_types(),
428 + 'default' => 'text',
429 + ]
430 + );
431 + $repeater->add_control(
432 + 'field_label',
433 + [
434 + 'label' => esc_html__('Label', 'uicore-elements'),
435 + 'type' => Controls_Manager::TEXT,
436 + 'default' => '',
437 + 'dynamic' => [
438 + 'active' => true,
439 + ],
440 + ]
441 + );
442 + $repeater->add_control(
443 + 'placeholder',
444 + [
445 + 'label' => esc_html__('Placeholder', 'uicore-elements'),
446 + 'type' => Controls_Manager::TEXT,
447 + 'default' => '',
448 + 'conditions' => [
449 + 'terms' => [
450 + [
451 + 'name' => 'field_type',
452 + 'operator' => 'in',
453 + 'value' => [
454 + 'tel',
455 + 'text',
456 + 'email',
457 + 'textarea',
458 + 'number',
459 + 'url',
460 + 'password',
461 + ],
462 + ],
463 + ],
464 + ],
465 + 'dynamic' => [
466 + 'active' => true,
467 + ],
468 + ]
469 + );
470 + $repeater->add_control(
471 + 'required',
472 + [
473 + 'label' => esc_html__('Required', 'uicore-elements'),
474 + 'type' => Controls_Manager::SWITCHER,
475 + 'return_value' => 'true',
476 + 'default' => '',
477 + 'conditions' => [
478 + 'terms' => [
479 + [
480 + 'name' => 'field_type',
481 + 'operator' => '!in',
482 + 'value' => [
483 + 'recaptcha',
484 + 'recaptcha_v3',
485 + 'hidden',
486 + 'html',
487 + ],
488 + ],
489 + ],
490 + ],
491 + ]
492 + );
493 + $repeater->add_control(
494 + 'field_options',
495 + [
496 + 'label' => esc_html__('Options', 'uicore-elements'),
497 + 'type' => Controls_Manager::TEXTAREA,
498 + 'default' => '',
499 + 'description' => esc_html__('Enter each option in a separate line. To differentiate between label and value, separate them with a pipe char ("|"). For example: First Name|f_name', 'uicore-elements'),
500 + 'conditions' => [
501 + 'terms' => [
502 + [
503 + 'name' => 'field_type',
504 + 'operator' => 'in',
505 + 'value' => [
506 + 'select',
507 + 'checkbox',
508 + 'radio',
509 + ],
510 + ],
511 + ],
512 + ],
513 + ]
514 + );
515 + $repeater->add_control(
516 + 'allow_multiple',
517 + [
518 + 'label' => esc_html__('Multiple Selection', 'uicore-elements'),
519 + 'type' => Controls_Manager::SWITCHER,
520 + 'return_value' => 'true',
521 + 'conditions' => [
522 + 'terms' => [
523 + [
524 + 'name' => 'field_type',
525 + 'value' => 'select',
526 + ],
527 + ],
528 + ],
529 + ]
530 + );
531 + $repeater->add_control(
532 + 'select_size',
533 + [
534 + 'label' => esc_html__('Rows', 'uicore-elements'),
535 + 'type' => Controls_Manager::NUMBER,
536 + 'min' => 2,
537 + 'step' => 1,
538 + 'conditions' => [
539 + 'terms' => [
540 + [
541 + 'name' => 'field_type',
542 + 'value' => 'select',
543 + ],
544 + [
545 + 'name' => 'allow_multiple',
546 + 'value' => 'true',
547 + ],
548 + ],
549 + ],
550 + ]
551 + );
552 + $repeater->add_control(
553 + 'inline_list',
554 + [
555 + 'label' => esc_html__('Inline List', 'uicore-elements'),
556 + 'type' => Controls_Manager::SWITCHER,
557 + 'return_value' => 'ui-e-subgroup-inline',
558 + 'default' => '',
559 + 'conditions' => [
560 + 'terms' => [
561 + [
562 + 'name' => 'field_type',
563 + 'operator' => 'in',
564 + 'value' => [
565 + 'checkbox',
566 + 'radio',
567 + ],
568 + ],
569 + ],
570 + ],
571 + ]
572 + );
573 + $repeater->add_control(
574 + 'field_html',
575 + [
576 + 'label' => esc_html__('HTML', 'uicore-elements'),
577 + 'type' => Controls_Manager::TEXTAREA,
578 + 'dynamic' => [
579 + 'active' => true,
580 + ],
581 + 'conditions' => [
582 + 'terms' => [
583 + [
584 + 'name' => 'field_type',
585 + 'value' => 'html',
586 + ],
587 + ],
588 + ],
589 + ]
590 + );
591 + $repeater->add_control(
592 + 'acceptance_text',
593 + [
594 + 'label' => esc_html__('Acceptance Text', 'uicore-elements'),
595 + 'type' => Controls_Manager::TEXTAREA,
596 + 'condition' => [
597 + 'field_type' => 'acceptance',
598 + ],
599 + ],
600 + );
601 + $repeater->add_control(
602 + 'checked_by_default',
603 + [
604 + 'label' => esc_html__('Checked by Default', 'uicore-elements'),
605 + 'type' => Controls_Manager::SWITCHER,
606 + 'condition' => [
607 + 'field_type' => 'acceptance',
608 + ],
609 + ],
610 + );
611 + $repeater->add_responsive_control(
612 + 'width',
613 + [
614 + 'label' => esc_html__('Column Width', 'uicore-elements'),
615 + 'type' => Controls_Manager::SELECT,
616 + 'options' => [
617 + '' => esc_html__('Default', 'uicore-elements'),
618 + '100' => '100%',
619 + '80' => '80%',
620 + '75' => '75%',
621 + '70' => '70%',
622 + '66' => '66%',
623 + '60' => '60%',
624 + '50' => '50%',
625 + '40' => '40%',
626 + '33' => '33%',
627 + '30' => '30%',
628 + '25' => '25%',
629 + '20' => '20%',
630 + ],
631 + 'default' => '100',
632 + 'conditions' => [
633 + 'terms' => [
634 + [
635 + 'name' => 'field_type',
636 + 'operator' => '!in',
637 + 'value' => [
638 + 'hidden',
639 + 'recaptcha',
640 + 'recaptcha_v3'
641 + ],
642 + ],
643 + ],
644 + ],
645 + ]
646 + );
647 + $repeater->add_control(
648 + 'rows',
649 + [
650 + 'label' => esc_html__('Rows', 'uicore-elements'),
651 + 'type' => Controls_Manager::NUMBER,
652 + 'default' => 4,
653 + 'conditions' => [
654 + 'terms' => [
655 + [
656 + 'name' => 'field_type',
657 + 'value' => 'textarea',
658 + ],
659 + ],
660 + ],
661 + ]
662 + );
663 + $repeater->add_control(
664 + 'recaptcha_hide',
665 + [
666 + 'label' => esc_html__('Badge', 'uicore-elements'),
667 + 'type' => Controls_Manager::SELECT,
668 + 'default' => 'hidden',
669 + 'options' => [
670 + 'hidden' => esc_html__('Hidden', 'uicore-elements'),
671 + 'visible' => esc_html__('Visible', 'uicore-elements')
672 + ],
673 + 'condition' => [
674 + 'field_type' => 'recaptcha_v3',
675 + ],
676 + 'selectors' => [
677 + '.grecaptcha-badge' => 'visibility: {{VALUE}};',
678 + ],
679 + ]
680 + );
681 + $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
682 + $repeater->add_control(
683 + 'recaptcha_warning',
684 + [
685 + 'type' => Controls_Manager::ALERT,
686 + 'alert_type' => 'warning',
687 + 'dismissible' => false,
688 + 'heading' => esc_html__("You haven't set your reCAPTCHA API keys yet.", 'uicore-elements'),
689 + 'content' => Helper::get_admin_settings_url(esc_html__("Click here to configure your API keys.", 'uicore-elements')),
690 + 'condition' => [
691 + 'field_type' => $recaptcha_keys ? ['recaptcha', 'recaptcha_v3'] : [],
692 + ]
693 + ]
694 + );
695 +
696 + $repeater->end_controls_tab();
697 +
698 + $repeater->start_controls_tab(
699 + 'form_fields_advanced_tab',
700 + [
701 + 'label' => esc_html__('Advanced', 'uicore-elements'),
702 + 'condition' => [
703 + 'field_type!' => ['html', 'address'],
704 + ],
705 + ]
706 + );
707 +
708 + $repeater->add_control(
709 + 'field_value',
710 + [
711 + 'label' => esc_html__('Default Value', 'uicore-elements'),
712 + 'type' => Controls_Manager::TEXT,
713 + 'default' => '',
714 + 'dynamic' => [
715 + 'active' => true,
716 + ],
717 + 'ai' => [
718 + 'active' => false,
719 + ],
720 + 'conditions' => [
721 + 'terms' => [
722 + [
723 + 'name' => 'field_type',
724 + 'operator' => 'in',
725 + 'value' => [
726 + 'text',
727 + 'email',
728 + 'textarea',
729 + 'url',
730 + 'tel',
731 + 'radio',
732 + 'select',
733 + 'number',
734 + 'date',
735 + 'time',
736 + 'hidden',
737 + ],
738 + ],
739 + ],
740 + ],
741 + ]
742 + );
743 + $repeater->add_control(
744 + 'custom_id',
745 + [
746 + 'label' => esc_html__('ID', 'uicore-elements'),
747 + 'type' => Controls_Manager::TEXT,
748 + 'description' => esc_html__('Please make sure the ID is unique and not used elsewhere in this form. This field allows `A-z 0-9` & underscore chars without spaces.', 'uicore-elements'),
749 + 'render_type' => 'none',
750 + 'required' => true,
751 + 'dynamic' => [
752 + 'active' => true,
753 + ],
754 + 'ai' => [
755 + 'active' => false,
756 + ],
757 + ]
758 + );
759 + $repeater->add_control(
760 + 'css_classes',
761 + [
762 + 'label' => esc_html__('Custom Class', 'uicore-elements'),
763 + 'type' => Controls_Manager::TEXT,
764 + 'default' => '',
765 + 'ai' => [
766 + 'active' => false,
767 + ],
768 + 'placeholder' => esc_html__('e.g: my-class', 'uicore-elements'),
769 + ]
770 + );
771 + $shortcode_template = '{{ view.container.settings.get( \'custom_id\' ) }}';
772 + $repeater->add_control(
773 + 'shortcode',
774 + [
775 + 'label' => esc_html__('Shortcode', 'uicore-elements'),
776 + 'type' => Controls_Manager::RAW_HTML,
777 + 'classes' => 'forms-field-shortcode',
778 + 'raw' => '<input class="elementor-form-field-shortcode" value=\'[field id="' . $shortcode_template . '"]\' readonly />',
779 + 'label_block' => false,
780 + ]
781 + );
782 +
783 + $repeater->end_controls_tab();
784 +
785 + $repeater->end_controls_tabs();
786 +
787 + $this->start_controls_section(
788 + 'section_form_fields',
789 + [
790 + 'label' => esc_html__('Form Fields', 'uicore-elements'),
791 + ]
792 + );
793 +
794 +
795 + $this->add_control(
796 + 'form_name',
797 + [
798 + 'label' => esc_html__('Form Name', 'uicore-elements'),
799 + 'type' => Controls_Manager::TEXT,
800 + 'default' => esc_html__('New Form', 'uicore-elements'),
801 + 'placeholder' => esc_html__('Form Name', 'uicore-elements'),
802 + ]
803 + );
804 + $this->add_control(
805 + 'form_fields',
806 + [
807 + 'type' => Controls_Manager::REPEATER,
808 + 'fields' => $repeater->get_controls(),
809 + 'default' => [
810 + [
811 + 'custom_id' => 'name',
812 + 'field_type' => 'text',
813 + 'field_label' => esc_html__('Name', 'uicore-elements'),
814 + 'placeholder' => esc_html__('Name', 'uicore-elements'),
815 + 'width' => '100',
816 + 'dynamic' => [
817 + 'active' => true,
818 + ],
819 + ],
820 + [
821 + 'custom_id' => 'email',
822 + 'field_type' => 'email',
823 + 'required' => 'true',
824 + 'field_label' => esc_html__('Email', 'uicore-elements'),
825 + 'placeholder' => esc_html__('Email', 'uicore-elements'),
826 + 'width' => '100',
827 + ],
828 + [
829 + 'custom_id' => 'address',
830 + 'field_type' => 'address',
831 + 'field_label' => esc_html__('address (honeypot)', 'uicore-elements'),
832 + 'placeholder' => esc_html__('address', 'uicore-elements'),
833 + 'width' => '100',
834 + ],
835 + [
836 + 'custom_id' => 'message',
837 + 'field_type' => 'textarea',
838 + 'field_label' => esc_html__('Message', 'uicore-elements'),
839 + 'placeholder' => esc_html__('Message', 'uicore-elements'),
840 + 'width' => '100',
841 + ],
842 + ],
843 + 'title_field' => '{{ field_label }}',
844 + ]
845 + );
846 + $this->add_control(
847 + 'show_labels',
848 + [
849 + 'label' => esc_html__('Label', 'uicore-elements'),
850 + 'type' => Controls_Manager::SWITCHER,
851 + 'label_on' => esc_html__('Show', 'uicore-elements'),
852 + 'label_off' => esc_html__('Hide', 'uicore-elements'),
853 + 'return_value' => 'true',
854 + 'default' => 'true',
855 + 'separator' => 'before',
856 + ]
857 + );
858 + $this->add_control(
859 + 'mark_required',
860 + [
861 + 'label' => esc_html__('Required Mark', 'uicore-elements'),
862 + 'type' => Controls_Manager::SWITCHER,
863 + 'label_on' => esc_html__('Show', 'uicore-elements'),
864 + 'label_off' => esc_html__('Hide', 'uicore-elements'),
865 + 'default' => '',
866 + 'render_type' => 'template',
867 + 'condition' => [
868 + 'show_labels!' => '',
869 + ],
870 + ]
871 + );
872 +
873 + $this->end_controls_section();
874 +
875 + $this->start_controls_section(
876 + 'section_buttons',
877 + [
878 + 'label' => esc_html__('Button', 'uicore-elements'),
879 + ]
880 + );
881 +
882 + $this->add_responsive_control(
883 + 'button_width',
884 + [
885 + 'label' => esc_html__('Column Width', 'uicore-elements'),
886 + 'type' => Controls_Manager::SELECT,
887 + 'options' => [
888 + '' => esc_html__('Default', 'uicore-elements'),
889 + '100' => '100%',
890 + '80' => '80%',
891 + '75' => '75%',
892 + '70' => '70%',
893 + '66' => '66%',
894 + '60' => '60%',
895 + '50' => '50%',
896 + '40' => '40%',
897 + '33' => '33%',
898 + '30' => '30%',
899 + '25' => '25%',
900 + '20' => '20%',
901 + ],
902 + 'default' => '100',
903 + ]
904 + );
905 + $this->add_responsive_control(
906 + 'button_align',
907 + [
908 + 'label' => esc_html__('Alignment', 'uicore-elements'),
909 + 'type' => Controls_Manager::CHOOSE,
910 + 'options' => [
911 + 'left' => [
912 + 'title' => esc_html__('Left', 'uicore-elements'),
913 + 'icon' => 'eicon-text-align-left',
914 + ],
915 + 'center' => [
916 + 'title' => esc_html__('Center', 'uicore-elements'),
917 + 'icon' => 'eicon-text-align-center',
918 + ],
919 + 'right' => [
920 + 'title' => esc_html__('Right', 'uicore-elements'),
921 + 'icon' => 'eicon-text-align-right',
922 + ],
923 + 'stretch' => [
924 + 'title' => esc_html__('Justified', 'uicore-elements'),
925 + 'icon' => 'eicon-text-align-justify',
926 + ],
927 + ],
928 + 'default' => 'stretch',
929 + 'prefix_class' => 'ui-e-submit-align-%s-',
930 + ]
931 + );
932 + $this->add_control(
933 + 'button_text',
934 + [
935 + 'label' => esc_html__('Submit', 'uicore-elements'),
936 + 'type' => Controls_Manager::TEXT,
937 + 'default' => esc_html__('Send', 'uicore-elements'),
938 + 'placeholder' => esc_html__('Send', 'uicore-elements'),
939 + 'dynamic' => [
940 + 'active' => true,
941 + ],
942 + 'ai' => [
943 + 'active' => false,
944 + ],
945 + ]
946 + );
947 + $this->add_control(
948 + 'selected_button_icon',
949 + [
950 + 'label' => esc_html__('Icon', 'uicore-elements'),
951 + 'type' => Controls_Manager::ICONS,
952 + 'skin' => 'inline',
953 + 'label_block' => false,
954 + ]
955 + );
956 + $this->add_control(
957 + 'button_icon_align',
958 + [
959 + 'label' => esc_html__('Icon Position', 'uicore-elements'),
960 + 'type' => Controls_Manager::SELECT,
961 + 'default' => 'left',
962 + 'options' => [
963 + 'left' => esc_html__('Before', 'uicore-elements'),
964 + 'right' => esc_html__('After', 'uicore-elements'),
965 + ],
966 + 'condition' => [
967 + 'selected_button_icon[value]!' => '',
968 + ],
969 + ]
970 + );
971 + $this->add_control(
972 + 'button_icon_indent',
973 + [
974 + 'label' => esc_html__('Icon Spacing', 'uicore-elements'),
975 + 'type' => Controls_Manager::SLIDER,
976 + 'size_units' => ['px', 'em', 'rem', 'custom'],
977 + 'range' => [
978 + 'px' => [
979 + 'max' => 100,
980 + ],
981 + 'em' => [
982 + 'max' => 10,
983 + ],
984 + 'rem' => [
985 + 'max' => 10,
986 + ],
987 + ],
988 + 'condition' => [
989 + 'selected_button_icon[value]!' => '',
990 + ],
991 + 'selectors' => [
992 + '{{WRAPPER}} .elementor-button .ui-e-align-right' => 'margin-left: {{SIZE}}{{UNIT}};',
993 + '{{WRAPPER}} .elementor-button .ui-e-align-left' => 'margin-right: {{SIZE}}{{UNIT}};',
994 + ],
995 + ]
996 + );
997 + $this->add_control(
998 + 'button_css_id',
999 + [
1000 + 'label' => esc_html__('Button ID', 'uicore-elements'),
1001 + 'type' => Controls_Manager::TEXT,
1002 + 'default' => '',
1003 + 'ai' => [
1004 + 'active' => false,
1005 + ],
1006 + 'title' => esc_html__('Add your custom id WITHOUT the Pound key. e.g: my-id', 'uicore-elements'),
1007 + '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'),
1008 + 'separator' => 'before',
1009 + 'dynamic' => [
1010 + 'active' => true,
1011 + ],
1012 + ]
1013 + );
1014 +
1015 +
1016 + $this->end_controls_section();
1017 +
1018 + $this->TRAIT_register_submit_actions_controls(Contact_Form_Service::get_form_submit_options());
1019 +
1020 + // Submit sections
1021 + $this->start_controls_section(
1022 + 'section_email',
1023 + [
1024 + 'label' => esc_html__('Email', 'uicore-elements'),
1025 + 'condition' => [
1026 + 'submit_actions' => 'email',
1027 + ],
1028 + ]
1029 + );
1030 +
1031 + $this->TRAIT_register_submit_email_controls($this);
1032 +
1033 + $this->end_controls_section();
1034 +
1035 + $this->start_controls_section(
1036 + 'section_email_2',
1037 + [
1038 + 'label' => esc_html__('Email 2', 'uicore-elements'),
1039 + 'condition' => [
1040 + 'submit_actions' => 'email_2',
1041 + ],
1042 + ]
1043 + );
1044 +
1045 + $this->TRAIT_register_submit_email_controls($this, '_2');
1046 +
1047 + $this->end_controls_section();
1048 +
1049 + $this->TRAIT_register_submit_redirect_controls();
1050 + $this->TRAIT_register_submit_popup_controls($this);
1051 + $this->TRAIT_register_submit_webhook_controls();
1052 + $this->TRAIT_register_submit_newsletter_services_controls(Newsletter_Services::get_services_list('keys'), true);
1053 + $default_messages = Contact_Form_Service::get_default_messages();
1054 + $this->TRAIT_register_additional_controls($default_messages);
1055 +
1056 + $this->TRAIT_register_all_form_style_controls();
1057 +
1058 + // Custom Fields additional Controls injection
1059 + $this->start_injection([
1060 + 'of' => 'redirect_message',
1061 + 'at' => 'before',
1062 + ]);
1063 + $this->add_control(
1064 + 'required_fields_message',
1065 + [
1066 + 'label' => esc_html__('Required Fields', 'uicore-elements'),
1067 + 'type' => Controls_Manager::TEXT,
1068 + 'default' => $default_messages['required'],
1069 + 'placeholder' => $default_messages['required'],
1070 + 'label_block' => true,
1071 + 'conditions' => [
1072 + 'terms' => [
1073 + [
1074 + 'name' => 'custom_messages',
1075 + 'operator' => '!=',
1076 + 'value' => '',
1077 + ],
1078 + ],
1079 + ],
1080 + 'render_type' => 'none',
1081 + 'dynamic' => [
1082 + 'active' => true,
1083 + ],
1084 + ]
1085 + );
1086 + $this->end_injection();
1087 +
1088 + // Specific Form style controls
1089 + $this->start_injection([
1090 + 'of' => 'form_styles_component_divider',
1091 + 'at' => 'after',
1092 + ]);
1093 +
1094 + $this->add_control(
1095 + 'heading_html',
1096 + [
1097 + 'label' => esc_html__('HTML Field', 'uicore-elements'),
1098 + 'type' => Controls_Manager::HEADING,
1099 + ]
1100 + );
1101 + $this->add_control(
1102 + 'html_spacing',
1103 + [
1104 + 'label' => esc_html__('Spacing', 'uicore-elements'),
1105 + 'type' => Controls_Manager::SLIDER,
1106 + 'size_units' => ['px', 'em', 'rem', 'custom'],
1107 + 'default' => [
1108 + 'size' => 0,
1109 + ],
1110 + 'range' => [
1111 + 'px' => [
1112 + 'max' => 60,
1113 + ],
1114 + 'em' => [
1115 + 'max' => 6,
1116 + ],
1117 + 'rem' => [
1118 + 'max' => 6,
1119 + ],
1120 + ],
1121 + 'selectors' => [
1122 + '{{WRAPPER}} .ui-e-field-type-html' => 'padding-bottom: {{SIZE}}{{UNIT}};',
1123 + ],
1124 + ]
1125 + );
1126 + $this->add_control(
1127 + 'html_color',
1128 + [
1129 + 'label' => esc_html__('Color', 'uicore-elements'),
1130 + 'type' => Controls_Manager::COLOR,
1131 + 'selectors' => [
1132 + '{{WRAPPER}} .ui-e-field-type-html' => 'color: {{VALUE}};',
1133 + ],
1134 + ]
1135 + );
1136 + $this->add_group_control(
1137 + Group_Control_Typography::get_type(),
1138 + [
1139 + 'name' => 'html_typography',
1140 + 'selector' => '{{WRAPPER}} .ui-e-field-type-html',
1141 + 'global' => [
1142 + 'default' => Global_Typography::TYPOGRAPHY_TEXT,
1143 + ],
1144 + ]
1145 + );
1146 +
1147 + $this->add_control(
1148 + 'heading_file',
1149 + [
1150 + 'label' => esc_html__('Upload File Field', 'uicore-elements'),
1151 + 'type' => Controls_Manager::HEADING,
1152 + 'separator' => 'before',
1153 + ]
1154 + );
1155 + $this->add_control(
1156 + 'file_color',
1157 + [
1158 + 'label' => esc_html__('Color', 'uicore-elements'),
1159 + 'type' => Controls_Manager::COLOR,
1160 + 'selectors' => [
1161 + '{{WRAPPER}} .ui-e-field-type-file input.ui-e-field' => 'color: {{VALUE}};',
1162 + ],
1163 + 'default' => 'var(--e-global-color-uicore_body)',
1164 +
1165 + ]
1166 + );
1167 + $this->end_injection();
1168 + }
1169 + function recaptcha_js()
1170 + {
1171 + ?>
1172 + <script>
1173 + window.uicore_elements_recaptcha = '<?php echo esc_html(get_option('uicore_elements_recaptcha_site_key')); ?>';
1174 + </script>
1175 + <?php
1176 + }
1177 +
1178 + protected function render()
1179 + {
1180 +
1181 + $instance = $this->get_settings_for_display();
1182 + $is_recaptcha_required = false;
1183 +
1184 + // Save widget settings so form API can retrieve them
1185 + set_transient('ui_e_form_widget_settings_' . $this->get_id(), $instance, DAY_IN_SECONDS);
1186 +
1187 + // Render Form Atts
1188 + $this->add_render_attribute(
1189 + [
1190 + 'wrapper' => [
1191 + 'class' => [
1192 + 'ui-e-fields-wrp',
1193 + ],
1194 + ],
1195 + 'submit-group' => [
1196 + 'class' => [
1197 + 'ui-e-field-group',
1198 + 'elementor-column',
1199 + 'ui-e-field-type-submit',
1200 + ],
1201 + ],
1202 + 'button' => [
1203 + 'class' => 'elementor-button',
1204 + ],
1205 + 'icon-align' => [
1206 + 'class' => [
1207 + empty($instance['button_icon_align']) ? '' : 'ui-e-icon ui-e-align-' . $instance['button_icon_align'],
1208 + ],
1209 + ],
1210 + ]
1211 + );
1212 +
1213 + // Fallback for empty control values
1214 + if (empty($instance['button_width'])) {
1215 + $instance['button_width'] = '100';
1216 + }
1217 +
1218 + // Button atts
1219 + $this->add_render_attribute('submit-group', 'class', 'elementor-col-' . $instance['button_width'] . ' e-form__buttons');
1220 +
1221 + if (! empty($instance['button_width_tablet'])) {
1222 + $this->add_render_attribute('submit-group', 'class', 'elementor-md-' . $instance['button_width_tablet']);
1223 + }
1224 + if (! empty($instance['button_width_mobile'])) {
1225 + $this->add_render_attribute('submit-group', 'class', 'elementor-sm-' . $instance['button_width_mobile']);
1226 + }
1227 + if ($instance['button_hover_animation']) {
1228 + $this->add_render_attribute('button', 'class', 'elementor-animation-' . $instance['button_hover_animation']);
1229 + }
1230 +
1231 + // Form atts
1232 + if (! empty($instance['form_id'])) {
1233 + $this->add_render_attribute('form', 'id', $instance['form_id']);
1234 + }
1235 + if (! empty($instance['form_name'])) {
1236 + $this->add_render_attribute('form', 'name', $instance['form_name']);
1237 + }
1238 + if ('no' === $instance['form_validation']) {
1239 + $this->add_render_attribute('form', 'novalidate');
1240 + }
1241 + if (! empty($instance['button_css_id'])) {
1242 + $this->add_render_attribute('button', 'id', $instance['button_css_id']);
1243 + }
1244 +
1245 + $referer_title = trim(wp_title('', false));
1246 + if (! $referer_title && is_home()) {
1247 + $referer_title = get_option('blogname');
1248 + }
1249 +
1250 + // Get default messages
1251 + $messages = Contact_Form_Service::get_default_messages();
1252 +
1253 + // Set frontend validation message
1254 + $front_msg_required = isset($instance['required_fields_message'])
1255 + ? $instance['required_fields_message']
1256 + : $messages['required'];
1257 + ?>
1258 +
1259 + <form class="ui-e-form" method="post" <?php $this->print_render_attribute_string('form'); ?>>
1260 +
1261 + <input type="hidden" name="post_id" value="<?php echo esc_attr(get_the_ID()); ?>" />
1262 + <input type="hidden" name="widget_type" value="contact-form">
1263 +
1264 + <input type="hidden" name="required_fields_message" value="<?php echo esc_html($front_msg_required); ?>">
1265 +
1266 + <div <?php $this->print_render_attribute_string('wrapper'); ?>>
1267 +
1268 + <?php foreach ($instance['form_fields'] as $item_index => $item) :
1269 + $this->form_fields_render_attributes($item_index, $instance, $item);
1270 +
1271 + $field_type = $item['field_type'];
1272 +
1273 + if ($field_type === 'recaptcha' || $field_type === 'recaptcha_v3') {
1274 + $is_recaptcha_required = true;
1275 + }
1276 +
1277 + $print_label = ! in_array($item['field_type'], ['hidden', 'html'], true);
1278 + ?>
1279 +
1280 + <div <?php $this->print_render_attribute_string('field-group' . $item_index); ?>>
1281 + <?php
1282 + // Print label (excepts if recaptcha)
1283 + if ($print_label && $item['field_label'] && $item['field_type'] !== 'recaptcha' && $item['field_type'] !== 'recaptcha_v3') {
1284 + ?>
1285 + <label <?php $this->print_render_attribute_string('label' . $item_index); ?>>
1286 + <?php // PHPCS - the variable $item['field_label'] is safe.
1287 + echo Helper::esc_string($item['field_label']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1288 + ?>
1289 + </label>
1290 + <?php
1291 + }
1292 +
1293 + // Print field
1294 + switch ($item['field_type']):
1295 + case 'html':
1296 + echo wp_kses_post(do_shortcode($item['field_html']));
1297 + break;
1298 +
1299 + case 'textarea':
1300 + // PHPCS - the method build_textarea_field is safe.
1301 + echo $this->build_textarea_field($item, $item_index); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1302 + break;
1303 +
1304 + case 'select':
1305 + // PHPCS - the method build_select_field is safe.
1306 + echo $this->build_select_field($item, $item_index); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1307 + break;
1308 +
1309 + case 'acceptance':
1310 + // PHPCS - the method build_select_field is safe.
1311 + $this->build_acceptance_field($item, $item_index); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1312 + break;
1313 +
1314 + case 'radio':
1315 + case 'checkbox':
1316 + // PHPCS - the method build_radio_checkbox_field is safe.
1317 + echo $this->build_radio_checkbox_field($item, $item_index, $item['field_type']); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1318 + break;
1319 +
1320 + case 'address': // is actually honeypot
1321 + // PHPCS - the method build_honeypot_field is safe.
1322 + echo $this->build_honeypot_field($item, $item_index); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1323 + break;
1324 +
1325 + case 'recaptcha':
1326 + // get widget ID
1327 + echo '<input type="hidden" name="recaptcha"/> <div id="ui-e-recaptcha-' . esc_attr($this->get_ID()) . '"></div>';
1328 + break;
1329 +
1330 + case 'recaptcha_v3':
1331 + echo '<input type="hidden" name="recaptcha_v3"/>';
1332 + break;
1333 +
1334 + // All other cases are covered by the add_render_atribute()
1335 + default:
1336 + $this->add_render_attribute('input' . $item_index, 'class', 'ui-e-field-textual');
1337 + ?>
1338 + <input size="1" <?php $this->print_render_attribute_string('input' . $item_index); ?>>
1339 + <?php
1340 + break;
1341 +
1342 + endswitch;
1343 + ?>
1344 + </div>
1345 +
1346 + <?php endforeach; ?>
1347 +
1348 + <div <?php $this->print_render_attribute_string('submit-group'); ?>>
1349 + <button type="submit" <?php $this->print_render_attribute_string('button'); ?>>
1350 + <span <?php $this->print_render_attribute_string('content-wrapper'); ?>>
1351 + <?php if (! empty($instance['button_icon']) || ! empty($instance['selected_button_icon'])) : ?>
1352 + <span <?php $this->print_render_attribute_string('icon-align'); ?>>
1353 + <?php Icons_Manager::render_icon($instance['selected_button_icon'], ['aria-hidden' => 'true']); ?>
1354 + <?php if (empty($instance['button_text'])) : ?>
1355 + <span class="elementor-screen-only"><?php echo esc_html__('Submit', 'uicore-elements'); ?></span>
1356 + <?php endif; ?>
1357 + </span>
1358 + <?php endif; ?>
1359 + <?php if (! empty($instance['button_text'])) : ?>
1360 + <span class="ui-e-text"><?php $this->print_unescaped_setting('button_text'); ?></span>
1361 + <?php endif; ?>
1362 + </span>
1363 + </button>
1364 + </div>
1365 +
1366 + </div>
1367 +
1368 + <div class="ui-e-message <?php echo $this->is_edit_mode() ? 'elementor-hidden' : ''; ?>">
1369 + <?php if ($this->is_edit_mode()) :
1370 + // Get custom messages if set, else use default
1371 + $success = isset($instance['success_message'])
1372 + ? $instance['success_message']
1373 + : $messages['success'];
1374 + $error = isset($instance['error_message'])
1375 + ? $instance['error_message']
1376 + : $messages['error'];
1377 + ?>
1378 + <span class="success"> <?php echo esc_html($success); ?> </span> <br>
1379 + <span class="error"> <?php echo esc_html($error); ?> </span>
1380 + <?php endif; ?>
1381 + </div>
1382 + </form>
1383 + <?php
1384 +
1385 + //add js to footer if recaptcha is enabled
1386 + if ($is_recaptcha_required) {
1387 + add_action('wp_footer', [$this, 'recaptcha_js'], 999);
1388 + }
1389 +
1390 + // Add frontend validation messages to js var
1391 + ?>
1392 + <script>
1393 + window.ui_e_form_validation_messages = <?php echo json_encode([
1394 + 'required_fields' => esc_html($front_msg_required),
1395 + ]); ?>;
1396 + </script>
1397 +<?php
1398 + }
1399 +}
1400 +\Elementor\Plugin::instance()->widgets_manager->register(new ContactForm());