Completed
Branch FET-10766-extract-activation-d... (a86901)
by
unknown
187:06 queued 176:14
created
core/services/cache/PostRelatedCacheManager.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -18,92 +18,92 @@
 block discarded – undo
18 18
 class PostRelatedCacheManager extends BasicCacheManager
19 19
 {
20 20
 
21
-    /**
22
-     * @type string
23
-     */
24
-    const POST_CACHE_PREFIX = 'ee_cache_post_';
25
-
26
-    /**
27
-     * wp-option option_name for tracking post related cache
28
-     *
29
-     * @type string
30
-     */
31
-    const POST_CACHE_OPTIONS_KEY = 'ee_post_cache';
32
-
33
-
34
-
35
-    /**
36
-     * PostRelatedCacheManager constructor.
37
-     *
38
-     * @param CacheStorageInterface      $cache_storage
39
-     */
40
-    public function __construct(CacheStorageInterface $cache_storage)
41
-    {
42
-        parent::__construct($cache_storage);
43
-        add_action('save_post', array($this, 'clearPostRelatedCache'));
44
-    }
45
-
46
-
47
-
48
-    /**
49
-     * returns a string that will be prepended to all cache identifiers
50
-     *
51
-     * @return string
52
-     */
53
-    public function cachePrefix()
54
-    {
55
-        return PostRelatedCacheManager::POST_CACHE_PREFIX;
56
-    }
57
-
58
-
59
-
60
-    /**
61
-     * If you are caching content that pertains to a Post of any type,
62
-     * then it is recommended to pass the post id and cache id prefix to this method
63
-     * so that it can be added to the post related cache tracking.
64
-     * Then, whenever that post is updated, the cache will automatically be deleted,
65
-     * which helps to ensure that outdated cache content will not be served
66
-     *
67
-     * @param int    $post_ID    [required]
68
-     * @param string $id_prefix  [required] Appended to all cache IDs. Can be helpful in finding specific cache types.
69
-     *                           May also be helpful to include an additional specific identifier,
70
-     *                           such as a post ID as part of the $id_prefix so that individual caches
71
-     *                           can be found and/or cleared. ex: "venue-28", or "shortcode-156".
72
-     *                           BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id.
73
-     */
74
-    public function clearPostRelatedCacheOnUpdate($post_ID, $id_prefix)
75
-    {
76
-        $post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array());
77
-        // if post is not already being tracked
78
-        if ( ! isset($post_related_cache[$post_ID])) {
79
-            // add array to add cache ids to
80
-            $post_related_cache[$post_ID] = array();
81
-        }
82
-        // add cache id to be tracked
83
-        $post_related_cache[$post_ID][] = $id_prefix;
84
-        update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache);
85
-    }
86
-
87
-
88
-
89
-    /**
90
-     * callback hooked into the WordPress "save_post" action
91
-     * deletes any cache content associated with the post
92
-     *
93
-     * @param int $post_ID [required]
94
-     */
95
-    public function clearPostRelatedCache($post_ID)
96
-    {
97
-        $post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array());
98
-        // if post is not being tracked
99
-        if ( ! isset($post_related_cache[$post_ID])) {
100
-            return;
101
-        }
102
-        // get cache id prefixes for post, and delete their corresponding transients
103
-        $this->clear($post_related_cache[$post_ID]);
104
-        unset($post_related_cache[$post_ID]);
105
-        update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache);
106
-    }
21
+	/**
22
+	 * @type string
23
+	 */
24
+	const POST_CACHE_PREFIX = 'ee_cache_post_';
25
+
26
+	/**
27
+	 * wp-option option_name for tracking post related cache
28
+	 *
29
+	 * @type string
30
+	 */
31
+	const POST_CACHE_OPTIONS_KEY = 'ee_post_cache';
32
+
33
+
34
+
35
+	/**
36
+	 * PostRelatedCacheManager constructor.
37
+	 *
38
+	 * @param CacheStorageInterface      $cache_storage
39
+	 */
40
+	public function __construct(CacheStorageInterface $cache_storage)
41
+	{
42
+		parent::__construct($cache_storage);
43
+		add_action('save_post', array($this, 'clearPostRelatedCache'));
44
+	}
45
+
46
+
47
+
48
+	/**
49
+	 * returns a string that will be prepended to all cache identifiers
50
+	 *
51
+	 * @return string
52
+	 */
53
+	public function cachePrefix()
54
+	{
55
+		return PostRelatedCacheManager::POST_CACHE_PREFIX;
56
+	}
57
+
58
+
59
+
60
+	/**
61
+	 * If you are caching content that pertains to a Post of any type,
62
+	 * then it is recommended to pass the post id and cache id prefix to this method
63
+	 * so that it can be added to the post related cache tracking.
64
+	 * Then, whenever that post is updated, the cache will automatically be deleted,
65
+	 * which helps to ensure that outdated cache content will not be served
66
+	 *
67
+	 * @param int    $post_ID    [required]
68
+	 * @param string $id_prefix  [required] Appended to all cache IDs. Can be helpful in finding specific cache types.
69
+	 *                           May also be helpful to include an additional specific identifier,
70
+	 *                           such as a post ID as part of the $id_prefix so that individual caches
71
+	 *                           can be found and/or cleared. ex: "venue-28", or "shortcode-156".
72
+	 *                           BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id.
73
+	 */
74
+	public function clearPostRelatedCacheOnUpdate($post_ID, $id_prefix)
75
+	{
76
+		$post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array());
77
+		// if post is not already being tracked
78
+		if ( ! isset($post_related_cache[$post_ID])) {
79
+			// add array to add cache ids to
80
+			$post_related_cache[$post_ID] = array();
81
+		}
82
+		// add cache id to be tracked
83
+		$post_related_cache[$post_ID][] = $id_prefix;
84
+		update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache);
85
+	}
86
+
87
+
88
+
89
+	/**
90
+	 * callback hooked into the WordPress "save_post" action
91
+	 * deletes any cache content associated with the post
92
+	 *
93
+	 * @param int $post_ID [required]
94
+	 */
95
+	public function clearPostRelatedCache($post_ID)
96
+	{
97
+		$post_related_cache = (array)get_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, array());
98
+		// if post is not being tracked
99
+		if ( ! isset($post_related_cache[$post_ID])) {
100
+			return;
101
+		}
102
+		// get cache id prefixes for post, and delete their corresponding transients
103
+		$this->clear($post_related_cache[$post_ID]);
104
+		unset($post_related_cache[$post_ID]);
105
+		update_option(PostRelatedCacheManager::POST_CACHE_OPTIONS_KEY, $post_related_cache);
106
+	}
107 107
 
108 108
 
109 109
 }
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +734 added lines, -734 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\services\loaders\LoaderInterface;
5 5
 
