PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.4.7
JetFormBuilder — Dynamic Blocks Form Builder v3.4.7
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / compatibility / elementor / elementor.php
jetformbuilder / compatibility / elementor Last commit date
assets 1 year ago widgets 1 year ago elementor.php 1 year ago onboarding-builder.php 1 year ago
elementor.php
176 lines
1 <?php
2
3
4 namespace JFB_Compatibility\Elementor;
5
6 use Jet_Form_Builder\Blocks;
7 use Jet_Form_Builder\Classes\Builder_Helper;
8 use JFB_Components\Compatibility\Base_Compat_Dir_Trait;
9 use JFB_Components\Module\Base_Module_After_Install_It;
10 use JFB_Components\Module\Base_Module_Dir_It;
11 use JFB_Modules\Deprecated;
12 use JFB_Components\Compatibility\Base_Compat_Handle_Trait;
13 use JFB_Components\Compatibility\Base_Compat_Url_Trait;
14 use JFB_Components\Module\Base_Module_Handle_It;
15 use JFB_Components\Module\Base_Module_It;
16 use JFB_Compatibility\Elementor\Widgets;
17 use JFB_Components\Module\Base_Module_Url_It;
18
19 // If this file is called directly, abort.
20 if ( ! defined( 'WPINC' ) ) {
21 die;
22 }
23
24 class Elementor implements
25 Base_Module_It,
26 Base_Module_Handle_It,
27 Base_Module_Url_It,
28 Base_Module_Dir_It,
29 Base_Module_After_Install_It {
30
31 use Base_Compat_Handle_Trait;
32 use Base_Compat_Url_Trait;
33 use Base_Compat_Dir_Trait;
34
35 private $types;
36
37 /**
38 * @var Onboarding_Builder
39 */
40 private $onboarding_builder;
41
42 public function rep_item_id() {
43 return 'elementor';
44 }
45
46 public function condition(): bool {
47 return defined( 'ELEMENTOR_VERSION' );
48 }
49
50 public function on_install() {
51 $this->onboarding_builder = new Onboarding_Builder();
52 }
53
54 public function on_uninstall() {
55 }
56
57 public function init_hooks() {
58 add_action( 'elementor/init', array( $this, 'init_widgets' ) );
59 add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'editor_styles' ) );
60 add_action( 'elementor/preview/enqueue_scripts', array( $this, 'enqueue_form_scripts' ), 9 );
61 add_action( 'elementor/preview/enqueue_styles', array( $this, 'enqueue_form_styles' ) );
62 add_action( 'elementor/elements/categories_registered', array( $this, 'register_category' ) );
63
64 $this->get_onboarding_builder()->init_hooks();
65
66 // compatibility with 3.7
67 if (
68 defined( 'ELEMENTOR_VERSION' ) &&
69 version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' )
70 ) {
71 add_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) );
72 } else {
73 add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widgets' ) );
74 }
75 }
76
77 public function remove_hooks() {
78 remove_action( 'elementor/init', array( $this, 'init_widgets' ) );
79 remove_action( 'elementor/editor/after_enqueue_styles', array( $this, 'editor_styles' ) );
80 remove_action( 'elementor/preview/enqueue_scripts', array( $this, 'enqueue_form_scripts' ), 9 );
81 remove_action( 'elementor/preview/enqueue_styles', array( $this, 'enqueue_form_styles' ) );
82 remove_action( 'elementor/elements/categories_registered', array( $this, 'register_category' ) );
83
84 // compatibility with 3.7
85 if (
86 defined( 'ELEMENTOR_VERSION' ) &&
87 version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' )
88 ) {
89 remove_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) );
90 } else {
91 remove_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widgets' ) );
92 }
93 }
94
95 public function init_widgets() {
96 $this->types = array(
97 new Widgets\Form(),
98 );
99
100 foreach ( $this->types as $type ) {
101 $type->init_hooks();
102 }
103 }
104
105 /**
106 * Register category for elementor if not exists
107 *
108 * @return void
109 */
110 public function register_category() {
111
112 $elements_manager = \Elementor\Plugin::instance()->elements_manager;
113
114 $elements_manager->add_category(
115 'jet-form-builder',
116 array(
117 'title' => esc_html__( 'JetFormBuilder', 'jet-form-builder' ),
118 'icon' => 'font',
119 )
120 );
121 }
122
123 /**
124 * Enqueue editor styles
125 *
126 * @return void
127 */
128 public function editor_styles() {
129 wp_enqueue_style(
130 $this->get_handle( 'icons' ),
131 $this->get_url( 'assets/build/css/icons.css' ),
132 array(),
133 jet_form_builder()->get_version()
134 );
135 }
136
137
138 public function register_widgets( $manager ) {
139 foreach ( $this->types as $widget ) {
140 // compatibility with 3.7
141 if ( method_exists( $manager, 'register' ) ) {
142 $manager->register( $widget );
143 } else {
144 $manager->register_widget_type( $widget );
145 }
146 }
147 }
148
149 /**
150 * @noinspection PhpUnhandledExceptionInspection
151 */
152 public function enqueue_form_scripts() {
153 /** @var Blocks\Module $blocks */
154 $blocks = jet_form_builder()->module( 'blocks' );
155 /** @var Deprecated\Module $deprecated */
156 $deprecated = jet_form_builder()->module( 'deprecated' );
157
158 $blocks->enqueue_frontend_assets();
159
160 // appointment/booking compatibility
161 $deprecated->register_scripts();
162 $deprecated->add_deprecated_script( '' );
163 }
164
165 public function enqueue_form_styles() {
166 wp_enqueue_style( 'jet-form-builder-frontend' );
167 }
168
169 /**
170 * @return Onboarding_Builder
171 */
172 public function get_onboarding_builder(): Onboarding_Builder {
173 return $this->onboarding_builder;
174 }
175 }
176