PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.21.4
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.21.4
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 2.10.1 2.10.2 All 137 releases
bit-form / includes / Widgets / BitFormElementorWidget.php

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

117 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\GlobalHelper;
6 use Elementor\Controls_Manager;
7 use Elementor\Widget_Base;
8
9 if (!\defined('ABSPATH')) {
10 exit;
11 }
12
13 class BitFormElementorWidget extends Widget_Base
14 {
15 public function get_name()
16 {
17 return 'bitform-widget';
18 }
19
20 public function get_keywords()
21 {
22 return [
23 'bitform',
24 'bitforms',
25 'form',
26 'bitform widget',
27 'form widget',
28 'contact forms',
29 'elementor form',
30 'bit form',
31 'form builder',
32 'shortcode',
33 ];
34 }
35
36 public function get_title()
37 {
38 return __('Bit Form', 'bit-form');
39 }
40
41 public function get_icon()
42 {
43 return 'eicon-form-horizontal';
44 }
45
46 public function get_script_depends()
47 {
48 return ['bitform-style'];
49 }
50
51 public function get_categories()
52 {
53 return ['general'];
54 }
55
56 protected function _register_controls()
57 {
58 $this->start_controls_section(
59 'section_bit_form',
60 [
61 'label' => __('Bit Form', 'bit-form'),
62 ]
63 );
64
65 $this->add_control(
66 'form_id',
67 [
68 'label' => esc_html__('Select Forms', 'bit-form'),
69 'type' => Controls_Manager::SELECT2,
70 'placeholder' => esc_html__('Select a Bitform', 'bit-form'),
71 'label_block' => true,
72 'multiple' => false,
73 'options' => GlobalHelper::getForms(),
74 'default' => 0,
75 'render_type' => 'template',
76 ]
77 );
78
79 $this->end_controls_section();
80 }
81
82 /**
83 * Render widget output on the frontend.
84 *
85 * @return void
86 */
87 protected function render()
88 {
89 $settings = $this->get_settings_for_display();
90 $form_id = $settings['form_id'];
91
92 if (empty($form_id)) {
93 return;
94 }
95
96 $css_path = BITFORMS_UPLOAD_BASE_URL . '/form-styles/bitform-' . $form_id . '-formid.css';
97
98 wp_dequeue_style('bitform-style-css');
99
100 if (is_admin() && \Elementor\Plugin::$instance->editor->is_edit_mode()) {
101 echo "<link rel='stylesheet' id='bitform-style-css' href='{$css_path}' type='text/css' media='all' />";
102 } else {
103 wp_enqueue_style('bitform-style', $css_path, [], time());
104 }
105
106 $form_html = do_shortcode("[bitform id='$form_id']");
107
108 if (\Elementor\Plugin::$instance->editor->is_edit_mode()) {
109 echo '<div class="bitform-preview">';
110 echo $form_html;
111 echo '</div>';
112 } else {
113 echo $form_html;
114 }
115 }
116 }
117