6 6
 if (! defined('EVENT_ESPRESSO_VERSION')) {
7
-    exit('No direct script access allowed');
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -21,739 +21,739 @@  discard block
 block discarded – undo
21 21
 class EE_Dependency_Map
22 22
 {
23 23
 
24
-    /**
25
-     * This means that the requested class dependency is not present in the dependency map
26
-     */
27
-    const not_registered = 0;
28
-
29
-    /**
30
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
31
-     */
32
-    const load_new_object = 1;
33
-
34
-    /**
35
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
36
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
37
-     */
38
-    const load_from_cache = 2;
39
-
40
-    /**
41
-     * When registering a dependency,
42
-     * this indicates to keep any existing dependencies that already exist,
43
-     * and simply discard any new dependencies declared in the incoming data
44
-     */
45
-    const KEEP_EXISTING_DEPENDENCIES = 0;
46
-
47
-    /**
48
-     * When registering a dependency,
49
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
50
-     */
51
-    const OVERWRITE_DEPENDENCIES = 1;
52
-
53
-
54
-
55
-    /**
56
-     * @type EE_Dependency_Map $_instance
57
-     */
58
-    protected static $_instance;
59
-
60
-    /**
61
-     * @type EE_Request $request
62
-     */
63
-    protected $_request;
64
-
65
-    /**
66
-     * @type EE_Response $response
67
-     */
68
-    protected $_response;
69
-
70
-    /**
71
-     * @type LoaderInterface $loader
72
-     */
73
-    protected $loader;
74
-
75
-    /**
76
-     * @type array $_dependency_map
77
-     */
78
-    protected $_dependency_map = array();
79
-
80
-    /**
81
-     * @type array $_class_loaders
82
-     */
83
-    protected $_class_loaders = array();
84
-
85
-    /**
86
-     * @type array $_aliases
87
-     */
88
-    protected $_aliases = array();
89
-
90
-
91
-
92
-    /**
93
-     * EE_Dependency_Map constructor.
94
-     *
95
-     * @param EE_Request  $request
96
-     * @param EE_Response $response
97
-     */
98
-    protected function __construct(EE_Request $request, EE_Response $response)
99
-    {
100
-        $this->_request = $request;
101
-        $this->_response = $response;
102
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
103
-        do_action('EE_Dependency_Map____construct');
104
-    }
105
-
106
-
107
-
108
-    /**
109
-     * @throws InvalidDataTypeException
110
-     * @throws InvalidInterfaceException
111
-     * @throws InvalidArgumentException
112
-     */
113
-    public function initialize()
114
-    {
115
-        $this->_register_core_dependencies();
116
-        $this->_register_core_class_loaders();
117
-        $this->_register_core_aliases();
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * @singleton method used to instantiate class object
124
-     * @access    public
125
-     * @param EE_Request  $request
126
-     * @param EE_Response $response
127
-     * @return EE_Dependency_Map
128
-     */
129
-    public static function instance(EE_Request $request = null, EE_Response $response = null)
130
-    {
131
-        // check if class object is instantiated, and instantiated properly
132
-        if (! self::$_instance instanceof EE_Dependency_Map) {
133
-            self::$_instance = new EE_Dependency_Map($request, $response);
134
-        }
135
-        return self::$_instance;
136
-    }
137
-
138
-
139
-
140
-    /**
141
-     * @param LoaderInterface $loader
142
-     */
143
-    public function setLoader(LoaderInterface $loader)
144
-    {
145
-        $this->loader = $loader;
146
-    }
147
-
148
-
149
-
150
-    /**
151
-     * @param string $class
152
-     * @param array  $dependencies
153
-     * @param int    $overwrite
154
-     * @return bool
155
-     */
156
-    public static function register_dependencies(
157
-        $class,
158
-        array $dependencies,
159
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
160
-    ) {
161
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
162
-    }
163
-
164
-
165
-
166
-    /**
167
-     * Assigns an array of class names and corresponding load sources (new or cached)
168
-     * to the class specified by the first parameter.
169
-     * IMPORTANT !!!
170
-     * The order of elements in the incoming $dependencies array MUST match
171
-     * the order of the constructor parameters for the class in question.
172
-     * This is especially important when overriding any existing dependencies that are registered.
173
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
174
-     *
175
-     * @param string $class
176
-     * @param array  $dependencies
177
-     * @param int    $overwrite
178
-     * @return bool
179
-     */
180
-    public function registerDependencies(
181
-        $class,
182
-        array $dependencies,
183
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
184
-    ) {
185
-        $registered = false;
186
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
187
-            self::$_instance->_dependency_map[ $class ] = array();
188
-        }
189
-        // we need to make sure that any aliases used when registering a dependency
190
-        // get resolved to the correct class name
191
-        foreach ((array)$dependencies as $dependency => $load_source) {
192
-            $alias = self::$_instance->get_alias($dependency);
193
-            if (
194
-                $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
195
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
196
-            ) {
197
-                unset($dependencies[$dependency]);
198
-                $dependencies[$alias] = $load_source;
199
-                $registered = true;
200
-            }
201
-        }
202
-        // now add our two lists of dependencies together.
203
-        // using Union (+=) favours the arrays in precedence from left to right,
204
-        // so $dependencies is NOT overwritten because it is listed first
205
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
206
-        // Union is way faster than array_merge() but should be used with caution...
207
-        // especially with numerically indexed arrays
208
-        $dependencies += self::$_instance->_dependency_map[ $class ];
209
-        // now we need to ensure that the resulting dependencies
210
-        // array only has the entries that are required for the class
211
-        // so first count how many dependencies were originally registered for the class
212
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
213
-        // if that count is non-zero (meaning dependencies were already registered)
214
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
215
-            // then truncate the  final array to match that count
216
-            ? array_slice($dependencies, 0, $dependency_count)
217
-            // otherwise just take the incoming array because nothing previously existed
218
-            : $dependencies;
219
-        return $registered;
220
-    }
221
-
222
-
223
-
224
-    /**
225
-     * @param string $class_name
226
-     * @param string $loader
227
-     * @return bool
228
-     * @throws DomainException
229
-     */
230
-    public static function register_class_loader($class_name, $loader = 'load_core')
231
-    {
232
-        if (strpos($class_name, '\\') !== false) {
233
-            throw new DomainException(
234
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
235
-            );
236
-        }
237
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
238
-        if (
239
-            ! is_callable($loader)
240
-            && (
241
-                strpos($loader, 'load_') !== 0
242
-                || ! method_exists('EE_Registry', $loader)
243
-            )
244
-        ) {
245
-            throw new DomainException(
246
-                sprintf(
247
-                    esc_html__(
248
-                        '"%1$s" is not a valid loader method on EE_Registry.',
249
-                        'event_espresso'
250
-                    ),
251
-                    $loader
252
-                )
253
-            );
254
-        }
255
-        $class_name = self::$_instance->get_alias($class_name);
256
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
257
-            self::$_instance->_class_loaders[$class_name] = $loader;
258
-            return true;
259
-        }
260
-        return false;
261
-    }
262
-
263
-
264
-
265
-    /**
266
-     * @return array
267
-     */
268
-    public function dependency_map()
269
-    {
270
-        return $this->_dependency_map;
271
-    }
272
-
273
-
274
-
275
-    /**
276
-     * returns TRUE if dependency map contains a listing for the provided class name
277
-     *
278
-     * @param string $class_name
279
-     * @return boolean
280
-     */
281
-    public function has($class_name = '')
282
-    {
283
-        return isset($this->_dependency_map[$class_name]) ? true : false;
284
-    }
285
-
286
-
287
-
288
-    /**
289
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
290
-     *
291
-     * @param string $class_name
292
-     * @param string $dependency
293
-     * @return bool
294
-     */
295
-    public function has_dependency_for_class($class_name = '', $dependency = '')
296
-    {
297
-        $dependency = $this->get_alias($dependency);
298
-        return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency])
299
-            ? true
300
-            : false;
301
-    }
302
-
303
-
304
-
305
-    /**
306
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
307
-     *
308
-     * @param string $class_name
309
-     * @param string $dependency
310
-     * @return int
311
-     */
312
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
313
-    {
314
-        $dependency = $this->get_alias($dependency);
315
-        return $this->has_dependency_for_class($class_name, $dependency)
316
-            ? $this->_dependency_map[$class_name][$dependency]
317
-            : EE_Dependency_Map::not_registered;
318
-    }
319
-
320
-
321
-
322
-    /**
323
-     * @param string $class_name
324
-     * @return string | Closure
325
-     */
326
-    public function class_loader($class_name)
327
-    {
328
-        // don't use loaders for FQCNs
329
-        if(strpos($class_name, '\\') !== false){
330
-            return '';
331
-        }
332
-        $class_name = $this->get_alias($class_name);
333
-        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
334
-    }
335
-
336
-
337
-
338
-    /**
339
-     * @return array
340
-     */
341
-    public function class_loaders()
342
-    {
343
-        return $this->_class_loaders;
344
-    }
345
-
346
-
347
-
348
-    /**
349
-     * adds an alias for a classname
350
-     *
351
-     * @param string $class_name the class name that should be used (concrete class to replace interface)
352
-     * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
353
-     * @param string $for_class  the class that has the dependency (is type hinting for the interface)
354
-     */
355
-    public function add_alias($class_name, $alias, $for_class = '')
356
-    {
357
-        if ($for_class !== '') {
358
-            if (! isset($this->_aliases[$for_class])) {
359
-                $this->_aliases[$for_class] = array();
360
-            }
361
-            $this->_aliases[$for_class][$class_name] = $alias;
362
-        }
363
-        $this->_aliases[$class_name] = $alias;
364
-    }
365
-
366
-
367
-
368
-    /**
369
-     * returns TRUE if the provided class name has an alias
370
-     *
371
-     * @param string $class_name
372
-     * @param string $for_class
373
-     * @return bool
374
-     */
375
-    public function has_alias($class_name = '', $for_class = '')
376
-    {
377
-        return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name])
378
-               || (
379
-                   isset($this->_aliases[$class_name])
380
-                   && ! is_array($this->_aliases[$class_name])
381
-               );
382
-    }
383
-
384
-
385
-
386
-    /**
387
-     * returns alias for class name if one exists, otherwise returns the original classname
388
-     * functions recursively, so that multiple aliases can be used to drill down to a classname
389
-     *  for example:
390
-     *      if the following two entries were added to the _aliases array:
391
-     *          array(
392
-     *              'interface_alias'           => 'some\namespace\interface'
393
-     *              'some\namespace\interface'  => 'some\namespace\classname'
394
-     *          )
395
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
396
-     *      to load an instance of 'some\namespace\classname'
397
-     *
398
-     * @param string $class_name
399
-     * @param string $for_class
400
-     * @return string
401
-     */
402
-    public function get_alias($class_name = '', $for_class = '')
403
-    {
404
-        if (! $this->has_alias($class_name, $for_class)) {
405
-            return $class_name;
406
-        }
407
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
408
-            return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
409
-        }
410
-        return $this->get_alias($this->_aliases[$class_name]);
411
-    }
412
-
413
-
414
-
415
-    /**
416
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
417
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
418
-     * This is done by using the following class constants:
419
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
420
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
421
-     */
422
-    protected function _register_core_dependencies()
423
-    {
424
-        $this->_dependency_map = array(
425
-            'EE_Request_Handler'                                                                                          => array(
426
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
427
-            ),
428
-            'EE_System'                                                                                                   => array(
429
-                'EE_Registry'                                => EE_Dependency_Map::load_from_cache,
430
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
431
-                'EE_Capabilities'                            => EE_Dependency_Map::load_from_cache,
432
-                'EE_Request'                                 => EE_Dependency_Map::load_from_cache,
433
-                'EE_Maintenance_Mode'                        => EE_Dependency_Map::load_from_cache,
434
-            ),
435
-            'EE_Session'                                                                                                  => array(
436
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
437
-                'EE_Encryption'                                           => EE_Dependency_Map::load_from_cache,
438
-            ),
439
-            'EE_Cart'                                                                                                     => array(
440
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
441
-            ),
442
-            'EE_Front_Controller'                                                                                         => array(
443
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
444
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
445
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
446
-            ),
447
-            'EE_Messenger_Collection_Loader'                                                                              => array(
448
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
449
-            ),
450
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
451
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
452
-            ),
453
-            'EE_Message_Resource_Manager'                                                                                 => array(
454
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
455
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
456
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
457
-            ),
458
-            'EE_Message_Factory'                                                                                          => array(
459
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
460
-            ),
461
-            'EE_messages'                                                                                                 => array(
462
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
463
-            ),
464
-            'EE_Messages_Generator'                                                                                       => array(
465
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
466
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
467
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
468
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
469
-            ),
470
-            'EE_Messages_Processor'                                                                                       => array(
471
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
472
-            ),
473
-            'EE_Messages_Queue'                                                                                           => array(
474
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
475
-            ),
476
-            'EE_Messages_Template_Defaults'                                                                               => array(
477
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
478
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
479
-            ),
480
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
481
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
482
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
483
-            ),
484
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
485
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
486
-            ),
487
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
488
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
489
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
490
-            ),
491
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
492
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
493
-            ),
494
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
495
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
496
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
497
-            ),
498
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
499
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
500
-            ),
501
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
502
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
503
-            ),
504
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
505
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
506
-            ),
507
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
508
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
509
-            ),
510
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
511
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
512
-            ),
513
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
514
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
515
-            ),
516
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
517
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
518
-            ),
519
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
520
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
521
-            ),
522
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
523
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
524
-            ),
525
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
526
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
527
-            ),
528
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
529
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
530
-            ),
531
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
532
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
533
-            ),
534
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
535
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
536
-            ),
537
-            'EE_Data_Migration_Class_Base'                                                                                => array(
538
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
539
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
540
-            ),
541
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
542
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
543
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
546
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
547
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
548
-            ),
549
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
550
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
551
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
552
-            ),
553
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
554
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
555
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
556
-            ),
557
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
558
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
559
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
560
-            ),
561
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
562
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
563
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
564
-            ),
565
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
566
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
567
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
568
-            ),
569
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
570
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
571
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
572
-            ),
573
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
574
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
575
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
576
-            ),
577
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
578
-                'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
579
-                'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
580
-            ),
581
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
582
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
583
-            ),
584
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
585
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
586
-            ),
587
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
588
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
589
-            ),
590
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
591
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
592
-            ),
593
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
594
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
595
-            ),
596
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
597
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
598
-            ),
599
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
600
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
601
-            ),
602
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
603
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
604
-            ),
605
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
606
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
607
-            ),
608
-        );
609
-    }
610
-
611
-
612
-
613
-    /**
614
-     * Registers how core classes are loaded.
615
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
616
-     *        'EE_Request_Handler' => 'load_core'
617
-     *        'EE_Messages_Queue'  => 'load_lib'
618
-     *        'EEH_Debug_Tools'    => 'load_helper'
619
-     * or, if greater control is required, by providing a custom closure. For example:
620
-     *        'Some_Class' => function () {
621
-     *            return new Some_Class();
622
-     *        },
623
-     * This is required for instantiating dependencies
624
-     * where an interface has been type hinted in a class constructor. For example:
625
-     *        'Required_Interface' => function () {
626
-     *            return new A_Class_That_Implements_Required_Interface();
627
-     *        },
628
-     */
629
-    protected function _register_core_class_loaders()
630
-    {
631
-        //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
632
-        //be used in a closure.
633
-        $request = &$this->_request;
634
-        $response = &$this->_response;
635
-        $loader = &$this->loader;
636
-        $this->_class_loaders = array(
637
-            //load_core
638
-            'EE_Maintenance_Mode'                  => 'load_core',
639
-            'EE_Capabilities'                      => 'load_core',
640
-            'EE_Encryption'                        => 'load_core',
641
-            'EE_Front_Controller'                  => 'load_core',
642
-            'EE_Module_Request_Router'             => 'load_core',
643
-            'EE_Registry'                          => 'load_core',
644
-            'EE_Request'                           => function () use (&$request) {
645
-                return $request;
646
-            },
647
-            'EE_Response'                          => function () use (&$response) {
648
-                return $response;
649
-            },
650
-            'EE_Request_Handler'                   => 'load_core',
651
-            'EE_Session'                           => 'load_core',
652
-            'EE_System'                            => 'load_core',
653
-            'EE_Maintenance_Mode'                  => 'load_core',
654
-            'EE_Register_CPTs'                     => 'load_core',
655
-            'EE_Admin'                             => 'load_core',
656
-            //load_lib
657
-            'EE_Message_Resource_Manager'          => 'load_lib',
658
-            'EE_Message_Type_Collection'           => 'load_lib',
659
-            'EE_Message_Type_Collection_Loader'    => 'load_lib',
660
-            'EE_Messenger_Collection'              => 'load_lib',
661
-            'EE_Messenger_Collection_Loader'       => 'load_lib',
662
-            'EE_Messages_Processor'                => 'load_lib',
663
-            'EE_Message_Repository'                => 'load_lib',
664
-            'EE_Messages_Queue'                    => 'load_lib',
665
-            'EE_Messages_Data_Handler_Collection'  => 'load_lib',
666
-            'EE_Message_Template_Group_Collection' => 'load_lib',
667
-            'EE_Messages_Generator'                => function () {
668
-                return EE_Registry::instance()->load_lib(
669
-                    'Messages_Generator',
670
-                    array(),
671
-                    false,
672
-                    false
673
-                );
674
-            },
675
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
676
-                return EE_Registry::instance()->load_lib(
677
-                    'Messages_Template_Defaults',
678
-                    $arguments,
679
-                    false,
680
-                    false
681
-                );
682
-            },
683
-            //load_model
684
-            'EEM_Message_Template_Group'           => 'load_model',
685
-            'EEM_Message_Template'                 => 'load_model',
686
-            //load_helper
687
-            'EEH_Parse_Shortcodes'                 => function () {
688
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
689
-                    return new EEH_Parse_Shortcodes();
690
-                }
691
-                return null;
692
-            },
693
-            'EE_Template_Config'                   => function () {
694
-                return EE_Config::instance()->template_settings;
695
-            },
696
-            'EE_Currency_Config'                   => function () {
697
-                return EE_Config::instance()->currency;
698
-            },
699
-            'EventEspresso\core\services\loaders\Loader' => function () use (&$loader) {
700
-                return $loader;
701
-            },
702
-        );
703
-    }
704
-
705
-
706
-
707
-    /**
708
-     * can be used for supplying alternate names for classes,
709
-     * or for connecting interface names to instantiable classes
710
-     */
711
-    protected function _register_core_aliases()
712
-    {
713
-        $this->_aliases = array(
714
-            'CommandBusInterface'                                                 => 'EventEspresso\core\services\commands\CommandBusInterface',
715
-            'EventEspresso\core\services\commands\CommandBusInterface'            => 'EventEspresso\core\services\commands\CommandBus',
716
-            'CommandHandlerManagerInterface'                                      => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
717
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager',
718
-            'CapChecker'                                                          => 'EventEspresso\core\services\commands\middleware\CapChecker',
719
-            'AddActionHook'                                                       => 'EventEspresso\core\services\commands\middleware\AddActionHook',
720
-            'CapabilitiesChecker'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
721
-            'CapabilitiesCheckerInterface'                                        => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
722
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
723
-            'CreateRegistrationService'                                           => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
724
-            'CreateRegCodeCommandHandler'                                         => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
725
-            'CreateRegUrlLinkCommandHandler'                                      => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
726
-            'CreateRegistrationCommandHandler'                                    => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
727
-            'CopyRegistrationDetailsCommandHandler'                               => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
728
-            'CopyRegistrationPaymentsCommandHandler'                              => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
729
-            'CancelRegistrationAndTicketLineItemCommandHandler'                   => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
730
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'           => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
731
-            'CreateTicketLineItemCommandHandler'                                  => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
732
-            'TableManager'                                                        => 'EventEspresso\core\services\database\TableManager',
733
-            'TableAnalysis'                                                       => 'EventEspresso\core\services\database\TableAnalysis',
734
-            'EspressoShortcode'                                                   => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
735
-            'ShortcodeInterface'                                                  => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
736
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'           => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
737
-            'EventEspresso\core\services\cache\CacheStorageInterface'             => 'EventEspresso\core\services\cache\TransientCacheStorage',
738
-            'LoaderInterface'                                                     => 'EventEspresso\core\services\loaders\LoaderInterface',
739
-            'EventEspresso\core\services\loaders\LoaderInterface'                 => 'EventEspresso\core\services\loaders\Loader',
740
-            'CommandFactoryInterface'                                             => 'EventEspresso\core\services\commands\CommandFactoryInterface',
741
-            'EventEspresso\core\services\commands\CommandFactoryInterface'        => 'EventEspresso\core\services\commands\CommandFactory',
742
-            'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session',
743
-        );
744
-    }
745
-
746
-
747
-
748
-    /**
749
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
750
-     * request Primarily used by unit tests.
751
-     */
752
-    public function reset()
753
-    {
754
-        $this->_register_core_class_loaders();
755
-        $this->_register_core_dependencies();
756
-    }
24
+	/**
25
+	 * This means that the requested class dependency is not present in the dependency map
26
+	 */
27
+	const not_registered = 0;
28
+
29
+	/**
30
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
31
+	 */
32
+	const load_new_object = 1;
33
+
34
+	/**
35
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
36
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
37
+	 */
38
+	const load_from_cache = 2;
39
+
40
+	/**
41
+	 * When registering a dependency,
42
+	 * this indicates to keep any existing dependencies that already exist,
43
+	 * and simply discard any new dependencies declared in the incoming data
44
+	 */
45
+	const KEEP_EXISTING_DEPENDENCIES = 0;
46
+
47
+	/**
48
+	 * When registering a dependency,
49
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
50
+	 */
51
+	const OVERWRITE_DEPENDENCIES = 1;
52
+
53
+
54
+
55
+	/**
56
+	 * @type EE_Dependency_Map $_instance
57
+	 */
58
+	protected static $_instance;
59
+
60
+	/**
61
+	 * @type EE_Request $request
62
+	 */
63
+	protected $_request;
64
+
65
+	/**
66
+	 * @type EE_Response $response
67
+	 */
68
+	protected $_response;
69
+
70
+	/**
71
+	 * @type LoaderInterface $loader
72
+	 */
73
+	protected $loader;
74
+
75
+	/**
76
+	 * @type array $_dependency_map
77
+	 */
78
+	protected $_dependency_map = array();
79
+
80
+	/**
81
+	 * @type array $_class_loaders
82
+	 */
83
+	protected $_class_loaders = array();
84
+
85
+	/**
86
+	 * @type array $_aliases
87
+	 */
88
+	protected $_aliases = array();
89
+
90
+
91
+
92
+	/**
93
+	 * EE_Dependency_Map constructor.
94
+	 *
95
+	 * @param EE_Request  $request
96
+	 * @param EE_Response $response
97
+	 */
98
+	protected function __construct(EE_Request $request, EE_Response $response)
99
+	{
100
+		$this->_request = $request;
101
+		$this->_response = $response;
102
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
103
+		do_action('EE_Dependency_Map____construct');
104
+	}
105
+
106
+
107
+
108
+	/**
109
+	 * @throws InvalidDataTypeException
110
+	 * @throws InvalidInterfaceException
111
+	 * @throws InvalidArgumentException
112
+	 */
113
+	public function initialize()
114
+	{
115
+		$this->_register_core_dependencies();
116
+		$this->_register_core_class_loaders();
117
+		$this->_register_core_aliases();
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * @singleton method used to instantiate class object
124
+	 * @access    public
125
+	 * @param EE_Request  $request
126
+	 * @param EE_Response $response
127
+	 * @return EE_Dependency_Map
128
+	 */
129
+	public static function instance(EE_Request $request = null, EE_Response $response = null)
130
+	{
131
+		// check if class object is instantiated, and instantiated properly
132
+		if (! self::$_instance instanceof EE_Dependency_Map) {
133
+			self::$_instance = new EE_Dependency_Map($request, $response);
134
+		}
135
+		return self::$_instance;
136
+	}
137
+
138
+
139
+
140
+	/**
141
+	 * @param LoaderInterface $loader
142
+	 */
143
+	public function setLoader(LoaderInterface $loader)
144
+	{
145
+		$this->loader = $loader;
146
+	}
147
+
148
+
149
+
150
+	/**
151
+	 * @param string $class
152
+	 * @param array  $dependencies
153
+	 * @param int    $overwrite
154
+	 * @return bool
155
+	 */
156
+	public static function register_dependencies(
157
+		$class,
158
+		array $dependencies,
159
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
160
+	) {
161
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
162
+	}
163
+
164
+
165
+
166
+	/**
167
+	 * Assigns an array of class names and corresponding load sources (new or cached)
168
+	 * to the class specified by the first parameter.
169
+	 * IMPORTANT !!!
170
+	 * The order of elements in the incoming $dependencies array MUST match
171
+	 * the order of the constructor parameters for the class in question.
172
+	 * This is especially important when overriding any existing dependencies that are registered.
173
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
174
+	 *
175
+	 * @param string $class
176
+	 * @param array  $dependencies
177
+	 * @param int    $overwrite
178
+	 * @return bool
179
+	 */
180
+	public function registerDependencies(
181
+		$class,
182
+		array $dependencies,
183
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
184
+	) {
185
+		$registered = false;
186
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
187
+			self::$_instance->_dependency_map[ $class ] = array();
188
+		}
189
+		// we need to make sure that any aliases used when registering a dependency
190
+		// get resolved to the correct class name
191
+		foreach ((array)$dependencies as $dependency => $load_source) {
192
+			$alias = self::$_instance->get_alias($dependency);
193
+			if (
194
+				$overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
195
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
196
+			) {
197
+				unset($dependencies[$dependency]);
198
+				$dependencies[$alias] = $load_source;
199
+				$registered = true;
200
+			}
201
+		}
202
+		// now add our two lists of dependencies together.
203
+		// using Union (+=) favours the arrays in precedence from left to right,
204
+		// so $dependencies is NOT overwritten because it is listed first
205
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
206
+		// Union is way faster than array_merge() but should be used with caution...
207
+		// especially with numerically indexed arrays
208
+		$dependencies += self::$_instance->_dependency_map[ $class ];
209
+		// now we need to ensure that the resulting dependencies
210
+		// array only has the entries that are required for the class
211
+		// so first count how many dependencies were originally registered for the class
212
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
213
+		// if that count is non-zero (meaning dependencies were already registered)
214
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
215
+			// then truncate the  final array to match that count
216
+			? array_slice($dependencies, 0, $dependency_count)
217
+			// otherwise just take the incoming array because nothing previously existed
218
+			: $dependencies;
219
+		return $registered;
220
+	}
221
+
222
+
223
+
224
+	/**
225
+	 * @param string $class_name
226
+	 * @param string $loader
227
+	 * @return bool
228
+	 * @throws DomainException
229
+	 */
230
+	public static function register_class_loader($class_name, $loader = 'load_core')
231
+	{
232
+		if (strpos($class_name, '\\') !== false) {
233
+			throw new DomainException(
234
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
235
+			);
236
+		}
237
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
238
+		if (
239
+			! is_callable($loader)
240
+			&& (
241
+				strpos($loader, 'load_') !== 0
242
+				|| ! method_exists('EE_Registry', $loader)
243
+			)
244
+		) {
245
+			throw new DomainException(
246
+				sprintf(
247
+					esc_html__(
248
+						'"%1$s" is not a valid loader method on EE_Registry.',
249
+						'event_espresso'
250
+					),
251
+					$loader
252
+				)
253
+			);
254
+		}
255
+		$class_name = self::$_instance->get_alias($class_name);
256
+		if (! isset(self::$_instance->_class_loaders[$class_name])) {
257
+			self::$_instance->_class_loaders[$class_name] = $loader;
258
+			return true;
259
+		}
260
+		return false;
261
+	}
262
+
263
+
264
+
265
+	/**
266
+	 * @return array
267
+	 */
268
+	public function dependency_map()
269
+	{
270
+		return $this->_dependency_map;
271
+	}
272
+
273
+
274
+
275
+	/**
276
+	 * returns TRUE if dependency map contains a listing for the provided class name
277
+	 *
278
+	 * @param string $class_name
279
+	 * @return boolean
280
+	 */
281
+	public function has($class_name = '')
282
+	{
283
+		return isset($this->_dependency_map[$class_name]) ? true : false;
284
+	}
285
+
286
+
287
+
288
+	/**
289
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
290
+	 *
291
+	 * @param string $class_name
292
+	 * @param string $dependency
293
+	 * @return bool
294
+	 */
295
+	public function has_dependency_for_class($class_name = '', $dependency = '')
296
+	{
297
+		$dependency = $this->get_alias($dependency);
298
+		return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency])
299
+			? true
300
+			: false;
301
+	}
302
+
303
+
304
+
305
+	/**
306
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
307
+	 *
308
+	 * @param string $class_name
309
+	 * @param string $dependency
310
+	 * @return int
311
+	 */
312
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
313
+	{
314
+		$dependency = $this->get_alias($dependency);
315
+		return $this->has_dependency_for_class($class_name, $dependency)
316
+			? $this->_dependency_map[$class_name][$dependency]
317
+			: EE_Dependency_Map::not_registered;
318
+	}
319
+
320
+
321
+
322
+	/**
323
+	 * @param string $class_name
324
+	 * @return string | Closure
325
+	 */
326
+	public function class_loader($class_name)
327
+	{
328
+		// don't use loaders for FQCNs
329
+		if(strpos($class_name, '\\') !== false){
330
+			return '';
331
+		}
332
+		$class_name = $this->get_alias($class_name);
333
+		return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
334
+	}
335
+
336
+
337
+
338
+	/**
339
+	 * @return array
340
+	 */
341
+	public function class_loaders()
342
+	{
343
+		return $this->_class_loaders;
344
+	}
345
+
346
+
347
+
348
+	/**
349
+	 * adds an alias for a classname
350
+	 *
351
+	 * @param string $class_name the class name that should be used (concrete class to replace interface)
352
+	 * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
353
+	 * @param string $for_class  the class that has the dependency (is type hinting for the interface)
354
+	 */
355
+	public function add_alias($class_name, $alias, $for_class = '')
356
+	{
357
+		if ($for_class !== '') {
358
+			if (! isset($this->_aliases[$for_class])) {
359
+				$this->_aliases[$for_class] = array();
360
+			}
361
+			$this->_aliases[$for_class][$class_name] = $alias;
362
+		}
363
+		$this->_aliases[$class_name] = $alias;
364
+	}
365
+
366
+
367
+
368
+	/**
369
+	 * returns TRUE if the provided class name has an alias
370
+	 *
371
+	 * @param string $class_name
372
+	 * @param string $for_class
373
+	 * @return bool
374
+	 */
375
+	public function has_alias($class_name = '', $for_class = '')
376
+	{
377
+		return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name])
378
+			   || (
379
+				   isset($this->_aliases[$class_name])
380
+				   && ! is_array($this->_aliases[$class_name])
381
+			   );
382
+	}
383
+
384
+
385
+
386
+	/**
387
+	 * returns alias for class name if one exists, otherwise returns the original classname
388
+	 * functions recursively, so that multiple aliases can be used to drill down to a classname
389
+	 *  for example:
390
+	 *      if the following two entries were added to the _aliases array:
391
+	 *          array(
392
+	 *              'interface_alias'           => 'some\namespace\interface'
393
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
394
+	 *          )
395
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
396
+	 *      to load an instance of 'some\namespace\classname'
397
+	 *
398
+	 * @param string $class_name
399
+	 * @param string $for_class
400
+	 * @return string
401
+	 */
402
+	public function get_alias($class_name = '', $for_class = '')
403
+	{
404
+		if (! $this->has_alias($class_name, $for_class)) {
405
+			return $class_name;
406
+		}
407
+		if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
408
+			return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
409
+		}
410
+		return $this->get_alias($this->_aliases[$class_name]);
411
+	}
412
+
413
+
414
+
415
+	/**
416
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
417
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
418
+	 * This is done by using the following class constants:
419
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
420
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
421
+	 */
422
+	protected function _register_core_dependencies()
423
+	{
424
+		$this->_dependency_map = array(
425
+			'EE_Request_Handler'                                                                                          => array(
426
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
427
+			),
428
+			'EE_System'                                                                                                   => array(
429
+				'EE_Registry'                                => EE_Dependency_Map::load_from_cache,
430
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
431
+				'EE_Capabilities'                            => EE_Dependency_Map::load_from_cache,
432
+				'EE_Request'                                 => EE_Dependency_Map::load_from_cache,
433
+				'EE_Maintenance_Mode'                        => EE_Dependency_Map::load_from_cache,
434
+			),
435
+			'EE_Session'                                                                                                  => array(
436
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
437
+				'EE_Encryption'                                           => EE_Dependency_Map::load_from_cache,
438
+			),
439
+			'EE_Cart'                                                                                                     => array(
440
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
441
+			),
442
+			'EE_Front_Controller'                                                                                         => array(
443
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
444
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
445
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
446
+			),
447
+			'EE_Messenger_Collection_Loader'                                                                              => array(
448
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
449
+			),
450
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
451
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
452
+			),
453
+			'EE_Message_Resource_Manager'                                                                                 => array(
454
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
455
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
456
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
457
+			),
458
+			'EE_Message_Factory'                                                                                          => array(
459
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
460
+			),
461
+			'EE_messages'                                                                                                 => array(
462
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
463
+			),
464
+			'EE_Messages_Generator'                                                                                       => array(
465
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
466
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
467
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
468
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
469
+			),
470
+			'EE_Messages_Processor'                                                                                       => array(
471
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
472
+			),
473
+			'EE_Messages_Queue'                                                                                           => array(
474
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
475
+			),
476
+			'EE_Messages_Template_Defaults'                                                                               => array(
477
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
478
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
479
+			),
480
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
481
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
482
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
483
+			),
484
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
485
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
486
+			),
487
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
488
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
489
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
490
+			),
491
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
492
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
493
+			),
494
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
495
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
496
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
497
+			),
498
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
499
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
500
+			),
501
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
502
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
503
+			),
504
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
505
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
506
+			),
507
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
508
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
509
+			),
510
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
511
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
512
+			),
513
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
514
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
515
+			),
516
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
517
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
518
+			),
519
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
520
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
521
+			),
522
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
523
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
524
+			),
525
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
526
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
527
+			),
528
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
529
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
530
+			),
531
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
532
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
533
+			),
534
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
535
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
536
+			),
537
+			'EE_Data_Migration_Class_Base'                                                                                => array(
538
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
539
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
540
+			),
541
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
542
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
543
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
546
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
547
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
548
+			),
549
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
550
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
551
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
552
+			),
553
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
554
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
555
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
556
+			),
557
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
558
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
559
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
560
+			),
561
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
562
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
563
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
564
+			),
565
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
566
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
567
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
568
+			),
569
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
570
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
571
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
572
+			),
573
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
574
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
575
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
576
+			),
577
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
578
+				'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
579
+				'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
580
+			),
581
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
582
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
583
+			),
584
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
585
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
586
+			),
587
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
588
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
589
+			),
590
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
591
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
592
+			),
593
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
594
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
595
+			),
596
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
597
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
598
+			),
599
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
600
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
601
+			),
602
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => array(
603
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
604
+			),
605
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => array(
606
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
607
+			),
608
+		);
609
+	}
610
+
611
+
612
+
613
+	/**
614
+	 * Registers how core classes are loaded.
615
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
616
+	 *        'EE_Request_Handler' => 'load_core'
617
+	 *        'EE_Messages_Queue'  => 'load_lib'
618
+	 *        'EEH_Debug_Tools'    => 'load_helper'
619
+	 * or, if greater control is required, by providing a custom closure. For example:
620
+	 *        'Some_Class' => function () {
621
+	 *            return new Some_Class();
622
+	 *        },
623
+	 * This is required for instantiating dependencies
624
+	 * where an interface has been type hinted in a class constructor. For example:
625
+	 *        'Required_Interface' => function () {
626
+	 *            return new A_Class_That_Implements_Required_Interface();
627
+	 *        },
628
+	 */
629
+	protected function _register_core_class_loaders()
630
+	{
631
+		//for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
632
+		//be used in a closure.
633
+		$request = &$this->_request;
634
+		$response = &$this->_response;
635
+		$loader = &$this->loader;
636
+		$this->_class_loaders = array(
637
+			//load_core
638
+			'EE_Maintenance_Mode'                  => 'load_core',
639
+			'EE_Capabilities'                      => 'load_core',
640
+			'EE_Encryption'                        => 'load_core',
641
+			'EE_Front_Controller'                  => 'load_core',
642
+			'EE_Module_Request_Router'             => 'load_core',
643
+			'EE_Registry'                          => 'load_core',
644
+			'EE_Request'                           => function () use (&$request) {
645
+				return $request;
646
+			},
647
+			'EE_Response'                          => function () use (&$response) {
648
+				return $response;
649
+			},
650
+			'EE_Request_Handler'                   => 'load_core',
651
+			'EE_Session'                           => 'load_core',
652
+			'EE_System'                            => 'load_core',
653
+			'EE_Maintenance_Mode'                  => 'load_core',
654
+			'EE_Register_CPTs'                     => 'load_core',
655
+			'EE_Admin'                             => 'load_core',
656
+			//load_lib
657
+			'EE_Message_Resource_Manager'          => 'load_lib',
658
+			'EE_Message_Type_Collection'           => 'load_lib',
659
+			'EE_Message_Type_Collection_Loader'    => 'load_lib',
660
+			'EE_Messenger_Collection'              => 'load_lib',
661
+			'EE_Messenger_Collection_Loader'       => 'load_lib',
662
+			'EE_Messages_Processor'                => 'load_lib',
663
+			'EE_Message_Repository'                => 'load_lib',
664
+			'EE_Messages_Queue'                    => 'load_lib',
665
+			'EE_Messages_Data_Handler_Collection'  => 'load_lib',
666
+			'EE_Message_Template_Group_Collection' => 'load_lib',
667
+			'EE_Messages_Generator'                => function () {
668
+				return EE_Registry::instance()->load_lib(
669
+					'Messages_Generator',
670
+					array(),
671
+					false,
672
+					false
673
+				);
674
+			},
675
+			'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
676
+				return EE_Registry::instance()->load_lib(
677
+					'Messages_Template_Defaults',
678
+					$arguments,
679
+					false,
680
+					false
681
+				);
682
+			},
683
+			//load_model
684
+			'EEM_Message_Template_Group'           => 'load_model',
685
+			'EEM_Message_Template'                 => 'load_model',
686
+			//load_helper
687
+			'EEH_Parse_Shortcodes'                 => function () {
688
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
689
+					return new EEH_Parse_Shortcodes();
690
+				}
691
+				return null;
692
+			},
693
+			'EE_Template_Config'                   => function () {
694
+				return EE_Config::instance()->template_settings;
695
+			},
696
+			'EE_Currency_Config'                   => function () {
697
+				return EE_Config::instance()->currency;
698
+			},
699
+			'EventEspresso\core\services\loaders\Loader' => function () use (&$loader) {
700
+				return $loader;
701
+			},
702
+		);
703
+	}
704
+
705
+
706
+
707
+	/**
708
+	 * can be used for supplying alternate names for classes,
709
+	 * or for connecting interface names to instantiable classes
710
+	 */
711
+	protected function _register_core_aliases()
712
+	{
713
+		$this->_aliases = array(
714
+			'CommandBusInterface'                                                 => 'EventEspresso\core\services\commands\CommandBusInterface',
715
+			'EventEspresso\core\services\commands\CommandBusInterface'            => 'EventEspresso\core\services\commands\CommandBus',
716
+			'CommandHandlerManagerInterface'                                      => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
717
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager',
718
+			'CapChecker'                                                          => 'EventEspresso\core\services\commands\middleware\CapChecker',
719
+			'AddActionHook'                                                       => 'EventEspresso\core\services\commands\middleware\AddActionHook',
720
+			'CapabilitiesChecker'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
721
+			'CapabilitiesCheckerInterface'                                        => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
722
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
723
+			'CreateRegistrationService'                                           => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
724
+			'CreateRegCodeCommandHandler'                                         => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
725
+			'CreateRegUrlLinkCommandHandler'                                      => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
726
+			'CreateRegistrationCommandHandler'                                    => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
727
+			'CopyRegistrationDetailsCommandHandler'                               => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
728
+			'CopyRegistrationPaymentsCommandHandler'                              => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
729
+			'CancelRegistrationAndTicketLineItemCommandHandler'                   => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
730
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'           => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
731
+			'CreateTicketLineItemCommandHandler'                                  => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
732
+			'TableManager'                                                        => 'EventEspresso\core\services\database\TableManager',
733
+			'TableAnalysis'                                                       => 'EventEspresso\core\services\database\TableAnalysis',
734
+			'EspressoShortcode'                                                   => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
735
+			'ShortcodeInterface'                                                  => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
736
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'           => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
737
+			'EventEspresso\core\services\cache\CacheStorageInterface'             => 'EventEspresso\core\services\cache\TransientCacheStorage',
738
+			'LoaderInterface'                                                     => 'EventEspresso\core\services\loaders\LoaderInterface',
739
+			'EventEspresso\core\services\loaders\LoaderInterface'                 => 'EventEspresso\core\services\loaders\Loader',
740
+			'CommandFactoryInterface'                                             => 'EventEspresso\core\services\commands\CommandFactoryInterface',
741
+			'EventEspresso\core\services\commands\CommandFactoryInterface'        => 'EventEspresso\core\services\commands\CommandFactory',
742
+			'EventEspresso\core\domain\services\session\SessionIdentifierInterface' => 'EE_Session',
743
+		);
744
+	}
745
+
746
+
747
+
748
+	/**
749
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
750
+	 * request Primarily used by unit tests.
751
+	 */
752
+	public function reset()
753
+	{
754
+		$this->_register_core_class_loaders();
755
+		$this->_register_core_dependencies();
756
+	}
757 757
 
