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 +198 -35 1.1.13.1.1 View file →
@@ -2,12 +2,28 @@
2 2
3 3 namespace Jet_Form_Builder;
4 4
5 5 // If this file is called directly, abort.
6 -use Jet_Form_Builder\Classes\Instance_Trait;
7 -use Jet_Form_Builder\Form_Patterns;
8 -use Jet_Form_Builder\Integrations\Forms_Captcha;
9 -use Jet_Form_Builder\Widgets\Elementor_Controller;
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;
10 26
11 27 if ( ! defined( 'WPINC' ) ) {
12 28 die;
13 29 }
@@ -12,32 +28,43 @@
12 28 die;
13 29 }
14 30
15 31 /**
16 - * Main file
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
17 43 */
18 44 class Plugin {
19 45
20 - use Instance_Trait;
21 -
22 46 public $post_type;
23 - public $blocks;
24 47 public $actions;
25 48 public $form;
26 49 public $form_handler;
27 50 public $editor;
28 - public $captcha;
29 - public $dev_manager;
51 + public $framework;
52 + public $addons_manager;
53 + public $msg_router;
54 + public $regexp;
30 55
31 - public $is_activated_jet_sm;
32 - public $allow_gateways;
56 + private $modules_controller;
57 + private $compat_controller;
33 58
34 - /**
35 - * Register autoloader.
36 - */
37 - private function register_autoloader() {
38 - require JET_FORM_BUILDER_PATH . 'includes' . DIRECTORY_SEPARATOR . 'autoloader.php';
39 - Autoloader::run();
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' );
40 67 }
41 68
42 69 /**
43 70 * Initialize plugin parts
@@ -44,27 +71,65 @@
44 71 *
45 72 * @return void
46 73 */
47 74 public function init_components() {
48 - $this->allow_gateways = apply_filters( 'jet-form-builder/allow-gateways', false );
75 + $this->get_modules()->rep_install();
76 + $this->get_compat()->rep_install();
49 77
50 - $this->post_type = new Post_Type();
51 - $this->blocks = new Blocks\Manager();
52 - $this->actions = new Actions\Manager();
53 - $this->form = new Form_Manager();
54 - $this->form_handler = new Form_Handler();
55 - $this->captcha = new Forms_Captcha();
78 + $this->get_modules()->init_hooks();
79 + $this->get_compat()->init_hooks();
56 80
57 - Dev_Mode\Manager::instance();
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 + */
58 92 File_Upload::instance();
59 - new Elementor_Controller();
93 + Validation::instance();
94 + Render_State::instance();
95 + new Dynamic_Value();
60 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 +
61 103 if ( is_admin() ) {
104 + Preset_Manager::instance();
105 +
62 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();
63 113 }
64 114 }
65 115
66 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 + /**
67 132 * Returns url to file or dir inside plugin folder
68 133 *
69 134 * @param string $path Path inside plugin dir.
70 135 *
@@ -69,28 +134,126 @@
69 134 * @param string $path Path inside plugin dir.
70 135 *
71 136 * @return string
72 137 */
73 - public function plugin_url( $path = null ) {
138 + public function plugin_url( string $path = '' ): string {
139 + $path = str_replace( '{min}', Tools::get_suffix(), $path );
140 +
74 141 return JET_FORM_BUILDER_URL . $path;
75 142 }
76 143
144 + public function plugin_dir( string $path = '' ): string {
145 + return JET_FORM_BUILDER_PATH . $path;
146 + }
147 +
77 148 /**
78 149 * Returns plugin version
79 150 */
80 - public function get_version() {
151 + public function get_version(): string {
81 152 return JET_FORM_BUILDER_VERSION;
82 153 }
83 154
84 155 /**
85 - * Plugin constructor.
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
86 160 */
87 - private function __construct() {
161 + public function module( string $name_or_class ): Base_Module_It {
162 + return $this->get_modules()->module( $name_or_class );
163 + }
88 164
89 - $this->register_autoloader();
165 + public function has_module( string $name_or_class ): bool {
166 + return $this->get_modules()->has_module( $name_or_class );
167 + }
90 168
91 - add_action( 'after_setup_theme', array( $this, 'init_components' ), 0 );
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;
92 175 }
93 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 +
94 259 }
95 -
96 -Plugin::instance();