PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.7
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.7
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 +84 -134 2.7.00.0.7 View file →
@@ -7,44 +7,30 @@
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;
14 +use SRFM\API\Block_Patterns;
15 +use SRFM\Inc\Forms_Data;
11 16 use SRFM\Admin\Admin;
12 -use SRFM\Admin\Analytics;
13 -use SRFM\Admin\Notice_Manager;
14 -use SRFM\Inc\Abilities\Abilities_Registrar;
17 +use SRFM\Inc\Blocks\Register;
18 +use SRFM\Inc\Frontend_Assets;
19 +use SRFM\Inc\Helper;
15 20 use SRFM\Inc\Activator;
16 21 use SRFM\Inc\Admin_Ajax;
17 -use SRFM\Inc\AI_Form_Builder\AI_Auth;
18 -use SRFM\Inc\AI_Form_Builder\AI_Form_Builder;
19 -use SRFM\Inc\AI_Form_Builder\AI_Helper;
20 -use SRFM\Inc\AI_Form_Builder\Field_Mapping;
21 -use SRFM\Inc\Background_Process;
22 -use SRFM\Inc\Blocks\Register;
23 -use SRFM\Inc\Compatibility\Themes\Astra;
24 -use SRFM\Inc\Create_New_Form;
25 -use SRFM\Inc\Database\Register as DatabaseRegister;
26 -use SRFM\Inc\Duplicate_Form;
27 -use SRFM\Inc\Events_Scheduler;
28 22 use SRFM\Inc\Export;
29 -use SRFM\Inc\Form_Restriction;
30 -use SRFM\Inc\Form_Submit;
31 -use SRFM\Inc\Forms_Data;
32 -use SRFM\Inc\Frontend_Assets;
23 +use SRFM\Inc\Smart_Tags;
33 24 use SRFM\Inc\Generate_Form_Markup;
25 +use SRFM\Inc\Create_New_Form;
26 +use SRFM\Inc\Global_Settings\Global_Settings;
34 27 use SRFM\Inc\Global_Settings\Email_Summary;
35 -use SRFM\Inc\Global_Settings\Global_Settings;
36 -use SRFM\Inc\Gutenberg_Hooks;
37 -use SRFM\Inc\Helper;
38 -use SRFM\Inc\Learn;
39 -use SRFM\Inc\Onboarding;
28 +use SRFM\Inc\Single_Form_Settings\Compliance_Settings;
29 +use SRFM\Inc\Events_Scheduler;
30 +use SRFM\Inc\Background_Process;
40 31 use SRFM\Inc\Page_Builders\Page_Builders;
41 -use SRFM\Inc\Payments\Payments;
42 -use SRFM\Inc\Post_Types;
43 32 use SRFM\Inc\Rest_Api;
44 -use SRFM\Inc\Single_Form_Settings\Compliance_Settings;
45 -use SRFM\Inc\Smart_Tags;
46 -use SRFM\Inc\Updater;
47 33
48 34 if ( ! defined( 'ABSPATH' ) ) {
49 35 exit; // Exit if accessed directly.
50 36 }
@@ -54,8 +40,9 @@
54 40 *
55 41 * @since 0.0.1
56 42 */
57 43 class Plugin_Loader {
44 +
58 45 /**
59 46 * Instance
60 47 *
61 48 * @access private
@@ -64,47 +51,8 @@
64 51 */
65 52 private static $instance = null;
66 53
67 54 /**
68 - * Constructor
69 - *
70 - * @since 0.0.1
71 - */
72 - public function __construct() {
73 - if ( ! defined( 'SRFM_DIR' ) || ! defined( 'SRFM_FILE' ) ) {
74 - return;
75 - }
76 - // Load the action scheduler before plugin loads.
77 - require_once SRFM_DIR . 'inc/lib/action-scheduler/action-scheduler.php';
78 -
79 - spl_autoload_register( [ $this, 'autoload' ] );
80 -
81 - add_action( 'plugins_loaded', [ $this, 'load_textdomain' ] );
82 - add_action( 'plugins_loaded', [ $this, 'load_plugin' ], 99 );
83 - add_action( 'init', [ $this, 'load_classes' ] );
84 - add_action( 'admin_init', [ $this, 'activation_redirect' ] );
85 - Analytics::get_instance();
86 - /**
87 - * The code that runs during plugin activation
88 - */
89 - register_activation_hook(
90 - SRFM_FILE,
91 - static function () {
92 - Activator::activate();
93 - }
94 - );
95 -
96 - register_deactivation_hook(
97 - SRFM_FILE,
98 - static function () {
99 - update_option( '__sureforms_do_redirect', false );
100 - Events_Scheduler::unschedule_events( 'srfm_weekly_scheduled_events' );
101 - Events_Scheduler::unschedule_events( 'srfm_daily_scheduled_action' );
102 - }
103 - );
104 - }
105 -
106 - /**
107 55 * Initiator
108 56 *
109 57 * @since 0.0.1
110 58 * @return object initialized object of class.
@@ -141,25 +89,77 @@
141 89 [ '', '$1-$2', '-', DIRECTORY_SEPARATOR ],
142 90 $class
143 91 );
144 92
145 - if ( ! is_string( $filename ) ) {
146 - return;
93 + if ( is_string( $filename ) ) {
94 +
95 + $filename = strtolower( $filename );
96 +
97 + $file = SRFM_DIR . $filename . '.php';
98 +
99 + // if the file is readable, include it.
100 + if ( is_readable( $file ) ) {
101 + require_once $file;
102 + }
147 103 }
148 104
149 - // Check for directory traversal.
150 - if ( strpos( $filename, '..' ) !== false ) {
151 - return;
152 - }
105 + }
153 106
154 - $filename = strtolower( $filename );
107 + /**
108 + * Constructor
109 + *
110 + * @since 0.0.1
111 + */
112 + public function __construct() {
113 + // Load the action scheduler before plugin loads.
114 + require_once SRFM_DIR . 'inc/lib/action-scheduler/action-scheduler.php';
155 115
156 - $file = SRFM_DIR . $filename . '.php';
116 + spl_autoload_register( [ $this, 'autoload' ] );
157 117
158 - // if the file is readable, include it.
159 - if ( is_readable( $file ) ) {
160 - require_once $file;
161 - }
118 + add_action( 'plugins_loaded', [ $this, 'load_textdomain' ] );
119 + add_action( 'plugins_loaded', [ $this, 'load_plugin' ], 99 );
120 + add_action( 'init', [ $this, 'load_classes' ] );
121 + add_action( 'admin_init', [ $this, 'activation_redirect' ] );
122 + Post_Types::get_instance();
123 + Form_Submit::get_instance();
124 + Block_Patterns::get_instance();
125 + Gutenberg_Hooks::get_instance();
126 + Register::get_instance();
127 + Frontend_Assets::get_instance();
128 + Helper::get_instance();
129 + Activator::get_instance();
130 + Admin_Ajax::get_instance();
131 + Forms_Data::get_instance();
132 + Export::get_instance();
133 + Smart_Tags::get_instance();
134 + Generate_Form_Markup::get_instance();
135 + Create_New_Form::get_instance();
136 + Global_Settings::get_instance();
137 + Email_Summary::get_instance();
138 + Compliance_Settings::get_instance();
139 + Events_Scheduler::get_instance();
140 + Background_Process::get_instance();
141 + Page_Builders::get_instance();
142 + Rest_Api::get_instance();
143 +
144 + /**
145 + * The code that runs during plugin activation
146 + */
147 + register_activation_hook(
148 + SRFM_FILE,
149 + function () {
150 + Activator::activate();
151 + }
152 + );
153 +
154 + register_deactivation_hook(
155 + SRFM_FILE,
156 + function () {
157 + update_option( '__sureforms_do_redirect', false );
158 + Events_Scheduler::unschedule_events( 'srfm_weekly_scheduled_events' );
159 + Events_Scheduler::unschedule_events( 'srfm_daily_scheduled_action' );
160 + }
161 + );
162 162 }
163 163
164 164 /**
165 165 * Activation Reset
@@ -167,18 +167,9 @@
167 167 * @return void
168 168 * @since 0.0.1
169 169 */
170 170 public function activation_redirect() {
171 - // Avoid redirection in case of WP_CLI calls.
172 - if ( defined( 'WP_CLI' ) && \WP_CLI ) {
173 - return;
174 - }
175 171
176 - // Avoid redirection in case of ajax calls.
177 - if ( wp_doing_ajax() ) {
178 - return;
179 - }
180 -
181 172 $do_redirect = apply_filters( 'srfm_enable_redirect_activation', get_option( '__srfm_do_redirect' ) );
182 173
183 174 if ( $do_redirect ) {
184 175
@@ -193,9 +184,9 @@
193 184 ],
194 185 admin_url( 'admin.php' )
195 186 )
196 187 );
197 - exit;
188 + exit();
198 189 }
199 190 }
200 191 }
201 192
@@ -205,18 +196,11 @@
205 196 * @return void
206 197 * @since 0.0.1
207 198 */
208 199 public function load_classes() {
209 -
210 - Register::get_instance();
211 200 if ( is_admin() ) {
212 201 Admin::get_instance();
213 - // phpcs:ignore /** @phpstan-ignore-next-line */ -- Class is loaded dynamically in WordPress
214 - Notice_Manager::get_instance();
215 202 }
216 - Payments::get_instance();
217 - Duplicate_Form::get_instance();
218 - Learn::get_instance();
219 203 }
220 204
221 205 /**
222 206 * Load Plugin Text Domain.
@@ -249,8 +233,9 @@
249 233
250 234 /**
251 235 * Language Locale for plugin
252 236 *
237 + * @var string $get_locale The locale to use.
253 238 * Uses get_user_locale()` in WordPress 4.7 or greater,
254 239 * otherwise uses `get_locale()`.
255 240 */
256 241 $locale = apply_filters( 'plugin_locale', $get_locale, 'sureforms' );//phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- wordpress hook
@@ -271,8 +256,9 @@
271 256 load_plugin_textdomain( 'sureforms', false, $lang_dir );
272 257 }
273 258 }
274 259
260 +
275 261 /**
276 262 * Loads plugin files.
277 263 *
278 264 * @since 0.0.1
@@ -279,46 +265,8 @@
279 265 *
280 266 * @return void
281 267 */
282 268 public function load_plugin() {
283 - Post_Types::get_instance();
284 - Form_Submit::get_instance();
285 - Gutenberg_Hooks::get_instance();
286 - Frontend_Assets::get_instance();
287 - Helper::get_instance();
288 - Activator::get_instance();
289 - Admin_Ajax::get_instance();
290 - Forms_Data::get_instance();
291 - Export::get_instance();
292 - Smart_Tags::get_instance();
293 - Generate_Form_Markup::get_instance();
294 - Create_New_Form::get_instance();
295 - Global_Settings::get_instance();
296 - Email_Summary::get_instance();
297 - Compliance_Settings::get_instance();
298 - Events_Scheduler::get_instance();
299 - AI_Form_Builder::get_instance();
300 - Field_Mapping::get_instance();
301 - Background_Process::get_instance();
302 - Page_Builders::get_instance();
303 - Rest_Api::get_instance();
304 - AI_Helper::get_instance();
305 - AI_Auth::get_instance();
306 - Updater::get_instance();
307 - Onboarding::get_instance();
308 - DatabaseRegister::init();
309 - Form_Restriction::get_instance();
310 - Abilities_Registrar::get_instance();
311 - // Initializing Compatibilities.
312 - Astra::get_instance();
313 -
314 - /**
315 - * Load core files necessary for the Spectra block.
316 - * This method is called in the Spectra block loader to ensure core files are loaded during the 'plugins_loaded' action.
317 - *
318 - * Note: This code is added at the bottom to ensure the form block is loaded first,
319 - * followed by the Spectra blocks such as heading, image, and icon blocks.
320 - */
321 269 $this->load_core_files();
322 270 }
323 271
324 272 /**
@@ -331,8 +279,10 @@
331 279 public function load_core_files() {
332 280 include_once SRFM_DIR . 'modules/gutenberg/classes/class-spec-block-loader.php';
333 281 }
334 282 }
283 +
284 +
335 285
336 286 /**
337 287 * Kicking this off by calling 'get_instance()' method
338 288 */