758 758
 
759 759
 }
Please login to merge, or discard this patch.
core/EE_System.core.php 2 patches
Indentation   +806 added lines, -806 removed lines patch added patch discarded remove patch
@@ -22,818 +22,818 @@
 block discarded – undo
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 ($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
-    }
644
-
645
-
646
-
647
-    /**
648
-     * initialize
649
-     * this is the best place to begin initializing client code
650
-     *
651
-     * @access public
652
-     * @return void
653
-     */
654
-    public function initialize()
655
-    {
656
-        do_action('AHEE__EE_System__initialize');
657
-    }
658
-
659
-
660
-
661
-    /**
662
-     * initialize_last
663
-     * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
664
-     * initialize has done so
665
-     *
666
-     * @access public
667
-     * @return void
668
-     */
669
-    public function initialize_last()
670
-    {
671
-        do_action('AHEE__EE_System__initialize_last');
672
-        add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
673
-    }
674
-
675
-
676
-
677
-    /**
678
-     * @return void
679
-     * @throws EE_Error
680
-     */
681
-    public function addEspressoToolbar()
682
-    {
683
-        $this->registry->create(
684
-            'EventEspresso\core\domain\services\admin\AdminToolBar',
685
-            array($this->registry->CAP)
686
-        );
687
-    }
688
-
689
-
690
-
691
-    /**
692
-     * do_not_cache
693
-     * sets no cache headers and defines no cache constants for WP plugins
694
-     *
695
-     * @access public
696
-     * @return void
697
-     */
698
-    public static function do_not_cache()
699
-    {
700
-        // set no cache constants
701
-        if (! defined('DONOTCACHEPAGE')) {
702
-            define('DONOTCACHEPAGE', true);
703
-        }
704
-        if (! defined('DONOTCACHCEOBJECT')) {
705
-            define('DONOTCACHCEOBJECT', true);
706
-        }
707
-        if (! defined('DONOTCACHEDB')) {
708
-            define('DONOTCACHEDB', true);
709
-        }
710
-        // add no cache headers
711
-        add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
712
-        // plus a little extra for nginx and Google Chrome
713
-        add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
714
-        // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
715
-        remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
716
-    }
717
-
718
-
719
-
720
-    /**
721
-     *    extra_nocache_headers
722
-     *
723
-     * @access    public
724
-     * @param $headers
725
-     * @return    array
726
-     */
727
-    public static function extra_nocache_headers($headers)
728
-    {
729
-        // for NGINX
730
-        $headers['X-Accel-Expires'] = 0;
731
-        // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
732
-        $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
733
-        return $headers;
734
-    }
735
-
736
-
737
-
738
-    /**
739
-     *    nocache_headers
740
-     *
741
-     * @access    public
742
-     * @return    void
743
-     */
744
-    public static function nocache_headers()
745
-    {
746
-        nocache_headers();
747
-    }
748
-
749
-
750
-
751
-
752
-    /**
753
-     * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
754
-     * never returned with the function.
755
-     *
756
-     * @param  array $exclude_array any existing pages being excluded are in this array.
757
-     * @return array
758
-     */
759
-    public function remove_pages_from_wp_list_pages($exclude_array)
760
-    {
761
-        return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
762
-    }
763
-
764
-
765
-
766
-    /******************************** DEPRECATED ***************************************/
767
-
768
-
769
-
770
-    /**
771
-     * @deprecated 4.9.40
772
-     * @return void
773
-     */
774
-    public function detect_if_activation_or_upgrade()
775
-    {
776
-    }
777
-
778
-
779
-
780
-    /**
781
-     * @deprecated 4.9.40
782
-     * @return void
783
-     */
784
-    public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
785
-    {
786
-    }
787
-
788
-
789
-
790
-    /**
791
-     * @deprecated 4.9.40
792
-     * @param null $espresso_db_update
793
-     * @return int one of the constants on EE_System::req_type_
794
-     */
795
-    public function detect_req_type($espresso_db_update = null)
796
-    {
797
-        return $this->request->getRequestType()->requestType();
798
-    }
799
-
800
-
801
-
802
-    /**
803
-     * @deprecated 4.9.40
804
-     * @return bool
805
-     */
806
-    public function is_major_version_change()
807
-    {
808
-        return $this->request->getRequestType()->isMajorVersionChange();
809
-    }
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 ($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
+	}
644
+
645
+
646
+
647
+	/**
648
+	 * initialize
649
+	 * this is the best place to begin initializing client code
650
+	 *
651
+	 * @access public
652
+	 * @return void
653
+	 */
654
+	public function initialize()
655
+	{
656
+		do_action('AHEE__EE_System__initialize');
657
+	}
658
+
659
+
660
+
661
+	/**
662
+	 * initialize_last
663
+	 * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
664
+	 * initialize has done so
665
+	 *
666
+	 * @access public
667
+	 * @return void
668
+	 */
669
+	public function initialize_last()
670
+	{
671
+		do_action('AHEE__EE_System__initialize_last');
672
+		add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
673
+	}
674
+
675
+
676
+
677
+	/**
678
+	 * @return void
679
+	 * @throws EE_Error
680
+	 */
681
+	public function addEspressoToolbar()
682
+	{
683
+		$this->registry->create(
684
+			'EventEspresso\core\domain\services\admin\AdminToolBar',
685
+			array($this->registry->CAP)
686
+		);
687
+	}
688
+
689
+
690
+
691
+	/**
692
+	 * do_not_cache
693
+	 * sets no cache headers and defines no cache constants for WP plugins
694
+	 *
695
+	 * @access public
696
+	 * @return void
697
+	 */
698
+	public static function do_not_cache()
699
+	{
700
+		// set no cache constants
701
+		if (! defined('DONOTCACHEPAGE')) {
702
+			define('DONOTCACHEPAGE', true);
703
+		}
704
+		if (! defined('DONOTCACHCEOBJECT')) {
705
+			define('DONOTCACHCEOBJECT', true);
706
+		}
707
+		if (! defined('DONOTCACHEDB')) {
708
+			define('DONOTCACHEDB', true);
709
+		}
710
+		// add no cache headers
711
+		add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
712
+		// plus a little extra for nginx and Google Chrome
713
+		add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
714
+		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
715
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
716
+	}
717
+
718
+
719
+
720
+	/**
721
+	 *    extra_nocache_headers
722
+	 *
723
+	 * @access    public
724
+	 * @param $headers
725
+	 * @return    array
726
+	 */
727
+	public static function extra_nocache_headers($headers)
728
+	{
729
+		// for NGINX
730
+		$headers['X-Accel-Expires'] = 0;
731
+		// plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
732
+		$headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
733
+		return $headers;
734
+	}
735
+
736
+
737
+
738
+	/**
739
+	 *    nocache_headers
740
+	 *
741
+	 * @access    public
742
+	 * @return    void
743
+	 */
744
+	public static function nocache_headers()
745
+	{
746
+		nocache_headers();
747
+	}
748
+
749
+
750
+
751
+
752
+	/**
753
+	 * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
754
+	 * never returned with the function.
755
+	 *
756
+	 * @param  array $exclude_array any existing pages being excluded are in this array.
757
+	 * @return array
758
+	 */
759
+	public function remove_pages_from_wp_list_pages($exclude_array)
760
+	{
761
+		return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
762
+	}
763
+
764
+
765
+
766
+	/******************************** DEPRECATED ***************************************/
767
+
768
+
769
+
770
+	/**
771
+	 * @deprecated 4.9.40
772
+	 * @return void
773
+	 */
774
+	public function detect_if_activation_or_upgrade()
775
+	{
776
+	}
777
+
778
+
779
+
780
+	/**
781
+	 * @deprecated 4.9.40
782
+	 * @return void
783
+	 */
784
+	public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
785
+	{
786
+	}
787
+
788
+
789
+
790
+	/**
791
+	 * @deprecated 4.9.40
792
+	 * @param null $espresso_db_update
793
+	 * @return int one of the constants on EE_System::req_type_
794
+	 */
795
+	public function detect_req_type($espresso_db_update = null)
796
+	{
797
+		return $this->request->getRequestType()->requestType();
798
+	}
799
+
800
+
801
+
802
+	/**
803
+	 * @deprecated 4.9.40
804
+	 * @return bool
805
+	 */
806
+	public function is_major_version_change()
807
+	{
808
+		return $this->request->getRequestType()->isMajorVersionChange();
809
+	}
810 810
 
