PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.0.8
JetFormBuilder — Dynamic Blocks Form Builder v3.0.8
3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 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 All 130 releases
← All changes | includes/plugin.php +260 -254 trunk3.0.8 View file →
@@ -1,254 +1,260 @@
1 -<?php
2 -
3 -namespace Jet_Form_Builder;
4 -
5 -// If this file is called directly, abort.
6 -use Jet_Form_Builder\Actions\Manager as ActionsManager;
7 -use Jet_Form_Builder\Admin\Pages\Pages_Manager;
8 -use Jet_Form_Builder\Blocks\Conditional_Block\Render_State;
9 -use Jet_Form_Builder\Blocks\Dynamic_Value;
10 -use Jet_Form_Builder\Classes\Regexp_Tools;
11 -use Jet_Form_Builder\Exceptions\Repository_Exception;
12 -use Jet_Form_Builder\Form_Messages;
13 -use Jet_Form_Builder\Form_Patterns\Manager as PatternsManager;
14 -use Jet_Form_Builder\Addons\Manager as AddonsManager;
15 -use JFB_Compatibility\Compatibility_Controller;
16 -use JFB_Components\Module\Base_Module_After_Install_It;
17 -use JFB_Components\Module\Base_Module_Dir_It;
18 -use JFB_Components\Module\Base_Module_Handle_It;
19 -use JFB_Components\Module\Base_Module_It;
20 -use JFB_Components\Module\Base_Module_Url_It;
21 -use JFB_Modules\Modules_Controller;
22 -use Jet_Form_Builder\Presets\Preset_Manager;
23 -
24 -if ( ! defined( 'WPINC' ) ) {
25 - die;
26 -}
27 -
28 -/**
29 - * @property ActionsManager $actions
30 - * @property Form_Manager $form
31 - * @property Form_Handler $form_handler
32 - * @property Admin\Editor $editor
33 - * @property AddonsManager $addons_manager
34 - * @property Form_Messages\Msg_Router $msg_router
35 - * @property Regexp_Tools $regexp
36 - *
37 - * Class Plugin
38 - * @package Jet_Form_Builder
39 - */
40 -final class Plugin {
41 -
42 - public $actions;
43 - public $form;
44 - public $form_handler;
45 - public $editor;
46 - public $framework;
47 - public $addons_manager;
48 - public $msg_router;
49 - public $regexp;
50 -
51 - private $modules_controller;
52 - private $compat_controller;
53 -
54 - public static $instance;
55 -
56 - public function init_plugin() {
57 - do_action( 'jet-form-builder/before-init' );
58 -
59 - jet_form_builder()->init_components();
60 -
61 - do_action( 'jet-form-builder/after-init' );
62 - }
63 -
64 - /**
65 - * Initialize plugin parts
66 - *
67 - * @return void
68 - */
69 - public function init_components() {
70 - $this->get_modules()->rep_install();
71 - $this->get_compat()->rep_install();
72 -
73 - $this->get_modules()->init_hooks();
74 - $this->get_compat()->init_hooks();
75 -
76 - $this->msg_router = new Form_Messages\Msg_Router();
77 - $this->actions = new Actions\Manager();
78 - $this->form = new Form_Manager();
79 - $this->form_handler = new Form_Handler();
80 - $this->addons_manager = new AddonsManager();
81 - $this->regexp = new Regexp_Tools();
82 -
83 - /**
84 - * Modules & components
85 - */
86 - File_Upload::instance();
87 - Render_State::instance();
88 - new Dynamic_Value();
89 -
90 - /**
91 - * REST API
92 - */
93 - ( new Blocks\Conditional_Block\Rest_Api\Rest_Api_Controller() )->rest_api_init();
94 -
95 - if ( is_admin() ) {
96 - Preset_Manager::instance();
97 -
98 - $this->editor = new Admin\Editor();
99 - Pages_Manager::instance()->set_up();
100 -
101 - new PatternsManager();
102 - } else {
103 - $this->form_handler->call_form();
104 - }
105 - }
106 -
107 - /**
108 - * Loads the translation files.
109 - *
110 - * @return void
111 - * @since 1.0.0
112 - * @access public
113 - */
114 - public function init_lang() {
115 - load_plugin_textdomain(
116 - 'jet-form-builder',
117 - false,
118 - dirname( plugin_basename( JET_FORM_BUILDER__FILE__ ) ) . '/languages'
119 - );
120 - }
121 -
122 - /**
123 - * Returns url to file or dir inside plugin folder
124 - *
125 - * @param string $path Path inside plugin dir.
126 - *
127 - * @return string
128 - */
129 - public function plugin_url( string $path = '' ): string {
130 - return JET_FORM_BUILDER_URL . $path;
131 - }
132 -
133 - public function plugin_dir( string $path = '' ): string {
134 - return JET_FORM_BUILDER_PATH . $path;
135 - }
136 -
137 - /**
138 - * Returns plugin version
139 - */
140 - public function get_version(): string {
141 - return JET_FORM_BUILDER_VERSION;
142 - }
143 -
144 - /**
145 - * @param string $name_or_class
146 - *
147 - * @return Base_Module_It|Base_Module_Handle_It|Base_Module_Url_It|Base_Module_Dir_It|Base_Module_After_Install_It
148 - * @throws Exceptions\Repository_Exception
149 - */
150 - public function module( string $name_or_class ): Base_Module_It {
151 - return $this->get_modules()->module( $name_or_class );
152 - }
153 -
154 - public function has_module( string $name_or_class ): bool {
155 - return $this->get_modules()->has_module( $name_or_class );
156 - }
157 -
158 - public function get_modules(): Modules_Controller {
159 - if ( is_null( $this->modules_controller ) ) {
160 - $this->modules_controller = new Modules_Controller();
161 - }
162 -
163 - return $this->modules_controller;
164 - }
165 -
166 - /**
167 - * @param string $name_or_class
168 - *
169 - * @return Base_Module_It|Base_Module_Handle_It|Base_Module_Url_It|Base_Module_Dir_It|Base_Module_After_Install_It
170 - * @throws Exceptions\Repository_Exception
171 - */
172 - public function compat( string $name_or_class ): Base_Module_It {
173 - return $this->get_compat()->module( $name_or_class );
174 - }
175 -
176 - public function has_compat( string $name_or_class ): bool {
177 - return $this->get_compat()->has_module( $name_or_class );
178 - }
179 -
180 - public function get_compat(): Compatibility_Controller {
181 - if ( is_null( $this->compat_controller ) ) {
182 - $this->compat_controller = new Compatibility_Controller();
183 - }
184 -
185 - return $this->compat_controller;
186 - }
187 -
188 - /**
189 - * Instance.
190 - *
191 - * Ensures only one instance of the plugin class is loaded or can be loaded.
192 - *
193 - * @since 1.0.0
194 - * @access public
195 - * @static
196 - */
197 - public static function instance() {
198 -
199 - if ( is_null( self::$instance ) ) {
200 - self::$instance = new self();
201 - }
202 -
203 - return self::$instance;
204 - }
205 -
206 - public static function clear() {
207 - self::$instance = null;
208 - }
209 -
210 - /**
211 - * Register autoloader.
212 - */
213 - public function register_autoloader() {
214 - require JET_FORM_BUILDER_PATH . 'includes' . DIRECTORY_SEPARATOR . 'autoloader.php';
215 - Autoloader::run();
216 - }
217 -
218 - /**
219 - * Backward compatibility to deprecated properties
220 - *
221 - * @param $name
222 - *
223 - * @return mixed
224 - */
225 - public function __get( $name ) {
226 - switch ( $name ) {
227 - case 'blocks':
228 - try {
229 - return jet_form_builder()->module( 'blocks' );
230 - } catch ( Repository_Exception $exception ) {
231 - return null;
232 - }
233 - case 'allow_gateways':
234 - return jet_form_builder()->has_module( 'gateways' );
235 - case 'post_type':
236 - try {
237 - return jet_form_builder()->module( 'post-type' );
238 - } catch ( Repository_Exception $exception ) {
239 - return null;
240 - }
241 - }
242 -
243 - return null;
244 - }
245 -
246 - public function __isset( $name ) {
247 - switch ( $name ) {
248 - case 'allow_gateways':
249 - return true;
250 - }
251 - return false;
252 - }
253 -
254 -}
1 +<?php
2 +
3 +namespace Jet_Form_Builder;
4 +
5 +// If this file is called directly, abort.
6 +use Jet_Form_Builder\Actions\Manager as ActionsManager;
7 +use Jet_Form_Builder\Admin\Pages\Pages_Manager;
8 +use Jet_Form_Builder\Admin\Tabs_Handlers\Tab_Handler_Manager;
9 +use Jet_Form_Builder\Blocks\Conditional_Block\Render_State;
10 +use Jet_Form_Builder\Blocks\Dynamic_Value;
11 +use Jet_Form_Builder\Blocks\Manager as BlocksManager;
12 +use Jet_Form_Builder\Blocks\Switch_Page_On_Change;
13 +use Jet_Form_Builder\Blocks\Validation;
14 +use Jet_Form_Builder\Classes\Regexp_Tools;
15 +use Jet_Form_Builder\Classes\Tools;
16 +use Jet_Form_Builder\Compatibility\Deprecated;
17 +use Jet_Form_Builder\Compatibility\Elementor\Elementor;
18 +use Jet_Form_Builder\Compatibility\Jet_Appointment\Jet_Appointment;
19 +use Jet_Form_Builder\Compatibility\Jet_Booking\Jet_Booking;
20 +use Jet_Form_Builder\Compatibility\Jet_Engine\Jet_Engine;
21 +use Jet_Form_Builder\Compatibility\Woocommerce\Woocommerce;
22 +use Jet_Form_Builder\Form_Actions\Form_Actions_Manager;
23 +use Jet_Form_Builder\Form_Messages;
24 +use Jet_Form_Builder\Form_Patterns\Manager as PatternsManager;
25 +use Jet_Form_Builder\Framework\CX_Loader;
26 +use Jet_Form_Builder\Gateways\Gateway_Manager;
27 +use Jet_Form_Builder\Integrations\Active_Campaign\Active_Campaign;
28 +use Jet_Form_Builder\Integrations\Forms_Captcha;
29 +use Jet_Form_Builder\Addons\Manager as AddonsManager;
30 +use Jet_Form_Builder\Presets\Preset_Manager;
31 +use Jet_Form_Builder\Wp_Cli\Wp_Cli_Manager;
32 +use Jet_Form_Builder\Migrations;
33 +
34 +if ( ! defined( 'WPINC' ) ) {
35 + die;
36 +}
37 +
38 +/**
39 + * @property Post_Type $post_type
40 + * @property BlocksManager $blocks
41 + * @property ActionsManager $actions
42 + * @property Form_Manager $form
43 + * @property Form_Handler $form_handler
44 + * @property Forms_Captcha $captcha
45 + * @property Admin\Editor $editor
46 + * @property AddonsManager $addons_manager
47 + * @property \Jet_Admin_Bar $admin_bar
48 + * @property Form_Messages\Msg_Router $msg_router
49 + * @property Regexp_Tools $regexp
50 + * Class Plugin
51 + * @package Jet_Form_Builder
52 + */
53 +class Plugin {
54 +
55 + public $post_type;
56 + public $blocks;
57 + public $actions;
58 + public $form;
59 + public $form_handler;
60 + public $editor;
61 + public $captcha;
62 + public $allow_gateways;
63 + public $framework;
64 + public $addons_manager;
65 + public $admin_bar;
66 + public $msg_router;
67 + public $regexp;
68 +
69 + private $suffix;
70 +
71 + public static $instance;
72 +
73 + /**
74 + * Instance.
75 + *
76 + * Ensures only one instance of the plugin class is loaded or can be loaded.
77 + *
78 + * @since 1.0.0
79 + * @access public
80 + * @static
81 + */
82 + public static function instance() {
83 +
84 + if ( is_null( self::$instance ) ) {
85 + self::$instance = new self();
86 + }
87 +
88 + return self::$instance;
89 + }
90 +
91 + public static function clear() {
92 + self::$instance = null;
93 + }
94 +
95 + /**
96 + * Register autoloader.
97 + */
98 + private function register_autoloader() {
99 + require JET_FORM_BUILDER_PATH . 'includes' . DIRECTORY_SEPARATOR . 'autoloader.php';
100 + Autoloader::run();
101 + }
102 +
103 + /**
104 + * Initialize plugin parts
105 + *
106 + * @return void
107 + */
108 + public function init_components() {
109 + $this->allow_gateways = apply_filters( 'jet-form-builder/allow-gateways', false );
110 + $this->maybe_enable_gateways();
111 +
112 + /**
113 + * Compatibility & Integrations
114 + */
115 + Woocommerce::register();
116 + Jet_Engine::register();
117 + Active_Campaign::register();
118 + Elementor::register();
119 + Jet_Appointment::register();
120 + Jet_Booking::register();
121 + new Deprecated();
122 +
123 + $this->admin_bar = \Jet_Admin_Bar::get_instance();
124 + $this->msg_router = new Form_Messages\Msg_Router();
125 + $this->post_type = new Post_Type();
126 + $this->blocks = new Blocks\Manager();
127 + $this->actions = new Actions\Manager();
128 + $this->form = new Form_Manager();
129 + $this->form_handler = new Form_Handler();
130 + $this->captcha = new Forms_Captcha();
131 + $this->addons_manager = new AddonsManager();
132 + $this->regexp = new Regexp_Tools();
133 +
134 + /**
135 + * Modules & components
136 + */
137 + Dev_Mode\Manager::instance();
138 + File_Upload::instance();
139 + Validation::instance();
140 + Render_State::instance();
141 + new Dynamic_Value();
142 + new Switch_Page_On_Change();
143 +
144 + /**
145 + * REST API
146 + */
147 + ( new Migrations\Rest_Api\Controller() )->rest_api_init();
148 + ( new Blocks\Conditional_Block\Rest_Api\Rest_Api_Controller() )->rest_api_init();
149 + ( new Blocks\Ssr_Validation\Rest_Controller() )->rest_api_init();
150 +
151 + if ( is_admin() ) {
152 + Preset_Manager::instance();
153 +
154 + $this->editor = new Admin\Editor();
155 + Pages_Manager::instance()->set_up();
156 +
157 + new Form_Actions_Manager();
158 + new PatternsManager();
159 + } else {
160 + $this->form_handler->call_form();
161 + }
162 + }
163 +
164 + public function init_framework() {
165 + require $this->plugin_dir( 'framework/loader.php' );
166 +
167 + $this->framework = new CX_Loader(
168 + array(
169 + $this->plugin_dir( 'framework/vue-ui/cherry-x-vue-ui.php' ),
170 + $this->plugin_dir( 'framework/admin-bar/jet-admin-bar.php' ),
171 + )
172 + );
173 + }
174 +
175 + public function maybe_enable_gateways() {
176 + Tab_Handler_Manager::instance()->tab( 'payments-gateways' )->save_global_options();
177 + $gateways = Tab_Handler_Manager::instance()->tab( 'payments-gateways' )->get_global_options();
178 +
179 + if ( isset( $gateways['enable_test_mode'] ) ) {
180 + add_filter(
181 + 'jet-form-builder/gateways/paypal/sandbox-mode',
182 + function () use ( $gateways ) {
183 + return $gateways['enable_test_mode'];
184 + }
185 + );
186 + }
187 +
188 + if ( isset( $gateways['use_gateways'] ) ) {
189 + $this->allow_gateways = $gateways['use_gateways'];
190 + }
191 +
192 + Gateway_Manager::instance()->set_up();
193 + }
194 +
195 + /**
196 + * Loads the translation files.
197 + *
198 + * @return void
199 + * @since 1.0.0
200 + * @access public
201 + */
202 + public function init_lang() {
203 + load_plugin_textdomain(
204 + 'jet-form-builder',
205 + false,
206 + dirname( plugin_basename( JET_FORM_BUILDER__FILE__ ) ) . '/languages'
207 + );
208 + }
209 +
210 + /**
211 + * Returns url to file or dir inside plugin folder
212 + *
213 + * @param string $path Path inside plugin dir.
214 + *
215 + * @return string
216 + */
217 + public function plugin_url( string $path = '' ): string {
218 + $path = str_replace( '{min}', Tools::get_suffix(), $path );
219 +
220 + return JET_FORM_BUILDER_URL . $path;
221 + }
222 +
223 + public function plugin_dir( string $path = '' ): string {
224 + return JET_FORM_BUILDER_PATH . $path;
225 + }
226 +
227 + /**
228 + * Returns plugin version
229 + */
230 + public function get_version(): string {
231 + return JET_FORM_BUILDER_VERSION;
232 + }
233 +
234 + /**
235 + * Plugin constructor.
236 + */
237 + private function __construct() {
238 +
239 + $this->register_autoloader();
240 + $this->init_lang();
241 +
242 + add_action(
243 + 'after_setup_theme',
244 + function () {
245 + do_action( 'jet-form-builder/before-init' );
246 +
247 + $this->init_components();
248 +
249 + do_action( 'jet-form-builder/after-init' );
250 + },
251 + 0
252 + );
253 +
254 + $this->init_framework();
255 + Wp_Cli_Manager::register();
256 + }
257 +
258 +}
259 +
260 +Plugin::instance();