PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.3.65
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.3.65
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
leadin / public / admin / widgets / class-elementorform.php

class-elementorform.php in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.3.65, at public/admin/widgets/class-elementorform.php

145 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Leadin\admin\widgets;
3
4 use Leadin\data\Filters;
5 use Leadin\data\Portal_Options;
6 use Elementor\Plugin;
7 use Elementor\Widget_Base;
8
9 /**
10 * ElementorForm Widget
11 */
12 class ElementorForm extends Widget_Base {
13
14 /**
15 * Widget internal name.
16 */
17 public function get_name() {
18 return 'hubspot-form';
19 }
20
21 /**
22 * Widget title.
23 */
24 public function get_title() {
25 return esc_html( 'HubSpot Form' );
26 }
27
28 /**
29 * Widget display icon.
30 */
31 public function get_icon() {
32 return 'eicon-form-horizontal';
33 }
34
35 /**
36 * Widget help url.
37 */
38 public function get_custom_help_url() {
39 return 'https://wordpress.org/support/plugin/leadin/';
40 }
41
42 /**
43 * Widget category.
44 */
45 public function get_categories() {
46 return array( 'general', 'hubspot' );
47 }
48
49 /**
50 * Widget keywords.
51 */
52 public function get_keywords() {
53 return array( 'hubspot', 'form', 'leadin' );
54 }
55
56 /**
57 * Widget style.
58 */
59 public function get_style_depends() {
60 wp_register_style( 'leadin-elementor', LEADIN_JS_BASE_PATH . '/elementor.css', array(), LEADIN_PLUGIN_VERSION );
61 wp_register_style( 'leadin-css', LEADIN_ASSETS_PATH . '/style/leadin.css', array(), LEADIN_PLUGIN_VERSION );
62 return array( 'leadin-elementor', 'leadin-css' );
63 }
64
65 /**
66 * Widget script.
67 */
68 public function get_script_depends() {
69 wp_register_script(
70 'leadin-forms-v2',
71 Filters::apply_forms_script_url_filters(),
72 array(),
73 LEADIN_PLUGIN_VERSION,
74 true
75 );
76
77 $scopes = array( 'leadin-forms-v2' );
78 $portal_id = Portal_Options::get_portal_id();
79 if ( $portal_id ) {
80 wp_register_script(
81 'leadin-forms-v4',
82 Filters::apply_forms_v4_script_url_filters( $portal_id ),
83 array(),
84 LEADIN_PLUGIN_VERSION,
85 true
86 );
87 $scopes[] = 'leadin-forms-v4';
88 }
89 return $scopes;
90 }
91
92 /**
93 * Widget controls.
94 */
95 protected function register_controls() {
96 $this->start_controls_section(
97 'content_section',
98 array(
99 'label' => esc_html( __( 'Form', 'leadin' ) ),
100 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
101 )
102 );
103
104 $this->add_control(
105 'content',
106 array(
107 'type' => 'leadinformselect',
108 )
109 );
110
111 $this->end_controls_section();
112 }
113
114 /**
115 * Render the widget
116 */
117 protected function render() {
118 $settings = $this->get_settings_for_display();
119 $content = $settings['content'];
120
121 if ( Plugin::$instance->editor->is_edit_mode() ) {
122
123 ?>
124 <div class="hubspot-form-edit-mode" data-attributes="<?php echo esc_attr( wp_json_encode( $content ) ); ?>">
125 &nbsp;
126 </div>
127 <?php
128 if ( empty( $content ) ) {
129 ?>
130 <div class="hubspot-widget-empty">
131
132 </div>
133 <?php
134 }
135 }
136
137 if ( ! empty( $content ) ) {
138 $portal_id = $content['portalId'];
139 $form_id = $content['formId'];
140 $version = isset( $content['embedVersion'] ) ? $content['embedVersion'] : '';
141 echo do_shortcode( '[hubspot portal="' . $portal_id . '" id="' . $form_id . '" type="form" version="' . $version . '"]' );
142 }
143 }
144 }
145