811 811
 
812 812
 
813
-    /**
814
-     * @deprecated 4.9.40
815
-     * @param array  $activation_history_for_addon
816
-     * @param string $activation_indicator_option_name
817
-     * @param string $version_to_upgrade_to
818
-     * @return int one of the constants on EE_System::req_type_*
819
-     */
820
-    public static function detect_req_type_given_activation_history(
821
-        $activation_history_for_addon,
822
-        $activation_indicator_option_name,
823
-        $version_to_upgrade_to
824
-    ) {
825
-        return EE_System::instance()->request->getRequestType()->requestType();
826
-    }
813
+	/**
814
+	 * @deprecated 4.9.40
815
+	 * @param array  $activation_history_for_addon
816
+	 * @param string $activation_indicator_option_name
817
+	 * @param string $version_to_upgrade_to
818
+	 * @return int one of the constants on EE_System::req_type_*
819
+	 */
820
+	public static function detect_req_type_given_activation_history(
821
+		$activation_history_for_addon,
822
+		$activation_indicator_option_name,
823
+		$version_to_upgrade_to
824
+	) {
825
+		return EE_System::instance()->request->getRequestType()->requestType();
826
+	}
827 827
 
828 828
 
829 829
 
830
-    /**
831
-     * @deprecated 4.9.40
832
-     * @return void
833
-     */
834
-    public function perform_activations_upgrades_and_migrations()
835
-    {
836
-    }
830
+	/**
831
+	 * @deprecated 4.9.40
832
+	 * @return void
833
+	 */
834
+	public function perform_activations_upgrades_and_migrations()
835
+	{
836
+	}
837 837
 
