@@ -22,819 +22,819 @@ |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * @deprecated 4.9.40 |
|
27 | - * @see \EventEspresso\core\services\request\RequestType |
|
28 | - */ |
|
29 | - const req_type_normal = 0; |
|
30 | - |
|
31 | - /** |
|
32 | - * @deprecated 4.9.40 |
|
33 | - * @see \EventEspresso\core\services\request\RequestType |
|
34 | - */ |
|
35 | - const req_type_new_activation = 1; |
|
36 | - |
|
37 | - /** |
|
38 | - * @deprecated 4.9.40 |
|
39 | - * @see \EventEspresso\core\services\request\RequestType |
|
40 | - */ |
|
41 | - const req_type_reactivation = 2; |
|
42 | - |
|
43 | - /** |
|
44 | - * @deprecated 4.9.40 |
|
45 | - * @see \EventEspresso\core\services\request\RequestType |
|
46 | - */ |
|
47 | - const req_type_upgrade = 3; |
|
48 | - |
|
49 | - /** |
|
50 | - * @deprecated 4.9.40 |
|
51 | - * @see \EventEspresso\core\services\request\RequestType |
|
52 | - */ |
|
53 | - const req_type_downgrade = 4; |
|
54 | - |
|
55 | - /** |
|
56 | - * @deprecated since version 4.6.0.dev.006 |
|
57 | - * Now whenever a new_activation is detected the request type is still just |
|
58 | - * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
59 | - * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
60 | - * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
61 | - * (Specifically, when the migration manager indicates migrations are finished |
|
62 | - * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
63 | - */ |
|
64 | - const req_type_activation_but_not_installed = 5; |
|
65 | - |
|
66 | - /** |
|
67 | - * @deprecated 4.9.40 |
|
68 | - * @see \EventEspresso\core\services\request\RequestType |
|
69 | - */ |
|
70 | - const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @var EE_System $_instance |
|
75 | - */ |
|
76 | - private static $_instance; |
|
77 | - |
|
78 | - /** |
|
79 | - * @var EE_Registry $registry |
|
80 | - */ |
|
81 | - private $registry; |
|
82 | - |
|
83 | - /** |
|
84 | - * @var LoaderInterface $loader |
|
85 | - */ |
|
86 | - private $loader; |
|
87 | - |
|
88 | - /** |
|
89 | - * @var EE_Capabilities $capabilities |
|
90 | - */ |
|
91 | - private $capabilities; |
|
92 | - |
|
93 | - /** |
|
94 | - * @var EE_Request $request |
|
95 | - */ |
|
96 | - private $request; |
|
97 | - |
|
98 | - /** |
|
99 | - * @var EE_Maintenance_Mode $maintenance_mode |
|
100 | - */ |
|
101 | - private $maintenance_mode; |
|
102 | - |
|
103 | - /** |
|
104 | - * @var ActivationsAndUpgradesManager $activations_and_upgrades_manager |
|
105 | - */ |
|
106 | - private $activations_and_upgrades_manager; |
|
107 | - |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @singleton method used to instantiate class object |
|
112 | - * @param EE_Registry|null $registry |
|
113 | - * @param LoaderInterface|null $loader |
|
114 | - * @param EE_Capabilities|null $capabilities |
|
115 | - * @param EE_Request|null $request |
|
116 | - * @param EE_Maintenance_Mode|null $maintenance_mode |
|
117 | - * @return EE_System |
|
118 | - */ |
|
119 | - public static function instance( |
|
120 | - EE_Registry $registry = null, |
|
121 | - LoaderInterface $loader = null, |
|
122 | - EE_Capabilities $capabilities = null, |
|
123 | - EE_Request $request = null, |
|
124 | - EE_Maintenance_Mode $maintenance_mode = null |
|
125 | - ) { |
|
126 | - // check if class object is instantiated |
|
127 | - if (! self::$_instance instanceof EE_System) { |
|
128 | - self::$_instance = new self($registry, $loader, $capabilities, $request, $maintenance_mode); |
|
129 | - } |
|
130 | - return self::$_instance; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * resets the instance and returns it |
|
137 | - * |
|
138 | - * @return EE_System |
|
139 | - * @throws InvalidArgumentException |
|
140 | - */ |
|
141 | - public static function reset() |
|
142 | - { |
|
143 | - //make sure none of the old hooks are left hanging around |
|
144 | - remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
145 | - //we need to reset the migration manager in order for it to detect DMSs properly |
|
146 | - EE_Data_Migration_Manager::reset(); |
|
147 | - self::instance()->detect_activations_or_upgrades(); |
|
148 | - self::instance()->activations_and_upgrades_manager->performActivationsAndUpgrades(); |
|
149 | - return self::instance(); |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - |
|
154 | - /** |
|
155 | - * sets hooks for running rest of system |
|
156 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
157 | - * starting EE Addons from any other point may lead to problems |
|
158 | - * |
|
159 | - * @param EE_Registry $registry |
|
160 | - * @param LoaderInterface $loader |
|
161 | - * @param EE_Capabilities $capabilities |
|
162 | - * @param EE_Request $request |
|
163 | - * @param EE_Maintenance_Mode $maintenance_mode |
|
164 | - */ |
|
165 | - private function __construct( |
|
166 | - EE_Registry $registry, |
|
167 | - LoaderInterface $loader, |
|
168 | - EE_Capabilities $capabilities, |
|
169 | - EE_Request $request, |
|
170 | - EE_Maintenance_Mode $maintenance_mode |
|
171 | - ) { |
|
172 | - $this->registry = $registry; |
|
173 | - $this->loader = $loader; |
|
174 | - $this->capabilities = $capabilities; |
|
175 | - $this->request = $request; |
|
176 | - $this->maintenance_mode = $maintenance_mode; |
|
177 | - do_action('AHEE__EE_System__construct__begin', $this); |
|
178 | - // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
179 | - add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
180 | - // when an ee addon is activated, we want to call the core hook(s) again |
|
181 | - // because the newly-activated addon didn't get a chance to run at all |
|
182 | - add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
183 | - // detect whether install or upgrade |
|
184 | - add_action( |
|
185 | - 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
186 | - 3 |
|
187 | - ); |
|
188 | - // load EE_Config, EE_Textdomain, etc |
|
189 | - add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
190 | - // load EE_Config, EE_Textdomain, etc |
|
191 | - add_action( |
|
192 | - 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
193 | - array($this, 'register_shortcodes_modules_and_widgets'), 7 |
|
194 | - ); |
|
195 | - // you wanna get going? I wanna get going... let's get going! |
|
196 | - add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
197 | - //other housekeeping |
|
198 | - //exclude EE critical pages from wp_list_pages |
|
199 | - add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
200 | - // ALL EE Addons should use the following hook point to attach their initial setup too |
|
201 | - // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
202 | - do_action('AHEE__EE_System__construct__complete', $this); |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * load_espresso_addons |
|
209 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
210 | - * this is hooked into both: |
|
211 | - * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
212 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
213 | - * and the WP 'activate_plugin' hook point |
|
214 | - * |
|
215 | - * @return void |
|
216 | - * @throws EE_Error |
|
217 | - */ |
|
218 | - public function load_espresso_addons() |
|
219 | - { |
|
220 | - // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
221 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
222 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
223 | - //caps need to be initialized on every request so that capability maps are set. |
|
224 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
225 | - $this->capabilities->init_caps(); |
|
226 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
227 | - //if the WP API basic auth plugin isn't already loaded, load it now. |
|
228 | - //We want it for mobile apps. Just include the entire plugin |
|
229 | - //also, don't load the basic auth when a plugin is getting activated, because |
|
230 | - //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
231 | - //and causes a fatal error |
|
232 | - if ( |
|
233 | - ! ( |
|
234 | - isset($_GET['activate']) |
|
235 | - && $_GET['activate'] === 'true' |
|
236 | - ) |
|
237 | - && ! function_exists('json_basic_auth_handler') |
|
238 | - && ! function_exists('json_basic_auth_error') |
|
239 | - && ! ( |
|
240 | - isset($_GET['action']) |
|
241 | - && in_array($_GET['action'], array('activate', 'activate-selected'), true) |
|
242 | - ) |
|
243 | - ) { |
|
244 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
245 | - } |
|
246 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
247 | - } |
|
248 | - |
|
249 | - |
|
250 | - |
|
251 | - /** |
|
252 | - * detect_activations_or_upgrades |
|
253 | - * Checks for activation or upgrade of core first; |
|
254 | - * then also checks if any registered addons have been activated or upgraded |
|
255 | - * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
256 | - * which runs during the WP 'plugins_loaded' action at priority 3 |
|
257 | - * |
|
258 | - * @return void |
|
259 | - * @throws InvalidArgumentException |
|
260 | - * @throws InvalidEntityException |
|
261 | - */ |
|
262 | - public function detect_activations_or_upgrades() |
|
263 | - { |
|
264 | - $this->activations_and_upgrades_manager = new ActivationsAndUpgradesManager( |
|
265 | - $this, |
|
266 | - $this->request->getRequestType()->getActivationHistory(), |
|
267 | - $this->request->getRequestType(), |
|
268 | - $this->maintenance_mode, |
|
269 | - get_object_vars($this->registry->addons) |
|
270 | - ); |
|
271 | - $this->activations_and_upgrades_manager->detectActivationsAndUpgrades(); |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - |
|
276 | - /** |
|
277 | - * Does the traditional work of setting up the plugin's database and adding default data. |
|
278 | - * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
279 | - * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
280 | - * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
281 | - * so that it will be done when migrations are finished |
|
282 | - * |
|
283 | - * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
284 | - * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
285 | - * This is a resource-intensive job |
|
286 | - * so we prefer to only do it when necessary |
|
287 | - * @return void |
|
288 | - * @throws EE_Error |
|
289 | - */ |
|
290 | - public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
291 | - { |
|
292 | - $request_type = $this->request->getRequestType()->requestType(); |
|
293 | - //only initialize system if we're not in maintenance mode. |
|
294 | - if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
295 | - update_option('ee_flush_rewrite_rules', true); |
|
296 | - if ($verify_schema) { |
|
297 | - EEH_Activation::initialize_db_and_folders(); |
|
298 | - } |
|
299 | - EEH_Activation::initialize_db_content(); |
|
300 | - EEH_Activation::system_initialization(); |
|
301 | - if ($initialize_addons_too) { |
|
302 | - $this->initialize_addons(); |
|
303 | - } |
|
304 | - } else { |
|
305 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
306 | - } |
|
307 | - if ($request_type === RequestType::REQUEST_TYPE_NEW_ACTIVATION |
|
308 | - || $request_type === RequestType::REQUEST_TYPE_REACTIVATION |
|
309 | - || ( |
|
310 | - $request_type === RequestType::REQUEST_TYPE_UPGRADE |
|
311 | - && $this->request->getRequestType()->isMajorVersionChange() |
|
312 | - ) |
|
313 | - ) { |
|
314 | - add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
315 | - } |
|
316 | - } |
|
317 | - |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * Initializes the db for all registered addons |
|
322 | - * |
|
323 | - * @throws EE_Error |
|
324 | - */ |
|
325 | - public function initialize_addons() |
|
326 | - { |
|
327 | - //foreach registered addon, make sure its db is up-to-date too |
|
328 | - foreach (get_object_vars($this->registry->addons) as $addon) { |
|
329 | - if($addon instanceof EE_Addon) { |
|
330 | - $addon->initialize_db_if_no_migrations_required(); |
|
331 | - } |
|
332 | - } |
|
333 | - } |
|
334 | - |
|
335 | - |
|
336 | - |
|
337 | - /** |
|
338 | - * This redirects to the about EE page after activation |
|
339 | - * |
|
340 | - * @return void |
|
341 | - */ |
|
342 | - public function redirect_to_about_ee() |
|
343 | - { |
|
344 | - $notices = EE_Error::get_notices(false); |
|
345 | - //if current user is an admin and it's not an ajax or rest request |
|
346 | - if ( |
|
347 | - ! (defined('DOING_AJAX') && DOING_AJAX) |
|
348 | - && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
349 | - && ! isset($notices['errors']) |
|
350 | - && apply_filters( |
|
351 | - 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
352 | - $this->capabilities->current_user_can('manage_options', 'espresso_about_default') |
|
353 | - ) |
|
354 | - ) { |
|
355 | - $query_params = array('page' => 'espresso_about'); |
|
356 | - $request_type = $this->request->getRequestType()->requestType(); |
|
357 | - if ($request_type === RequestType::REQUEST_TYPE_NEW_ACTIVATION) { |
|
358 | - $query_params['new_activation'] = true; |
|
359 | - } else if ($request_type === RequestType::REQUEST_TYPE_REACTIVATION) { |
|
360 | - $query_params['reactivation'] = true; |
|
361 | - } |
|
362 | - $url = add_query_arg($query_params, admin_url('admin.php')); |
|
363 | - wp_safe_redirect($url); |
|
364 | - exit(); |
|
365 | - } |
|
366 | - } |
|
367 | - |
|
368 | - |
|
369 | - |
|
370 | - /** |
|
371 | - * load_core_configuration |
|
372 | - * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
373 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
374 | - * |
|
375 | - * @return void |
|
376 | - * @throws ReflectionException |
|
377 | - */ |
|
378 | - public function load_core_configuration() |
|
379 | - { |
|
380 | - do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
381 | - $this->loader->getShared('EE_Load_Textdomain'); |
|
382 | - //load textdomain |
|
383 | - EE_Load_Textdomain::load_textdomain(); |
|
384 | - // load and setup EE_Config and EE_Network_Config |
|
385 | - $config = $this->loader->getShared('EE_Config'); |
|
386 | - $this->loader->getShared('EE_Network_Config'); |
|
387 | - // setup autoloaders |
|
388 | - // enable logging? |
|
389 | - if ($config->admin->use_full_logging) { |
|
390 | - $this->loader->getShared('EE_Log'); |
|
391 | - } |
|
392 | - // check for activation errors |
|
393 | - $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
394 | - if ($activation_errors) { |
|
395 | - EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
396 | - update_option('ee_plugin_activation_errors', false); |
|
397 | - } |
|
398 | - // get model names |
|
399 | - $this->_parse_model_names(); |
|
400 | - //load caf stuff a chance to play during the activation process too. |
|
401 | - $this->_maybe_brew_regular(); |
|
402 | - do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
403 | - } |
|
404 | - |
|
405 | - |
|
406 | - |
|
407 | - /** |
|
408 | - * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
409 | - * |
|
410 | - * @return void |
|
411 | - * @throws ReflectionException |
|
412 | - */ |
|
413 | - private function _parse_model_names() |
|
414 | - { |
|
415 | - //get all the files in the EE_MODELS folder that end in .model.php |
|
416 | - $models = glob(EE_MODELS . '*.model.php'); |
|
417 | - $model_names = array(); |
|
418 | - $non_abstract_db_models = array(); |
|
419 | - foreach ($models as $model) { |
|
420 | - // get model classname |
|
421 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
422 | - $short_name = str_replace('EEM_', '', $classname); |
|
423 | - $reflectionClass = new ReflectionClass($classname); |
|
424 | - if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
425 | - $non_abstract_db_models[ $short_name ] = $classname; |
|
426 | - } |
|
427 | - $model_names[ $short_name ] = $classname; |
|
428 | - } |
|
429 | - $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
430 | - $this->registry->non_abstract_db_models = apply_filters( |
|
431 | - 'FHEE__EE_System__parse_implemented_model_names', |
|
432 | - $non_abstract_db_models |
|
433 | - ); |
|
434 | - } |
|
435 | - |
|
436 | - |
|
437 | - |
|
438 | - /** |
|
439 | - * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
440 | - * that need to be setup before our EE_System launches. |
|
441 | - * |
|
442 | - * @return void |
|
443 | - */ |
|
444 | - private function _maybe_brew_regular() |
|
445 | - { |
|
446 | - if ((! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
447 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
448 | - } |
|
449 | - } |
|
450 | - |
|
451 | - |
|
452 | - |
|
453 | - /** |
|
454 | - * register_shortcodes_modules_and_widgets |
|
455 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
456 | - * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
457 | - * which runs during the WP 'plugins_loaded' action at priority 7 |
|
458 | - * |
|
459 | - * @access public |
|
460 | - * @return void |
|
461 | - */ |
|
462 | - public function register_shortcodes_modules_and_widgets() |
|
463 | - { |
|
464 | - try { |
|
465 | - // load, register, and add shortcodes the new way |
|
466 | - new ShortcodesManager( |
|
467 | - // and the old way, but we'll put it under control of the new system |
|
468 | - EE_Config::getLegacyShortcodesManager() |
|
469 | - ); |
|
470 | - } catch (Exception $exception) { |
|
471 | - new ExceptionStackTraceDisplay($exception); |
|
472 | - } |
|
473 | - do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
474 | - // check for addons using old hook point |
|
475 | - if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
476 | - $this->_incompatible_addon_error(); |
|
477 | - } |
|
478 | - } |
|
479 | - |
|
480 | - |
|
481 | - |
|
482 | - /** |
|
483 | - * _incompatible_addon_error |
|
484 | - * |
|
485 | - * @access public |
|
486 | - * @return void |
|
487 | - */ |
|
488 | - private function _incompatible_addon_error() |
|
489 | - { |
|
490 | - // get array of classes hooking into here |
|
491 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
492 | - 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
493 | - ); |
|
494 | - if (! empty($class_names)) { |
|
495 | - $msg = __( |
|
496 | - 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
497 | - 'event_espresso' |
|
498 | - ); |
|
499 | - $msg .= '<ul>'; |
|
500 | - foreach ($class_names as $class_name) { |
|
501 | - $msg .= '<li><b>Event Espresso - ' . str_replace( |
|
502 | - array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
503 | - $class_name |
|
504 | - ) . '</b></li>'; |
|
505 | - } |
|
506 | - $msg .= '</ul>'; |
|
507 | - $msg .= __( |
|
508 | - 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
509 | - 'event_espresso' |
|
510 | - ); |
|
511 | - // save list of incompatible addons to wp-options for later use |
|
512 | - add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
513 | - if (is_admin()) { |
|
514 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
515 | - } |
|
516 | - } |
|
517 | - } |
|
518 | - |
|
519 | - |
|
520 | - |
|
521 | - /** |
|
522 | - * brew_espresso |
|
523 | - * begins the process of setting hooks for initializing EE in the correct order |
|
524 | - * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
525 | - * which runs during the WP 'plugins_loaded' action at priority 9 |
|
526 | - * |
|
527 | - * @return void |
|
528 | - */ |
|
529 | - public function brew_espresso() |
|
530 | - { |
|
531 | - do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
532 | - // load some final core systems |
|
533 | - add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
534 | - add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
535 | - add_action('init', array($this, 'load_controllers'), 7); |
|
536 | - add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
537 | - add_action('init', array($this, 'initialize'), 10); |
|
538 | - add_action('init', array($this, 'initialize_last'), 100); |
|
539 | - if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
540 | - // pew pew pew |
|
541 | - $this->loader->getShared('EE_PUE'); |
|
542 | - do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
543 | - } |
|
544 | - do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
545 | - } |
|
546 | - |
|
547 | - |
|
548 | - |
|
549 | - /** |
|
550 | - * set_hooks_for_core |
|
551 | - * |
|
552 | - * @access public |
|
553 | - * @return void |
|
554 | - */ |
|
555 | - public function set_hooks_for_core() |
|
556 | - { |
|
557 | - $this->_deactivate_incompatible_addons(); |
|
558 | - do_action('AHEE__EE_System__set_hooks_for_core'); |
|
559 | - } |
|
560 | - |
|
561 | - |
|
562 | - |
|
563 | - /** |
|
564 | - * Using the information gathered in EE_System::_incompatible_addon_error, |
|
565 | - * deactivates any addons considered incompatible with the current version of EE |
|
566 | - */ |
|
567 | - private function _deactivate_incompatible_addons() |
|
568 | - { |
|
569 | - $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
570 | - if (! empty($incompatible_addons)) { |
|
571 | - $active_plugins = get_option('active_plugins', array()); |
|
572 | - foreach ($active_plugins as $active_plugin) { |
|
573 | - foreach ($incompatible_addons as $incompatible_addon) { |
|
574 | - if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
575 | - unset($_GET['activate']); |
|
576 | - espresso_deactivate_plugin($active_plugin); |
|
577 | - } |
|
578 | - } |
|
579 | - } |
|
580 | - } |
|
581 | - } |
|
582 | - |
|
583 | - |
|
584 | - |
|
585 | - /** |
|
586 | - * load_CPTs_and_session |
|
587 | - * |
|
588 | - * @access public |
|
589 | - * @return void |
|
590 | - */ |
|
591 | - public function load_CPTs_and_session() |
|
592 | - { |
|
593 | - do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
594 | - // register Custom Post Types |
|
595 | - $this->loader->getShared('EE_Register_CPTs'); |
|
596 | - do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
597 | - } |
|
598 | - |
|
599 | - |
|
600 | - |
|
601 | - /** |
|
602 | - * load_controllers |
|
603 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
604 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
605 | - * time |
|
606 | - * |
|
607 | - * @access public |
|
608 | - * @return void |
|
609 | - */ |
|
610 | - public function load_controllers() |
|
611 | - { |
|
612 | - do_action('AHEE__EE_System__load_controllers__start'); |
|
613 | - // let's get it started |
|
614 | - if (! is_admin() && ! $this->maintenance_mode->level()) { |
|
615 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
616 | - $this->loader->getShared('EE_Front_Controller'); |
|
617 | - } else if (! EE_FRONT_AJAX) { |
|
618 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
619 | - $this->loader->getShared('EE_Admin'); |
|
620 | - } |
|
621 | - do_action('AHEE__EE_System__load_controllers__complete'); |
|
622 | - } |
|
623 | - |
|
624 | - |
|
625 | - |
|
626 | - /** |
|
627 | - * core_loaded_and_ready |
|
628 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
629 | - * |
|
630 | - * @access public |
|
631 | - * @return void |
|
632 | - */ |
|
633 | - public function core_loaded_and_ready() |
|
634 | - { |
|
635 | - $this->loader->getShared('EE_Session'); |
|
636 | - do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
637 | - // load_espresso_template_tags |
|
638 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
639 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
640 | - } |
|
641 | - do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
642 | - $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
643 | - wp_enqueue_script('espresso_core'); |
|
644 | - } |
|
645 | - |
|
646 | - |
|
647 | - |
|
648 | - /** |
|
649 | - * initialize |
|
650 | - * this is the best place to begin initializing client code |
|
651 | - * |
|
652 | - * @access public |
|
653 | - * @return void |
|
654 | - */ |
|
655 | - public function initialize() |
|
656 | - { |
|
657 | - do_action('AHEE__EE_System__initialize'); |
|
658 | - } |
|
659 | - |
|
660 | - |
|
661 | - |
|
662 | - /** |
|
663 | - * initialize_last |
|
664 | - * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
665 | - * initialize has done so |
|
666 | - * |
|
667 | - * @access public |
|
668 | - * @return void |
|
669 | - */ |
|
670 | - public function initialize_last() |
|
671 | - { |
|
672 | - do_action('AHEE__EE_System__initialize_last'); |
|
673 | - add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
674 | - } |
|
675 | - |
|
676 | - |
|
677 | - |
|
678 | - /** |
|
679 | - * @return void |
|
680 | - * @throws EE_Error |
|
681 | - */ |
|
682 | - public function addEspressoToolbar() |
|
683 | - { |
|
684 | - $this->registry->create( |
|
685 | - 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
686 | - array($this->registry->CAP) |
|
687 | - ); |
|
688 | - } |
|
689 | - |
|
690 | - |
|
691 | - |
|
692 | - /** |
|
693 | - * do_not_cache |
|
694 | - * sets no cache headers and defines no cache constants for WP plugins |
|
695 | - * |
|
696 | - * @access public |
|
697 | - * @return void |
|
698 | - */ |
|
699 | - public static function do_not_cache() |
|
700 | - { |
|
701 | - // set no cache constants |
|
702 | - if (! defined('DONOTCACHEPAGE')) { |
|
703 | - define('DONOTCACHEPAGE', true); |
|
704 | - } |
|
705 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
706 | - define('DONOTCACHCEOBJECT', true); |
|
707 | - } |
|
708 | - if (! defined('DONOTCACHEDB')) { |
|
709 | - define('DONOTCACHEDB', true); |
|
710 | - } |
|
711 | - // add no cache headers |
|
712 | - add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
713 | - // plus a little extra for nginx and Google Chrome |
|
714 | - add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
715 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
716 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
717 | - } |
|
718 | - |
|
719 | - |
|
720 | - |
|
721 | - /** |
|
722 | - * extra_nocache_headers |
|
723 | - * |
|
724 | - * @access public |
|
725 | - * @param $headers |
|
726 | - * @return array |
|
727 | - */ |
|
728 | - public static function extra_nocache_headers($headers) |
|
729 | - { |
|
730 | - // for NGINX |
|
731 | - $headers['X-Accel-Expires'] = 0; |
|
732 | - // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
733 | - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
734 | - return $headers; |
|
735 | - } |
|
736 | - |
|
737 | - |
|
738 | - |
|
739 | - /** |
|
740 | - * nocache_headers |
|
741 | - * |
|
742 | - * @access public |
|
743 | - * @return void |
|
744 | - */ |
|
745 | - public static function nocache_headers() |
|
746 | - { |
|
747 | - nocache_headers(); |
|
748 | - } |
|
749 | - |
|
750 | - |
|
751 | - |
|
752 | - |
|
753 | - /** |
|
754 | - * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
755 | - * never returned with the function. |
|
756 | - * |
|
757 | - * @param array $exclude_array any existing pages being excluded are in this array. |
|
758 | - * @return array |
|
759 | - */ |
|
760 | - public function remove_pages_from_wp_list_pages($exclude_array) |
|
761 | - { |
|
762 | - return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
763 | - } |
|
764 | - |
|
765 | - |
|
766 | - |
|
767 | - /******************************** DEPRECATED ***************************************/ |
|
768 | - |
|
769 | - |
|
770 | - |
|
771 | - /** |
|
772 | - * @deprecated 4.9.40 |
|
773 | - * @return void |
|
774 | - */ |
|
775 | - public function detect_if_activation_or_upgrade() |
|
776 | - { |
|
777 | - } |
|
778 | - |
|
779 | - |
|
780 | - |
|
781 | - /** |
|
782 | - * @deprecated 4.9.40 |
|
783 | - * @return void |
|
784 | - */ |
|
785 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
786 | - { |
|
787 | - } |
|
788 | - |
|
789 | - |
|
790 | - |
|
791 | - /** |
|
792 | - * @deprecated 4.9.40 |
|
793 | - * @param null $espresso_db_update |
|
794 | - * @return int one of the constants on EE_System::req_type_ |
|
795 | - */ |
|
796 | - public function detect_req_type($espresso_db_update = null) |
|
797 | - { |
|
798 | - return $this->request->getRequestType()->requestType(); |
|
799 | - } |
|
800 | - |
|
801 | - |
|
802 | - |
|
803 | - /** |
|
804 | - * @deprecated 4.9.40 |
|
805 | - * @return bool |
|
806 | - */ |
|
807 | - public function is_major_version_change() |
|
808 | - { |
|
809 | - return $this->request->getRequestType()->isMajorVersionChange(); |
|
810 | - } |
|
25 | + /** |
|
26 | + * @deprecated 4.9.40 |
|
27 | + * @see \EventEspresso\core\services\request\RequestType |
|
28 | + */ |
|
29 | + const req_type_normal = 0; |
|
30 | + |
|
31 | + /** |
|
32 | + * @deprecated 4.9.40 |
|
33 | + * @see \EventEspresso\core\services\request\RequestType |
|
34 | + */ |
|
35 | + const req_type_new_activation = 1; |
|
36 | + |
|
37 | + /** |
|
38 | + * @deprecated 4.9.40 |
|
39 | + * @see \EventEspresso\core\services\request\RequestType |
|
40 | + */ |
|
41 | + const req_type_reactivation = 2; |
|
42 | + |
|
43 | + /** |
|
44 | + * @deprecated 4.9.40 |
|
45 | + * @see \EventEspresso\core\services\request\RequestType |
|
46 | + */ |
|
47 | + const req_type_upgrade = 3; |
|
48 | + |
|
49 | + /** |
|
50 | + * @deprecated 4.9.40 |
|
51 | + * @see \EventEspresso\core\services\request\RequestType |
|
52 | + */ |
|
53 | + const req_type_downgrade = 4; |
|
54 | + |
|
55 | + /** |
|
56 | + * @deprecated since version 4.6.0.dev.006 |
|
57 | + * Now whenever a new_activation is detected the request type is still just |
|
58 | + * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
59 | + * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
60 | + * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
61 | + * (Specifically, when the migration manager indicates migrations are finished |
|
62 | + * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
63 | + */ |
|
64 | + const req_type_activation_but_not_installed = 5; |
|
65 | + |
|
66 | + /** |
|
67 | + * @deprecated 4.9.40 |
|
68 | + * @see \EventEspresso\core\services\request\RequestType |
|
69 | + */ |
|
70 | + const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @var EE_System $_instance |
|
75 | + */ |
|
76 | + private static $_instance; |
|
77 | + |
|
78 | + /** |
|
79 | + * @var EE_Registry $registry |
|
80 | + */ |
|
81 | + private $registry; |
|
82 | + |
|
83 | + /** |
|
84 | + * @var LoaderInterface $loader |
|
85 | + */ |
|
86 | + private $loader; |
|
87 | + |
|
88 | + /** |
|
89 | + * @var EE_Capabilities $capabilities |
|
90 | + */ |
|
91 | + private $capabilities; |
|
92 | + |
|
93 | + /** |
|
94 | + * @var EE_Request $request |
|
95 | + */ |
|
96 | + private $request; |
|
97 | + |
|
98 | + /** |
|
99 | + * @var EE_Maintenance_Mode $maintenance_mode |
|
100 | + */ |
|
101 | + private $maintenance_mode; |
|
102 | + |
|
103 | + /** |
|
104 | + * @var ActivationsAndUpgradesManager $activations_and_upgrades_manager |
|
105 | + */ |
|
106 | + private $activations_and_upgrades_manager; |
|
107 | + |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @singleton method used to instantiate class object |
|
112 | + * @param EE_Registry|null $registry |
|
113 | + * @param LoaderInterface|null $loader |
|
114 | + * @param EE_Capabilities|null $capabilities |
|
115 | + * @param EE_Request|null $request |
|
116 | + * @param EE_Maintenance_Mode|null $maintenance_mode |
|
117 | + * @return EE_System |
|
118 | + */ |
|
119 | + public static function instance( |
|
120 | + EE_Registry $registry = null, |
|
121 | + LoaderInterface $loader = null, |
|
122 | + EE_Capabilities $capabilities = null, |
|
123 | + EE_Request $request = null, |
|
124 | + EE_Maintenance_Mode $maintenance_mode = null |
|
125 | + ) { |
|
126 | + // check if class object is instantiated |
|
127 | + if (! self::$_instance instanceof EE_System) { |
|
128 | + self::$_instance = new self($registry, $loader, $capabilities, $request, $maintenance_mode); |
|
129 | + } |
|
130 | + return self::$_instance; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * resets the instance and returns it |
|
137 | + * |
|
138 | + * @return EE_System |
|
139 | + * @throws InvalidArgumentException |
|
140 | + */ |
|
141 | + public static function reset() |
|
142 | + { |
|
143 | + //make sure none of the old hooks are left hanging around |
|
144 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
145 | + //we need to reset the migration manager in order for it to detect DMSs properly |
|
146 | + EE_Data_Migration_Manager::reset(); |
|
147 | + self::instance()->detect_activations_or_upgrades(); |
|
148 | + self::instance()->activations_and_upgrades_manager->performActivationsAndUpgrades(); |
|
149 | + return self::instance(); |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + |
|
154 | + /** |
|
155 | + * sets hooks for running rest of system |
|
156 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
157 | + * starting EE Addons from any other point may lead to problems |
|
158 | + * |
|
159 | + * @param EE_Registry $registry |
|
160 | + * @param LoaderInterface $loader |
|
161 | + * @param EE_Capabilities $capabilities |
|
162 | + * @param EE_Request $request |
|
163 | + * @param EE_Maintenance_Mode $maintenance_mode |
|
164 | + */ |
|
165 | + private function __construct( |
|
166 | + EE_Registry $registry, |
|
167 | + LoaderInterface $loader, |
|
168 | + EE_Capabilities $capabilities, |
|
169 | + EE_Request $request, |
|
170 | + EE_Maintenance_Mode $maintenance_mode |
|
171 | + ) { |
|
172 | + $this->registry = $registry; |
|
173 | + $this->loader = $loader; |
|
174 | + $this->capabilities = $capabilities; |
|
175 | + $this->request = $request; |
|
176 | + $this->maintenance_mode = $maintenance_mode; |
|
177 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
178 | + // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
179 | + add_action('AHEE__EE_Bootstrap__load_espresso_addons', array($this, 'load_espresso_addons')); |
|
180 | + // when an ee addon is activated, we want to call the core hook(s) again |
|
181 | + // because the newly-activated addon didn't get a chance to run at all |
|
182 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
183 | + // detect whether install or upgrade |
|
184 | + add_action( |
|
185 | + 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', array($this, 'detect_activations_or_upgrades'), |
|
186 | + 3 |
|
187 | + ); |
|
188 | + // load EE_Config, EE_Textdomain, etc |
|
189 | + add_action('AHEE__EE_Bootstrap__load_core_configuration', array($this, 'load_core_configuration'), 5); |
|
190 | + // load EE_Config, EE_Textdomain, etc |
|
191 | + add_action( |
|
192 | + 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
193 | + array($this, 'register_shortcodes_modules_and_widgets'), 7 |
|
194 | + ); |
|
195 | + // you wanna get going? I wanna get going... let's get going! |
|
196 | + add_action('AHEE__EE_Bootstrap__brew_espresso', array($this, 'brew_espresso'), 9); |
|
197 | + //other housekeeping |
|
198 | + //exclude EE critical pages from wp_list_pages |
|
199 | + add_filter('wp_list_pages_excludes', array($this, 'remove_pages_from_wp_list_pages'), 10); |
|
200 | + // ALL EE Addons should use the following hook point to attach their initial setup too |
|
201 | + // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
202 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * load_espresso_addons |
|
209 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
210 | + * this is hooked into both: |
|
211 | + * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
212 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
213 | + * and the WP 'activate_plugin' hook point |
|
214 | + * |
|
215 | + * @return void |
|
216 | + * @throws EE_Error |
|
217 | + */ |
|
218 | + public function load_espresso_addons() |
|
219 | + { |
|
220 | + // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
221 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
222 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
223 | + //caps need to be initialized on every request so that capability maps are set. |
|
224 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
225 | + $this->capabilities->init_caps(); |
|
226 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
227 | + //if the WP API basic auth plugin isn't already loaded, load it now. |
|
228 | + //We want it for mobile apps. Just include the entire plugin |
|
229 | + //also, don't load the basic auth when a plugin is getting activated, because |
|
230 | + //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
231 | + //and causes a fatal error |
|
232 | + if ( |
|
233 | + ! ( |
|
234 | + isset($_GET['activate']) |
|
235 | + && $_GET['activate'] === 'true' |
|
236 | + ) |
|
237 | + && ! function_exists('json_basic_auth_handler') |
|
238 | + && ! function_exists('json_basic_auth_error') |
|
239 | + && ! ( |
|
240 | + isset($_GET['action']) |
|
241 | + && in_array($_GET['action'], array('activate', 'activate-selected'), true) |
|
242 | + ) |
|
243 | + ) { |
|
244 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
245 | + } |
|
246 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
247 | + } |
|
248 | + |
|
249 | + |
|
250 | + |
|
251 | + /** |
|
252 | + * detect_activations_or_upgrades |
|
253 | + * Checks for activation or upgrade of core first; |
|
254 | + * then also checks if any registered addons have been activated or upgraded |
|
255 | + * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
256 | + * which runs during the WP 'plugins_loaded' action at priority 3 |
|
257 | + * |
|
258 | + * @return void |
|
259 | + * @throws InvalidArgumentException |
|
260 | + * @throws InvalidEntityException |
|
261 | + */ |
|
262 | + public function detect_activations_or_upgrades() |
|
263 | + { |
|
264 | + $this->activations_and_upgrades_manager = new ActivationsAndUpgradesManager( |
|
265 | + $this, |
|
266 | + $this->request->getRequestType()->getActivationHistory(), |
|
267 | + $this->request->getRequestType(), |
|
268 | + $this->maintenance_mode, |
|
269 | + get_object_vars($this->registry->addons) |
|
270 | + ); |
|
271 | + $this->activations_and_upgrades_manager->detectActivationsAndUpgrades(); |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + |
|
276 | + /** |
|
277 | + * Does the traditional work of setting up the plugin's database and adding default data. |
|
278 | + * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
279 | + * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
280 | + * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
281 | + * so that it will be done when migrations are finished |
|
282 | + * |
|
283 | + * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
284 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
285 | + * This is a resource-intensive job |
|
286 | + * so we prefer to only do it when necessary |
|
287 | + * @return void |
|
288 | + * @throws EE_Error |
|
289 | + */ |
|
290 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
291 | + { |
|
292 | + $request_type = $this->request->getRequestType()->requestType(); |
|
293 | + //only initialize system if we're not in maintenance mode. |
|
294 | + if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
295 | + update_option('ee_flush_rewrite_rules', true); |
|
296 | + if ($verify_schema) { |
|
297 | + EEH_Activation::initialize_db_and_folders(); |
|
298 | + } |
|
299 | + EEH_Activation::initialize_db_content(); |
|
300 | + EEH_Activation::system_initialization(); |
|
301 | + if ($initialize_addons_too) { |
|
302 | + $this->initialize_addons(); |
|
303 | + } |
|
304 | + } else { |
|
305 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
306 | + } |
|
307 | + if ($request_type === RequestType::REQUEST_TYPE_NEW_ACTIVATION |
|
308 | + || $request_type === RequestType::REQUEST_TYPE_REACTIVATION |
|
309 | + || ( |
|
310 | + $request_type === RequestType::REQUEST_TYPE_UPGRADE |
|
311 | + && $this->request->getRequestType()->isMajorVersionChange() |
|
312 | + ) |
|
313 | + ) { |
|
314 | + add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
315 | + } |
|
316 | + } |
|
317 | + |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * Initializes the db for all registered addons |
|
322 | + * |
|
323 | + * @throws EE_Error |
|
324 | + */ |
|
325 | + public function initialize_addons() |
|
326 | + { |
|
327 | + //foreach registered addon, make sure its db is up-to-date too |
|
328 | + foreach (get_object_vars($this->registry->addons) as $addon) { |
|
329 | + if($addon instanceof EE_Addon) { |
|
330 | + $addon->initialize_db_if_no_migrations_required(); |
|
331 | + } |
|
332 | + } |
|
333 | + } |
|
334 | + |
|
335 | + |
|
336 | + |
|
337 | + /** |
|
338 | + * This redirects to the about EE page after activation |
|
339 | + * |
|
340 | + * @return void |
|
341 | + */ |
|
342 | + public function redirect_to_about_ee() |
|
343 | + { |
|
344 | + $notices = EE_Error::get_notices(false); |
|
345 | + //if current user is an admin and it's not an ajax or rest request |
|
346 | + if ( |
|
347 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
348 | + && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
349 | + && ! isset($notices['errors']) |
|
350 | + && apply_filters( |
|
351 | + 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
352 | + $this->capabilities->current_user_can('manage_options', 'espresso_about_default') |
|
353 | + ) |
|
354 | + ) { |
|
355 | + $query_params = array('page' => 'espresso_about'); |
|
356 | + $request_type = $this->request->getRequestType()->requestType(); |
|
357 | + if ($request_type === RequestType::REQUEST_TYPE_NEW_ACTIVATION) { |
|
358 | + $query_params['new_activation'] = true; |
|
359 | + } else if ($request_type === RequestType::REQUEST_TYPE_REACTIVATION) { |
|
360 | + $query_params['reactivation'] = true; |
|
361 | + } |
|
362 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
363 | + wp_safe_redirect($url); |
|
364 | + exit(); |
|
365 | + } |
|
366 | + } |
|
367 | + |
|
368 | + |
|
369 | + |
|
370 | + /** |
|
371 | + * load_core_configuration |
|
372 | + * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
373 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
374 | + * |
|
375 | + * @return void |
|
376 | + * @throws ReflectionException |
|
377 | + */ |
|
378 | + public function load_core_configuration() |
|
379 | + { |
|
380 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
381 | + $this->loader->getShared('EE_Load_Textdomain'); |
|
382 | + //load textdomain |
|
383 | + EE_Load_Textdomain::load_textdomain(); |
|
384 | + // load and setup EE_Config and EE_Network_Config |
|
385 | + $config = $this->loader->getShared('EE_Config'); |
|
386 | + $this->loader->getShared('EE_Network_Config'); |
|
387 | + // setup autoloaders |
|
388 | + // enable logging? |
|
389 | + if ($config->admin->use_full_logging) { |
|
390 | + $this->loader->getShared('EE_Log'); |
|
391 | + } |
|
392 | + // check for activation errors |
|
393 | + $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
394 | + if ($activation_errors) { |
|
395 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
396 | + update_option('ee_plugin_activation_errors', false); |
|
397 | + } |
|
398 | + // get model names |
|
399 | + $this->_parse_model_names(); |
|
400 | + //load caf stuff a chance to play during the activation process too. |
|
401 | + $this->_maybe_brew_regular(); |
|
402 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
403 | + } |
|
404 | + |
|
405 | + |
|
406 | + |
|
407 | + /** |
|
408 | + * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
409 | + * |
|
410 | + * @return void |
|
411 | + * @throws ReflectionException |
|
412 | + */ |
|
413 | + private function _parse_model_names() |
|
414 | + { |
|
415 | + //get all the files in the EE_MODELS folder that end in .model.php |
|
416 | + $models = glob(EE_MODELS . '*.model.php'); |
|
417 | + $model_names = array(); |
|
418 | + $non_abstract_db_models = array(); |
|
419 | + foreach ($models as $model) { |
|
420 | + // get model classname |
|
421 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
422 | + $short_name = str_replace('EEM_', '', $classname); |
|
423 | + $reflectionClass = new ReflectionClass($classname); |
|
424 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
425 | + $non_abstract_db_models[ $short_name ] = $classname; |
|
426 | + } |
|
427 | + $model_names[ $short_name ] = $classname; |
|
428 | + } |
|
429 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
430 | + $this->registry->non_abstract_db_models = apply_filters( |
|
431 | + 'FHEE__EE_System__parse_implemented_model_names', |
|
432 | + $non_abstract_db_models |
|
433 | + ); |
|
434 | + } |
|
435 | + |
|
436 | + |
|
437 | + |
|
438 | + /** |
|
439 | + * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
440 | + * that need to be setup before our EE_System launches. |
|
441 | + * |
|
442 | + * @return void |
|
443 | + */ |
|
444 | + private function _maybe_brew_regular() |
|
445 | + { |
|
446 | + if ((! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
447 | + require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
448 | + } |
|
449 | + } |
|
450 | + |
|
451 | + |
|
452 | + |
|
453 | + /** |
|
454 | + * register_shortcodes_modules_and_widgets |
|
455 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
456 | + * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
457 | + * which runs during the WP 'plugins_loaded' action at priority 7 |
|
458 | + * |
|
459 | + * @access public |
|
460 | + * @return void |
|
461 | + */ |
|
462 | + public function register_shortcodes_modules_and_widgets() |
|
463 | + { |
|
464 | + try { |
|
465 | + // load, register, and add shortcodes the new way |
|
466 | + new ShortcodesManager( |
|
467 | + // and the old way, but we'll put it under control of the new system |
|
468 | + EE_Config::getLegacyShortcodesManager() |
|
469 | + ); |
|
470 | + } catch (Exception $exception) { |
|
471 | + new ExceptionStackTraceDisplay($exception); |
|
472 | + } |
|
473 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
474 | + // check for addons using old hook point |
|
475 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
476 | + $this->_incompatible_addon_error(); |
|
477 | + } |
|
478 | + } |
|
479 | + |
|
480 | + |
|
481 | + |
|
482 | + /** |
|
483 | + * _incompatible_addon_error |
|
484 | + * |
|
485 | + * @access public |
|
486 | + * @return void |
|
487 | + */ |
|
488 | + private function _incompatible_addon_error() |
|
489 | + { |
|
490 | + // get array of classes hooking into here |
|
491 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
492 | + 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
493 | + ); |
|
494 | + if (! empty($class_names)) { |
|
495 | + $msg = __( |
|
496 | + 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
497 | + 'event_espresso' |
|
498 | + ); |
|
499 | + $msg .= '<ul>'; |
|
500 | + foreach ($class_names as $class_name) { |
|
501 | + $msg .= '<li><b>Event Espresso - ' . str_replace( |
|
502 | + array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
503 | + $class_name |
|
504 | + ) . '</b></li>'; |
|
505 | + } |
|
506 | + $msg .= '</ul>'; |
|
507 | + $msg .= __( |
|
508 | + 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
509 | + 'event_espresso' |
|
510 | + ); |
|
511 | + // save list of incompatible addons to wp-options for later use |
|
512 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
513 | + if (is_admin()) { |
|
514 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
515 | + } |
|
516 | + } |
|
517 | + } |
|
518 | + |
|
519 | + |
|
520 | + |
|
521 | + /** |
|
522 | + * brew_espresso |
|
523 | + * begins the process of setting hooks for initializing EE in the correct order |
|
524 | + * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
525 | + * which runs during the WP 'plugins_loaded' action at priority 9 |
|
526 | + * |
|
527 | + * @return void |
|
528 | + */ |
|
529 | + public function brew_espresso() |
|
530 | + { |
|
531 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
532 | + // load some final core systems |
|
533 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
534 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
535 | + add_action('init', array($this, 'load_controllers'), 7); |
|
536 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
537 | + add_action('init', array($this, 'initialize'), 10); |
|
538 | + add_action('init', array($this, 'initialize_last'), 100); |
|
539 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
540 | + // pew pew pew |
|
541 | + $this->loader->getShared('EE_PUE'); |
|
542 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
543 | + } |
|
544 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
545 | + } |
|
546 | + |
|
547 | + |
|
548 | + |
|
549 | + /** |
|
550 | + * set_hooks_for_core |
|
551 | + * |
|
552 | + * @access public |
|
553 | + * @return void |
|
554 | + */ |
|
555 | + public function set_hooks_for_core() |
|
556 | + { |
|
557 | + $this->_deactivate_incompatible_addons(); |
|
558 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
559 | + } |
|
560 | + |
|
561 | + |
|
562 | + |
|
563 | + /** |
|
564 | + * Using the information gathered in EE_System::_incompatible_addon_error, |
|
565 | + * deactivates any addons considered incompatible with the current version of EE |
|
566 | + */ |
|
567 | + private function _deactivate_incompatible_addons() |
|
568 | + { |
|
569 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
570 | + if (! empty($incompatible_addons)) { |
|
571 | + $active_plugins = get_option('active_plugins', array()); |
|
572 | + foreach ($active_plugins as $active_plugin) { |
|
573 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
574 | + if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
575 | + unset($_GET['activate']); |
|
576 | + espresso_deactivate_plugin($active_plugin); |
|
577 | + } |
|
578 | + } |
|
579 | + } |
|
580 | + } |
|
581 | + } |
|
582 | + |
|
583 | + |
|
584 | + |
|
585 | + /** |
|
586 | + * load_CPTs_and_session |
|
587 | + * |
|
588 | + * @access public |
|
589 | + * @return void |
|
590 | + */ |
|
591 | + public function load_CPTs_and_session() |
|
592 | + { |
|
593 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
594 | + // register Custom Post Types |
|
595 | + $this->loader->getShared('EE_Register_CPTs'); |
|
596 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
597 | + } |
|
598 | + |
|
599 | + |
|
600 | + |
|
601 | + /** |
|
602 | + * load_controllers |
|
603 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
604 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
605 | + * time |
|
606 | + * |
|
607 | + * @access public |
|
608 | + * @return void |
|
609 | + */ |
|
610 | + public function load_controllers() |
|
611 | + { |
|
612 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
613 | + // let's get it started |
|
614 | + if (! is_admin() && ! $this->maintenance_mode->level()) { |
|
615 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
616 | + $this->loader->getShared('EE_Front_Controller'); |
|
617 | + } else if (! EE_FRONT_AJAX) { |
|
618 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
619 | + $this->loader->getShared('EE_Admin'); |
|
620 | + } |
|
621 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
622 | + } |
|
623 | + |
|
624 | + |
|
625 | + |
|
626 | + /** |
|
627 | + * core_loaded_and_ready |
|
628 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
629 | + * |
|
630 | + * @access public |
|
631 | + * @return void |
|
632 | + */ |
|
633 | + public function core_loaded_and_ready() |
|
634 | + { |
|
635 | + $this->loader->getShared('EE_Session'); |
|
636 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
637 | + // load_espresso_template_tags |
|
638 | + if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
639 | + require_once(EE_PUBLIC . 'template_tags.php'); |
|
640 | + } |
|
641 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
642 | + $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
643 | + wp_enqueue_script('espresso_core'); |
|
644 | + } |
|
645 | + |
|
646 | + |
|
647 | + |
|
648 | + /** |
|
649 | + * initialize |
|
650 | + * this is the best place to begin initializing client code |
|
651 | + * |
|
652 | + * @access public |
|
653 | + * @return void |
|
654 | + */ |
|
655 | + public function initialize() |
|
656 | + { |
|
657 | + do_action('AHEE__EE_System__initialize'); |
|
658 | + } |
|
659 | + |
|
660 | + |
|
661 | + |
|
662 | + /** |
|
663 | + * initialize_last |
|
664 | + * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
665 | + * initialize has done so |
|
666 | + * |
|
667 | + * @access public |
|
668 | + * @return void |
|
669 | + */ |
|
670 | + public function initialize_last() |
|
671 | + { |
|
672 | + do_action('AHEE__EE_System__initialize_last'); |
|
673 | + add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
674 | + } |
|
675 | + |
|
676 | + |
|
677 | + |
|
678 | + /** |
|
679 | + * @return void |
|
680 | + * @throws EE_Error |
|
681 | + */ |
|
682 | + public function addEspressoToolbar() |
|
683 | + { |
|
684 | + $this->registry->create( |
|
685 | + 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
686 | + array($this->registry->CAP) |
|
687 | + ); |
|
688 | + } |
|
689 | + |
|
690 | + |
|
691 | + |
|
692 | + /** |
|
693 | + * do_not_cache |
|
694 | + * sets no cache headers and defines no cache constants for WP plugins |
|
695 | + * |
|
696 | + * @access public |
|
697 | + * @return void |
|
698 | + */ |
|
699 | + public static function do_not_cache() |
|
700 | + { |
|
701 | + // set no cache constants |
|
702 | + if (! defined('DONOTCACHEPAGE')) { |
|
703 | + define('DONOTCACHEPAGE', true); |
|
704 | + } |
|
705 | + if (! defined('DONOTCACHCEOBJECT')) { |
|
706 | + define('DONOTCACHCEOBJECT', true); |
|
707 | + } |
|
708 | + if (! defined('DONOTCACHEDB')) { |
|
709 | + define('DONOTCACHEDB', true); |
|
710 | + } |
|
711 | + // add no cache headers |
|
712 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
713 | + // plus a little extra for nginx and Google Chrome |
|
714 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
715 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
716 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
717 | + } |
|
718 | + |
|
719 | + |
|
720 | + |
|
721 | + /** |
|
722 | + * extra_nocache_headers |
|
723 | + * |
|
724 | + * @access public |
|
725 | + * @param $headers |
|
726 | + * @return array |
|
727 | + */ |
|
728 | + public static function extra_nocache_headers($headers) |
|
729 | + { |
|
730 | + // for NGINX |
|
731 | + $headers['X-Accel-Expires'] = 0; |
|
732 | + // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
733 | + $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
734 | + return $headers; |
|
735 | + } |
|
736 | + |
|
737 | + |
|
738 | + |
|
739 | + /** |
|
740 | + * nocache_headers |
|
741 | + * |
|
742 | + * @access public |
|
743 | + * @return void |
|
744 | + */ |
|
745 | + public static function nocache_headers() |
|
746 | + { |
|
747 | + nocache_headers(); |
|
748 | + } |
|
749 | + |
|
750 | + |
|
751 | + |
|
752 | + |
|
753 | + /** |
|
754 | + * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
755 | + * never returned with the function. |
|
756 | + * |
|
757 | + * @param array $exclude_array any existing pages being excluded are in this array. |
|
758 | + * @return array |
|
759 | + */ |
|
760 | + public function remove_pages_from_wp_list_pages($exclude_array) |
|
761 | + { |
|
762 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
763 | + } |
|
764 | + |
|
765 | + |
|
766 | + |
|
767 | + /******************************** DEPRECATED ***************************************/ |
|
768 | + |
|
769 | + |
|
770 | + |
|
771 | + /** |
|
772 | + * @deprecated 4.9.40 |
|
773 | + * @return void |
|
774 | + */ |
|
775 | + public function detect_if_activation_or_upgrade() |
|
776 | + { |
|
777 | + } |
|
778 | + |
|
779 | + |
|
780 | + |
|
781 | + /** |
|
782 | + * @deprecated 4.9.40 |
|
783 | + * @return void |
|
784 | + */ |
|
785 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
786 | + { |
|
787 | + } |
|
788 | + |
|
789 | + |
|
790 | + |
|
791 | + /** |
|
792 | + * @deprecated 4.9.40 |
|
793 | + * @param null $espresso_db_update |
|
794 | + * @return int one of the constants on EE_System::req_type_ |
|
795 | + */ |
|
796 | + public function detect_req_type($espresso_db_update = null) |
|
797 | + { |
|
798 | + return $this->request->getRequestType()->requestType(); |
|
799 | + } |
|
800 | + |
|
801 | + |
|
802 | + |
|
803 | + /** |
|
804 | + * @deprecated 4.9.40 |
|
805 | + * @return bool |
|
806 | + */ |
|
807 | + public function is_major_version_change() |
|
808 | + { |
|
809 | + return $this->request->getRequestType()->isMajorVersionChange(); |
|
810 | + } |
|
811 | 811 | |
812 | 812 | |
813 | 813 | |
814 | - /** |
|
815 | - * @deprecated 4.9.40 |
|
816 | - * @param array $activation_history_for_addon |
|
817 | - * @param string $activation_indicator_option_name |
|
818 | - * @param string $version_to_upgrade_to |
|
819 | - * @return int one of the constants on EE_System::req_type_* |
|
820 | - */ |
|
821 | - public static function detect_req_type_given_activation_history( |
|
822 | - $activation_history_for_addon, |
|
823 | - $activation_indicator_option_name, |
|
824 | - $version_to_upgrade_to |
|
825 | - ) { |
|
826 | - return EE_System::instance()->request->getRequestType()->requestType(); |
|
827 | - } |
|
814 | + /** |
|
815 | + * @deprecated 4.9.40 |
|
816 | + * @param array $activation_history_for_addon |
|
817 | + * @param string $activation_indicator_option_name |
|
818 | + * @param string $version_to_upgrade_to |
|
819 | + * @return int one of the constants on EE_System::req_type_* |
|
820 | + */ |
|
821 | + public static function detect_req_type_given_activation_history( |
|
822 | + $activation_history_for_addon, |
|
823 | + $activation_indicator_option_name, |
|
824 | + $version_to_upgrade_to |
|
825 | + ) { |
|
826 | + return EE_System::instance()->request->getRequestType()->requestType(); |
|
827 | + } |
|
828 | 828 | |
829 | 829 | |
830 | 830 | |
831 | - /** |
|
832 | - * @deprecated 4.9.40 |
|
833 | - * @return void |
|
834 | - */ |
|
835 | - public function perform_activations_upgrades_and_migrations() |
|
836 | - { |
|
837 | - } |
|
831 | + /** |
|
832 | + * @deprecated 4.9.40 |
|
833 | + * @return void |
|
834 | + */ |
|
835 | + public function perform_activations_upgrades_and_migrations() |
|
836 | + { |
|
837 | + } |
|
838 | 838 | |
839 | 839 | |
840 | 840 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | EE_Maintenance_Mode $maintenance_mode = null |
125 | 125 | ) { |
126 | 126 | // check if class object is instantiated |
127 | - if (! self::$_instance instanceof EE_System) { |
|
127 | + if ( ! self::$_instance instanceof EE_System) { |
|
128 | 128 | self::$_instance = new self($registry, $loader, $capabilities, $request, $maintenance_mode); |
129 | 129 | } |
130 | 130 | return self::$_instance; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | { |
220 | 220 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
221 | 221 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
222 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
222 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
223 | 223 | //caps need to be initialized on every request so that capability maps are set. |
224 | 224 | //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
225 | 225 | $this->capabilities->init_caps(); |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | && in_array($_GET['action'], array('activate', 'activate-selected'), true) |
242 | 242 | ) |
243 | 243 | ) { |
244 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
244 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php'; |
|
245 | 245 | } |
246 | 246 | do_action('AHEE__EE_System__load_espresso_addons__complete'); |
247 | 247 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | { |
327 | 327 | //foreach registered addon, make sure its db is up-to-date too |
328 | 328 | foreach (get_object_vars($this->registry->addons) as $addon) { |
329 | - if($addon instanceof EE_Addon) { |
|
329 | + if ($addon instanceof EE_Addon) { |
|
330 | 330 | $addon->initialize_db_if_no_migrations_required(); |
331 | 331 | } |
332 | 332 | } |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | private function _parse_model_names() |
414 | 414 | { |
415 | 415 | //get all the files in the EE_MODELS folder that end in .model.php |
416 | - $models = glob(EE_MODELS . '*.model.php'); |
|
416 | + $models = glob(EE_MODELS.'*.model.php'); |
|
417 | 417 | $model_names = array(); |
418 | 418 | $non_abstract_db_models = array(); |
419 | 419 | foreach ($models as $model) { |
@@ -422,9 +422,9 @@ discard block |
||
422 | 422 | $short_name = str_replace('EEM_', '', $classname); |
423 | 423 | $reflectionClass = new ReflectionClass($classname); |
424 | 424 | if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
425 | - $non_abstract_db_models[ $short_name ] = $classname; |
|
425 | + $non_abstract_db_models[$short_name] = $classname; |
|
426 | 426 | } |
427 | - $model_names[ $short_name ] = $classname; |
|
427 | + $model_names[$short_name] = $classname; |
|
428 | 428 | } |
429 | 429 | $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
430 | 430 | $this->registry->non_abstract_db_models = apply_filters( |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | */ |
444 | 444 | private function _maybe_brew_regular() |
445 | 445 | { |
446 | - if ((! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
447 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
446 | + if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) { |
|
447 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
@@ -491,17 +491,17 @@ discard block |
||
491 | 491 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
492 | 492 | 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
493 | 493 | ); |
494 | - if (! empty($class_names)) { |
|
494 | + if ( ! empty($class_names)) { |
|
495 | 495 | $msg = __( |
496 | 496 | 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
497 | 497 | 'event_espresso' |
498 | 498 | ); |
499 | 499 | $msg .= '<ul>'; |
500 | 500 | foreach ($class_names as $class_name) { |
501 | - $msg .= '<li><b>Event Espresso - ' . str_replace( |
|
501 | + $msg .= '<li><b>Event Espresso - '.str_replace( |
|
502 | 502 | array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
503 | 503 | $class_name |
504 | - ) . '</b></li>'; |
|
504 | + ).'</b></li>'; |
|
505 | 505 | } |
506 | 506 | $msg .= '</ul>'; |
507 | 507 | $msg .= __( |
@@ -567,7 +567,7 @@ discard block |
||
567 | 567 | private function _deactivate_incompatible_addons() |
568 | 568 | { |
569 | 569 | $incompatible_addons = get_option('ee_incompatible_addons', array()); |
570 | - if (! empty($incompatible_addons)) { |
|
570 | + if ( ! empty($incompatible_addons)) { |
|
571 | 571 | $active_plugins = get_option('active_plugins', array()); |
572 | 572 | foreach ($active_plugins as $active_plugin) { |
573 | 573 | foreach ($incompatible_addons as $incompatible_addon) { |
@@ -611,10 +611,10 @@ discard block |
||
611 | 611 | { |
612 | 612 | do_action('AHEE__EE_System__load_controllers__start'); |
613 | 613 | // let's get it started |
614 | - if (! is_admin() && ! $this->maintenance_mode->level()) { |
|
614 | + if ( ! is_admin() && ! $this->maintenance_mode->level()) { |
|
615 | 615 | do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
616 | 616 | $this->loader->getShared('EE_Front_Controller'); |
617 | - } else if (! EE_FRONT_AJAX) { |
|
617 | + } else if ( ! EE_FRONT_AJAX) { |
|
618 | 618 | do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
619 | 619 | $this->loader->getShared('EE_Admin'); |
620 | 620 | } |
@@ -635,8 +635,8 @@ discard block |
||
635 | 635 | $this->loader->getShared('EE_Session'); |
636 | 636 | do_action('AHEE__EE_System__core_loaded_and_ready'); |
637 | 637 | // load_espresso_template_tags |
638 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
639 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
638 | + if (is_readable(EE_PUBLIC.'template_tags.php')) { |
|
639 | + require_once(EE_PUBLIC.'template_tags.php'); |
|
640 | 640 | } |
641 | 641 | do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
642 | 642 | $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
@@ -699,13 +699,13 @@ discard block |
||
699 | 699 | public static function do_not_cache() |
700 | 700 | { |
701 | 701 | // set no cache constants |
702 | - if (! defined('DONOTCACHEPAGE')) { |
|
702 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
703 | 703 | define('DONOTCACHEPAGE', true); |
704 | 704 | } |
705 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
705 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
706 | 706 | define('DONOTCACHCEOBJECT', true); |
707 | 707 | } |
708 | - if (! defined('DONOTCACHEDB')) { |
|
708 | + if ( ! defined('DONOTCACHEDB')) { |
|
709 | 709 | define('DONOTCACHEDB', true); |
710 | 710 | } |
711 | 711 | // add no cache headers |