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