838 838
 
839 839
 }
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
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) {
@@ -443,8 +443,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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');
@@ -698,13 +698,13 @@  discard block
 block discarded – undo
698 698
     public static function do_not_cache()
699 699
     {
700 700
         // set no cache constants
701
-        if (! defined('DONOTCACHEPAGE')) {
701
+        if ( ! defined('DONOTCACHEPAGE')) {
702 702
             define('DONOTCACHEPAGE', true);
703 703
         }
704
-        if (! defined('DONOTCACHCEOBJECT')) {
704
+        if ( ! defined('DONOTCACHCEOBJECT')) {
705 705
             define('DONOTCACHCEOBJECT', true);
706 706
         }
707
-        if (! defined('DONOTCACHEDB')) {
707
+        if ( ! defined('DONOTCACHEDB')) {
708 708
             define('DONOTCACHEDB', true);
709 709
         }
710 710
         // add no cache headers
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,245 +40,245 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.44.rc.010');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.44.rc.010');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Psr4AutoloaderInit', EE_CORE . 'EE_Psr4AutoloaderInit.core.php');
262
-        new EE_Psr4AutoloaderInit();
263
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
264
-        new EE_Bootstrap();
265
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Psr4AutoloaderInit', EE_CORE . 'EE_Psr4AutoloaderInit.core.php');
262
+		new EE_Psr4AutoloaderInit();
263
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
264
+		new EE_Bootstrap();
265
+	}
266 266
 }
267 267
 if ( ! function_exists('espresso_deactivate_plugin')) {
268
-    /**
269
-     *    deactivate_plugin
270
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
271
-     *
272
-     * @access public
273
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
274
-     * @return    void
275
-     */
276
-    function espresso_deactivate_plugin($plugin_basename = '')
277
-    {
278
-        if ( ! function_exists('deactivate_plugins')) {
279
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
280
-        }
281
-        unset($_GET['activate'], $_REQUEST['activate']);
282
-        deactivate_plugins($plugin_basename);
283
-    }
268
+	/**
269
+	 *    deactivate_plugin
270
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
271
+	 *
272
+	 * @access public
273
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
274
+	 * @return    void
275
+	 */
276
+	function espresso_deactivate_plugin($plugin_basename = '')
277
+	{
278
+		if ( ! function_exists('deactivate_plugins')) {
279
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
280
+		}
281
+		unset($_GET['activate'], $_REQUEST['activate']);
282
+		deactivate_plugins($plugin_basename);
283
+	}
284 284
 }
285 285
\ No newline at end of file
Please login to merge, or discard this patch.