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