PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 1.1.0
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v1.1.0
2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 0.0.3 All 96 releases
← All changes | plugin-loader.php +104 -87 0.0.121.1.0 View file →
@@ -7,34 +7,35 @@
7 7 */
8 8
9 9 namespace SRFM;
10 10
11 -use SRFM\Inc\Post_Types;
12 -use SRFM\Inc\Form_Submit;
13 -use SRFM\Inc\Gutenberg_Hooks;
11 +use SRFM\Admin\Admin;
14 12 use SRFM\API\Block_Patterns;
15 -use SRFM\Inc\Forms_Data;
16 -use SRFM\Admin\Admin;
17 -use SRFM\Inc\Blocks\Register;
18 -use SRFM\Inc\Frontend_Assets;
19 -use SRFM\Inc\Helper;
20 13 use SRFM\Inc\Activator;
21 14 use SRFM\Inc\Admin_Ajax;
15 +use SRFM\Inc\AI_Form_Builder\AI_Auth;
16 +use SRFM\Inc\AI_Form_Builder\AI_Form_Builder;
17 +use SRFM\Inc\AI_Form_Builder\AI_Helper;
18 +use SRFM\Inc\AI_Form_Builder\Field_Mapping;
19 +use SRFM\Inc\Background_Process;
20 +use SRFM\Inc\Blocks\Register;
21 +use SRFM\Inc\Create_New_Form;
22 +use SRFM\Inc\Database\Register as DatabaseRegister;
23 +use SRFM\Inc\Events_Scheduler;
22 24 use SRFM\Inc\Export;
23 -use SRFM\Inc\Smart_Tags;
25 +use SRFM\Inc\Form_Submit;
26 +use SRFM\Inc\Forms_Data;
27 +use SRFM\Inc\Frontend_Assets;
24 28 use SRFM\Inc\Generate_Form_Markup;
25 -use SRFM\Inc\Create_New_Form;
29 +use SRFM\Inc\Global_Settings\Email_Summary;
26 30 use SRFM\Inc\Global_Settings\Global_Settings;
27 -use SRFM\Inc\Global_Settings\Email_Summary;
28 -use SRFM\Inc\Single_Form_Settings\Compliance_Settings;
29 -use SRFM\Inc\Events_Scheduler;
30 -use SRFM\Inc\AI_Form_Builder\AI_Form_Builder;
31 -use SRFM\Inc\AI_Form_Builder\Field_Mapping;
32 -use SRFM\Inc\Background_Process;
31 +use SRFM\Inc\Gutenberg_Hooks;
32 +use SRFM\Inc\Helper;
33 33 use SRFM\Inc\Page_Builders\Page_Builders;
34 +use SRFM\Inc\Post_Types;
34 35 use SRFM\Inc\Rest_Api;
35 -use SRFM\Inc\AI_Form_Builder\AI_Helper;
36 -use SRFM\Inc\AI_Form_Builder\AI_Auth;
36 +use SRFM\Inc\Single_Form_Settings\Compliance_Settings;
37 +use SRFM\Inc\Smart_Tags;
37 38 use SRFM\Inc\Updater;
38 39
39 40 if ( ! defined( 'ABSPATH' ) ) {
40 41 exit; // Exit if accessed directly.
@@ -45,9 +46,8 @@
45 46 *
46 47 * @since 0.0.1
47 48 */
48 49 class Plugin_Loader {
49 -
50 50 /**
51 51 * Instance
52 52 *
53 53 * @access private
@@ -56,8 +56,47 @@
56 56 */
57 57 private static $instance = null;
58 58
59 59 /**
60 + * Constructor
61 + *
62 + * @since 0.0.1
63 + */
64 + public function __construct() {
65 + if ( ! defined( 'SRFM_DIR' ) || ! defined( 'SRFM_FILE' ) ) {
66 + return;
67 + }
68 + // Load the action scheduler before plugin loads.
69 + require_once SRFM_DIR . 'inc/lib/action-scheduler/action-scheduler.php';
70 +
71 + spl_autoload_register( [ $this, 'autoload' ] );
72 +
73 + add_action( 'plugins_loaded', [ $this, 'load_textdomain' ] );
74 + add_action( 'plugins_loaded', [ $this, 'load_plugin' ], 99 );
75 + add_action( 'init', [ $this, 'load_classes' ] );
76 + add_action( 'admin_init', [ $this, 'activation_redirect' ] );
77 +
78 + /**
79 + * The code that runs during plugin activation
80 + */
81 + register_activation_hook(
82 + SRFM_FILE,
83 + static function () {
84 + Activator::activate();
85 + }
86 + );
87 +
88 + register_deactivation_hook(
89 + SRFM_FILE,
90 + static function () {
91 + update_option( '__sureforms_do_redirect', false );
92 + Events_Scheduler::unschedule_events( 'srfm_weekly_scheduled_events' );
93 + Events_Scheduler::unschedule_events( 'srfm_daily_scheduled_action' );
94 + }
95 + );
96 + }
97 +
98 + /**
60 99 * Initiator
61 100 *
62 101 * @since 0.0.1
63 102 * @return object initialized object of class.
@@ -105,74 +144,11 @@
105 144 if ( is_readable( $file ) ) {
106 145 require_once $file;
107 146 }
108 147 }
109 -
110 148 }
111 149
112 150 /**
113 - * Constructor
114 - *
115 - * @since 0.0.1
116 - */
117 - public function __construct() {
118 - // Load the action scheduler before plugin loads.
119 - require_once SRFM_DIR . 'inc/lib/action-scheduler/action-scheduler.php';
120 -
121 - spl_autoload_register( [ $this, 'autoload' ] );
122 -
123 - add_action( 'plugins_loaded', [ $this, 'load_textdomain' ] );
124 - add_action( 'plugins_loaded', [ $this, 'load_plugin' ], 99 );
125 - add_action( 'init', [ $this, 'load_classes' ] );
126 - add_action( 'admin_init', [ $this, 'activation_redirect' ] );
127 - Post_Types::get_instance();
128 - Form_Submit::get_instance();
129 - Block_Patterns::get_instance();
130 - Gutenberg_Hooks::get_instance();
131 - Register::get_instance();
132 - Frontend_Assets::get_instance();
133 - Helper::get_instance();
134 - Activator::get_instance();
135 - Admin_Ajax::get_instance();
136 - Forms_Data::get_instance();
137 - Export::get_instance();
138 - Smart_Tags::get_instance();
139 - Generate_Form_Markup::get_instance();
140 - Create_New_Form::get_instance();
141 - Global_Settings::get_instance();
142 - Email_Summary::get_instance();
143 - Compliance_Settings::get_instance();
144 - Events_Scheduler::get_instance();
145 - AI_Form_Builder::get_instance();
146 - Field_Mapping::get_instance();
147 - Background_Process::get_instance();
148 - Page_Builders::get_instance();
149 - Rest_Api::get_instance();
150 - AI_Helper::get_instance();
151 - AI_Auth::get_instance();
152 - Updater::get_instance();
153 -
154 - /**
155 - * The code that runs during plugin activation
156 - */
157 - register_activation_hook(
158 - SRFM_FILE,
159 - function () {
160 - Activator::activate();
161 - }
162 - );
163 -
164 - register_deactivation_hook(
165 - SRFM_FILE,
166 - function () {
167 - update_option( '__sureforms_do_redirect', false );
168 - Events_Scheduler::unschedule_events( 'srfm_weekly_scheduled_events' );
169 - Events_Scheduler::unschedule_events( 'srfm_daily_scheduled_action' );
170 - }
171 - );
172 - }
173 -
174 - /**
175 151 * Activation Reset
176 152 *
177 153 * @return void
178 154 * @since 0.0.1
@@ -177,9 +153,18 @@
177 153 * @return void
178 154 * @since 0.0.1
179 155 */
180 156 public function activation_redirect() {
157 + // Avoid redirection in case of WP_CLI calls.
158 + if ( defined( 'WP_CLI' ) && \WP_CLI ) {
159 + return;
160 + }
181 161
162 + // Avoid redirection in case of ajax calls.
163 + if ( wp_doing_ajax() ) {
164 + return;
165 + }
166 +
182 167 $do_redirect = apply_filters( 'srfm_enable_redirect_activation', get_option( '__srfm_do_redirect' ) );
183 168
184 169 if ( $do_redirect ) {
185 170
@@ -194,9 +179,9 @@
194 179 ],
195 180 admin_url( 'admin.php' )
196 181 )
197 182 );
198 - exit();
183 + exit;
199 184 }
200 185 }
201 186 }
202 187
@@ -206,8 +191,10 @@
206 191 * @return void
207 192 * @since 0.0.1
208 193 */
209 194 public function load_classes() {
195 +
196 + Register::get_instance();
210 197 if ( is_admin() ) {
211 198 Admin::get_instance();
212 199 }
213 200 }
@@ -243,9 +230,8 @@
243 230
244 231 /**
245 232 * Language Locale for plugin
246 233 *
247 - * @var string $get_locale The locale to use.
248 234 * Uses get_user_locale()` in WordPress 4.7 or greater,
249 235 * otherwise uses `get_locale()`.
250 236 */
251 237 $locale = apply_filters( 'plugin_locale', $get_locale, 'sureforms' );//phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- wordpress hook
@@ -266,9 +252,8 @@
266 252 load_plugin_textdomain( 'sureforms', false, $lang_dir );
267 253 }
268 254 }
269 255
270 -
271 256 /**
272 257 * Loads plugin files.
273 258 *
274 259 * @since 0.0.1
@@ -275,8 +260,42 @@
275 260 *
276 261 * @return void
277 262 */
278 263 public function load_plugin() {
264 + Post_Types::get_instance();
265 + Form_Submit::get_instance();
266 + Block_Patterns::get_instance();
267 + Gutenberg_Hooks::get_instance();
268 + Frontend_Assets::get_instance();
269 + Helper::get_instance();
270 + Activator::get_instance();
271 + Admin_Ajax::get_instance();
272 + Forms_Data::get_instance();
273 + Export::get_instance();
274 + Smart_Tags::get_instance();
275 + Generate_Form_Markup::get_instance();
276 + Create_New_Form::get_instance();
277 + Global_Settings::get_instance();
278 + Email_Summary::get_instance();
279 + Compliance_Settings::get_instance();
280 + Events_Scheduler::get_instance();
281 + AI_Form_Builder::get_instance();
282 + Field_Mapping::get_instance();
283 + Background_Process::get_instance();
284 + Page_Builders::get_instance();
285 + Rest_Api::get_instance();
286 + AI_Helper::get_instance();
287 + AI_Auth::get_instance();
288 + Updater::get_instance();
289 + DatabaseRegister::init();
290 +
291 + /**
292 + * Load core files necessary for the Spectra block.
293 + * This method is called in the Spectra block loader to ensure core files are loaded during the 'plugins_loaded' action.
294 + *
295 + * Note: This code is added at the bottom to ensure the form block is loaded first,
296 + * followed by the Spectra blocks such as heading, image, and icon blocks.
297 + */
279 298 $this->load_core_files();
280 299 }
281 300
282 301 /**
@@ -289,10 +308,8 @@
289 308 public function load_core_files() {
290 309 include_once SRFM_DIR . 'modules/gutenberg/classes/class-spec-block-loader.php';
291 310 }
292 311 }
293 -
294 -
295 312
296 313 /**
297 314 * Kicking this off by calling 'get_instance()' method
298 315 */