PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 1.5.0
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v1.5.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 +117 -86 0.0.101.5.0 View file →
@@ -7,34 +7,39 @@
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;
12 +use SRFM\Admin\Analytics;
14 13 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 14 use SRFM\Inc\Activator;
21 15 use SRFM\Inc\Admin_Ajax;
16 +use SRFM\Inc\AI_Form_Builder\AI_Auth;
17 +use SRFM\Inc\AI_Form_Builder\AI_Form_Builder;
18 +use SRFM\Inc\AI_Form_Builder\AI_Helper;
19 +use SRFM\Inc\AI_Form_Builder\Field_Mapping;
20 +use SRFM\Inc\Background_Process;
21 +use SRFM\Inc\Blocks\Register;
22 +use SRFM\Inc\Create_New_Form;
23 +use SRFM\Inc\Database\Register as DatabaseRegister;
24 +use SRFM\Inc\Events_Scheduler;
22 25 use SRFM\Inc\Export;
23 -use SRFM\Inc\Smart_Tags;
26 +use SRFM\Inc\Form_Submit;
27 +use SRFM\Inc\Forms_Data;
28 +use SRFM\Inc\Frontend_Assets;
24 29 use SRFM\Inc\Generate_Form_Markup;
25 -use SRFM\Inc\Create_New_Form;
30 +use SRFM\Inc\Global_Settings\Email_Summary;
26 31 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;
32 +use SRFM\Inc\Gutenberg_Hooks;
33 +use SRFM\Inc\Helper;
34 +use SRFM\Inc\Lib\SRFM_Nps_Survey;
35 +use SRFM\Inc\Nps_Notice;
33 36 use SRFM\Inc\Page_Builders\Page_Builders;
37 +use SRFM\Inc\Post_Types;
34 38 use SRFM\Inc\Rest_Api;
35 -use SRFM\Inc\AI_Form_Builder\AI_Helper;
36 -use SRFM\Inc\AI_Form_Builder\AI_Auth;
39 +use SRFM\Inc\Single_Form_Settings\Compliance_Settings;
40 +use SRFM\Inc\Smart_Tags;
41 +use SRFM\Inc\Updater;
37 42
38 43 if ( ! defined( 'ABSPATH' ) ) {
39 44 exit; // Exit if accessed directly.
40 45 }
@@ -44,9 +49,8 @@
44 49 *
45 50 * @since 0.0.1
46 51 */
47 52 class Plugin_Loader {
48 -
49 53 /**
50 54 * Instance
51 55 *
52 56 * @access private
@@ -55,8 +59,47 @@
55 59 */
56 60 private static $instance = null;
57 61
58 62 /**
63 + * Constructor
64 + *
65 + * @since 0.0.1
66 + */
67 + public function __construct() {
68 + if ( ! defined( 'SRFM_DIR' ) || ! defined( 'SRFM_FILE' ) ) {
69 + return;
70 + }
71 + // Load the action scheduler before plugin loads.
72 + require_once SRFM_DIR . 'inc/lib/action-scheduler/action-scheduler.php';
73 +
74 + spl_autoload_register( [ $this, 'autoload' ] );
75 +
76 + add_action( 'plugins_loaded', [ $this, 'load_textdomain' ] );
77 + add_action( 'plugins_loaded', [ $this, 'load_plugin' ], 99 );
78 + add_action( 'init', [ $this, 'load_classes' ] );
79 + add_action( 'admin_init', [ $this, 'activation_redirect' ] );
80 + Analytics::get_instance();
81 + /**
82 + * The code that runs during plugin activation
83 + */
84 + register_activation_hook(
85 + SRFM_FILE,
86 + static function () {
87 + Activator::activate();
88 + }
89 + );
90 +
91 + register_deactivation_hook(
92 + SRFM_FILE,
93 + static function () {
94 + update_option( '__sureforms_do_redirect', false );
95 + Events_Scheduler::unschedule_events( 'srfm_weekly_scheduled_events' );
96 + Events_Scheduler::unschedule_events( 'srfm_daily_scheduled_action' );
97 + }
98 + );
99 + }
100 +
101 + /**
59 102 * Initiator
60 103 *
61 104 * @since 0.0.1
62 105 * @return object initialized object of class.
@@ -104,73 +147,11 @@
104 147 if ( is_readable( $file ) ) {
105 148 require_once $file;
106 149 }
107 150 }
108 -
109 151 }
110 152
111 153 /**
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';
119 -
120 - spl_autoload_register( [ $this, 'autoload' ] );
121 -
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 - );
170 - }
171 -
172 - /**
173 154 * Activation Reset
174 155 *
175 156 * @return void
176 157 * @since 0.0.1
@@ -175,9 +156,18 @@
175 156 * @return void
176 157 * @since 0.0.1
177 158 */
178 159 public function activation_redirect() {
160 + // Avoid redirection in case of WP_CLI calls.
161 + if ( defined( 'WP_CLI' ) && \WP_CLI ) {
162 + return;
163 + }
179 164
165 + // Avoid redirection in case of ajax calls.
166 + if ( wp_doing_ajax() ) {
167 + return;
168 + }
169 +
180 170 $do_redirect = apply_filters( 'srfm_enable_redirect_activation', get_option( '__srfm_do_redirect' ) );
181 171
182 172 if ( $do_redirect ) {
183 173
@@ -192,9 +182,9 @@
192 182 ],
193 183 admin_url( 'admin.php' )
194 184 )
195 185 );
196 - exit();
186 + exit;
197 187 }
198 188 }
199 189 }
200 190
@@ -204,8 +194,10 @@
204 194 * @return void
205 195 * @since 0.0.1
206 196 */
207 197 public function load_classes() {
198 +
199 + Register::get_instance();
208 200 if ( is_admin() ) {
209 201 Admin::get_instance();
210 202 }
211 203 }
@@ -241,9 +233,8 @@
241 233
242 234 /**
243 235 * Language Locale for plugin
244 236 *
245 - * @var string $get_locale The locale to use.
246 237 * Uses get_user_locale()` in WordPress 4.7 or greater,
247 238 * otherwise uses `get_locale()`.
248 239 */
249 240 $locale = apply_filters( 'plugin_locale', $get_locale, 'sureforms' );//phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- wordpress hook
@@ -264,9 +255,8 @@
264 255 load_plugin_textdomain( 'sureforms', false, $lang_dir );
265 256 }
266 257 }
267 258
268 -
269 259 /**
270 260 * Loads plugin files.
271 261 *
272 262 * @since 0.0.1
@@ -273,8 +263,51 @@
273 263 *
274 264 * @return void
275 265 */
276 266 public function load_plugin() {
267 + Post_Types::get_instance();
268 + Form_Submit::get_instance();
269 + Block_Patterns::get_instance();
270 + Gutenberg_Hooks::get_instance();
271 + Frontend_Assets::get_instance();
272 + Helper::get_instance();
273 + Activator::get_instance();
274 + Admin_Ajax::get_instance();
275 + Forms_Data::get_instance();
276 + Export::get_instance();
277 + Smart_Tags::get_instance();
278 + Generate_Form_Markup::get_instance();
279 + Create_New_Form::get_instance();
280 + Global_Settings::get_instance();
281 + Email_Summary::get_instance();
282 + Compliance_Settings::get_instance();
283 + Events_Scheduler::get_instance();
284 + AI_Form_Builder::get_instance();
285 + Field_Mapping::get_instance();
286 + Background_Process::get_instance();
287 + Page_Builders::get_instance();
288 + Rest_Api::get_instance();
289 + AI_Helper::get_instance();
290 + AI_Auth::get_instance();
291 + Updater::get_instance();
292 + DatabaseRegister::init();
293 + /**
294 + * Required to add the if check for the class existence to resolve phpstan error,
295 + * as the phpstan configuration ignores the inc/lib directory which gives error
296 + * unknown class.
297 + */
298 + if ( class_exists( 'SRFM\Inc\Lib\SRFM_Nps_Survey' ) && ! apply_filters( 'srfm_disable_nps_survey', false ) ) {
299 + SRFM_Nps_Survey::get_instance(); // Inits the NPS Survey class for which inits the NPS Survey plugin.
300 + Nps_Notice::get_instance(); // Responsible for displaying the NPS Survey: keeping the line out of the check will also work.
301 + }
302 +
303 + /**
304 + * Load core files necessary for the Spectra block.
305 + * This method is called in the Spectra block loader to ensure core files are loaded during the 'plugins_loaded' action.
306 + *
307 + * Note: This code is added at the bottom to ensure the form block is loaded first,
308 + * followed by the Spectra blocks such as heading, image, and icon blocks.
309 + */
277 310 $this->load_core_files();
278 311 }
279 312
280 313 /**
@@ -287,10 +320,8 @@
287 320 public function load_core_files() {
288 321 include_once SRFM_DIR . 'modules/gutenberg/classes/class-spec-block-loader.php';
289 322 }
290 323 }
291 -
292 -
293 324
294 325 /**
295 326 * Kicking this off by calling 'get_instance()' method
296 327 */