PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.1.6
JetFormBuilder — Dynamic Blocks Form Builder v3.1.6
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 2 years ago widgets 2 years ago elementor.php 2 years ago
elementor.php
141 lines
1 <?php
2
3
4 namespace JFB_Compatibility\Elementor;
5
6 use Jet_Form_Builder\Blocks;
7 use JFB_Modules\Deprecated;
8 use JFB_Components\Compatibility\Base_Compat_Handle_Trait;
9 use JFB_Components\Compatibility\Base_Compat_Url_Trait;
10 use JFB_Components\Module\Base_Module_Handle_It;
11 use JFB_Components\Module\Base_Module_It;
12 use JFB_Compatibility\Elementor\Widgets;
13 use JFB_Components\Module\Base_Module_Url_It;
14
15 // If this file is called directly, abort.
16 if ( ! defined( 'WPINC' ) ) {
17 die;
18 }
19
20 class Elementor implements Base_Module_It, Base_Module_Handle_It, Base_Module_Url_It {
21
22 use Base_Compat_Handle_Trait;
23 use Base_Compat_Url_Trait;
24
25 private $types;
26
27 public function rep_item_id() {
28 return 'elementor';
29 }
30
31 public function condition(): bool {
32 return defined( 'ELEMENTOR_VERSION' );
33 }
34
35 public function init_hooks() {
36 add_action( 'elementor/init', array( $this, 'init_widgets' ) );
37 add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'editor_styles' ) );
38 add_action( 'elementor/preview/enqueue_scripts', array( $this, 'enqueue_form_assets' ), 9 );
39 add_action( 'elementor/elements/categories_registered', array( $this, 'register_category' ) );
40
41 // compatibility with 3.7
42 if (
43 defined( 'ELEMENTOR_VERSION' ) &&
44 version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' )
45 ) {
46 add_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) );
47 } else {
48 add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widgets' ) );
49 }
50 }
51
52 public function remove_hooks() {
53 remove_action( 'elementor/init', array( $this, 'init_widgets' ) );
54 remove_action( 'elementor/editor/after_enqueue_styles', array( $this, 'editor_styles' ) );
55 remove_action( 'elementor/preview/enqueue_scripts', array( $this, 'enqueue_form_assets' ), 9 );
56 add_action( 'elementor/elements/categories_registered', array( $this, 'register_category' ) );
57
58 // compatibility with 3.7
59 if (
60 defined( 'ELEMENTOR_VERSION' ) &&
61 version_compare( ELEMENTOR_VERSION, '3.5.0', '>=' )
62 ) {
63 remove_action( 'elementor/widgets/register', array( $this, 'register_widgets' ) );
64 } else {
65 remove_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widgets' ) );
66 }
67 }
68
69 public function init_widgets() {
70 $this->types = array(
71 new Widgets\Form(),
72 );
73
74 foreach ( $this->types as $type ) {
75 $type->init_hooks();
76 }
77 }
78
79 /**
80 * Register category for elementor if not exists
81 *
82 * @return void
83 */
84 public function register_category() {
85
86 $elements_manager = \Elementor\Plugin::instance()->elements_manager;
87
88 $elements_manager->add_category(
89 'jet-form-builder',
90 array(
91 'title' => esc_html__( 'JetFormBuilder', 'jet-form-builder' ),
92 'icon' => 'font',
93 )
94 );
95 }
96
97 /**
98 * Enqueue editor styles
99 *
100 * @return void
101 */
102 public function editor_styles() {
103 wp_enqueue_style(
104 $this->get_handle( 'icons' ),
105 $this->get_url( 'assets/build/css/icons.css' ),
106 array(),
107 jet_form_builder()->get_version()
108 );
109 }
110
111
112 public function register_widgets( $manager ) {
113 foreach ( $this->types as $widget ) {
114 // compatibility with 3.7
115 if ( method_exists( $manager, 'register' ) ) {
116 $manager->register( $widget );
117 } else {
118 $manager->register_widget_type( $widget );
119 }
120 }
121 }
122
123 /**
124 * @noinspection PhpUnhandledExceptionInspection
125 */
126 public function enqueue_form_assets() {
127 /** @var Blocks\Module $blocks */
128 $blocks = jet_form_builder()->module( 'blocks' );
129 /** @var Deprecated\Module $deprecated */
130 $deprecated = jet_form_builder()->module( 'deprecated' );
131
132 $blocks->enqueue_frontend_assets();
133
134 // appointment/booking compatibility
135 $deprecated->register_scripts();
136 $deprecated->add_deprecated_script( '' );
137
138 wp_enqueue_style( 'jet-form-builder-frontend' );
139 }
140 }
141