PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.5.0
Easy Elements for Elementor – Addons & Website Templates v1.5.0
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / widgets / cf7 / contact-cf7.php

contact-cf7.php in Easy Elements for Elementor – Addons & Website Templates 1.5.0, at widgets/cf7/contact-cf7.php

660 lines 21.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Easyel\EasyElements\Widgets;
3 use Elementor\Controls_Manager;
4 use Elementor\Group_Control_Box_Shadow;
5 use Elementor\Group_Control_Typography;
6 use Elementor\Group_Control_Border;
7 use Elementor\Group_Control_Background;
8
9 defined( 'ABSPATH' ) || die();
10
11 class easyel__CF7_Widget extends \Elementor\Widget_Base {
12
13 public function get_name() {
14 return 'eel-cf7';
15 }
16
17 /**
18 * Get widget title.
19 *
20 * Retrieve counter widget title.
21 *
22 * @since 1.0.0
23 * @access public
24 *
25 * @return string Widget title.
26 */
27 public function get_title() {
28 return esc_html__( 'Contact Form 7', 'easy-elements' );
29 }
30
31 /**
32 * Get widget icon.
33 *
34 * Retrieve counter widget icon.
35 *
36 * @since 1.0.0
37 * @access public
38 *
39 * @return string Widget icon.
40 */
41 public function get_icon() {
42 return 'easyicon easyelIcon-contact-form';
43 }
44
45 /**
46 * Retrieve the list of scripts the counter widget depended on.
47 *
48 * Used to set scripts dependencies required to run the widget.
49 *
50 * @since 1.3.0
51 * @access public
52 *
53 * @return array Widget scripts dependencies.
54 */
55 public function get_categories() {
56 return [ 'easyelements_category_form' ];
57 }
58
59 /**
60 * Get widget keywords.
61 *
62 * Retrieve the list of keywords the widget belongs to.
63 *
64 * @since 2.1.0
65 * @access public
66 *
67 * @return array Widget keywords.
68 */
69 public function get_keywords() {
70 return [ 'contact', 'form', 'input', 'text' ];
71 }
72
73 public function get_style_depends() {
74 return [
75 'eel-cf7',
76 ];
77 }
78
79
80 protected function register_controls() {
81 $this->start_controls_section(
82 '_section_cf7',
83 [
84 'label' => class_exists( 'WPCF7' ) ? esc_html__( 'Form Settings', 'easy-elements' ) : esc_html__( 'Notice', 'easy-elements' ),
85 'tab' => Controls_Manager::TAB_CONTENT,
86 ]
87 );
88
89 if ( ! class_exists( 'WPCF7' ) ) {
90 $this->add_control(
91 'cf7_missing_notice',
92 [
93 'type' => Controls_Manager::RAW_HTML,
94 'raw' => sprintf(
95 esc_html__( 'Hi, it seems contact form7 is missing in your site. Please install and activate contact form7 first.', 'easy-elements' ),
96 '<a href="https://wordpress.org/plugins/contact-form-7/" target="_blank" rel="noopener">Contact Form 7</a>'
97 ),
98 'content_classes' => 'elementor-panel-alert elementor-panel-alert-warning',
99 ]
100 );
101 $this->end_controls_section();
102 return;
103 }
104
105 $this->add_control(
106 'selected_form_id',
107 [
108 'label' => esc_html__( 'Chosse Your Form', 'easy-elements' ),
109 'type' => Controls_Manager::SELECT,
110 'label_block' => true,
111 'options' => ['' => esc_html__( 'Select', 'easy-elements' ) ] + \easyel_get_cf7_forms(),
112 ]
113 );
114
115 $this->end_controls_section();
116
117 $this->start_controls_section(
118 '_section_fields_style',
119 [
120 'label' => esc_html__( 'Form Fields', 'easy-elements' ),
121 'tab' => Controls_Manager::TAB_STYLE,
122 ]
123 );
124
125 $this->add_responsive_control(
126 'field_width',
127 [
128 'label' => esc_html__( 'Width', 'easy-elements' ),
129 'type' => Controls_Manager::SLIDER,
130 'default' => [
131 'unit' => '%',
132 ],
133 'tablet_default' => [
134 'unit' => '%',
135 ],
136 'mobile_default' => [
137 'unit' => '%',
138 ],
139 'size_units' => [ '%', 'px' ],
140 'range' => [
141 '%' => [
142 'min' => 1,
143 'max' => 100,
144 ],
145 'px' => [
146 'min' => 1,
147 'max' => 500,
148 ],
149 ],
150 'selectors' => [
151 '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)' => 'width: {{SIZE}}{{UNIT}};',
152
153
154 ],
155 ]
156 );
157
158 $this->add_responsive_control(
159 'field_margin',
160 [
161 'label' => esc_html__( 'Spacing Bottom', 'easy-elements' ),
162 'type' => Controls_Manager::SLIDER,
163 'size_units' => [ 'px' ],
164 'range' => [
165 'px' => [
166 'min' => 0,
167 'max' => 100,
168 ],
169 ],
170 'selectors' => [
171 '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)' => 'margin-bottom: {{SIZE}}{{UNIT}};',
172 ],
173 ]
174 );
175
176 $this->add_responsive_control(
177 'field_padding',
178 [
179 'label' => esc_html__( 'Padding', 'easy-elements' ),
180 'type' => Controls_Manager::DIMENSIONS,
181 'size_units' => [ 'px', 'em', '%' ],
182 'selectors' => [
183 '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
184 ],
185 ]
186 );
187
188 $this->add_responsive_control(
189 'field_border_radius',
190 [
191 'label' => esc_html__( 'Border Radius', 'easy-elements' ),
192 'type' => Controls_Manager::DIMENSIONS,
193 'size_units' => [ 'px', '%' ],
194 'selectors' => [
195 '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
196 ],
197 ]
198 );
199
200 $this->add_control(
201 'hr',
202 [
203 'type' => Controls_Manager::DIVIDER,
204 'style' => 'thick',
205 ]
206 );
207
208 $this->add_group_control(
209 Group_Control_Typography::get_type(),
210 [
211 'name' => 'field_typography',
212 'label' => esc_html__( 'Typography', 'easy-elements' ),
213 'selector' => '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)',
214
215 ]
216 );
217
218 $this->add_control(
219 'field_color',
220 [
221 'label' => esc_html__( 'Text Color', 'easy-elements' ),
222 'type' => Controls_Manager::COLOR,
223 'selectors' => [
224 '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)' => 'color: {{VALUE}}',
225 ],
226 ]
227 );
228
229 $this->add_control(
230 'field_placeholder_color',
231 [
232 'label' => esc_html__( 'Placeholder Text Color', 'easy-elements' ),
233 'type' => Controls_Manager::COLOR,
234 'selectors' => [
235 '{{WRAPPER}} ::-webkit-input-placeholder' => 'color: {{VALUE}};',
236 '{{WRAPPER}} ::-moz-placeholder' => 'color: {{VALUE}};',
237 '{{WRAPPER}} ::-ms-input-placeholder' => 'color: {{VALUE}};',
238 ],
239 ]
240 );
241
242 $this->add_control(
243 'field_focus_color',
244 [
245 'label' => esc_html__( 'Focus Outline Color', 'easy-elements' ),
246 'type' => Controls_Manager::COLOR,
247 'selectors' => [
248 '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit):focus' => 'outline: 1px solid {{VALUE}}',
249 ],
250 ]
251 );
252
253 $this->start_controls_tabs( 'tabs_field_state' );
254
255 $this->start_controls_tab(
256 'tab_field_normal',
257 [
258 'label' => esc_html__( 'Normal', 'easy-elements' ),
259 ]
260 );
261
262 $this->add_group_control(
263 Group_Control_Border::get_type(),
264 [
265 'name' => 'field_border',
266 'selector' => '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)',
267 ]
268 );
269
270 $this->add_group_control(
271 Group_Control_Box_Shadow::get_type(),
272 [
273 'name' => 'field_box_shadow',
274 'selector' => '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)',
275 ]
276 );
277
278 $this->add_control(
279 'field_bg_color',
280 [
281 'label' => esc_html__( 'Background Color', 'easy-elements' ),
282 'type' => Controls_Manager::COLOR,
283 'selectors' => [
284 '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)' => 'background-color: {{VALUE}}',
285 ],
286 ]
287 );
288
289 $this->end_controls_tab();
290
291 $this->start_controls_tab(
292 'tab_field_focus',
293 [
294 'label' => esc_html__( 'Focus', 'easy-elements' ),
295 ]
296 );
297
298 $this->add_group_control(
299 Group_Control_Border::get_type(),
300 [
301 'name' => 'field_focus_border',
302 'selector' => '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit):focus',
303 ]
304 );
305
306 $this->add_group_control(
307 Group_Control_Box_Shadow::get_type(),
308 [
309 'name' => 'field_focus_box_shadow',
310 // phpcs:ignore WordPressVIPMinimum.Performance.WPQueryParams.PostNotIn_exclude
311 'exclude' => [
312 'box_shadow_position',
313 ],
314 'selector' => '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit):focus',
315 ]
316 );
317
318 $this->add_control(
319 'field_focus_bg_color',
320 [
321 'label' => esc_html__( 'Background Color', 'easy-elements' ),
322 'type' => Controls_Manager::COLOR,
323 'selectors' => [
324 '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit):focus' => 'background-color: {{VALUE}}',
325 ],
326 ]
327 );
328
329 $this->end_controls_tab();
330 $this->end_controls_tabs();
331
332 $this->end_controls_section();
333
334
335 $this->start_controls_section(
336 '_section_textarea_style',
337 [
338 'label' => esc_html__( 'Form Texarea', 'easy-elements' ),
339 'tab' => Controls_Manager::TAB_STYLE,
340 ]
341 );
342
343 $this->add_responsive_control(
344 'texarea_height',
345 [
346 'label' => esc_html__( 'Height', 'easy-elements' ),
347 'type' => \Elementor\Controls_Manager::SLIDER,
348 'size_units' => [ 'px' ],
349 'range' => [
350 'px' => [
351 'min' => 30,
352 'max' => 600,
353 ],
354 ],
355 'selectors' => [
356 '{{WRAPPER}} .wpcf7-form-control.wpcf7-textarea:not(.wpcf7-submit)' => 'height: {{SIZE}}{{UNIT}}; min-height:auto;',
357 ],
358 ]
359 );
360
361 $this->end_controls_section();
362
363 $this->start_controls_section(
364 'cf7-form-label',
365 [
366 'label' => esc_html__( 'Form Fields Label', 'easy-elements' ),
367 'tab' => Controls_Manager::TAB_STYLE,
368 ]
369 );
370
371 $this->add_responsive_control(
372 'label_margin',
373 [
374 'label' => esc_html__( 'Spacing Bottom', 'easy-elements' ),
375 'type' => Controls_Manager::SLIDER,
376 'size_units' => [ 'px' ],
377 'range' => [
378 'px' => [
379 'min' => 0,
380 'max' => 100,
381 ],
382 ],
383 'selectors' => [
384 '{{WRAPPER}} .wpcf7-form-control:not(.wpcf7-submit)' => 'margin-top: {{SIZE}}{{UNIT}};',
385 ],
386 ]
387 );
388
389 $this->add_control(
390 'hr3',
391 [
392 'type' => Controls_Manager::DIVIDER,
393 'style' => 'thick',
394 ]
395 );
396
397 $this->add_group_control(
398 Group_Control_Typography::get_type(),
399 [
400 'name' => 'label_typography',
401 'label' => esc_html__( 'Typography', 'easy-elements' ),
402 'selector' => '{{WRAPPER}} label',
403
404 ]
405 );
406
407 $this->add_control(
408 'label_color',
409 [
410 'label' => esc_html__( 'Text Color', 'easy-elements' ),
411 'type' => Controls_Manager::COLOR,
412 'selectors' => [
413 '{{WRAPPER}} label' => 'color: {{VALUE}}',
414 ],
415 ]
416 );
417
418 $this->end_controls_section();
419
420 $this->start_controls_section(
421 'submit',
422 [
423 'label' => esc_html__( 'Submit Button', 'easy-elements' ),
424 'tab' => Controls_Manager::TAB_STYLE,
425 ]
426 );
427
428 $this->start_controls_tabs( 'tabs_button_style' );
429
430 $this->start_controls_tab(
431 'tab_button_normal',
432 [
433 'label' => esc_html__( 'Normal', 'easy-elements' ),
434 ]
435 );
436
437 $this->add_control(
438 'submit_color',
439 [
440 'label' => esc_html__( 'Text Color', 'easy-elements' ),
441 'type' => Controls_Manager::COLOR,
442 'default' => '',
443 'selectors' => [
444 '{{WRAPPER}} .wpcf7-submit' => 'color: {{VALUE}} !important;',
445 '{{WRAPPER}} .right-arrow-style:after' => 'color: {{VALUE}} !important;',
446 ],
447 ]
448 );
449
450
451 $this->add_group_control(
452 Group_Control_Background::get_type(),
453 [
454 'name' => 'submit_bg_color',
455 'label' => esc_html__( 'Overlay Background Color', 'easy-elements' ),
456 'types' => [ 'classic', 'gradient' ],
457 'selector' => '{{WRAPPER}} .wpcf7-submit',
458 ]
459 );
460
461 $this->end_controls_tab();
462
463 $this->start_controls_tab(
464 'tab_button_hover',
465 [
466 'label' => esc_html__( 'Hover', 'easy-elements' ),
467 ]
468 );
469
470 $this->add_control(
471 'submit_hover_color',
472 [
473 'label' => esc_html__( 'Text Color', 'easy-elements' ),
474 'type' => Controls_Manager::COLOR,
475 'selectors' => [
476 '{{WRAPPER}} .wpcf7-submit:hover, {{WRAPPER}} .wpcf7-submit:focus' => 'color: {{VALUE}} !important;',
477 ],
478 ]
479 );
480
481
482 $this->add_group_control(
483 Group_Control_Background::get_type(),
484 [
485 'name' => 'submit_hover_bg_color',
486 'label' => esc_html__( 'Overlay Background Color', 'easy-elements' ),
487 'types' => [ 'classic', 'gradient' ],
488 'selector' => '{{WRAPPER}} .wpcf7-submit:hover',
489 ]
490 );
491
492
493
494 $this->add_control(
495 'submit_hover_border_color',
496 [
497 'label' => esc_html__( 'Border Color', 'easy-elements' ),
498 'type' => Controls_Manager::COLOR,
499 'selectors' => [
500 '{{WRAPPER}} .wpcf7-submit:hover, {{WRAPPER}} .wpcf7-submit:focus' => 'border-color: {{VALUE}};',
501 ],
502 ]
503 );
504
505 $this->end_controls_tab();
506 $this->end_controls_tabs();
507
508 $this->add_responsive_control(
509 'field_width_btn',
510 [
511 'label' => esc_html__( 'Button Width', 'easy-elements' ),
512 'type' => Controls_Manager::SLIDER,
513 'default' => [
514 'unit' => '%',
515 ],
516 'tablet_default' => [
517 'unit' => '%',
518 ],
519 'mobile_default' => [
520 'unit' => '%',
521 ],
522 'size_units' => [ '%', 'px' ],
523 'range' => [
524 '%' => [
525 'min' => 1,
526 'max' => 100,
527 ],
528 'px' => [
529 'min' => 1,
530 'max' => 500,
531 ],
532 ],
533 'selectors' => [
534 '{{WRAPPER}} .wpcf7-form-control.wpcf7-submit' => 'width: {{SIZE}}{{UNIT}};',
535
536 ],
537 ]
538 );
539
540 $this->add_responsive_control(
541 'btn_item_alignment',
542 [
543 'label' => esc_html__( 'Buton Alignment', 'easy-elements' ),
544 'type' => Controls_Manager::CHOOSE,
545 'options' => [
546 'left' => [
547 'title' => esc_html__( 'Left', 'easy-elements' ),
548 'icon' => 'eicon-text-align-left',
549 ],
550 'center' => [
551 'title' => esc_html__( 'Center', 'easy-elements' ),
552 'icon' => 'eicon-text-align-center',
553 ],
554 'right' => [
555 'title' => esc_html__( 'Right', 'easy-elements' ),
556 'icon' => 'eicon-text-align-right',
557 ],
558
559 ],
560 'toggle' => true,
561 ]
562 );
563
564 $this->add_responsive_control(
565 'submit_margin',
566 [
567 'label' => esc_html__( 'Margin', 'easy-elements' ),
568 'type' => Controls_Manager::DIMENSIONS,
569 'size_units' => [ 'px', '%' ],
570 'selectors' => [
571 '{{WRAPPER}} .wpcf7-submit' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
572 ],
573 ]
574 );
575
576 $this->add_responsive_control(
577 'submit_padding',
578 [
579 'label' => esc_html__( 'Padding', 'easy-elements' ),
580 'type' => Controls_Manager::DIMENSIONS,
581 'size_units' => [ 'px', 'em', '%' ],
582 'selectors' => [
583 '{{WRAPPER}} .wpcf7-submit' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
584 ],
585 ]
586 );
587
588 $this->add_group_control(
589 Group_Control_Typography::get_type(),
590 [
591 'name' => 'submit_typography',
592 'selector' => '{{WRAPPER}} .wpcf7-submit',
593
594 ]
595 );
596
597 $this->add_group_control(
598 Group_Control_Border::get_type(),
599 [
600 'name' => 'submit_border',
601 'selector' => '{{WRAPPER}} .wpcf7-submit',
602 ]
603 );
604
605 $this->add_control(
606 'submit_border_radius',
607 [
608 'label' => esc_html__( 'Border Radius', 'easy-elements' ),
609 'type' => Controls_Manager::DIMENSIONS,
610 'size_units' => [ 'px', '%' ],
611 'selectors' => [
612 '{{WRAPPER}} .wpcf7-submit' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
613 ],
614 ]
615 );
616
617 $this->add_group_control(
618 Group_Control_Box_Shadow::get_type(),
619 [
620 'name' => 'submit_box_shadow',
621 'selector' => '{{WRAPPER}} .wpcf7-submit',
622 ]
623 );
624
625 $this->add_control(
626 'hr4',
627 [
628 'type' => Controls_Manager::DIVIDER,
629 'style' => 'thick',
630 ]
631 );
632
633
634
635 $this->end_controls_section();
636 }
637
638 protected function render() {
639 if ( ! class_exists('WPCF7') ) {
640 echo '<p class="easy-elements-notice">' . esc_html__('Contact Form 7 plugin is not active.', 'easy-elements') . '</p>';
641 return;
642 }
643 $settings = $this->get_settings_for_display();
644
645 if ( empty( $settings['selected_form_id'] ) ) {
646 echo '<p class="easy-elements-notice">' . esc_html__('Please select a form to display.', 'easy-elements') . '</p>';
647 return;
648 }
649
650 if ( ! empty( $settings['selected_form_id'] ) ) {
651 $form = \WPCF7_ContactForm::get_instance( $settings['selected_form_id'] );
652 if ( $form ) {
653 echo '<div class="form__btn__' . esc_attr($settings['btn_item_alignment']) . '">';
654 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
655 echo $form->form_html();
656 echo '</div>';
657 }
658 }
659 }
660 }