PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / V3.3.2
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder vV3.3.2
V3.3.2 3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 All 139 releases
bit-form / includes / Widgets / BitFormElementorWidget.php

BitFormElementorWidget.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder V3.3.2, at includes/Widgets/BitFormElementorWidget.php

114 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Widgets;
4
5 use BitCode\BitForm\Core\Util\FrontendHelpers;
6 use BitCode\BitForm\GlobalHelper;
7 use Elementor\Controls_Manager;
8 use Elementor\Widget_Base;
9
10 if (!defined('ABSPATH')) {
11 exit;
12 }
13
14 class BitFormElementorWidget extends Widget_Base
15 {
16 public function get_name()
17 {
18 return 'bitform-widget';
19 }
20
21 public function get_keywords()
22 {
23 return [
24 'bitform',
25 'bitforms',
26 'form',
27 'bitform widget',
28 'form widget',
29 'contact forms',
30 'elementor form',
31 'bit form',
32 'form builder',
33 'shortcode',
34 ];
35 }
36
37 public function get_title()
38 {
39 return __('Bit Form', 'bit-form');
40 }
41
42 public function get_icon()
43 {
44 return 'eicon-form-horizontal';
45 }
46
47 public function get_script_depends()
48 {
49 return ['bitform-style'];
50 }
51
52 public function get_categories()
53 {
54 return ['general'];
55 }
56
57 protected function _register_controls()
58 {
59 $this->start_controls_section(
60 'section_bit_form',
61 [
62 'label' => __('Bit Form', 'bit-form'),
63 ]
64 );
65
66 $this->add_control(
67 'form_id',
68 [
69 'label' => esc_html__('Select Forms', 'bit-form'),
70 'type' => Controls_Manager::SELECT2,
71 'placeholder' => esc_html__('Select a Bitform', 'bit-form'),
72 'label_block' => true,
73 'multiple' => false,
74 'options' => GlobalHelper::getForms(),
75 'default' => 0,
76 'render_type' => 'template',
77 ]
78 );
79
80 $this->end_controls_section();
81 }
82
83 /**
84 * Render widget output on the frontend.
85 *
86 * @return void
87 */
88 protected function render()
89 {
90 $settings = $this->get_settings_for_display();
91 $form_id = $settings['form_id'];
92
93 if (empty($form_id)) {
94 return;
95 }
96
97 $css_path = FrontendHelpers::styleSrc('form-styles/bitform-' . $form_id . '-formid.css');
98
99 wp_dequeue_style('bitform-style-css');
100
101 $formUpdateVersion = get_option('bitform_form_update_version');
102 wp_register_style('bitform-elementor-style-' . (int) $form_id, $css_path, [], $formUpdateVersion);
103 wp_enqueue_style('bitform-elementor-style-' . (int) $form_id);
104
105 if (\Elementor\Plugin::$instance->editor->is_edit_mode()) {
106 echo '<div class="bitform-preview">';
107 echo do_shortcode('[bitform id="' . esc_attr($form_id) . '"]');
108 echo '</div>';
109 } else {
110 echo do_shortcode('[bitform id="' . esc_attr($form_id) . '"]');
111 }
112 }
113 }
114