PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.11
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.11
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 +92 -136 2.8.20.0.11 View file →
@@ -7,45 +7,34 @@
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;
22 +use SRFM\Inc\Export;
23 +use SRFM\Inc\Smart_Tags;
24 +use SRFM\Inc\Generate_Form_Markup;
25 +use SRFM\Inc\Create_New_Form;
26 +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;
19 30 use SRFM\Inc\AI_Form_Builder\AI_Form_Builder;
20 -use SRFM\Inc\AI_Form_Builder\AI_Helper;
21 31 use SRFM\Inc\AI_Form_Builder\Field_Mapping;
22 32 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 -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;
34 -use SRFM\Inc\Generate_Form_Markup;
35 -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 33 use SRFM\Inc\Page_Builders\Page_Builders;
42 -use SRFM\Inc\Payments\Payments;
43 -use SRFM\Inc\Post_Types;
44 34 use SRFM\Inc\Rest_Api;
45 -use SRFM\Inc\Single_Form_Settings\Compliance_Settings;
46 -use SRFM\Inc\Smart_Tags;
47 -use SRFM\Inc\Updater;
35 +use SRFM\Inc\AI_Form_Builder\AI_Helper;
36 +use SRFM\Inc\AI_Form_Builder\AI_Auth;
48 37
49 38 if ( ! defined( 'ABSPATH' ) ) {
50 39 exit; // Exit if accessed directly.
51 40 }
@@ -55,8 +44,9 @@
55 44 *
56 45 * @since 0.0.1
57 46 */
58 47 class Plugin_Loader {
48 +
59 49 /**
60 50 * Instance
61 51 *
62 52 * @access private
@@ -65,47 +55,8 @@
65 55 */
66 56 private static $instance = null;
67 57
68 58 /**
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 59 * Initiator
109 60 *
110 61 * @since 0.0.1
111 62 * @return object initialized object of class.
@@ -142,25 +93,81 @@
142 93 [ '', '$1-$2', '-', DIRECTORY_SEPARATOR ],
143 94 $class
144 95 );
145 96
146 - if ( ! is_string( $filename ) ) {
147 - return;
97 + if ( is_string( $filename ) ) {
98 +
99 + $filename = strtolower( $filename );
100 +
101 + $file = SRFM_DIR . $filename . '.php';
102 +
103 + // if the file is readable, include it.
104 + if ( is_readable( $file ) ) {
105 + require_once $file;
106 + }
148 107 }
149 108
150 - // Check for directory traversal.
151 - if ( strpos( $filename, '..' ) !== false ) {
152 - return;
153 - }
109 + }
154 110
155 - $filename = strtolower( $filename );
111 + /**
112 + * Constructor
113 + *
114 + * @since 0.0.1
115 + */
116 + public function __construct() {
117 + // Load the action scheduler before plugin loads.
118 + require_once SRFM_DIR . 'inc/lib/action-scheduler/action-scheduler.php';
156 119
157 - $file = SRFM_DIR . $filename . '.php';
120 + spl_autoload_register( [ $this, 'autoload' ] );
158 121
159 - // if the file is readable, include it.
160 - if ( is_readable( $file ) ) {
161 - require_once $file;
162 - }
122 + add_action( 'plugins_loaded', [ $this, 'load_textdomain' ] );
123 + add_action( 'plugins_loaded', [ $this, 'load_plugin' ], 99 );
124 + add_action( 'init', [ $this, 'load_classes' ] );
125 + add_action( 'admin_init', [ $this, 'activation_redirect' ] );
126 + Post_Types::get_instance();
127 + Form_Submit::get_instance();
128 + Block_Patterns::get_instance();
129 + Gutenberg_Hooks::get_instance();
130 + Register::get_instance();
131 + Frontend_Assets::get_instance();
132 + Helper::get_instance();
133 + Activator::get_instance();
134 + Admin_Ajax::get_instance();
135 + Forms_Data::get_instance();
136 + Export::get_instance();
137 + Smart_Tags::get_instance();
138 + Generate_Form_Markup::get_instance();
139 + Create_New_Form::get_instance();
140 + Global_Settings::get_instance();
141 + Email_Summary::get_instance();
142 + Compliance_Settings::get_instance();
143 + Events_Scheduler::get_instance();
144 + AI_Form_Builder::get_instance();
145 + Field_Mapping::get_instance();
146 + Background_Process::get_instance();
147 + Page_Builders::get_instance();
148 + Rest_Api::get_instance();
149 + AI_Helper::get_instance();
150 + AI_Auth::get_instance();
151 +
152 + /**
153 + * The code that runs during plugin activation
154 + */
155 + register_activation_hook(
156 + SRFM_FILE,
157 + function () {
158 + Activator::activate();
159 + }
160 + );
161 +
162 + register_deactivation_hook(
163 + SRFM_FILE,
164 + function () {
165 + update_option( '__sureforms_do_redirect', false );
166 + Events_Scheduler::unschedule_events( 'srfm_weekly_scheduled_events' );
167 + Events_Scheduler::unschedule_events( 'srfm_daily_scheduled_action' );
168 + }
169 + );
163 170 }
164 171
165 172 /**
166 173 * Activation Reset
@@ -168,18 +175,9 @@
168 175 * @return void
169 176 * @since 0.0.1
170 177 */
171 178 public function activation_redirect() {
172 - // Avoid redirection in case of WP_CLI calls.
173 - if ( defined( 'WP_CLI' ) && \WP_CLI ) {
174 - return;
175 - }
176 179
177 - // Avoid redirection in case of ajax calls.
178 - if ( wp_doing_ajax() ) {
179 - return;
180 - }
181 -
182 180 $do_redirect = apply_filters( 'srfm_enable_redirect_activation', get_option( '__srfm_do_redirect' ) );
183 181
184 182 if ( $do_redirect ) {
185 183
@@ -194,9 +192,9 @@
194 192 ],
195 193 admin_url( 'admin.php' )
196 194 )
197 195 );
198 - exit;
196 + exit();
199 197 }
200 198 }
201 199 }
202 200
@@ -206,19 +204,11 @@
206 204 * @return void
207 205 * @since 0.0.1
208 206 */
209 207 public function load_classes() {
210 -
211 - Register::get_instance();
212 208 if ( is_admin() ) {
213 209 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 210 }
218 - Payments::get_instance();
219 - Duplicate_Form::get_instance();
220 - Learn::get_instance();
221 211 }
222 212
223 213 /**
224 214 * Load Plugin Text Domain.
@@ -251,8 +241,9 @@
251 241
252 242 /**
253 243 * Language Locale for plugin
254 244 *
245 + * @var string $get_locale The locale to use.
255 246 * Uses get_user_locale()` in WordPress 4.7 or greater,
256 247 * otherwise uses `get_locale()`.
257 248 */
258 249 $locale = apply_filters( 'plugin_locale', $get_locale, 'sureforms' );//phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- wordpress hook
@@ -273,8 +264,9 @@
273 264 load_plugin_textdomain( 'sureforms', false, $lang_dir );
274 265 }
275 266 }
276 267
268 +
277 269 /**
278 270 * Loads plugin files.
279 271 *
280 272 * @since 0.0.1
@@ -281,46 +273,8 @@
281 273 *
282 274 * @return void
283 275 */
284 276 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 277 $this->load_core_files();
324 278 }
325 279
326 280 /**
@@ -333,8 +287,10 @@
333 287 public function load_core_files() {
334 288 include_once SRFM_DIR . 'modules/gutenberg/classes/class-spec-block-loader.php';
335 289 }
336 290 }
291 +
292 +
337 293
338 294 /**
339 295 * Kicking this off by calling 'get_instance()' method
340 296 */