PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 2.1.3
JetFormBuilder — Dynamic Blocks Form Builder v2.1.3
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 +137 -15 1.1.12.1.3 View file →
@@ -2,12 +2,23 @@
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;
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\Manager as BlocksManager;
10 +use Jet_Form_Builder\Form_Actions\Form_Actions_Manager;
11 +use Jet_Form_Builder\Form_Messages;
12 +use Jet_Form_Builder\Form_Patterns\Manager as PatternsManager;
13 +use Jet_Form_Builder\Framework\CX_Loader;
14 +use Jet_Form_Builder\Gateways\Gateway_Manager;
8 15 use Jet_Form_Builder\Integrations\Forms_Captcha;
16 +use Jet_Form_Builder\Addons\Manager as AddonsManager;
17 +use Jet_Form_Builder\Presets\Preset_Manager;
9 18 use Jet_Form_Builder\Widgets\Elementor_Controller;
19 +use Jet_Form_Builder\Wp_Cli\Wp_Cli_Manager;
20 +use Jet_Form_Builder\Migrations;
10 21
11 22 if ( ! defined( 'WPINC' ) ) {
12 23 die;
13 24 }
@@ -12,14 +23,23 @@
12 23 die;
13 24 }
14 25
15 26 /**
16 - * Main file
27 + * @property Post_Type $post_type
28 + * @property BlocksManager $blocks
29 + * @property ActionsManager $actions
30 + * @property Form_Manager $form
31 + * @property Form_Handler $form_handler
32 + * @property Forms_Captcha $captcha
33 + * @property Admin\Editor $editor
34 + * @property AddonsManager $addons_manager
35 + * @property \Jet_Admin_Bar $admin_bar
36 + * @property Form_Messages\Msg_Router $msg_router
37 + * Class Plugin
38 + * @package Jet_Form_Builder
17 39 */
18 40 class Plugin {
19 41
20 - use Instance_Trait;
21 -
22 42 public $post_type;
23 43 public $blocks;
24 44 public $actions;
25 45 public $form;
@@ -25,14 +45,39 @@
25 45 public $form;
26 46 public $form_handler;
27 47 public $editor;
28 48 public $captcha;
29 - public $dev_manager;
49 + public $allow_gateways;
50 + public $framework;
51 + public $addons_manager;
52 + public $admin_bar;
53 + public $msg_router;
30 54
31 - public $is_activated_jet_sm;
32 - public $allow_gateways;
55 + public static $instance;
33 56
34 57 /**
58 + * Instance.
59 + *
60 + * Ensures only one instance of the plugin class is loaded or can be loaded.
61 + *
62 + * @since 1.0.0
63 + * @access public
64 + * @static
65 + */
66 + public static function instance() {
67 +
68 + if ( is_null( self::$instance ) ) {
69 + self::$instance = new self();
70 + }
71 +
72 + return self::$instance;
73 + }
74 +
75 + public static function clear() {
76 + self::$instance = null;
77 + }
78 +
79 + /**
35 80 * Register autoloader.
36 81 */
37 82 private function register_autoloader() {
38 83 require JET_FORM_BUILDER_PATH . 'includes' . DIRECTORY_SEPARATOR . 'autoloader.php';
@@ -45,26 +90,85 @@
45 90 * @return void
46 91 */
47 92 public function init_components() {
48 93 $this->allow_gateways = apply_filters( 'jet-form-builder/allow-gateways', false );
94 + $this->maybe_enable_gateways();
49 95
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();
96 + $this->admin_bar = \Jet_Admin_Bar::get_instance();
97 + $this->msg_router = new Form_Messages\Msg_Router();
98 + $this->post_type = new Post_Type();
99 + $this->blocks = new Blocks\Manager();
100 + $this->actions = new Actions\Manager();
101 + $this->form = new Form_Manager();
102 + $this->form_handler = new Form_Handler();
103 + $this->captcha = new Forms_Captcha();
104 + $this->addons_manager = new AddonsManager();
56 105
57 106 Dev_Mode\Manager::instance();
58 107 File_Upload::instance();
59 108 new Elementor_Controller();
109 + ( new Migrations\Rest_Api\Controller() )->rest_api_init();
60 110
61 111 if ( is_admin() ) {
112 + Preset_Manager::instance();
113 +
62 114 $this->editor = new Admin\Editor();
115 + Pages_Manager::instance()->set_up();
116 +
117 + new Form_Actions_Manager();
118 + new PatternsManager();
119 + } else {
120 + $this->form_handler->call_form();
63 121 }
64 122 }
65 123
124 + public function init_framework() {
125 + require $this->plugin_dir( 'framework/loader.php' );
126 +
127 + $this->framework = new CX_Loader(
128 + array(
129 + $this->plugin_dir( 'framework/vue-ui/cherry-x-vue-ui.php' ),
130 + $this->plugin_dir( 'framework/admin-bar/jet-admin-bar.php' ),
131 + )
132 + );
133 + }
134 +
135 + public function maybe_enable_gateways() {
136 + Tab_Handler_Manager::instance()->tab( 'payments-gateways' )->save_global_options();
137 + $gateways = Tab_Handler_Manager::instance()->tab( 'payments-gateways' )->get_global_options();
138 +
139 + if ( isset( $gateways['enable_test_mode'] ) ) {
140 + add_filter(
141 + 'jet-form-builder/gateways/paypal/sandbox-mode',
142 + function () use ( $gateways ) {
143 + return $gateways['enable_test_mode'];
144 + }
145 + );
146 + }
147 +
148 + if ( isset( $gateways['use_gateways'] ) ) {
149 + $this->allow_gateways = $gateways['use_gateways'];
150 + }
151 +
152 + Gateway_Manager::instance()->set_up();
153 + }
154 +
66 155 /**
156 + * Loads the translation files.
157 + *
158 + * @return void
159 + * @since 1.0.0
160 + * @access public
161 + */
162 + public function init_lang() {
163 + load_plugin_textdomain(
164 + 'jet-form-builder',
165 + false,
166 + dirname( plugin_basename( JET_FORM_BUILDER__FILE__ ) ) . '/languages'
167 + );
168 + }
169 +
170 + /**
67 171 * Returns url to file or dir inside plugin folder
68 172 *
69 173 * @param string $path Path inside plugin dir.
70 174 *
@@ -73,8 +177,12 @@
73 177 public function plugin_url( $path = null ) {
74 178 return JET_FORM_BUILDER_URL . $path;
75 179 }
76 180
181 + public function plugin_dir( $path = '' ) {
182 + return JET_FORM_BUILDER_PATH . $path;
183 + }
184 +
77 185 /**
78 186 * Returns plugin version
79 187 */
80 188 public function get_version() {
@@ -86,10 +194,24 @@
86 194 */
87 195 private function __construct() {
88 196
89 197 $this->register_autoloader();
198 + $this->init_lang();
90 199
91 - add_action( 'after_setup_theme', array( $this, 'init_components' ), 0 );
200 + add_action(
201 + 'after_setup_theme',
202 + function () {
203 + do_action( 'jet-form-builder/before-init' );
204 +
205 + $this->init_components();
206 +
207 + do_action( 'jet-form-builder/after-init' );
208 + },
209 + 0
210 + );
211 +
212 + $this->init_framework();
213 + Wp_Cli_Manager::register();
92 214 }
93 215
94 216 }
95 217