Completed
Branch FET/11183/improvements-to-pue-... (dfe6b8)
by
unknown
20:21 queued 12s
created
core/services/licensing/LicenseService.php 2 patches
Indentation   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -14,94 +14,94 @@
 block discarded – undo
14 14
  */
15 15
 class LicenseService
16 16
 {
17
-    /**
18
-     * @var Config
19
-     */
20
-    private $config;
17
+	/**
18
+	 * @var Config
19
+	 */
20
+	private $config;
21 21
 
22 22
 
23
-    /**
24
-     * @var Stats
25
-     */
26
-    private $stats_collection;
23
+	/**
24
+	 * @var Stats
25
+	 */
26
+	private $stats_collection;
27 27
 
28
-    public function __construct(Stats $stats_collection, Config $config)
29
-    {
30
-        $this->config = $config;
31
-        $this->stats_collection = $stats_collection;
32
-        $this->loadPueClient();
33
-    }
28
+	public function __construct(Stats $stats_collection, Config $config)
29
+	{
30
+		$this->config = $config;
31
+		$this->stats_collection = $stats_collection;
32
+		$this->loadPueClient();
33
+	}
34 34
 
35
-    private function loadPueClient()
36
-    {
37
-        // PUE Auto Upgrades stuff
38
-        if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { //include the file
39
-            require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
35
+	private function loadPueClient()
36
+	{
37
+		// PUE Auto Upgrades stuff
38
+		if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { //include the file
39
+			require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
40 40
 
41
-            //$options needs to be an array with the included keys as listed.
42
-            $options = array(
43
-                //	'optionName' => '', //(optional) - used as the reference for saving update information in the
44
-                // clients options table.  Will be automatically set if left blank.
45
-                'apikey'                => $this->config->siteLicenseKey(),
46
-                //(required), you will need to obtain the apikey that the client gets from your site and
47
-                // then saves in their sites options table (see 'getting an api-key' below)
48
-                'lang_domain'           => $this->config->i18nDomain(),
49
-                //(optional) - put here whatever reference you are using for the localization of your plugin (if it's
50
-                // localized).  That way strings in this file will be included in the translation for your plugin.
51
-                'checkPeriod'           => $this->config->checkPeriod(),
52
-                //(optional) - use this parameter to indicate how often you want the client's install to ping your
53
-                // server for update checks.  The integer indicates hours.  If you don't include this parameter it will
54
-                // default to 12 hours.
55
-                'option_key'            => $this->config->optionKey(),
56
-                //this is what is used to reference the api_key in your plugin options.  PUE uses this to trigger
57
-                // updating your information message whenever this option_key is modified.
58
-                'options_page_slug'     => $this->config->optionsPageSlug(),
59
-                'plugin_basename'       => EE_PLUGIN_BASENAME,
60
-                'use_wp_update'         => true,
61
-                //if TRUE then you want FREE versions of the plugin to be updated from WP
62
-                'extra_stats'           => $this->stats_collection->statsCallback(),
63
-                'turn_on_notices_saved' => true,
64
-            );
65
-            //initiate the class and start the plugin update engine!
66
-            new PluginUpdateEngineChecker(
67
-                $this->config->hostServerUrl(),
68
-                $this->config->pluginSlug(),
69
-                $options
70
-            );
71
-        }
72
-    }
41
+			//$options needs to be an array with the included keys as listed.
42
+			$options = array(
43
+				//	'optionName' => '', //(optional) - used as the reference for saving update information in the
44
+				// clients options table.  Will be automatically set if left blank.
45
+				'apikey'                => $this->config->siteLicenseKey(),
46
+				//(required), you will need to obtain the apikey that the client gets from your site and
47
+				// then saves in their sites options table (see 'getting an api-key' below)
48
+				'lang_domain'           => $this->config->i18nDomain(),
49
+				//(optional) - put here whatever reference you are using for the localization of your plugin (if it's
50
+				// localized).  That way strings in this file will be included in the translation for your plugin.
51
+				'checkPeriod'           => $this->config->checkPeriod(),
52
+				//(optional) - use this parameter to indicate how often you want the client's install to ping your
53
+				// server for update checks.  The integer indicates hours.  If you don't include this parameter it will
54
+				// default to 12 hours.
55
+				'option_key'            => $this->config->optionKey(),
56
+				//this is what is used to reference the api_key in your plugin options.  PUE uses this to trigger
57
+				// updating your information message whenever this option_key is modified.
58
+				'options_page_slug'     => $this->config->optionsPageSlug(),
59
+				'plugin_basename'       => EE_PLUGIN_BASENAME,
60
+				'use_wp_update'         => true,
61
+				//if TRUE then you want FREE versions of the plugin to be updated from WP
62
+				'extra_stats'           => $this->stats_collection->statsCallback(),
63
+				'turn_on_notices_saved' => true,
64
+			);
65
+			//initiate the class and start the plugin update engine!
66
+			new PluginUpdateEngineChecker(
67
+				$this->config->hostServerUrl(),
68
+				$this->config->pluginSlug(),
69
+				$options
70
+			);
71
+		}
72
+	}
73 73
 
74 74
 
75
-    /**
76
-     * This is a handy helper method for retrieving whether there is an update available for the given plugin.
77
-     *
78
-     * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
79
-     *                          identify plugins. Defaults to core update
80
-     * @return boolean           True if update available, false if not.
81
-     */
82
-    public static function isUpdateAvailable($basename = '')
83
-    {
84
-        $basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME;
75
+	/**
76
+	 * This is a handy helper method for retrieving whether there is an update available for the given plugin.
77
+	 *
78
+	 * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
79
+	 *                          identify plugins. Defaults to core update
80
+	 * @return boolean           True if update available, false if not.
81
+	 */
82
+	public static function isUpdateAvailable($basename = '')
83
+	{
84
+		$basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME;
85 85
 
86
-        $update = false;
86
+		$update = false;
87 87
 
88
-        // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
89
-        $folder = DS . dirname($basename);
88
+		// should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
89
+		$folder = DS . dirname($basename);
90 90
 
91
-        $plugins = get_plugins($folder);
92
-        $current = get_site_transient('update_plugins');
91
+		$plugins = get_plugins($folder);
92
+		$current = get_site_transient('update_plugins');
93 93
 
94
-        foreach ((array)$plugins as $plugin_file => $plugin_data) {
95
-            if (isset($current->response['plugin_file'])) {
96
-                $update = true;
97
-            }
98
-        }
94
+		foreach ((array)$plugins as $plugin_file => $plugin_data) {
95
+			if (isset($current->response['plugin_file'])) {
96
+				$update = true;
97
+			}
98
+		}
99 99
 
100
-        //it's possible that there is an update but an invalid site-license-key is in use
101
-        if (get_site_option('pue_json_error_' . $basename)) {
102
-            $update = true;
103
-        }
100
+		//it's possible that there is an update but an invalid site-license-key is in use
101
+		if (get_site_option('pue_json_error_' . $basename)) {
102
+			$update = true;
103
+		}
104 104
 
105
-        return $update;
106
-    }
105
+		return $update;
106
+	}
107 107
 }
108 108
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
     private function loadPueClient()
36 36
     {
37 37
         // PUE Auto Upgrades stuff
38
-        if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { //include the file
39
-            require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
38
+        if (is_readable(EE_THIRD_PARTY.'pue/pue-client.php')) { //include the file
39
+            require_once(EE_THIRD_PARTY.'pue/pue-client.php');
40 40
 
41 41
             //$options needs to be an array with the included keys as listed.
42 42
             $options = array(
@@ -86,19 +86,19 @@  discard block
 block discarded – undo
86 86
         $update = false;
87 87
 
88 88
         // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
89
-        $folder = DS . dirname($basename);
89
+        $folder = DS.dirname($basename);
90 90
 
91 91
         $plugins = get_plugins($folder);
92 92
         $current = get_site_transient('update_plugins');
93 93
 
94
-        foreach ((array)$plugins as $plugin_file => $plugin_data) {
94
+        foreach ((array) $plugins as $plugin_file => $plugin_data) {
95 95
             if (isset($current->response['plugin_file'])) {
96 96
                 $update = true;
97 97
             }
98 98
         }
99 99
 
100 100
         //it's possible that there is an update but an invalid site-license-key is in use
101
-        if (get_site_option('pue_json_error_' . $basename)) {
101
+        if (get_site_option('pue_json_error_'.$basename)) {
102 102
             $update = true;
103 103
         }
104 104
 
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 2 patches
Indentation   +825 added lines, -825 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use EventEspresso\core\services\loaders\LoaderInterface;
6 6
 
7 7
 if (! defined('EVENT_ESPRESSO_VERSION')) {
8
-    exit('No direct script access allowed');
8
+	exit('No direct script access allowed');
9 9
 }
10 10
 
11 11
 
@@ -22,830 +22,830 @@  discard block
 block discarded – undo
22 22
 class EE_Dependency_Map
23 23
 {
24 24
 
25
-    /**
26
-     * This means that the requested class dependency is not present in the dependency map
27
-     */
28
-    const not_registered = 0;
29
-
30
-    /**
31
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
32
-     */
33
-    const load_new_object = 1;
34
-
35
-    /**
36
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
37
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
38
-     */
39
-    const load_from_cache = 2;
40
-
41
-    /**
42
-     * When registering a dependency,
43
-     * this indicates to keep any existing dependencies that already exist,
44
-     * and simply discard any new dependencies declared in the incoming data
45
-     */
46
-    const KEEP_EXISTING_DEPENDENCIES = 0;
47
-
48
-    /**
49
-     * When registering a dependency,
50
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
51
-     */
52
-    const OVERWRITE_DEPENDENCIES = 1;
53
-
54
-
55
-
56
-    /**
57
-     * @type EE_Dependency_Map $_instance
58
-     */
59
-    protected static $_instance;
60
-
61
-    /**
62
-     * @type EE_Request $request
63
-     */
64
-    protected $_request;
65
-
66
-    /**
67
-     * @type EE_Response $response
68
-     */
69
-    protected $_response;
70
-
71
-    /**
72
-     * @type LoaderInterface $loader
73
-     */
74
-    protected $loader;
75
-
76
-    /**
77
-     * @type array $_dependency_map
78
-     */
79
-    protected $_dependency_map = array();
80
-
81
-    /**
82
-     * @type array $_class_loaders
83
-     */
84
-    protected $_class_loaders = array();
85
-
86
-    /**
87
-     * @type array $_aliases
88
-     */
89
-    protected $_aliases = array();
90
-
91
-
92
-
93
-    /**
94
-     * EE_Dependency_Map constructor.
95
-     *
96
-     * @param EE_Request  $request
97
-     * @param EE_Response $response
98
-     */
99
-    protected function __construct(EE_Request $request, EE_Response $response)
100
-    {
101
-        $this->_request = $request;
102
-        $this->_response = $response;
103
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
104
-        do_action('EE_Dependency_Map____construct');
105
-    }
106
-
107
-
108
-
109
-    /**
110
-     * @throws InvalidDataTypeException
111
-     * @throws InvalidInterfaceException
112
-     * @throws InvalidArgumentException
113
-     */
114
-    public function initialize()
115
-    {
116
-        $this->_register_core_dependencies();
117
-        $this->_register_core_class_loaders();
118
-        $this->_register_core_aliases();
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     * @singleton method used to instantiate class object
125
-     * @access    public
126
-     * @param EE_Request  $request
127
-     * @param EE_Response $response
128
-     * @return EE_Dependency_Map
129
-     */
130
-    public static function instance(EE_Request $request = null, EE_Response $response = null)
131
-    {
132
-        // check if class object is instantiated, and instantiated properly
133
-        if (! self::$_instance instanceof EE_Dependency_Map) {
134
-            self::$_instance = new EE_Dependency_Map($request, $response);
135
-        }
136
-        return self::$_instance;
137
-    }
138
-
139
-
140
-
141
-    /**
142
-     * @param LoaderInterface $loader
143
-     */
144
-    public function setLoader(LoaderInterface $loader)
145
-    {
146
-        $this->loader = $loader;
147
-    }
148
-
149
-
150
-
151
-    /**
152
-     * @param string $class
153
-     * @param array  $dependencies
154
-     * @param int    $overwrite
155
-     * @return bool
156
-     */
157
-    public static function register_dependencies(
158
-        $class,
159
-        array $dependencies,
160
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
161
-    ) {
162
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * Assigns an array of class names and corresponding load sources (new or cached)
169
-     * to the class specified by the first parameter.
170
-     * IMPORTANT !!!
171
-     * The order of elements in the incoming $dependencies array MUST match
172
-     * the order of the constructor parameters for the class in question.
173
-     * This is especially important when overriding any existing dependencies that are registered.
174
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
175
-     *
176
-     * @param string $class
177
-     * @param array  $dependencies
178
-     * @param int    $overwrite
179
-     * @return bool
180
-     */
181
-    public function registerDependencies(
182
-        $class,
183
-        array $dependencies,
184
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
185
-    ) {
186
-        $class = trim($class, '\\');
187
-        $registered = false;
188
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
189
-            self::$_instance->_dependency_map[ $class ] = array();
190
-        }
191
-        // we need to make sure that any aliases used when registering a dependency
192
-        // get resolved to the correct class name
193
-        foreach ((array)$dependencies as $dependency => $load_source) {
194
-            $alias = self::$_instance->get_alias($dependency);
195
-            if (
196
-                $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
197
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
198
-            ) {
199
-                unset($dependencies[$dependency]);
200
-                $dependencies[$alias] = $load_source;
201
-                $registered = true;
202
-            }
203
-        }
204
-        // now add our two lists of dependencies together.
205
-        // using Union (+=) favours the arrays in precedence from left to right,
206
-        // so $dependencies is NOT overwritten because it is listed first
207
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
208
-        // Union is way faster than array_merge() but should be used with caution...
209
-        // especially with numerically indexed arrays
210
-        $dependencies += self::$_instance->_dependency_map[ $class ];
211
-        // now we need to ensure that the resulting dependencies
212
-        // array only has the entries that are required for the class
213
-        // so first count how many dependencies were originally registered for the class
214
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
215
-        // if that count is non-zero (meaning dependencies were already registered)
216
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
217
-            // then truncate the  final array to match that count
218
-            ? array_slice($dependencies, 0, $dependency_count)
219
-            // otherwise just take the incoming array because nothing previously existed
220
-            : $dependencies;
221
-        return $registered;
222
-    }
223
-
224
-
225
-
226
-    /**
227
-     * @param string $class_name
228
-     * @param string $loader
229
-     * @return bool
230
-     * @throws DomainException
231
-     */
232
-    public static function register_class_loader($class_name, $loader = 'load_core')
233
-    {
234
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
235
-            throw new DomainException(
236
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
237
-            );
238
-        }
239
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
240
-        if (
241
-            ! is_callable($loader)
242
-            && (
243
-                strpos($loader, 'load_') !== 0
244
-                || ! method_exists('EE_Registry', $loader)
245
-            )
246
-        ) {
247
-            throw new DomainException(
248
-                sprintf(
249
-                    esc_html__(
250
-                        '"%1$s" is not a valid loader method on EE_Registry.',
251
-                        'event_espresso'
252
-                    ),
253
-                    $loader
254
-                )
255
-            );
256
-        }
257
-        $class_name = self::$_instance->get_alias($class_name);
258
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
259
-            self::$_instance->_class_loaders[$class_name] = $loader;
260
-            return true;
261
-        }
262
-        return false;
263
-    }
264
-
265
-
266
-
267
-    /**
268
-     * @return array
269
-     */
270
-    public function dependency_map()
271
-    {
272
-        return $this->_dependency_map;
273
-    }
274
-
275
-
276
-
277
-    /**
278
-     * returns TRUE if dependency map contains a listing for the provided class name
279
-     *
280
-     * @param string $class_name
281
-     * @return boolean
282
-     */
283
-    public function has($class_name = '')
284
-    {
285
-        // all legacy models have the same dependencies
286
-        if (strpos($class_name, 'EEM_') === 0) {
287
-            $class_name = 'LEGACY_MODELS';
288
-        }
289
-        return isset($this->_dependency_map[$class_name]) ? true : false;
290
-    }
291
-
292
-
293
-
294
-    /**
295
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
296
-     *
297
-     * @param string $class_name
298
-     * @param string $dependency
299
-     * @return bool
300
-     */
301
-    public function has_dependency_for_class($class_name = '', $dependency = '')
302
-    {
303
-        // all legacy models have the same dependencies
304
-        if (strpos($class_name, 'EEM_') === 0) {
305
-            $class_name = 'LEGACY_MODELS';
306
-        }
307
-        $dependency = $this->get_alias($dependency);
308
-        return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency])
309
-            ? true
310
-            : false;
311
-    }
312
-
313
-
314
-
315
-    /**
316
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
317
-     *
318
-     * @param string $class_name
319
-     * @param string $dependency
320
-     * @return int
321
-     */
322
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
323
-    {
324
-        // all legacy models have the same dependencies
325
-        if (strpos($class_name, 'EEM_') === 0) {
326
-            $class_name = 'LEGACY_MODELS';
327
-        }
328
-        $dependency = $this->get_alias($dependency);
329
-        return $this->has_dependency_for_class($class_name, $dependency)
330
-            ? $this->_dependency_map[$class_name][$dependency]
331
-            : EE_Dependency_Map::not_registered;
332
-    }
333
-
334
-
335
-
336
-    /**
337
-     * @param string $class_name
338
-     * @return string | Closure
339
-     */
340
-    public function class_loader($class_name)
341
-    {
342
-        // all legacy models use load_model()
343
-        if(strpos($class_name, 'EEM_') === 0){
344
-            return 'load_model';
345
-        }
346
-        $class_name = $this->get_alias($class_name);
347
-        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
348
-    }
349
-
350
-
351
-
352
-    /**
353
-     * @return array
354
-     */
355
-    public function class_loaders()
356
-    {
357
-        return $this->_class_loaders;
358
-    }
359
-
360
-
361
-
362
-    /**
363
-     * adds an alias for a classname
364
-     *
365
-     * @param string $class_name the class name that should be used (concrete class to replace interface)
366
-     * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
367
-     * @param string $for_class  the class that has the dependency (is type hinting for the interface)
368
-     */
369
-    public function add_alias($class_name, $alias, $for_class = '')
370
-    {
371
-        if ($for_class !== '') {
372
-            if (! isset($this->_aliases[$for_class])) {
373
-                $this->_aliases[$for_class] = array();
374
-            }
375
-            $this->_aliases[$for_class][$class_name] = $alias;
376
-        }
377
-        $this->_aliases[$class_name] = $alias;
378
-    }
379
-
380
-
381
-
382
-    /**
383
-     * returns TRUE if the provided class name has an alias
384
-     *
385
-     * @param string $class_name
386
-     * @param string $for_class
387
-     * @return bool
388
-     */
389
-    public function has_alias($class_name = '', $for_class = '')
390
-    {
391
-        return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name])
392
-               || (
393
-                   isset($this->_aliases[$class_name])
394
-                   && ! is_array($this->_aliases[$class_name])
395
-               );
396
-    }
397
-
398
-
399
-
400
-    /**
401
-     * returns alias for class name if one exists, otherwise returns the original classname
402
-     * functions recursively, so that multiple aliases can be used to drill down to a classname
403
-     *  for example:
404
-     *      if the following two entries were added to the _aliases array:
405
-     *          array(
406
-     *              'interface_alias'           => 'some\namespace\interface'
407
-     *              'some\namespace\interface'  => 'some\namespace\classname'
408
-     *          )
409
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
410
-     *      to load an instance of 'some\namespace\classname'
411
-     *
412
-     * @param string $class_name
413
-     * @param string $for_class
414
-     * @return string
415
-     */
416
-    public function get_alias($class_name = '', $for_class = '')
417
-    {
418
-        if (! $this->has_alias($class_name, $for_class)) {
419
-            return $class_name;
420
-        }
421
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
422
-            return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
423
-        }
424
-        return $this->get_alias($this->_aliases[$class_name]);
425
-    }
426
-
427
-
428
-
429
-    /**
430
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
431
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
432
-     * This is done by using the following class constants:
433
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
434
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
435
-     */
436
-    protected function _register_core_dependencies()
437
-    {
438
-        $this->_dependency_map = array(
439
-            'EE_Request_Handler'                                                                                          => array(
440
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
441
-            ),
442
-            'EE_System'                                                                                                   => array(
443
-                'EE_Registry'                                => EE_Dependency_Map::load_from_cache,
444
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
445
-                'EE_Capabilities'                            => EE_Dependency_Map::load_from_cache,
446
-                'EE_Request'                                 => EE_Dependency_Map::load_from_cache,
447
-                'EE_Maintenance_Mode'                        => EE_Dependency_Map::load_from_cache,
448
-            ),
449
-            'EE_Session'                                                                                                  => array(
450
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
451
-                'EE_Encryption'                                           => EE_Dependency_Map::load_from_cache,
452
-            ),
453
-            'EE_Cart'                                                                                                     => array(
454
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
455
-            ),
456
-            'EE_Front_Controller'                                                                                         => array(
457
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
458
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
459
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
460
-            ),
461
-            'EE_Messenger_Collection_Loader'                                                                              => array(
462
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
463
-            ),
464
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
465
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
466
-            ),
467
-            'EE_Message_Resource_Manager'                                                                                 => array(
468
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
469
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
470
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
471
-            ),
472
-            'EE_Message_Factory'                                                                                          => array(
473
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
474
-            ),
475
-            'EE_messages'                                                                                                 => array(
476
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
477
-            ),
478
-            'EE_Messages_Generator'                                                                                       => array(
479
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
480
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
481
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
482
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
483
-            ),
484
-            'EE_Messages_Processor'                                                                                       => array(
485
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
-            ),
487
-            'EE_Messages_Queue'                                                                                           => array(
488
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
489
-            ),
490
-            'EE_Messages_Template_Defaults'                                                                               => array(
491
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
492
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
493
-            ),
494
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
495
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
496
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
497
-            ),
498
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
499
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
500
-            ),
501
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
502
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
503
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
504
-            ),
505
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
506
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
507
-            ),
508
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
509
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
510
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
511
-            ),
512
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
513
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
514
-            ),
515
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
516
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
517
-            ),
518
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
519
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
522
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
523
-            ),
524
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
525
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
526
-            ),
527
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
528
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
529
-            ),
530
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
531
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
532
-            ),
533
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
534
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
535
-            ),
536
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
537
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
540
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
543
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
546
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
549
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
552
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EE_Data_Migration_Class_Base'                                                                                => array(
555
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
556
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
557
-            ),
558
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
559
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
560
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
561
-            ),
562
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
563
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
564
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
565
-            ),
566
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
567
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
568
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
569
-            ),
570
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
571
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
572
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
573
-            ),
574
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
575
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
576
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
577
-            ),
578
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
579
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
581
-            ),
582
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
583
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
585
-            ),
586
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
587
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
588
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
589
-            ),
590
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
591
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
592
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
593
-            ),
594
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
595
-                'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
596
-                'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
597
-            ),
598
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
599
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
600
-            ),
601
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
602
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
603
-            ),
604
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
605
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
606
-            ),
607
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
608
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
609
-            ),
610
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
611
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
612
-            ),
613
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
614
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
615
-            ),
616
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
617
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
-            ),
619
-            'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
620
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
621
-            ),
622
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
623
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
624
-            ),
625
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
626
-                'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
627
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
628
-            ),
629
-            'EventEspresso\core\domain\values\EmailAddress'                              => array(
630
-                null,
631
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
632
-            ),
633
-            'EventEspresso\core\services\orm\ModelFieldFactory' => array(
634
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
635
-            ),
636
-            'LEGACY_MODELS'                                                   => array(
637
-                null,
638
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
639
-            ),
640
-            'EE_Module_Request_Router' => array(
641
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
642
-            ),
643
-            'EE_Registration_Processor' => array(
644
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
645
-            ),
646
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
647
-                null,
648
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
649
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
650
-            ),
651
-            'EventEspresso\core\services\licensing\LicenseService' => array(
652
-                'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache,
653
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache
654
-            ),
655
-            'EventEspresso\core\domain\services\pue\Stats' => array(
656
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
657
-                'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache,
658
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache
659
-            ),
660
-            'EventEspresso\core\domain\services\pue\Config' => array(
661
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
662
-                'EE_Config' => EE_Dependency_Map::load_from_cache
663
-            ),
664
-            'EventEspresso\core\domain\services\pue\StatsGatherer' => array(
665
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
666
-                'EEM_Event' => EE_Dependency_Map::load_from_cache,
667
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
668
-                'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
669
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
670
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
671
-                'EE_Config' => EE_Dependency_Map::load_from_cache
672
-            )
673
-        );
674
-    }
675
-
676
-
677
-
678
-    /**
679
-     * Registers how core classes are loaded.
680
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
681
-     *        'EE_Request_Handler' => 'load_core'
682
-     *        'EE_Messages_Queue'  => 'load_lib'
683
-     *        'EEH_Debug_Tools'    => 'load_helper'
684
-     * or, if greater control is required, by providing a custom closure. For example:
685
-     *        'Some_Class' => function () {
686
-     *            return new Some_Class();
687
-     *        },
688
-     * This is required for instantiating dependencies
689
-     * where an interface has been type hinted in a class constructor. For example:
690
-     *        'Required_Interface' => function () {
691
-     *            return new A_Class_That_Implements_Required_Interface();
692
-     *        },
693
-     *
694
-     * @throws InvalidInterfaceException
695
-     * @throws InvalidDataTypeException
696
-     * @throws InvalidArgumentException
697
-     */
698
-    protected function _register_core_class_loaders()
699
-    {
700
-        //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
701
-        //be used in a closure.
702
-        $request = &$this->_request;
703
-        $response = &$this->_response;
704
-        //models (EEM_Base children) automatically have loaders registered elsewhere
705
-        //@see self::class_loader()
706
-        $this->_class_loaders = array(
707
-            //load_core
708
-            'EE_Capabilities'                      => 'load_core',
709
-            'EE_Encryption'                        => 'load_core',
710
-            'EE_Front_Controller'                  => 'load_core',
711
-            'EE_Module_Request_Router'             => 'load_core',
712
-            'EE_Registry'                          => 'load_core',
713
-            'EE_Request'                           => function () use (&$request) {
714
-                return $request;
715
-            },
716
-            'EE_Response'                          => function () use (&$response) {
717
-                return $response;
718
-            },
719
-            'EE_Request_Handler'                   => 'load_core',
720
-            'EE_Session'                           => 'load_core',
721
-            'EE_Cron_Tasks'                        => 'load_core',
722
-            'EE_System'                            => 'load_core',
723
-            'EE_Maintenance_Mode'                  => 'load_core',
724
-            'EE_Register_CPTs'                     => 'load_core',
725
-            'EE_Admin'                             => 'load_core',
726
-            //load_lib
727
-            'EE_Message_Resource_Manager'          => 'load_lib',
728
-            'EE_Message_Type_Collection'           => 'load_lib',
729
-            'EE_Message_Type_Collection_Loader'    => 'load_lib',
730
-            'EE_Messenger_Collection'              => 'load_lib',
731
-            'EE_Messenger_Collection_Loader'       => 'load_lib',
732
-            'EE_Messages_Processor'                => 'load_lib',
733
-            'EE_Message_Repository'                => 'load_lib',
734
-            'EE_Messages_Queue'                    => 'load_lib',
735
-            'EE_Messages_Data_Handler_Collection'  => 'load_lib',
736
-            'EE_Message_Template_Group_Collection' => 'load_lib',
737
-            'EE_Payment_Method_Manager'            => 'load_lib',
738
-            'EE_Messages_Generator'                => function () {
739
-                return EE_Registry::instance()->load_lib(
740
-                    'Messages_Generator',
741
-                    array(),
742
-                    false,
743
-                    false
744
-                );
745
-            },
746
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
747
-                return EE_Registry::instance()->load_lib(
748
-                    'Messages_Template_Defaults',
749
-                    $arguments,
750
-                    false,
751
-                    false
752
-                );
753
-            },
754
-            //load_helper
755
-            'EEH_Parse_Shortcodes'                 => function () {
756
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
757
-                    return new EEH_Parse_Shortcodes();
758
-                }
759
-                return null;
760
-            },
761
-            'EE_Template_Config'                   => function () {
762
-                return EE_Config::instance()->template_settings;
763
-            },
764
-            'EE_Currency_Config'                   => function () {
765
-                return EE_Config::instance()->currency;
766
-            },
767
-            'EE_Registration_Config'                   => function () {
768
-                return EE_Config::instance()->registration;
769
-            },
770
-            'EventEspresso\core\services\loaders\Loader' => function () {
771
-                return LoaderFactory::getLoader();
772
-            },
773
-            'EE_Network_Config' => function() {
774
-                return EE_Network_Config::instance();
775
-            },
776
-            'EE_Config' => function () {
777
-                return EE_Config::instance();
778
-            }
779
-        );
780
-    }
781
-
782
-
783
-
784
-    /**
785
-     * can be used for supplying alternate names for classes,
786
-     * or for connecting interface names to instantiable classes
787
-     */
788
-    protected function _register_core_aliases()
789
-    {
790
-        $this->_aliases = array(
791
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
792
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
793
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
794
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
795
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
796
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
797
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
798
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
799
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
800
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
801
-            'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
802
-            'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
803
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
804
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
805
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
806
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
807
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
808
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
809
-            'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
810
-            'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
811
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
812
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
813
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
814
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
815
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
816
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
817
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
818
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
819
-            'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
820
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
821
-            'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
822
-            'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
823
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
824
-            'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
825
-            'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
826
-            'NoticesContainerInterface'                                            => 'EventEspresso\core\services\notices\NoticesContainerInterface',
827
-            'EventEspresso\core\services\notices\NoticesContainerInterface'        => 'EventEspresso\core\services\notices\NoticesContainer',
828
-        );
829
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
830
-            $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
831
-        }
832
-    }
833
-
834
-
835
-
836
-    /**
837
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
838
-     * request Primarily used by unit tests.
839
-     *
840
-     * @throws InvalidDataTypeException
841
-     * @throws InvalidInterfaceException
842
-     * @throws InvalidArgumentException
843
-     */
844
-    public function reset()
845
-    {
846
-        $this->_register_core_class_loaders();
847
-        $this->_register_core_dependencies();
848
-    }
25
+	/**
26
+	 * This means that the requested class dependency is not present in the dependency map
27
+	 */
28
+	const not_registered = 0;
29
+
30
+	/**
31
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
32
+	 */
33
+	const load_new_object = 1;
34
+
35
+	/**
36
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
37
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
38
+	 */
39
+	const load_from_cache = 2;
40
+
41
+	/**
42
+	 * When registering a dependency,
43
+	 * this indicates to keep any existing dependencies that already exist,
44
+	 * and simply discard any new dependencies declared in the incoming data
45
+	 */
46
+	const KEEP_EXISTING_DEPENDENCIES = 0;
47
+
48
+	/**
49
+	 * When registering a dependency,
50
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
51
+	 */
52
+	const OVERWRITE_DEPENDENCIES = 1;
53
+
54
+
55
+
56
+	/**
57
+	 * @type EE_Dependency_Map $_instance
58
+	 */
59
+	protected static $_instance;
60
+
61
+	/**
62
+	 * @type EE_Request $request
63
+	 */
64
+	protected $_request;
65
+
66
+	/**
67
+	 * @type EE_Response $response
68
+	 */
69
+	protected $_response;
70
+
71
+	/**
72
+	 * @type LoaderInterface $loader
73
+	 */
74
+	protected $loader;
75
+
76
+	/**
77
+	 * @type array $_dependency_map
78
+	 */
79
+	protected $_dependency_map = array();
80
+
81
+	/**
82
+	 * @type array $_class_loaders
83
+	 */
84
+	protected $_class_loaders = array();
85
+
86
+	/**
87
+	 * @type array $_aliases
88
+	 */
89
+	protected $_aliases = array();
90
+
91
+
92
+
93
+	/**
94
+	 * EE_Dependency_Map constructor.
95
+	 *
96
+	 * @param EE_Request  $request
97
+	 * @param EE_Response $response
98
+	 */
99
+	protected function __construct(EE_Request $request, EE_Response $response)
100
+	{
101
+		$this->_request = $request;
102
+		$this->_response = $response;
103
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
104
+		do_action('EE_Dependency_Map____construct');
105
+	}
106
+
107
+
108
+
109
+	/**
110
+	 * @throws InvalidDataTypeException
111
+	 * @throws InvalidInterfaceException
112
+	 * @throws InvalidArgumentException
113
+	 */
114
+	public function initialize()
115
+	{
116
+		$this->_register_core_dependencies();
117
+		$this->_register_core_class_loaders();
118
+		$this->_register_core_aliases();
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 * @singleton method used to instantiate class object
125
+	 * @access    public
126
+	 * @param EE_Request  $request
127
+	 * @param EE_Response $response
128
+	 * @return EE_Dependency_Map
129
+	 */
130
+	public static function instance(EE_Request $request = null, EE_Response $response = null)
131
+	{
132
+		// check if class object is instantiated, and instantiated properly
133
+		if (! self::$_instance instanceof EE_Dependency_Map) {
134
+			self::$_instance = new EE_Dependency_Map($request, $response);
135
+		}
136
+		return self::$_instance;
137
+	}
138
+
139
+
140
+
141
+	/**
142
+	 * @param LoaderInterface $loader
143
+	 */
144
+	public function setLoader(LoaderInterface $loader)
145
+	{
146
+		$this->loader = $loader;
147
+	}
148
+
149
+
150
+
151
+	/**
152
+	 * @param string $class
153
+	 * @param array  $dependencies
154
+	 * @param int    $overwrite
155
+	 * @return bool
156
+	 */
157
+	public static function register_dependencies(
158
+		$class,
159
+		array $dependencies,
160
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
161
+	) {
162
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * Assigns an array of class names and corresponding load sources (new or cached)
169
+	 * to the class specified by the first parameter.
170
+	 * IMPORTANT !!!
171
+	 * The order of elements in the incoming $dependencies array MUST match
172
+	 * the order of the constructor parameters for the class in question.
173
+	 * This is especially important when overriding any existing dependencies that are registered.
174
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
175
+	 *
176
+	 * @param string $class
177
+	 * @param array  $dependencies
178
+	 * @param int    $overwrite
179
+	 * @return bool
180
+	 */
181
+	public function registerDependencies(
182
+		$class,
183
+		array $dependencies,
184
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
185
+	) {
186
+		$class = trim($class, '\\');
187
+		$registered = false;
188
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
189
+			self::$_instance->_dependency_map[ $class ] = array();
190
+		}
191
+		// we need to make sure that any aliases used when registering a dependency
192
+		// get resolved to the correct class name
193
+		foreach ((array)$dependencies as $dependency => $load_source) {
194
+			$alias = self::$_instance->get_alias($dependency);
195
+			if (
196
+				$overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
197
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
198
+			) {
199
+				unset($dependencies[$dependency]);
200
+				$dependencies[$alias] = $load_source;
201
+				$registered = true;
202
+			}
203
+		}
204
+		// now add our two lists of dependencies together.
205
+		// using Union (+=) favours the arrays in precedence from left to right,
206
+		// so $dependencies is NOT overwritten because it is listed first
207
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
208
+		// Union is way faster than array_merge() but should be used with caution...
209
+		// especially with numerically indexed arrays
210
+		$dependencies += self::$_instance->_dependency_map[ $class ];
211
+		// now we need to ensure that the resulting dependencies
212
+		// array only has the entries that are required for the class
213
+		// so first count how many dependencies were originally registered for the class
214
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
215
+		// if that count is non-zero (meaning dependencies were already registered)
216
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
217
+			// then truncate the  final array to match that count
218
+			? array_slice($dependencies, 0, $dependency_count)
219
+			// otherwise just take the incoming array because nothing previously existed
220
+			: $dependencies;
221
+		return $registered;
222
+	}
223
+
224
+
225
+
226
+	/**
227
+	 * @param string $class_name
228
+	 * @param string $loader
229
+	 * @return bool
230
+	 * @throws DomainException
231
+	 */
232
+	public static function register_class_loader($class_name, $loader = 'load_core')
233
+	{
234
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
235
+			throw new DomainException(
236
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
237
+			);
238
+		}
239
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
240
+		if (
241
+			! is_callable($loader)
242
+			&& (
243
+				strpos($loader, 'load_') !== 0
244
+				|| ! method_exists('EE_Registry', $loader)
245
+			)
246
+		) {
247
+			throw new DomainException(
248
+				sprintf(
249
+					esc_html__(
250
+						'"%1$s" is not a valid loader method on EE_Registry.',
251
+						'event_espresso'
252
+					),
253
+					$loader
254
+				)
255
+			);
256
+		}
257
+		$class_name = self::$_instance->get_alias($class_name);
258
+		if (! isset(self::$_instance->_class_loaders[$class_name])) {
259
+			self::$_instance->_class_loaders[$class_name] = $loader;
260
+			return true;
261
+		}
262
+		return false;
263
+	}
264
+
265
+
266
+
267
+	/**
268
+	 * @return array
269
+	 */
270
+	public function dependency_map()
271
+	{
272
+		return $this->_dependency_map;
273
+	}
274
+
275
+
276
+
277
+	/**
278
+	 * returns TRUE if dependency map contains a listing for the provided class name
279
+	 *
280
+	 * @param string $class_name
281
+	 * @return boolean
282
+	 */
283
+	public function has($class_name = '')
284
+	{
285
+		// all legacy models have the same dependencies
286
+		if (strpos($class_name, 'EEM_') === 0) {
287
+			$class_name = 'LEGACY_MODELS';
288
+		}
289
+		return isset($this->_dependency_map[$class_name]) ? true : false;
290
+	}
291
+
292
+
293
+
294
+	/**
295
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
296
+	 *
297
+	 * @param string $class_name
298
+	 * @param string $dependency
299
+	 * @return bool
300
+	 */
301
+	public function has_dependency_for_class($class_name = '', $dependency = '')
302
+	{
303
+		// all legacy models have the same dependencies
304
+		if (strpos($class_name, 'EEM_') === 0) {
305
+			$class_name = 'LEGACY_MODELS';
306
+		}
307
+		$dependency = $this->get_alias($dependency);
308
+		return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency])
309
+			? true
310
+			: false;
311
+	}
312
+
313
+
314
+
315
+	/**
316
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
317
+	 *
318
+	 * @param string $class_name
319
+	 * @param string $dependency
320
+	 * @return int
321
+	 */
322
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
323
+	{
324
+		// all legacy models have the same dependencies
325
+		if (strpos($class_name, 'EEM_') === 0) {
326
+			$class_name = 'LEGACY_MODELS';
327
+		}
328
+		$dependency = $this->get_alias($dependency);
329
+		return $this->has_dependency_for_class($class_name, $dependency)
330
+			? $this->_dependency_map[$class_name][$dependency]
331
+			: EE_Dependency_Map::not_registered;
332
+	}
333
+
334
+
335
+
336
+	/**
337
+	 * @param string $class_name
338
+	 * @return string | Closure
339
+	 */
340
+	public function class_loader($class_name)
341
+	{
342
+		// all legacy models use load_model()
343
+		if(strpos($class_name, 'EEM_') === 0){
344
+			return 'load_model';
345
+		}
346
+		$class_name = $this->get_alias($class_name);
347
+		return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
348
+	}
349
+
350
+
351
+
352
+	/**
353
+	 * @return array
354
+	 */
355
+	public function class_loaders()
356
+	{
357
+		return $this->_class_loaders;
358
+	}
359
+
360
+
361
+
362
+	/**
363
+	 * adds an alias for a classname
364
+	 *
365
+	 * @param string $class_name the class name that should be used (concrete class to replace interface)
366
+	 * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
367
+	 * @param string $for_class  the class that has the dependency (is type hinting for the interface)
368
+	 */
369
+	public function add_alias($class_name, $alias, $for_class = '')
370
+	{
371
+		if ($for_class !== '') {
372
+			if (! isset($this->_aliases[$for_class])) {
373
+				$this->_aliases[$for_class] = array();
374
+			}
375
+			$this->_aliases[$for_class][$class_name] = $alias;
376
+		}
377
+		$this->_aliases[$class_name] = $alias;
378
+	}
379
+
380
+
381
+
382
+	/**
383
+	 * returns TRUE if the provided class name has an alias
384
+	 *
385
+	 * @param string $class_name
386
+	 * @param string $for_class
387
+	 * @return bool
388
+	 */
389
+	public function has_alias($class_name = '', $for_class = '')
390
+	{
391
+		return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name])
392
+			   || (
393
+				   isset($this->_aliases[$class_name])
394
+				   && ! is_array($this->_aliases[$class_name])
395
+			   );
396
+	}
397
+
398
+
399
+
400
+	/**
401
+	 * returns alias for class name if one exists, otherwise returns the original classname
402
+	 * functions recursively, so that multiple aliases can be used to drill down to a classname
403
+	 *  for example:
404
+	 *      if the following two entries were added to the _aliases array:
405
+	 *          array(
406
+	 *              'interface_alias'           => 'some\namespace\interface'
407
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
408
+	 *          )
409
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
410
+	 *      to load an instance of 'some\namespace\classname'
411
+	 *
412
+	 * @param string $class_name
413
+	 * @param string $for_class
414
+	 * @return string
415
+	 */
416
+	public function get_alias($class_name = '', $for_class = '')
417
+	{
418
+		if (! $this->has_alias($class_name, $for_class)) {
419
+			return $class_name;
420
+		}
421
+		if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
422
+			return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
423
+		}
424
+		return $this->get_alias($this->_aliases[$class_name]);
425
+	}
426
+
427
+
428
+
429
+	/**
430
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
431
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
432
+	 * This is done by using the following class constants:
433
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
434
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
435
+	 */
436
+	protected function _register_core_dependencies()
437
+	{
438
+		$this->_dependency_map = array(
439
+			'EE_Request_Handler'                                                                                          => array(
440
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
441
+			),
442
+			'EE_System'                                                                                                   => array(
443
+				'EE_Registry'                                => EE_Dependency_Map::load_from_cache,
444
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
445
+				'EE_Capabilities'                            => EE_Dependency_Map::load_from_cache,
446
+				'EE_Request'                                 => EE_Dependency_Map::load_from_cache,
447
+				'EE_Maintenance_Mode'                        => EE_Dependency_Map::load_from_cache,
448
+			),
449
+			'EE_Session'                                                                                                  => array(
450
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
451
+				'EE_Encryption'                                           => EE_Dependency_Map::load_from_cache,
452
+			),
453
+			'EE_Cart'                                                                                                     => array(
454
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
455
+			),
456
+			'EE_Front_Controller'                                                                                         => array(
457
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
458
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
459
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
460
+			),
461
+			'EE_Messenger_Collection_Loader'                                                                              => array(
462
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
463
+			),
464
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
465
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
466
+			),
467
+			'EE_Message_Resource_Manager'                                                                                 => array(
468
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
469
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
470
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
471
+			),
472
+			'EE_Message_Factory'                                                                                          => array(
473
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
474
+			),
475
+			'EE_messages'                                                                                                 => array(
476
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
477
+			),
478
+			'EE_Messages_Generator'                                                                                       => array(
479
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
480
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
481
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
482
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
483
+			),
484
+			'EE_Messages_Processor'                                                                                       => array(
485
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
+			),
487
+			'EE_Messages_Queue'                                                                                           => array(
488
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
489
+			),
490
+			'EE_Messages_Template_Defaults'                                                                               => array(
491
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
492
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
493
+			),
494
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
495
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
496
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
497
+			),
498
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
499
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
500
+			),
501
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
502
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
503
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
504
+			),
505
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
506
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
507
+			),
508
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
509
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
510
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
511
+			),
512
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
513
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
514
+			),
515
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
516
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
517
+			),
518
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
519
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
522
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
523
+			),
524
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
525
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
526
+			),
527
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
528
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
529
+			),
530
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
531
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
532
+			),
533
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
534
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
535
+			),
536
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
537
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
540
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
543
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
546
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
549
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
552
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EE_Data_Migration_Class_Base'                                                                                => array(
555
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
556
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
557
+			),
558
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
559
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
560
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
561
+			),
562
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
563
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
564
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
565
+			),
566
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
567
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
568
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
569
+			),
570
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
571
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
572
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
573
+			),
574
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
575
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
576
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
577
+			),
578
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
579
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
581
+			),
582
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
583
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
585
+			),
586
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
587
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
588
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
589
+			),
590
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
591
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
592
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
593
+			),
594
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
595
+				'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
596
+				'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
597
+			),
598
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
599
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
600
+			),
601
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
602
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
603
+			),
604
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
605
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
606
+			),
607
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
608
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
609
+			),
610
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
611
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
612
+			),
613
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
614
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
615
+			),
616
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
617
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
+			),
619
+			'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
620
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
621
+			),
622
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
623
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
624
+			),
625
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
626
+				'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
627
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
628
+			),
629
+			'EventEspresso\core\domain\values\EmailAddress'                              => array(
630
+				null,
631
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
632
+			),
633
+			'EventEspresso\core\services\orm\ModelFieldFactory' => array(
634
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
635
+			),
636
+			'LEGACY_MODELS'                                                   => array(
637
+				null,
638
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
639
+			),
640
+			'EE_Module_Request_Router' => array(
641
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
642
+			),
643
+			'EE_Registration_Processor' => array(
644
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
645
+			),
646
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array(
647
+				null,
648
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
649
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
650
+			),
651
+			'EventEspresso\core\services\licensing\LicenseService' => array(
652
+				'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache,
653
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache
654
+			),
655
+			'EventEspresso\core\domain\services\pue\Stats' => array(
656
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
657
+				'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache,
658
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache
659
+			),
660
+			'EventEspresso\core\domain\services\pue\Config' => array(
661
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
662
+				'EE_Config' => EE_Dependency_Map::load_from_cache
663
+			),
664
+			'EventEspresso\core\domain\services\pue\StatsGatherer' => array(
665
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
666
+				'EEM_Event' => EE_Dependency_Map::load_from_cache,
667
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
668
+				'EEM_Ticket' => EE_Dependency_Map::load_from_cache,
669
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
670
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
671
+				'EE_Config' => EE_Dependency_Map::load_from_cache
672
+			)
673
+		);
674
+	}
675
+
676
+
677
+
678
+	/**
679
+	 * Registers how core classes are loaded.
680
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
681
+	 *        'EE_Request_Handler' => 'load_core'
682
+	 *        'EE_Messages_Queue'  => 'load_lib'
683
+	 *        'EEH_Debug_Tools'    => 'load_helper'
684
+	 * or, if greater control is required, by providing a custom closure. For example:
685
+	 *        'Some_Class' => function () {
686
+	 *            return new Some_Class();
687
+	 *        },
688
+	 * This is required for instantiating dependencies
689
+	 * where an interface has been type hinted in a class constructor. For example:
690
+	 *        'Required_Interface' => function () {
691
+	 *            return new A_Class_That_Implements_Required_Interface();
692
+	 *        },
693
+	 *
694
+	 * @throws InvalidInterfaceException
695
+	 * @throws InvalidDataTypeException
696
+	 * @throws InvalidArgumentException
697
+	 */
698
+	protected function _register_core_class_loaders()
699
+	{
700
+		//for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
701
+		//be used in a closure.
702
+		$request = &$this->_request;
703
+		$response = &$this->_response;
704
+		//models (EEM_Base children) automatically have loaders registered elsewhere
705
+		//@see self::class_loader()
706
+		$this->_class_loaders = array(
707
+			//load_core
708
+			'EE_Capabilities'                      => 'load_core',
709
+			'EE_Encryption'                        => 'load_core',
710
+			'EE_Front_Controller'                  => 'load_core',
711
+			'EE_Module_Request_Router'             => 'load_core',
712
+			'EE_Registry'                          => 'load_core',
713
+			'EE_Request'                           => function () use (&$request) {
714
+				return $request;
715
+			},
716
+			'EE_Response'                          => function () use (&$response) {
717
+				return $response;
718
+			},
719
+			'EE_Request_Handler'                   => 'load_core',
720
+			'EE_Session'                           => 'load_core',
721
+			'EE_Cron_Tasks'                        => 'load_core',
722
+			'EE_System'                            => 'load_core',
723
+			'EE_Maintenance_Mode'                  => 'load_core',
724
+			'EE_Register_CPTs'                     => 'load_core',
725
+			'EE_Admin'                             => 'load_core',
726
+			//load_lib
727
+			'EE_Message_Resource_Manager'          => 'load_lib',
728
+			'EE_Message_Type_Collection'           => 'load_lib',
729
+			'EE_Message_Type_Collection_Loader'    => 'load_lib',
730
+			'EE_Messenger_Collection'              => 'load_lib',
731
+			'EE_Messenger_Collection_Loader'       => 'load_lib',
732
+			'EE_Messages_Processor'                => 'load_lib',
733
+			'EE_Message_Repository'                => 'load_lib',
734
+			'EE_Messages_Queue'                    => 'load_lib',
735
+			'EE_Messages_Data_Handler_Collection'  => 'load_lib',
736
+			'EE_Message_Template_Group_Collection' => 'load_lib',
737
+			'EE_Payment_Method_Manager'            => 'load_lib',
738
+			'EE_Messages_Generator'                => function () {
739
+				return EE_Registry::instance()->load_lib(
740
+					'Messages_Generator',
741
+					array(),
742
+					false,
743
+					false
744
+				);
745
+			},
746
+			'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
747
+				return EE_Registry::instance()->load_lib(
748
+					'Messages_Template_Defaults',
749
+					$arguments,
750
+					false,
751
+					false
752
+				);
753
+			},
754
+			//load_helper
755
+			'EEH_Parse_Shortcodes'                 => function () {
756
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
757
+					return new EEH_Parse_Shortcodes();
758
+				}
759
+				return null;
760
+			},
761
+			'EE_Template_Config'                   => function () {
762
+				return EE_Config::instance()->template_settings;
763
+			},
764
+			'EE_Currency_Config'                   => function () {
765
+				return EE_Config::instance()->currency;
766
+			},
767
+			'EE_Registration_Config'                   => function () {
768
+				return EE_Config::instance()->registration;
769
+			},
770
+			'EventEspresso\core\services\loaders\Loader' => function () {
771
+				return LoaderFactory::getLoader();
772
+			},
773
+			'EE_Network_Config' => function() {
774
+				return EE_Network_Config::instance();
775
+			},
776
+			'EE_Config' => function () {
777
+				return EE_Config::instance();
778
+			}
779
+		);
780
+	}
781
+
782
+
783
+
784
+	/**
785
+	 * can be used for supplying alternate names for classes,
786
+	 * or for connecting interface names to instantiable classes
787
+	 */
788
+	protected function _register_core_aliases()
789
+	{
790
+		$this->_aliases = array(
791
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
792
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
793
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
794
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
795
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
796
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
797
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
798
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
799
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
800
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
801
+			'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
802
+			'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
803
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
804
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
805
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
806
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
807
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
808
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
809
+			'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
810
+			'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
811
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
812
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
813
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
814
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
815
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
816
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
817
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
818
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
819
+			'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
820
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
821
+			'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
822
+			'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
823
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
824
+			'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
825
+			'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
826
+			'NoticesContainerInterface'                                            => 'EventEspresso\core\services\notices\NoticesContainerInterface',
827
+			'EventEspresso\core\services\notices\NoticesContainerInterface'        => 'EventEspresso\core\services\notices\NoticesContainer',
828
+		);
829
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
830
+			$this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
831
+		}
832
+	}
833
+
834
+
835
+
836
+	/**
837
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
838
+	 * request Primarily used by unit tests.
839
+	 *
840
+	 * @throws InvalidDataTypeException
841
+	 * @throws InvalidInterfaceException
842
+	 * @throws InvalidArgumentException
843
+	 */
844
+	public function reset()
845
+	{
846
+		$this->_register_core_class_loaders();
847
+		$this->_register_core_dependencies();
848
+	}
849 849
 
850 850
 
851 851
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\services\loaders\LoaderFactory;
5 5
 use EventEspresso\core\services\loaders\LoaderInterface;
6 6
 
7
-if (! defined('EVENT_ESPRESSO_VERSION')) {
7
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
8 8
     exit('No direct script access allowed');
9 9
 }
10 10
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     public static function instance(EE_Request $request = null, EE_Response $response = null)
131 131
     {
132 132
         // check if class object is instantiated, and instantiated properly
133
-        if (! self::$_instance instanceof EE_Dependency_Map) {
133
+        if ( ! self::$_instance instanceof EE_Dependency_Map) {
134 134
             self::$_instance = new EE_Dependency_Map($request, $response);
135 135
         }
136 136
         return self::$_instance;
@@ -185,16 +185,16 @@  discard block
 block discarded – undo
185 185
     ) {
186 186
         $class = trim($class, '\\');
187 187
         $registered = false;
188
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
189
-            self::$_instance->_dependency_map[ $class ] = array();
188
+        if (empty(self::$_instance->_dependency_map[$class])) {
189
+            self::$_instance->_dependency_map[$class] = array();
190 190
         }
191 191
         // we need to make sure that any aliases used when registering a dependency
192 192
         // get resolved to the correct class name
193
-        foreach ((array)$dependencies as $dependency => $load_source) {
193
+        foreach ((array) $dependencies as $dependency => $load_source) {
194 194
             $alias = self::$_instance->get_alias($dependency);
195 195
             if (
196 196
                 $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
197
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
197
+                || ! isset(self::$_instance->_dependency_map[$class][$alias])
198 198
             ) {
199 199
                 unset($dependencies[$dependency]);
200 200
                 $dependencies[$alias] = $load_source;
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
         // ie: with A = B + C, entries in B take precedence over duplicate entries in C
208 208
         // Union is way faster than array_merge() but should be used with caution...
209 209
         // especially with numerically indexed arrays
210
-        $dependencies += self::$_instance->_dependency_map[ $class ];
210
+        $dependencies += self::$_instance->_dependency_map[$class];
211 211
         // now we need to ensure that the resulting dependencies
212 212
         // array only has the entries that are required for the class
213 213
         // so first count how many dependencies were originally registered for the class
214
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
214
+        $dependency_count = count(self::$_instance->_dependency_map[$class]);
215 215
         // if that count is non-zero (meaning dependencies were already registered)
216
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
216
+        self::$_instance->_dependency_map[$class] = $dependency_count
217 217
             // then truncate the  final array to match that count
218 218
             ? array_slice($dependencies, 0, $dependency_count)
219 219
             // otherwise just take the incoming array because nothing previously existed
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
      */
232 232
     public static function register_class_loader($class_name, $loader = 'load_core')
233 233
     {
234
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
234
+        if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
235 235
             throw new DomainException(
236 236
                 esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
237 237
             );
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
             );
256 256
         }
257 257
         $class_name = self::$_instance->get_alias($class_name);
258
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
258
+        if ( ! isset(self::$_instance->_class_loaders[$class_name])) {
259 259
             self::$_instance->_class_loaders[$class_name] = $loader;
260 260
             return true;
261 261
         }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     public function class_loader($class_name)
341 341
     {
342 342
         // all legacy models use load_model()
343
-        if(strpos($class_name, 'EEM_') === 0){
343
+        if (strpos($class_name, 'EEM_') === 0) {
344 344
             return 'load_model';
345 345
         }
346 346
         $class_name = $this->get_alias($class_name);
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
     public function add_alias($class_name, $alias, $for_class = '')
370 370
     {
371 371
         if ($for_class !== '') {
372
-            if (! isset($this->_aliases[$for_class])) {
372
+            if ( ! isset($this->_aliases[$for_class])) {
373 373
                 $this->_aliases[$for_class] = array();
374 374
             }
375 375
             $this->_aliases[$for_class][$class_name] = $alias;
@@ -415,10 +415,10 @@  discard block
 block discarded – undo
415 415
      */
416 416
     public function get_alias($class_name = '', $for_class = '')
417 417
     {
418
-        if (! $this->has_alias($class_name, $for_class)) {
418
+        if ( ! $this->has_alias($class_name, $for_class)) {
419 419
             return $class_name;
420 420
         }
421
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
421
+        if ($for_class !== '' && isset($this->_aliases[$for_class][$class_name])) {
422 422
             return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
423 423
         }
424 424
         return $this->get_alias($this->_aliases[$class_name]);
@@ -710,10 +710,10 @@  discard block
 block discarded – undo
710 710
             'EE_Front_Controller'                  => 'load_core',
711 711
             'EE_Module_Request_Router'             => 'load_core',
712 712
             'EE_Registry'                          => 'load_core',
713
-            'EE_Request'                           => function () use (&$request) {
713
+            'EE_Request'                           => function() use (&$request) {
714 714
                 return $request;
715 715
             },
716
-            'EE_Response'                          => function () use (&$response) {
716
+            'EE_Response'                          => function() use (&$response) {
717 717
                 return $response;
718 718
             },
719 719
             'EE_Request_Handler'                   => 'load_core',
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
             'EE_Messages_Data_Handler_Collection'  => 'load_lib',
736 736
             'EE_Message_Template_Group_Collection' => 'load_lib',
737 737
             'EE_Payment_Method_Manager'            => 'load_lib',
738
-            'EE_Messages_Generator'                => function () {
738
+            'EE_Messages_Generator'                => function() {
739 739
                 return EE_Registry::instance()->load_lib(
740 740
                     'Messages_Generator',
741 741
                     array(),
@@ -743,7 +743,7 @@  discard block
 block discarded – undo
743 743
                     false
744 744
                 );
745 745
             },
746
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
746
+            'EE_Messages_Template_Defaults'        => function($arguments = array()) {
747 747
                 return EE_Registry::instance()->load_lib(
748 748
                     'Messages_Template_Defaults',
749 749
                     $arguments,
@@ -752,28 +752,28 @@  discard block
 block discarded – undo
752 752
                 );
753 753
             },
754 754
             //load_helper
755
-            'EEH_Parse_Shortcodes'                 => function () {
755
+            'EEH_Parse_Shortcodes'                 => function() {
756 756
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
757 757
                     return new EEH_Parse_Shortcodes();
758 758
                 }
759 759
                 return null;
760 760
             },
761
-            'EE_Template_Config'                   => function () {
761
+            'EE_Template_Config'                   => function() {
762 762
                 return EE_Config::instance()->template_settings;
763 763
             },
764
-            'EE_Currency_Config'                   => function () {
764
+            'EE_Currency_Config'                   => function() {
765 765
                 return EE_Config::instance()->currency;
766 766
             },
767
-            'EE_Registration_Config'                   => function () {
767
+            'EE_Registration_Config'                   => function() {
768 768
                 return EE_Config::instance()->registration;
769 769
             },
770
-            'EventEspresso\core\services\loaders\Loader' => function () {
770
+            'EventEspresso\core\services\loaders\Loader' => function() {
771 771
                 return LoaderFactory::getLoader();
772 772
             },
773 773
             'EE_Network_Config' => function() {
774 774
                 return EE_Network_Config::instance();
775 775
             },
776
-            'EE_Config' => function () {
776
+            'EE_Config' => function() {
777 777
                 return EE_Config::instance();
778 778
             }
779 779
         );
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
             'NoticesContainerInterface'                                            => 'EventEspresso\core\services\notices\NoticesContainerInterface',
827 827
             'EventEspresso\core\services\notices\NoticesContainerInterface'        => 'EventEspresso\core\services\notices\NoticesContainer',
828 828
         );
829
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
829
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
830 830
             $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
831 831
         }
832 832
     }
Please login to merge, or discard this patch.
core/domain/services/pue/StatsGatherer.php 2 patches
Indentation   +260 added lines, -260 removed lines patch added patch discarded remove patch
@@ -16,284 +16,284 @@
 block discarded – undo
16 16
 class StatsGatherer
17 17
 {
18 18
 
19
-    const COUNT_ALL_EVENTS = 'event';
20
-    const COUNT_ACTIVE_EVENTS = 'active_event';
21
-    const COUNT_DATETIMES = 'datetime';
22
-    const COUNT_TICKETS = 'ticket';
23
-    const COUNT_DATETIMES_SOLD = 'datetime_sold';
24
-    const COUNT_TICKETS_FREE = 'free_ticket';
25
-    const COUNT_TICKETS_PAID = 'paid_ticket';
26
-    const COUNT_TICKETS_SOLD = 'ticket_sold';
27
-    const COUNT_REGISTRATIONS_APPROVED = 'registrations_approved';
28
-    const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved';
29
-    const COUNT_REGISTRATIONS_PENDING = 'registrations_pending';
30
-    const COUNT_REGISTRATIONS_INCOMPLETE = 'registrations_incomplete';
31
-    const COUNT_REGISTRATIONS_ALL = 'registrations_all';
32
-    const COUNT_REGISTRATIONS_CANCELLED = 'registrations_cancelled';
33
-    const COUNT_REGISTRATIONS_DECLINED = 'registrations_declined';
34
-    const SUM_TRANSACTIONS_COMPLETE_TOTAL = 'transactions_complete_total_sum';
35
-    const SUM_TRANSACTIONS_ALL_PAID = 'transactions_all_paid';
36
-    const INFO_SITE_CURRENCY = 'site_currency';
19
+	const COUNT_ALL_EVENTS = 'event';
20
+	const COUNT_ACTIVE_EVENTS = 'active_event';
21
+	const COUNT_DATETIMES = 'datetime';
22
+	const COUNT_TICKETS = 'ticket';
23
+	const COUNT_DATETIMES_SOLD = 'datetime_sold';
24
+	const COUNT_TICKETS_FREE = 'free_ticket';
25
+	const COUNT_TICKETS_PAID = 'paid_ticket';
26
+	const COUNT_TICKETS_SOLD = 'ticket_sold';
27
+	const COUNT_REGISTRATIONS_APPROVED = 'registrations_approved';
28
+	const COUNT_REGISTRATIONS_NOT_APPROVED = 'registrations_not_approved';
29
+	const COUNT_REGISTRATIONS_PENDING = 'registrations_pending';
30
+	const COUNT_REGISTRATIONS_INCOMPLETE = 'registrations_incomplete';
31
+	const COUNT_REGISTRATIONS_ALL = 'registrations_all';
32
+	const COUNT_REGISTRATIONS_CANCELLED = 'registrations_cancelled';
33
+	const COUNT_REGISTRATIONS_DECLINED = 'registrations_declined';
34
+	const SUM_TRANSACTIONS_COMPLETE_TOTAL = 'transactions_complete_total_sum';
35
+	const SUM_TRANSACTIONS_ALL_PAID = 'transactions_all_paid';
36
+	const INFO_SITE_CURRENCY = 'site_currency';
37 37
 
38 38
 
39
-    /**
40
-     * @var EEM_Payment_Method
41
-     */
42
-    private $payment_method_model;
39
+	/**
40
+	 * @var EEM_Payment_Method
41
+	 */
42
+	private $payment_method_model;
43 43
 
44 44
 
45
-    /**
46
-     * @var EEM_Event
47
-     */
48
-    private $event_model;
45
+	/**
46
+	 * @var EEM_Event
47
+	 */
48
+	private $event_model;
49 49
 
50
-    /**
51
-     * @var EEM_Datetime
52
-     */
53
-    private $datetime_model;
50
+	/**
51
+	 * @var EEM_Datetime
52
+	 */
53
+	private $datetime_model;
54 54
 
55 55
 
56
-    /**
57
-     * @var EEM_Ticket
58
-     */
59
-    private $ticket_model;
56
+	/**
57
+	 * @var EEM_Ticket
58
+	 */
59
+	private $ticket_model;
60 60
 
61 61
 
62
-    /**
63
-     * @var EEM_Registration
64
-     */
65
-    private $registration_model;
62
+	/**
63
+	 * @var EEM_Registration
64
+	 */
65
+	private $registration_model;
66 66
 
67 67
 
68
-    /**
69
-     * @var EEM_Transaction
70
-     */
71
-    private $transaction_model;
68
+	/**
69
+	 * @var EEM_Transaction
70
+	 */
71
+	private $transaction_model;
72 72
 
73 73
 
74
-    /**
75
-     * @var EE_Config
76
-     */
77
-    private $config;
74
+	/**
75
+	 * @var EE_Config
76
+	 */
77
+	private $config;
78 78
 
79 79
 
80
-    /**
81
-     * StatsGatherer constructor.
82
-     *
83
-     * @param EEM_Payment_Method $payment_method_model
84
-     * @param EEM_Event          $event_model
85
-     * @param EEM_Datetime       $datetime_model
86
-     * @param EEM_Ticket         $ticket_model
87
-     * @param EEM_Registration   $registration_model
88
-     * @param EEM_Transaction    $transaction_model
89
-     * @param EE_Config          $config
90
-     */
91
-    public function __construct(
92
-        EEM_Payment_Method $payment_method_model,
93
-        EEM_Event $event_model,
94
-        EEM_Datetime $datetime_model,
95
-        EEM_Ticket $ticket_model,
96
-        EEM_Registration $registration_model,
97
-        EEM_Transaction $transaction_model,
98
-        EE_Config $config
99
-    ) {
100
-        $this->payment_method_model = $payment_method_model;
101
-        $this->event_model = $event_model;
102
-        $this->datetime_model = $datetime_model;
103
-        $this->ticket_model = $ticket_model;
104
-        $this->registration_model = $registration_model;
105
-        $this->transaction_model = $transaction_model;
106
-        $this->config = $config;
107
-    }
80
+	/**
81
+	 * StatsGatherer constructor.
82
+	 *
83
+	 * @param EEM_Payment_Method $payment_method_model
84
+	 * @param EEM_Event          $event_model
85
+	 * @param EEM_Datetime       $datetime_model
86
+	 * @param EEM_Ticket         $ticket_model
87
+	 * @param EEM_Registration   $registration_model
88
+	 * @param EEM_Transaction    $transaction_model
89
+	 * @param EE_Config          $config
90
+	 */
91
+	public function __construct(
92
+		EEM_Payment_Method $payment_method_model,
93
+		EEM_Event $event_model,
94
+		EEM_Datetime $datetime_model,
95
+		EEM_Ticket $ticket_model,
96
+		EEM_Registration $registration_model,
97
+		EEM_Transaction $transaction_model,
98
+		EE_Config $config
99
+	) {
100
+		$this->payment_method_model = $payment_method_model;
101
+		$this->event_model = $event_model;
102
+		$this->datetime_model = $datetime_model;
103
+		$this->ticket_model = $ticket_model;
104
+		$this->registration_model = $registration_model;
105
+		$this->transaction_model = $transaction_model;
106
+		$this->config = $config;
107
+	}
108 108
 
109 109
 
110
-    /**
111
-     * Return the stats array for PUE UXIP stats.
112
-     * @return array
113
-     */
114
-    public function stats()
115
-    {
116
-        $stats = $this->paymentMethodStats();
117
-        //a-ok so let's setup our stats.
118
-        $stats = array_merge($stats, array(
119
-            'is_multisite' => is_multisite() && is_main_site(),
120
-            'active_theme' => $this->getActiveThemeStat(),
121
-            'ee4_all_events_count' => $this->getCountFor(self::COUNT_ALL_EVENTS),
122
-            'ee4_active_events_count' => $this->getCountFor(self::COUNT_ACTIVE_EVENTS),
123
-            'all_dtts_count' => $this->getCountFor(self::COUNT_DATETIMES),
124
-            'dtt_sold' => $this->getCountFor(self::COUNT_DATETIMES_SOLD),
125
-            'all_tkt_count' => $this->getCountFor(self::COUNT_TICKETS),
126
-            'free_tkt_count' => $this->getCountFor(self::COUNT_TICKETS_FREE),
127
-            'paid_tkt_count' => $this->getCountFor(self::COUNT_TICKETS_PAID),
128
-            'tkt_sold' => $this->getCountFor(self::COUNT_TICKETS_SOLD),
129
-            'approve_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED),
130
-            'pending_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING),
131
-            'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED),
132
-            'incomplete_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE),
133
-            'cancelled_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED),
134
-            'declined_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED),
135
-            'all_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL),
136
-            'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL),
137
-            'all_transaction_paid_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID),
138
-            self::INFO_SITE_CURRENCY => $this->config->currency instanceof EE_Currency_Config
139
-                ? $this->config->currency->code
140
-                : 'unknown',
141
-            'phpversion' => implode('.', array(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION))
142
-        ));
143
-        //remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
144
-        return array_filter($stats, function ($value) {
145
-            return $value !== null;
146
-        });
147
-    }
110
+	/**
111
+	 * Return the stats array for PUE UXIP stats.
112
+	 * @return array
113
+	 */
114
+	public function stats()
115
+	{
116
+		$stats = $this->paymentMethodStats();
117
+		//a-ok so let's setup our stats.
118
+		$stats = array_merge($stats, array(
119
+			'is_multisite' => is_multisite() && is_main_site(),
120
+			'active_theme' => $this->getActiveThemeStat(),
121
+			'ee4_all_events_count' => $this->getCountFor(self::COUNT_ALL_EVENTS),
122
+			'ee4_active_events_count' => $this->getCountFor(self::COUNT_ACTIVE_EVENTS),
123
+			'all_dtts_count' => $this->getCountFor(self::COUNT_DATETIMES),
124
+			'dtt_sold' => $this->getCountFor(self::COUNT_DATETIMES_SOLD),
125
+			'all_tkt_count' => $this->getCountFor(self::COUNT_TICKETS),
126
+			'free_tkt_count' => $this->getCountFor(self::COUNT_TICKETS_FREE),
127
+			'paid_tkt_count' => $this->getCountFor(self::COUNT_TICKETS_PAID),
128
+			'tkt_sold' => $this->getCountFor(self::COUNT_TICKETS_SOLD),
129
+			'approve_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_APPROVED),
130
+			'pending_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_PENDING),
131
+			'not_approved_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_NOT_APPROVED),
132
+			'incomplete_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_INCOMPLETE),
133
+			'cancelled_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_CANCELLED),
134
+			'declined_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_DECLINED),
135
+			'all_registration_count' => $this->getCountFor(self::COUNT_REGISTRATIONS_ALL),
136
+			'completed_transaction_total_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_COMPLETE_TOTAL),
137
+			'all_transaction_paid_sum' => $this->getCountFor(self::SUM_TRANSACTIONS_ALL_PAID),
138
+			self::INFO_SITE_CURRENCY => $this->config->currency instanceof EE_Currency_Config
139
+				? $this->config->currency->code
140
+				: 'unknown',
141
+			'phpversion' => implode('.', array(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION))
142
+		));
143
+		//remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
144
+		return array_filter($stats, function ($value) {
145
+			return $value !== null;
146
+		});
147
+	}
148 148
 
149
-    /**
150
-     * @param string $which enum (@see constants prefixed with COUNT)
151
-     * @return int|null
152
-     */
153
-    private function getCountFor($which)
154
-    {
155
-        try {
156
-            switch ($which) {
157
-                case self::COUNT_ALL_EVENTS:
158
-                    $count = $this->event_model->count();
159
-                    break;
160
-                case self::COUNT_TICKETS:
161
-                    $count = $this->ticket_model->count();
162
-                    break;
163
-                case self::COUNT_DATETIMES:
164
-                    $count = $this->datetime_model->count();
165
-                    break;
166
-                case self::COUNT_ACTIVE_EVENTS:
167
-                    $count = $this->event_model->get_active_events(array(), true);
168
-                    break;
169
-                case self::COUNT_DATETIMES_SOLD:
170
-                    $count = $this->datetime_model->sum(array(), 'DTT_sold');
171
-                    break;
172
-                case self::COUNT_TICKETS_FREE:
173
-                    $count = $this->ticket_model->count(array(array(
174
-                        'TKT_price' => 0
175
-                    )));
176
-                    break;
177
-                case self::COUNT_TICKETS_PAID:
178
-                    $count = $this->ticket_model->count(array(array(
179
-                        'TKT_price' => array('>', 0)
180
-                    )));
181
-                    break;
182
-                case self::COUNT_TICKETS_SOLD:
183
-                    $count = $this->ticket_model->sum(array(), 'TKT_sold');
184
-                    break;
185
-                case self::COUNT_REGISTRATIONS_ALL:
186
-                    $count = $this->registration_model->count();
187
-                    break;
188
-                case self::COUNT_REGISTRATIONS_CANCELLED:
189
-                    $count = $this->registration_model->count(
190
-                        array(
191
-                            array(
192
-                                'STS_ID' => EEM_Registration::status_id_cancelled
193
-                            )
194
-                        )
195
-                    );
196
-                    break;
197
-                case self::COUNT_REGISTRATIONS_INCOMPLETE:
198
-                    $count = $this->registration_model->count(
199
-                        array(
200
-                            array(
201
-                                'STS_ID' => EEM_Registration::status_id_incomplete
202
-                            )
203
-                        )
204
-                    );
205
-                    break;
206
-                case self::COUNT_REGISTRATIONS_NOT_APPROVED:
207
-                    $count = $this->registration_model->count(
208
-                        array(
209
-                            array(
210
-                                'STS_ID' => EEM_Registration::status_id_not_approved
211
-                            )
212
-                        )
213
-                    );
214
-                    break;
215
-                case self::COUNT_REGISTRATIONS_DECLINED:
216
-                    $count = $this->registration_model->count(
217
-                        array(
218
-                            array(
219
-                                'STS_ID' => EEM_Registration::status_id_declined
220
-                            )
221
-                        )
222
-                    );
223
-                    break;
224
-                case self::COUNT_REGISTRATIONS_PENDING:
225
-                    $count = $this->registration_model->count(
226
-                        array(
227
-                            array(
228
-                                'STS_ID' => EEM_Registration::status_id_pending_payment
229
-                            )
230
-                        )
231
-                    );
232
-                    break;
233
-                case self::COUNT_REGISTRATIONS_APPROVED:
234
-                    $count = $this->registration_model->count(
235
-                        array(
236
-                            array(
237
-                                'STS_ID' => EEM_Registration::status_id_approved
238
-                            )
239
-                        )
240
-                    );
241
-                    break;
242
-                case self::SUM_TRANSACTIONS_COMPLETE_TOTAL:
243
-                    $count = $this->transaction_model->sum(
244
-                        array(
245
-                            array(
246
-                                'STS_ID' => EEM_Transaction::complete_status_code
247
-                            )
248
-                        ),
249
-                        'TXN_total'
250
-                    );
251
-                    break;
252
-                case self::SUM_TRANSACTIONS_ALL_PAID:
253
-                    $count = $this->transaction_model->sum(
254
-                        array(),
255
-                        'TXN_paid'
256
-                    );
257
-                    break;
258
-                default:
259
-                    $count = null;
260
-                    break;
261
-            }
262
-        } catch (Exception $e) {
263
-            $count = null;
264
-        }
265
-        return $count;
266
-    }
149
+	/**
150
+	 * @param string $which enum (@see constants prefixed with COUNT)
151
+	 * @return int|null
152
+	 */
153
+	private function getCountFor($which)
154
+	{
155
+		try {
156
+			switch ($which) {
157
+				case self::COUNT_ALL_EVENTS:
158
+					$count = $this->event_model->count();
159
+					break;
160
+				case self::COUNT_TICKETS:
161
+					$count = $this->ticket_model->count();
162
+					break;
163
+				case self::COUNT_DATETIMES:
164
+					$count = $this->datetime_model->count();
165
+					break;
166
+				case self::COUNT_ACTIVE_EVENTS:
167
+					$count = $this->event_model->get_active_events(array(), true);
168
+					break;
169
+				case self::COUNT_DATETIMES_SOLD:
170
+					$count = $this->datetime_model->sum(array(), 'DTT_sold');
171
+					break;
172
+				case self::COUNT_TICKETS_FREE:
173
+					$count = $this->ticket_model->count(array(array(
174
+						'TKT_price' => 0
175
+					)));
176
+					break;
177
+				case self::COUNT_TICKETS_PAID:
178
+					$count = $this->ticket_model->count(array(array(
179
+						'TKT_price' => array('>', 0)
180
+					)));
181
+					break;
182
+				case self::COUNT_TICKETS_SOLD:
183
+					$count = $this->ticket_model->sum(array(), 'TKT_sold');
184
+					break;
185
+				case self::COUNT_REGISTRATIONS_ALL:
186
+					$count = $this->registration_model->count();
187
+					break;
188
+				case self::COUNT_REGISTRATIONS_CANCELLED:
189
+					$count = $this->registration_model->count(
190
+						array(
191
+							array(
192
+								'STS_ID' => EEM_Registration::status_id_cancelled
193
+							)
194
+						)
195
+					);
196
+					break;
197
+				case self::COUNT_REGISTRATIONS_INCOMPLETE:
198
+					$count = $this->registration_model->count(
199
+						array(
200
+							array(
201
+								'STS_ID' => EEM_Registration::status_id_incomplete
202
+							)
203
+						)
204
+					);
205
+					break;
206
+				case self::COUNT_REGISTRATIONS_NOT_APPROVED:
207
+					$count = $this->registration_model->count(
208
+						array(
209
+							array(
210
+								'STS_ID' => EEM_Registration::status_id_not_approved
211
+							)
212
+						)
213
+					);
214
+					break;
215
+				case self::COUNT_REGISTRATIONS_DECLINED:
216
+					$count = $this->registration_model->count(
217
+						array(
218
+							array(
219
+								'STS_ID' => EEM_Registration::status_id_declined
220
+							)
221
+						)
222
+					);
223
+					break;
224
+				case self::COUNT_REGISTRATIONS_PENDING:
225
+					$count = $this->registration_model->count(
226
+						array(
227
+							array(
228
+								'STS_ID' => EEM_Registration::status_id_pending_payment
229
+							)
230
+						)
231
+					);
232
+					break;
233
+				case self::COUNT_REGISTRATIONS_APPROVED:
234
+					$count = $this->registration_model->count(
235
+						array(
236
+							array(
237
+								'STS_ID' => EEM_Registration::status_id_approved
238
+							)
239
+						)
240
+					);
241
+					break;
242
+				case self::SUM_TRANSACTIONS_COMPLETE_TOTAL:
243
+					$count = $this->transaction_model->sum(
244
+						array(
245
+							array(
246
+								'STS_ID' => EEM_Transaction::complete_status_code
247
+							)
248
+						),
249
+						'TXN_total'
250
+					);
251
+					break;
252
+				case self::SUM_TRANSACTIONS_ALL_PAID:
253
+					$count = $this->transaction_model->sum(
254
+						array(),
255
+						'TXN_paid'
256
+					);
257
+					break;
258
+				default:
259
+					$count = null;
260
+					break;
261
+			}
262
+		} catch (Exception $e) {
263
+			$count = null;
264
+		}
265
+		return $count;
266
+	}
267 267
 
268
-    /**
269
-     * Return the active theme.
270
-     * @return false|string
271
-     */
272
-    private function getActiveThemeStat()
273
-    {
274
-        $theme = wp_get_theme();
275
-        return $theme->get('Name');
276
-    }
268
+	/**
269
+	 * Return the active theme.
270
+	 * @return false|string
271
+	 */
272
+	private function getActiveThemeStat()
273
+	{
274
+		$theme = wp_get_theme();
275
+		return $theme->get('Name');
276
+	}
277 277
 
278
-    /**
279
-     * @return array
280
-     */
281
-    private function paymentMethodStats()
282
-    {
283
-        $payment_method_stats = array();
284
-        try {
285
-            $active_payment_methods = $this->payment_method_model->get_all_active(
286
-                null,
287
-                array('group_by' => 'PMD_type')
288
-            );
289
-            if ($active_payment_methods) {
290
-                foreach ($active_payment_methods as $payment_method) {
291
-                    $payment_method_stats[$payment_method->name() . '_active_payment_method'] = 1;
292
-                }
293
-            }
294
-        } catch (Exception $e) {
295
-            //do nothing just prevents fatals.
296
-        }
297
-        return $payment_method_stats;
298
-    }
278
+	/**
279
+	 * @return array
280
+	 */
281
+	private function paymentMethodStats()
282
+	{
283
+		$payment_method_stats = array();
284
+		try {
285
+			$active_payment_methods = $this->payment_method_model->get_all_active(
286
+				null,
287
+				array('group_by' => 'PMD_type')
288
+			);
289
+			if ($active_payment_methods) {
290
+				foreach ($active_payment_methods as $payment_method) {
291
+					$payment_method_stats[$payment_method->name() . '_active_payment_method'] = 1;
292
+				}
293
+			}
294
+		} catch (Exception $e) {
295
+			//do nothing just prevents fatals.
296
+		}
297
+		return $payment_method_stats;
298
+	}
299 299
 }
300 300
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
             'phpversion' => implode('.', array(PHP_MAJOR_VERSION, PHP_MINOR_VERSION, PHP_RELEASE_VERSION))
142 142
         ));
143 143
         //remove any values that equal null.  This ensures any stats that weren't retrieved successfully are excluded.
144
-        return array_filter($stats, function ($value) {
144
+        return array_filter($stats, function($value) {
145 145
             return $value !== null;
146 146
         });
147 147
     }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
             );
289 289
             if ($active_payment_methods) {
290 290
                 foreach ($active_payment_methods as $payment_method) {
291
-                    $payment_method_stats[$payment_method->name() . '_active_payment_method'] = 1;
291
+                    $payment_method_stats[$payment_method->name().'_active_payment_method'] = 1;
292 292
                 }
293 293
             }
294 294
         } catch (Exception $e) {
Please login to merge, or discard this patch.
core/domain/services/pue/Config.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -17,135 +17,135 @@
 block discarded – undo
17 17
  */
18 18
 class Config
19 19
 {
20
-    /**
21
-     * @var EE_Network_Config
22
-     */
23
-    private $network_config;
20
+	/**
21
+	 * @var EE_Network_Config
22
+	 */
23
+	private $network_config;
24 24
 
25 25
 
26
-    /**
27
-     * @var EE_Config
28
-     */
29
-    private $ee_config;
26
+	/**
27
+	 * @var EE_Config
28
+	 */
29
+	private $ee_config;
30 30
 
31 31
 
32 32
 
33
-    public function __construct(EE_Network_Config $network_config, EE_Config $ee_config)
34
-    {
35
-        $this->network_config = $network_config;
36
-        $this->ee_config = $ee_config;
37
-    }
33
+	public function __construct(EE_Network_Config $network_config, EE_Config $ee_config)
34
+	{
35
+		$this->network_config = $network_config;
36
+		$this->ee_config = $ee_config;
37
+	}
38 38
 
39 39
 
40
-    /**
41
-     * Get the site license key for the site.
42
-     */
43
-    public function siteLicenseKey()
44
-    {
45
-        return $this->network_config->core->site_license_key;
46
-    }
40
+	/**
41
+	 * Get the site license key for the site.
42
+	 */
43
+	public function siteLicenseKey()
44
+	{
45
+		return $this->network_config->core->site_license_key;
46
+	}
47 47
 
48 48
 
49 49
 
50
-    public function i18nDomain()
51
-    {
52
-        return 'event_espresso';
53
-    }
50
+	public function i18nDomain()
51
+	{
52
+		return 'event_espresso';
53
+	}
54 54
 
55 55
 
56 56
 
57
-    public function checkPeriod()
58
-    {
59
-        return 24;
60
-    }
57
+	public function checkPeriod()
58
+	{
59
+		return 24;
60
+	}
61 61
 
62 62
 
63 63
 
64
-    public function optionKey()
65
-    {
66
-        return 'site_license_key';
67
-    }
64
+	public function optionKey()
65
+	{
66
+		return 'site_license_key';
67
+	}
68 68
 
69 69
 
70 70
 
71
-    public function optionsPageSlug()
72
-    {
73
-        return 'espresso_general_settings';
74
-    }
71
+	public function optionsPageSlug()
72
+	{
73
+		return 'espresso_general_settings';
74
+	}
75 75
 
76 76
 
77
-    public function hostServerUrl()
78
-    {
79
-        return defined('PUE_UPDATES_ENDPOINT')
80
-            ? PUE_UPDATES_ENDPOINT
81
-            : 'https://eventespresso.com';
82
-    }
77
+	public function hostServerUrl()
78
+	{
79
+		return defined('PUE_UPDATES_ENDPOINT')
80
+			? PUE_UPDATES_ENDPOINT
81
+			: 'https://eventespresso.com';
82
+	}
83 83
 
84 84
 
85
-    public function pluginSlug()
86
-    {
87
-        //Note: PUE uses a simple preg_match to determine what type is currently installed based on version number.
88
-        //  So it's important that you use a key for the version type that is unique and not found in another key.
89
-        //For example:
90
-        //$plugin_slug['premium']['p'] = 'some-premium-slug';
91
-        //$plugin_slug['prerelease']['pr'] = 'some-pre-release-slug';
92
-        //The above would not work because "p" is found in both keys for the version type. ( i.e 1.0.p vs 1.0.pr )
93
-        // so doing something like:
94
-        //$plugin_slug['premium']['p'] = 'some-premium-slug';
95
-        //$plugin_slug['prerelease']['b'] = 'some-pre-release-slug';
96
-        //..WOULD work!
97
-        return array(
98
-            'free'       => array('decaf' => 'event-espresso-core-decaf'),
99
-            'premium'    => array('p' => 'event-espresso-core-reg'),
100
-            'prerelease' => array('beta' => 'event-espresso-core-pr'),
101
-        );
102
-    }
85
+	public function pluginSlug()
86
+	{
87
+		//Note: PUE uses a simple preg_match to determine what type is currently installed based on version number.
88
+		//  So it's important that you use a key for the version type that is unique and not found in another key.
89
+		//For example:
90
+		//$plugin_slug['premium']['p'] = 'some-premium-slug';
91
+		//$plugin_slug['prerelease']['pr'] = 'some-pre-release-slug';
92
+		//The above would not work because "p" is found in both keys for the version type. ( i.e 1.0.p vs 1.0.pr )
93
+		// so doing something like:
94
+		//$plugin_slug['premium']['p'] = 'some-premium-slug';
95
+		//$plugin_slug['prerelease']['b'] = 'some-pre-release-slug';
96
+		//..WOULD work!
97
+		return array(
98
+			'free'       => array('decaf' => 'event-espresso-core-decaf'),
99
+			'premium'    => array('p' => 'event-espresso-core-reg'),
100
+			'prerelease' => array('beta' => 'event-espresso-core-pr'),
101
+		);
102
+	}
103 103
 
104 104
 
105
-    /**
106
-     * Return whether the site is opted in for UXIP or not.
107
-     * @return bool
108
-     */
109
-    public function isOptedInForUxip()
110
-    {
111
-        return filter_var($this->ee_config->core->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN);
112
-    }
105
+	/**
106
+	 * Return whether the site is opted in for UXIP or not.
107
+	 * @return bool
108
+	 */
109
+	public function isOptedInForUxip()
110
+	{
111
+		return filter_var($this->ee_config->core->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN);
112
+	}
113 113
 
114 114
 
115
-    /**
116
-     * Return whether the site has been notified about UXIP or not.
117
-     * @return bool
118
-     */
119
-    public function hasNotifiedForUxip()
120
-    {
121
-        return filter_var($this->ee_config->core->ee_ueip_has_notified, FILTER_VALIDATE_BOOLEAN);
122
-    }
115
+	/**
116
+	 * Return whether the site has been notified about UXIP or not.
117
+	 * @return bool
118
+	 */
119
+	public function hasNotifiedForUxip()
120
+	{
121
+		return filter_var($this->ee_config->core->ee_ueip_has_notified, FILTER_VALIDATE_BOOLEAN);
122
+	}
123 123
 
124 124
 
125
-    /**
126
-     * Set the site opted in for UXIP.
127
-     */
128
-    public function setHasOptedInForUxip()
129
-    {
130
-        $this->ee_config->core->ee_ueip_optin = true;
131
-        $this->ee_config->update_espresso_config(false, false);
132
-    }
125
+	/**
126
+	 * Set the site opted in for UXIP.
127
+	 */
128
+	public function setHasOptedInForUxip()
129
+	{
130
+		$this->ee_config->core->ee_ueip_optin = true;
131
+		$this->ee_config->update_espresso_config(false, false);
132
+	}
133 133
 
134 134
 
135
-    /**
136
-     * Set the site opted out for UXIP
137
-     */
138
-    public function setHasOptedOutForUxip()
139
-    {
140
-        $this->ee_config->core->ee_ueip_optin = false;
141
-        $this->ee_config->update_espresso_config(false, false);
142
-    }
135
+	/**
136
+	 * Set the site opted out for UXIP
137
+	 */
138
+	public function setHasOptedOutForUxip()
139
+	{
140
+		$this->ee_config->core->ee_ueip_optin = false;
141
+		$this->ee_config->update_espresso_config(false, false);
142
+	}
143 143
 
144 144
 
145 145
 
146
-    public function setHasNotifiedAboutUxip()
147
-    {
148
-        $this->ee_config->core->ee_ueip_has_notified = true;
149
-        $this->ee_config->update_espresso_config(false, false);
150
-    }
146
+	public function setHasNotifiedAboutUxip()
147
+	{
148
+		$this->ee_config->core->ee_ueip_has_notified = true;
149
+		$this->ee_config->update_espresso_config(false, false);
150
+	}
151 151
 }
Please login to merge, or discard this patch.
core/domain/services/pue/Stats.php 2 patches
Indentation   +199 added lines, -199 removed lines patch added patch discarded remove patch
@@ -22,86 +22,86 @@  discard block
 block discarded – undo
22 22
 class Stats
23 23
 {
24 24
 
25
-    const OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS = 'ee_uxip_stats_expiry';
26
-
27
-    /**
28
-     * @var Config
29
-     */
30
-    private $config;
31
-
32
-
33
-    /**
34
-     * @var StatsGatherer
35
-     */
36
-    private $stats_gatherer;
37
-
38
-
39
-    /**
40
-     * @var EE_Maintenance_Mode
41
-     */
42
-    private $maintenance_mode;
43
-
44
-    public function __construct(
45
-        Config $config,
46
-        EE_Maintenance_Mode $maintenance_mode,
47
-        StatsGatherer $stats_gatherer
48
-    ) {
49
-        $this->config = $config;
50
-        $this->maintenance_mode = $maintenance_mode;
51
-        $this->stats_gatherer = $stats_gatherer;
52
-        $this->setUxipNotices();
53
-    }
54
-
55
-
56
-    /**
57
-     * Displays uxip opt-in notice if necessary.
58
-     */
59
-    private function setUxipNotices()
60
-    {
61
-        if ($this->canDisplayNotices()) {
62
-            add_action('admin_notices', array($this, 'optinNotice'));
63
-            add_action('admin_enqueue_scripts', array($this, 'enqueueScripts'));
64
-            add_action('wp_ajax_espresso_data_optin', array($this, 'ajaxHandler'));
65
-            //makes sure optin defaults to yes even if its currently empty.
66
-            $this->config->setHasOptedInForUxip();
67
-        }
68
-    }
69
-
70
-
71
-    /**
72
-     * This returns the callback that PluginUpdateEngineChecker will use for getting any extra stats to send.
73
-     * @return Closure
74
-     */
75
-    public function statsCallback()
76
-    {
77
-        //returns a callback that can is used to retrieve the stats to send along to the pue server.
78
-        return function () {
79
-            //we only send stats one a week, so let's see if our stat timestamp has expired.
80
-            if (! $this->sendStats()) {
81
-                return array();
82
-            }
83
-            return $this->stats_gatherer->stats();
84
-        };
85
-    }
86
-
87
-
88
-    /**
89
-     * Return whether notices can be displayed or not
90
-     * @return bool
91
-     */
92
-    private function canDisplayNotices()
93
-    {
94
-        return ! $this->config->hasNotifiedForUxip()
95
-               && $this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance;
96
-    }
97
-
98
-
99
-    /**
100
-     * Callback for the admin_notices hook that outputs the UXIP optin-in notice.
101
-     */
102
-    public function optinNotice()
103
-    {
104
-        ?>
25
+	const OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS = 'ee_uxip_stats_expiry';
26
+
27
+	/**
28
+	 * @var Config
29
+	 */
30
+	private $config;
31
+
32
+
33
+	/**
34
+	 * @var StatsGatherer
35
+	 */
36
+	private $stats_gatherer;
37
+
38
+
39
+	/**
40
+	 * @var EE_Maintenance_Mode
41
+	 */
42
+	private $maintenance_mode;
43
+
44
+	public function __construct(
45
+		Config $config,
46
+		EE_Maintenance_Mode $maintenance_mode,
47
+		StatsGatherer $stats_gatherer
48
+	) {
49
+		$this->config = $config;
50
+		$this->maintenance_mode = $maintenance_mode;
51
+		$this->stats_gatherer = $stats_gatherer;
52
+		$this->setUxipNotices();
53
+	}
54
+
55
+
56
+	/**
57
+	 * Displays uxip opt-in notice if necessary.
58
+	 */
59
+	private function setUxipNotices()
60
+	{
61
+		if ($this->canDisplayNotices()) {
62
+			add_action('admin_notices', array($this, 'optinNotice'));
63
+			add_action('admin_enqueue_scripts', array($this, 'enqueueScripts'));
64
+			add_action('wp_ajax_espresso_data_optin', array($this, 'ajaxHandler'));
65
+			//makes sure optin defaults to yes even if its currently empty.
66
+			$this->config->setHasOptedInForUxip();
67
+		}
68
+	}
69
+
70
+
71
+	/**
72
+	 * This returns the callback that PluginUpdateEngineChecker will use for getting any extra stats to send.
73
+	 * @return Closure
74
+	 */
75
+	public function statsCallback()
76
+	{
77
+		//returns a callback that can is used to retrieve the stats to send along to the pue server.
78
+		return function () {
79
+			//we only send stats one a week, so let's see if our stat timestamp has expired.
80
+			if (! $this->sendStats()) {
81
+				return array();
82
+			}
83
+			return $this->stats_gatherer->stats();
84
+		};
85
+	}
86
+
87
+
88
+	/**
89
+	 * Return whether notices can be displayed or not
90
+	 * @return bool
91
+	 */
92
+	private function canDisplayNotices()
93
+	{
94
+		return ! $this->config->hasNotifiedForUxip()
95
+			   && $this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance;
96
+	}
97
+
98
+
99
+	/**
100
+	 * Callback for the admin_notices hook that outputs the UXIP optin-in notice.
101
+	 */
102
+	public function optinNotice()
103
+	{
104
+		?>
105 105
         <div class="updated data-collect-optin" id="espresso-data-collect-optin-container">
106 106
             <div id="data-collect-optin-options-container">
107 107
                 <span class="dashicons dashicons-admin-site"></span>
@@ -114,123 +114,123 @@  discard block
 block discarded – undo
114 114
             </div>
115 115
         </div>
116 116
         <?php
117
-    }
118
-
119
-
120
-    /**
121
-     * Retrieves the optin text (static so it can be used in multiple places as necessary).
122
-     * @param bool $extra
123
-     */
124
-    public static function optinText($extra = true)
125
-    {
126
-        if (! $extra) {
127
-            echo '<h2 class="ee-admin-settings-hdr" '
128
-                 . (! $extra ? 'id="UXIP_settings"' : '')
129
-                 . '>'
130
-                 . esc_html__('User eXperience Improvement Program (UXIP)', 'event_espresso')
131
-                 . EEH_Template::get_help_tab_link('organization_logo_info')
132
-                 . '</h2>';
133
-            printf(
134
-                esc_html__(
135
-                    '%sPlease help us make Event Espresso better and vote for your favorite features.%s The %sUser eXperience Improvement Program (UXIP)%s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary but it is enabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %sPlease see our %sPrivacy Policy%s for more information.',
136
-                    'event_espresso'
137
-                ),
138
-                '<p><em>',
139
-                '</em></p>',
140
-                '<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
141
-                '</a>',
142
-                '<br><br>',
143
-                '<a href="https://eventespresso.com/about/privacy-policy/" target="_blank">',
144
-                '</a>'
145
-            );
146
-        } else {
147
-            $settings_url = EE_Admin_Page::add_query_args_and_nonce(
148
-                array('action' => 'default'),
149
-                admin_url('admin.php?page=espresso_general_settings')
150
-            );
151
-            $settings_url .= '#UXIP_settings';
152
-            printf(
153
-                esc_html__(
154
-                    'The Event Espresso UXIP feature is active on your site. For %smore info%s and to opt-out %sclick here%s.',
155
-                    'event_espresso'
156
-                ),
157
-                '<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
158
-                '</a>',
159
-                '<a href="' . $settings_url . '" target="_blank">',
160
-                '</a>'
161
-            );
162
-        }
163
-    }
164
-
165
-
166
-    /**
167
-     * Callback for admin_enqueue_scripts that sets up the scripts and styles for the uxip notice
168
-     */
169
-    public function enqueueScripts()
170
-    {
171
-        wp_register_script(
172
-            'ee-data-optin-js',
173
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-data-optin.js',
174
-            array('jquery'),
175
-            EVENT_ESPRESSO_VERSION,
176
-            true
177
-        );
178
-        wp_register_style(
179
-            'ee-data-optin-css',
180
-            EE_GLOBAL_ASSETS_URL . 'css/ee-data-optin.css',
181
-            array(),
182
-            EVENT_ESPRESSO_VERSION
183
-        );
184
-
185
-        wp_enqueue_script('ee-data-optin-js');
186
-        wp_enqueue_style('ee-data-optin-css');
187
-    }
188
-
189
-
190
-    /**
191
-     * Callback for wp_ajax_espresso_data_optin that handles the ajax request
192
-     */
193
-    public function ajaxHandler()
194
-    {
195
-        //verify nonce
196
-        if (isset($_POST['nonce']) && ! wp_verify_nonce($_POST['nonce'], 'ee-data-optin')) {
197
-            exit();
198
-        }
199
-
200
-        //update has notified option
201
-        $this->config->setHasNotifiedAboutUxip();
202
-        exit();
203
-    }
204
-
205
-
206
-    /**
207
-     * Used to determine whether additional stats are sent.
208
-     */
209
-    private function sendStats()
210
-    {
211
-        return $this->config->isOptedInForUxip()
212
-            && $this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
213
-            && $this->statSendTimestampExpired();
214
-    }
215
-
216
-
217
-    /**
218
-     * Returns true when the timestamp used to track whether stats get sent (currently a weekly interval) is expired.
219
-     * Returns false otherwise.
220
-     * @return bool
221
-     */
222
-    private function statSendTimestampExpired()
223
-    {
224
-        $current_expiry = get_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, null);
225
-        if ($current_expiry === null) {
226
-            add_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS, '', 'no');
227
-            return true;
228
-        }
229
-
230
-        if (time() > (int) $current_expiry) {
231
-            update_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS);
232
-            return true;
233
-        }
234
-        return false;
235
-    }
117
+	}
118
+
119
+
120
+	/**
121
+	 * Retrieves the optin text (static so it can be used in multiple places as necessary).
122
+	 * @param bool $extra
123
+	 */
124
+	public static function optinText($extra = true)
125
+	{
126
+		if (! $extra) {
127
+			echo '<h2 class="ee-admin-settings-hdr" '
128
+				 . (! $extra ? 'id="UXIP_settings"' : '')
129
+				 . '>'
130
+				 . esc_html__('User eXperience Improvement Program (UXIP)', 'event_espresso')
131
+				 . EEH_Template::get_help_tab_link('organization_logo_info')
132
+				 . '</h2>';
133
+			printf(
134
+				esc_html__(
135
+					'%sPlease help us make Event Espresso better and vote for your favorite features.%s The %sUser eXperience Improvement Program (UXIP)%s, has been created so when you use Event Espresso you are voting for the features and settings that are important to you. The UXIP helps us understand how you use our products and services, track problems and in what context. If you opt-out of the UXIP you essentially elect for us to disregard how you use Event Espresso as we build new features and make changes. Participation in the program is completely voluntary but it is enabled by default. The end results of the UXIP are software improvements to better meet your needs. The data we collect will never be sold, traded, or misused in any way. %sPlease see our %sPrivacy Policy%s for more information.',
136
+					'event_espresso'
137
+				),
138
+				'<p><em>',
139
+				'</em></p>',
140
+				'<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
141
+				'</a>',
142
+				'<br><br>',
143
+				'<a href="https://eventespresso.com/about/privacy-policy/" target="_blank">',
144
+				'</a>'
145
+			);
146
+		} else {
147
+			$settings_url = EE_Admin_Page::add_query_args_and_nonce(
148
+				array('action' => 'default'),
149
+				admin_url('admin.php?page=espresso_general_settings')
150
+			);
151
+			$settings_url .= '#UXIP_settings';
152
+			printf(
153
+				esc_html__(
154
+					'The Event Espresso UXIP feature is active on your site. For %smore info%s and to opt-out %sclick here%s.',
155
+					'event_espresso'
156
+				),
157
+				'<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
158
+				'</a>',
159
+				'<a href="' . $settings_url . '" target="_blank">',
160
+				'</a>'
161
+			);
162
+		}
163
+	}
164
+
165
+
166
+	/**
167
+	 * Callback for admin_enqueue_scripts that sets up the scripts and styles for the uxip notice
168
+	 */
169
+	public function enqueueScripts()
170
+	{
171
+		wp_register_script(
172
+			'ee-data-optin-js',
173
+			EE_GLOBAL_ASSETS_URL . 'scripts/ee-data-optin.js',
174
+			array('jquery'),
175
+			EVENT_ESPRESSO_VERSION,
176
+			true
177
+		);
178
+		wp_register_style(
179
+			'ee-data-optin-css',
180
+			EE_GLOBAL_ASSETS_URL . 'css/ee-data-optin.css',
181
+			array(),
182
+			EVENT_ESPRESSO_VERSION
183
+		);
184
+
185
+		wp_enqueue_script('ee-data-optin-js');
186
+		wp_enqueue_style('ee-data-optin-css');
187
+	}
188
+
189
+
190
+	/**
191
+	 * Callback for wp_ajax_espresso_data_optin that handles the ajax request
192
+	 */
193
+	public function ajaxHandler()
194
+	{
195
+		//verify nonce
196
+		if (isset($_POST['nonce']) && ! wp_verify_nonce($_POST['nonce'], 'ee-data-optin')) {
197
+			exit();
198
+		}
199
+
200
+		//update has notified option
201
+		$this->config->setHasNotifiedAboutUxip();
202
+		exit();
203
+	}
204
+
205
+
206
+	/**
207
+	 * Used to determine whether additional stats are sent.
208
+	 */
209
+	private function sendStats()
210
+	{
211
+		return $this->config->isOptedInForUxip()
212
+			&& $this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
213
+			&& $this->statSendTimestampExpired();
214
+	}
215
+
216
+
217
+	/**
218
+	 * Returns true when the timestamp used to track whether stats get sent (currently a weekly interval) is expired.
219
+	 * Returns false otherwise.
220
+	 * @return bool
221
+	 */
222
+	private function statSendTimestampExpired()
223
+	{
224
+		$current_expiry = get_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, null);
225
+		if ($current_expiry === null) {
226
+			add_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS, '', 'no');
227
+			return true;
228
+		}
229
+
230
+		if (time() > (int) $current_expiry) {
231
+			update_option(self::OPTIONS_KEY_EXPIRY_TIMESTAMP_FOR_SENDING_STATS, time() + WEEK_IN_SECONDS);
232
+			return true;
233
+		}
234
+		return false;
235
+	}
236 236
 }
237 237
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
     public function statsCallback()
76 76
     {
77 77
         //returns a callback that can is used to retrieve the stats to send along to the pue server.
78
-        return function () {
78
+        return function() {
79 79
             //we only send stats one a week, so let's see if our stat timestamp has expired.
80
-            if (! $this->sendStats()) {
80
+            if ( ! $this->sendStats()) {
81 81
                 return array();
82 82
             }
83 83
             return $this->stats_gatherer->stats();
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public static function optinText($extra = true)
125 125
     {
126
-        if (! $extra) {
126
+        if ( ! $extra) {
127 127
             echo '<h2 class="ee-admin-settings-hdr" '
128
-                 . (! $extra ? 'id="UXIP_settings"' : '')
128
+                 . ( ! $extra ? 'id="UXIP_settings"' : '')
129 129
                  . '>'
130 130
                  . esc_html__('User eXperience Improvement Program (UXIP)', 'event_espresso')
131 131
                  . EEH_Template::get_help_tab_link('organization_logo_info')
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
                 ),
157 157
                 '<a href="https://eventespresso.com/about/user-experience-improvement-program-uxip/" target="_blank">',
158 158
                 '</a>',
159
-                '<a href="' . $settings_url . '" target="_blank">',
159
+                '<a href="'.$settings_url.'" target="_blank">',
160 160
                 '</a>'
161 161
             );
162 162
         }
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
     {
171 171
         wp_register_script(
172 172
             'ee-data-optin-js',
173
-            EE_GLOBAL_ASSETS_URL . 'scripts/ee-data-optin.js',
173
+            EE_GLOBAL_ASSETS_URL.'scripts/ee-data-optin.js',
174 174
             array('jquery'),
175 175
             EVENT_ESPRESSO_VERSION,
176 176
             true
177 177
         );
178 178
         wp_register_style(
179 179
             'ee-data-optin-css',
180
-            EE_GLOBAL_ASSETS_URL . 'css/ee-data-optin.css',
180
+            EE_GLOBAL_ASSETS_URL.'css/ee-data-optin.css',
181 181
             array(),
182 182
             EVENT_ESPRESSO_VERSION
183 183
         );
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 1 patch
Indentation   +4118 added lines, -4118 removed lines patch added patch discarded remove patch
@@ -20,4203 +20,4203 @@
 block discarded – undo
20 20
 {
21 21
 
22 22
 
23
-    //set in _init_page_props()
24
-    public $page_slug;
23
+	//set in _init_page_props()
24
+	public $page_slug;
25 25
 
26
-    public $page_label;
26
+	public $page_label;
27 27
 
28
-    public $page_folder;
28
+	public $page_folder;
29 29
 
30
-    //set in define_page_props()
31
-    protected $_admin_base_url;
30
+	//set in define_page_props()
31
+	protected $_admin_base_url;
32 32
 
33
-    protected $_admin_base_path;
33
+	protected $_admin_base_path;
34 34
 
35
-    protected $_admin_page_title;
35
+	protected $_admin_page_title;
36 36
 
37
-    protected $_labels;
37
+	protected $_labels;
38 38
 
39 39
 
40
-    //set early within EE_Admin_Init
41
-    protected $_wp_page_slug;
40
+	//set early within EE_Admin_Init
41
+	protected $_wp_page_slug;
42 42
 
43
-    //navtabs
44
-    protected $_nav_tabs;
43
+	//navtabs
44
+	protected $_nav_tabs;
45 45
 
46
-    protected $_default_nav_tab_name;
46
+	protected $_default_nav_tab_name;
47 47
 
48
-    /**
49
-     * @var array $_help_tour
50
-     */
51
-    protected $_help_tour = array();
48
+	/**
49
+	 * @var array $_help_tour
50
+	 */
51
+	protected $_help_tour = array();
52 52
 
53 53
 
54
-    //template variables (used by templates)
55
-    protected $_template_path;
54
+	//template variables (used by templates)
55
+	protected $_template_path;
56 56
 
57
-    protected $_column_template_path;
57
+	protected $_column_template_path;
58 58
 
59
-    /**
60
-     * @var array $_template_args
61
-     */
62
-    protected $_template_args = array();
59
+	/**
60
+	 * @var array $_template_args
61
+	 */
62
+	protected $_template_args = array();
63 63
 
64
-    /**
65
-     * this will hold the list table object for a given view.
66
-     *
67
-     * @var EE_Admin_List_Table $_list_table_object
68
-     */
69
-    protected $_list_table_object;
64
+	/**
65
+	 * this will hold the list table object for a given view.
66
+	 *
67
+	 * @var EE_Admin_List_Table $_list_table_object
68
+	 */
69
+	protected $_list_table_object;
70 70
 
71
-    //bools
72
-    protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
71
+	//bools
72
+	protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
73 73
 
74
-    protected $_routing;
74
+	protected $_routing;
75 75
 
76
-    //list table args
77
-    protected $_view;
76
+	//list table args
77
+	protected $_view;
78 78
 
79
-    protected $_views;
79
+	protected $_views;
80 80
 
81 81
 
82
-    //action => method pairs used for routing incoming requests
83
-    protected $_page_routes;
82
+	//action => method pairs used for routing incoming requests
83
+	protected $_page_routes;
84 84
 
85
-    /**
86
-     * @var array $_page_config
87
-     */
88
-    protected $_page_config;
85
+	/**
86
+	 * @var array $_page_config
87
+	 */
88
+	protected $_page_config;
89 89
 
90
-    /**
91
-     * the current page route and route config
92
-     *
93
-     * @var string $_route
94
-     */
95
-    protected $_route;
90
+	/**
91
+	 * the current page route and route config
92
+	 *
93
+	 * @var string $_route
94
+	 */
95
+	protected $_route;
96 96
 
97
-    /**
98
-     * @var string $_cpt_route
99
-     */
100
-    protected $_cpt_route;
97
+	/**
98
+	 * @var string $_cpt_route
99
+	 */
100
+	protected $_cpt_route;
101 101
 
102
-    /**
103
-     * @var array $_route_config
104
-     */
105
-    protected $_route_config;
102
+	/**
103
+	 * @var array $_route_config
104
+	 */
105
+	protected $_route_config;
106 106
 
107
-    /**
108
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
109
-     * actions.
110
-     *
111
-     * @since 4.6.x
112
-     * @var array.
113
-     */
114
-    protected $_default_route_query_args;
115
-
116
-    //set via request page and action args.
117
-    protected $_current_page;
107
+	/**
108
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
109
+	 * actions.
110
+	 *
111
+	 * @since 4.6.x
112
+	 * @var array.
113
+	 */
114
+	protected $_default_route_query_args;
115
+
116
+	//set via request page and action args.
117
+	protected $_current_page;
118 118
 
119
-    protected $_current_view;
119
+	protected $_current_view;
120 120
 
121
-    protected $_current_page_view_url;
121
+	protected $_current_page_view_url;
122 122
 
123
-    //sanitized request action (and nonce)
123
+	//sanitized request action (and nonce)
124 124
 
125
-    /**
126
-     * @var string $_req_action
127
-     */
128
-    protected $_req_action;
129
-
130
-    /**
131
-     * @var string $_req_nonce
132
-     */
133
-    protected $_req_nonce;
134
-
135
-    //search related
136
-    protected $_search_btn_label;
137
-
138
-    protected $_search_box_callback;
139
-
140
-    /**
141
-     * WP Current Screen object
142
-     *
143
-     * @var WP_Screen
144
-     */
145
-    protected $_current_screen;
146
-
147
-    //for holding EE_Admin_Hooks object when needed (set via set_hook_object())
148
-    protected $_hook_obj;
149
-
150
-    //for holding incoming request data
151
-    protected $_req_data;
152
-
153
-    // yes / no array for admin form fields
154
-    protected $_yes_no_values = array();
155
-
156
-    //some default things shared by all child classes
157
-    protected $_default_espresso_metaboxes;
158
-
159
-    /**
160
-     *    EE_Registry Object
161
-     *
162
-     * @var    EE_Registry
163
-     */
164
-    protected $EE = null;
165
-
166
-
167
-
168
-    /**
169
-     * This is just a property that flags whether the given route is a caffeinated route or not.
170
-     *
171
-     * @var boolean
172
-     */
173
-    protected $_is_caf = false;
174
-
175
-
176
-
177
-    /**
178
-     * @Constructor
179
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
-     * @throws EE_Error
181
-     * @throws InvalidArgumentException
182
-     * @throws ReflectionException
183
-     * @throws InvalidDataTypeException
184
-     * @throws InvalidInterfaceException
185
-     */
186
-    public function __construct($routing = true)
187
-    {
188
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
189
-            $this->_is_caf = true;
190
-        }
191
-        $this->_yes_no_values = array(
192
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
193
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
194
-        );
195
-        //set the _req_data property.
196
-        $this->_req_data = array_merge($_GET, $_POST);
197
-        //routing enabled?
198
-        $this->_routing = $routing;
199
-        //set initial page props (child method)
200
-        $this->_init_page_props();
201
-        //set global defaults
202
-        $this->_set_defaults();
203
-        //set early because incoming requests could be ajax related and we need to register those hooks.
204
-        $this->_global_ajax_hooks();
205
-        $this->_ajax_hooks();
206
-        //other_page_hooks have to be early too.
207
-        $this->_do_other_page_hooks();
208
-        //This just allows us to have extending classes do something specific
209
-        // before the parent constructor runs _page_setup().
210
-        if (method_exists($this, '_before_page_setup')) {
211
-            $this->_before_page_setup();
212
-        }
213
-        //set up page dependencies
214
-        $this->_page_setup();
215
-    }
216
-
217
-
218
-
219
-    /**
220
-     * _init_page_props
221
-     * Child classes use to set at least the following properties:
222
-     * $page_slug.
223
-     * $page_label.
224
-     *
225
-     * @abstract
226
-     * @return void
227
-     */
228
-    abstract protected function _init_page_props();
229
-
230
-
231
-
232
-    /**
233
-     * _ajax_hooks
234
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
235
-     * Note: within the ajax callback methods.
236
-     *
237
-     * @abstract
238
-     * @return void
239
-     */
240
-    abstract protected function _ajax_hooks();
241
-
242
-
243
-
244
-    /**
245
-     * _define_page_props
246
-     * child classes define page properties in here.  Must include at least:
247
-     * $_admin_base_url = base_url for all admin pages
248
-     * $_admin_page_title = default admin_page_title for admin pages
249
-     * $_labels = array of default labels for various automatically generated elements:
250
-     *    array(
251
-     *        'buttons' => array(
252
-     *            'add' => esc_html__('label for add new button'),
253
-     *            'edit' => esc_html__('label for edit button'),
254
-     *            'delete' => esc_html__('label for delete button')
255
-     *            )
256
-     *        )
257
-     *
258
-     * @abstract
259
-     * @return void
260
-     */
261
-    abstract protected function _define_page_props();
262
-
263
-
264
-
265
-    /**
266
-     * _set_page_routes
267
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
268
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
269
-     * have a 'default' route. Here's the format
270
-     * $this->_page_routes = array(
271
-     *        'default' => array(
272
-     *            'func' => '_default_method_handling_route',
273
-     *            'args' => array('array','of','args'),
274
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
275
-     *            ajax request, backend processing)
276
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
277
-     *            headers route after.  The string you enter here should match the defined route reference for a
278
-     *            headers sent route.
279
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
280
-     *            this route.
281
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
282
-     *            checks).
283
-     *        ),
284
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
285
-     *        handling method.
286
-     *        )
287
-     * )
288
-     *
289
-     * @abstract
290
-     * @return void
291
-     */
292
-    abstract protected function _set_page_routes();
293
-
294
-
295
-
296
-    /**
297
-     * _set_page_config
298
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
299
-     * array corresponds to the page_route for the loaded page. Format:
300
-     * $this->_page_config = array(
301
-     *        'default' => array(
302
-     *            'labels' => array(
303
-     *                'buttons' => array(
304
-     *                    'add' => esc_html__('label for adding item'),
305
-     *                    'edit' => esc_html__('label for editing item'),
306
-     *                    'delete' => esc_html__('label for deleting item')
307
-     *                ),
308
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
309
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
310
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
311
-     *            _define_page_props() method
312
-     *            'nav' => array(
313
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
314
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
315
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
316
-     *                'order' => 10, //required to indicate tab position.
317
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
318
-     *                displayed then add this parameter.
319
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
320
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
321
-     *            metaboxes set for eventespresso admin pages.
322
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
323
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
324
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
325
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
326
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
327
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
328
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
329
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
330
-     *            want to display.
331
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
332
-     *                'tab_id' => array(
333
-     *                    'title' => 'tab_title',
334
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
335
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
336
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
337
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
338
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
339
-     *                    attempt to use the callback which should match the name of a method in the class
340
-     *                    ),
341
-     *                'tab2_id' => array(
342
-     *                    'title' => 'tab2 title',
343
-     *                    'filename' => 'file_name_2'
344
-     *                    'callback' => 'callback_method_for_content',
345
-     *                 ),
346
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
347
-     *            help tab area on an admin page. @link
348
-     *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
349
-     *            'help_tour' => array(
350
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
351
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
352
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
353
-     *            ),
354
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
355
-     *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
356
-     *            just set
357
-     *            'require_nonce' to FALSE
358
-     *            )
359
-     * )
360
-     *
361
-     * @abstract
362
-     * @return void
363
-     */
364
-    abstract protected function _set_page_config();
365
-
366
-
367
-
368
-
369
-
370
-    /** end sample help_tour methods **/
371
-    /**
372
-     * _add_screen_options
373
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
374
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
375
-     * to a particular view.
376
-     *
377
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
378
-     *         see also WP_Screen object documents...
379
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
380
-     * @abstract
381
-     * @return void
382
-     */
383
-    abstract protected function _add_screen_options();
384
-
385
-
386
-
387
-    /**
388
-     * _add_feature_pointers
389
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
390
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
391
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
392
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
393
-     * extended) also see:
394
-     *
395
-     * @link   http://eamann.com/tech/wordpress-portland/
396
-     * @abstract
397
-     * @return void
398
-     */
399
-    abstract protected function _add_feature_pointers();
400
-
401
-
402
-
403
-    /**
404
-     * load_scripts_styles
405
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
406
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
407
-     * scripts/styles per view by putting them in a dynamic function in this format
408
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
409
-     *
410
-     * @abstract
411
-     * @return void
412
-     */
413
-    abstract public function load_scripts_styles();
414
-
415
-
416
-
417
-    /**
418
-     * admin_init
419
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
420
-     * all pages/views loaded by child class.
421
-     *
422
-     * @abstract
423
-     * @return void
424
-     */
425
-    abstract public function admin_init();
426
-
427
-
428
-
429
-    /**
430
-     * admin_notices
431
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
432
-     * all pages/views loaded by child class.
433
-     *
434
-     * @abstract
435
-     * @return void
436
-     */
437
-    abstract public function admin_notices();
438
-
439
-
440
-
441
-    /**
442
-     * admin_footer_scripts
443
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
444
-     * will apply to all pages/views loaded by child class.
445
-     *
446
-     * @return void
447
-     */
448
-    abstract public function admin_footer_scripts();
449
-
450
-
451
-
452
-    /**
453
-     * admin_footer
454
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
455
-     * apply to all pages/views loaded by child class.
456
-     *
457
-     * @return void
458
-     */
459
-    public function admin_footer()
460
-    {
461
-    }
462
-
463
-
464
-
465
-    /**
466
-     * _global_ajax_hooks
467
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
468
-     * Note: within the ajax callback methods.
469
-     *
470
-     * @abstract
471
-     * @return void
472
-     */
473
-    protected function _global_ajax_hooks()
474
-    {
475
-        //for lazy loading of metabox content
476
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
477
-    }
478
-
479
-
480
-
481
-    public function ajax_metabox_content()
482
-    {
483
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
484
-        $url       = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
485
-        self::cached_rss_display($contentid, $url);
486
-        wp_die();
487
-    }
488
-
489
-
490
-
491
-    /**
492
-     * _page_setup
493
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
494
-     * doesn't match the object.
495
-     *
496
-     * @final
497
-     * @return void
498
-     * @throws EE_Error
499
-     * @throws InvalidArgumentException
500
-     * @throws ReflectionException
501
-     * @throws InvalidDataTypeException
502
-     * @throws InvalidInterfaceException
503
-     */
504
-    final protected function _page_setup()
505
-    {
506
-        //requires?
507
-        //admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
508
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
509
-        //next verify if we need to load anything...
510
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
511
-        $this->page_folder   = strtolower(
512
-            str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
513
-        );
514
-        global $ee_menu_slugs;
515
-        $ee_menu_slugs = (array)$ee_menu_slugs;
516
-        if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))) {
517
-            return;
518
-        }
519
-        // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
520
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
521
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
522
-                ? $this->_req_data['action2']
523
-                : $this->_req_data['action'];
524
-        }
525
-        // then set blank or -1 action values to 'default'
526
-        $this->_req_action = isset($this->_req_data['action'])
527
-                             && ! empty($this->_req_data['action'])
528
-                             && $this->_req_data['action'] !== '-1'
529
-            ? sanitize_key($this->_req_data['action'])
530
-            : 'default';
531
-        // if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
532
-        //  This covers cases where we're coming in from a list table that isn't on the default route.
533
-        $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
534
-            ? $this->_req_data['route'] : $this->_req_action;
535
-        //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
536
-        $this->_req_action   = defined('DOING_AJAX') && isset($this->_req_data['route'])
537
-            ? $this->_req_data['route']
538
-            : $this->_req_action;
539
-        $this->_current_view = $this->_req_action;
540
-        $this->_req_nonce    = $this->_req_action . '_nonce';
541
-        $this->_define_page_props();
542
-        $this->_current_page_view_url = add_query_arg(
543
-            array('page' => $this->_current_page, 'action' => $this->_current_view),
544
-            $this->_admin_base_url
545
-        );
546
-        //default things
547
-        $this->_default_espresso_metaboxes = array(
548
-            '_espresso_news_post_box',
549
-            '_espresso_links_post_box',
550
-            '_espresso_ratings_request',
551
-            '_espresso_sponsors_post_box',
552
-        );
553
-        //set page configs
554
-        $this->_set_page_routes();
555
-        $this->_set_page_config();
556
-        //let's include any referrer data in our default_query_args for this route for "stickiness".
557
-        if (isset($this->_req_data['wp_referer'])) {
558
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
559
-        }
560
-        //for caffeinated and other extended functionality.
561
-        //  If there is a _extend_page_config method
562
-        // then let's run that to modify the all the various page configuration arrays
563
-        if (method_exists($this, '_extend_page_config')) {
564
-            $this->_extend_page_config();
565
-        }
566
-        //for CPT and other extended functionality.
567
-        // If there is an _extend_page_config_for_cpt
568
-        // then let's run that to modify all the various page configuration arrays.
569
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
570
-            $this->_extend_page_config_for_cpt();
571
-        }
572
-        //filter routes and page_config so addons can add their stuff. Filtering done per class
573
-        $this->_page_routes = apply_filters(
574
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
575
-            $this->_page_routes,
576
-            $this
577
-        );
578
-        $this->_page_config = apply_filters(
579
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
580
-            $this->_page_config,
581
-            $this
582
-        );
583
-        //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
584
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
585
-        if (
586
-            method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)
587
-        ) {
588
-            add_action(
589
-                'AHEE__EE_Admin_Page__route_admin_request',
590
-                array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
591
-                10,
592
-                2
593
-            );
594
-        }
595
-        //next route only if routing enabled
596
-        if ($this->_routing && ! defined('DOING_AJAX')) {
597
-            $this->_verify_routes();
598
-            //next let's just check user_access and kill if no access
599
-            $this->check_user_access();
600
-            if ($this->_is_UI_request) {
601
-                //admin_init stuff - global, all views for this page class, specific view
602
-                add_action('admin_init', array($this, 'admin_init'), 10);
603
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
604
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
605
-                }
606
-            } else {
607
-                //hijack regular WP loading and route admin request immediately
608
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
609
-                $this->route_admin_request();
610
-            }
611
-        }
612
-    }
613
-
614
-
615
-
616
-    /**
617
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
618
-     *
619
-     * @return void
620
-     * @throws ReflectionException
621
-     * @throws EE_Error
622
-     */
623
-    private function _do_other_page_hooks()
624
-    {
625
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
626
-        foreach ($registered_pages as $page) {
627
-            //now let's setup the file name and class that should be present
628
-            $classname = str_replace('.class.php', '', $page);
629
-            //autoloaders should take care of loading file
630
-            if (! class_exists($classname)) {
631
-                $error_msg[] = sprintf(
632
-                    esc_html__(
633
-                        'Something went wrong with loading the %s admin hooks page.',
634
-                        'event_espresso'
635
-                    ),
636
-                    $page
637
-                );
638
-                $error_msg[] = $error_msg[0]
639
-                               . "\r\n"
640
-                               . sprintf(
641
-                                   esc_html__(
642
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
643
-                                       'event_espresso'
644
-                                   ),
645
-                                   $page,
646
-                                   '<br />',
647
-                                   '<strong>' . $classname . '</strong>'
648
-                               );
649
-                throw new EE_Error(implode('||', $error_msg));
650
-            }
651
-            $a = new ReflectionClass($classname);
652
-            //notice we are passing the instance of this class to the hook object.
653
-            $hookobj[] = $a->newInstance($this);
654
-        }
655
-    }
656
-
657
-
658
-
659
-    public function load_page_dependencies()
660
-    {
661
-        try {
662
-            $this->_load_page_dependencies();
663
-        } catch (EE_Error $e) {
664
-            $e->get_error();
665
-        }
666
-    }
667
-
668
-
669
-
670
-    /**
671
-     * load_page_dependencies
672
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
673
-     *
674
-     * @return void
675
-     * @throws DomainException
676
-     * @throws EE_Error
677
-     * @throws InvalidArgumentException
678
-     * @throws InvalidDataTypeException
679
-     * @throws InvalidInterfaceException
680
-     * @throws ReflectionException
681
-     */
682
-    protected function _load_page_dependencies()
683
-    {
684
-        //let's set the current_screen and screen options to override what WP set
685
-        $this->_current_screen = get_current_screen();
686
-        //load admin_notices - global, page class, and view specific
687
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
688
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
689
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
690
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
691
-        }
692
-        //load network admin_notices - global, page class, and view specific
693
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
694
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
695
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
696
-        }
697
-        //this will save any per_page screen options if they are present
698
-        $this->_set_per_page_screen_options();
699
-        //setup list table properties
700
-        $this->_set_list_table();
701
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
702
-        // However in some cases the metaboxes will need to be added within a route handling callback.
703
-        $this->_add_registered_meta_boxes();
704
-        $this->_add_screen_columns();
705
-        //add screen options - global, page child class, and view specific
706
-        $this->_add_global_screen_options();
707
-        $this->_add_screen_options();
708
-        $add_screen_options  = "_add_screen_options_{$this->_current_view}";
709
-        if (method_exists($this, $add_screen_options )) {
710
-            $this->{$add_screen_options}();
711
-        }
712
-        //add help tab(s) and tours- set via page_config and qtips.
713
-        $this->_add_help_tour();
714
-        $this->_add_help_tabs();
715
-        $this->_add_qtips();
716
-        //add feature_pointers - global, page child class, and view specific
717
-        $this->_add_feature_pointers();
718
-        $this->_add_global_feature_pointers();
719
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
720
-        if (method_exists($this, $add_feature_pointer )) {
721
-            $this->{$add_feature_pointer}();
722
-        }
723
-        //enqueue scripts/styles - global, page class, and view specific
724
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
725
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
726
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
727
-            add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
728
-        }
729
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
730
-        // admin_print_footer_scripts - global, page child class, and view specific.
731
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
732
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
733
-        // is a good use case. Notice the late priority we're giving these
734
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
735
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
736
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
737
-            add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
738
-        }
739
-        //admin footer scripts
740
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
741
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
742
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
743
-            add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
744
-        }
745
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
746
-        //targeted hook
747
-        do_action(
748
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
749
-
750
-        );
751
-    }
752
-
753
-
754
-
755
-    /**
756
-     * _set_defaults
757
-     * This sets some global defaults for class properties.
758
-     */
759
-    private function _set_defaults()
760
-    {
761
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
762
-        $this->_event = $this->_template_path = $this->_column_template_path = null;
763
-        $this->_nav_tabs = $this->_views = $this->_page_routes = array();
764
-        $this->_page_config = $this->_default_route_query_args = array();
765
-        $this->_default_nav_tab_name = 'overview';
766
-        //init template args
767
-        $this->_template_args = array(
768
-            'admin_page_header'  => '',
769
-            'admin_page_content' => '',
770
-            'post_body_content'  => '',
771
-            'before_list_table'  => '',
772
-            'after_list_table'   => '',
773
-        );
774
-    }
775
-
776
-
777
-
778
-    /**
779
-     * route_admin_request
780
-     *
781
-     * @see    _route_admin_request()
782
-     * @return exception|void error
783
-     * @throws InvalidArgumentException
784
-     * @throws InvalidInterfaceException
785
-     * @throws InvalidDataTypeException
786
-     * @throws EE_Error
787
-     * @throws ReflectionException
788
-     */
789
-    public function route_admin_request()
790
-    {
791
-        try {
792
-            $this->_route_admin_request();
793
-        } catch (EE_Error $e) {
794
-            $e->get_error();
795
-        }
796
-    }
797
-
798
-
799
-
800
-    public function set_wp_page_slug($wp_page_slug)
801
-    {
802
-        $this->_wp_page_slug = $wp_page_slug;
803
-        //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
804
-        if (is_network_admin()) {
805
-            $this->_wp_page_slug .= '-network';
806
-        }
807
-    }
808
-
809
-
810
-
811
-    /**
812
-     * _verify_routes
813
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
814
-     * we know if we need to drop out.
815
-     *
816
-     * @return bool
817
-     * @throws EE_Error
818
-     */
819
-    protected function _verify_routes()
820
-    {
821
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
822
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
823
-            return false;
824
-        }
825
-        $this->_route = false;
826
-        // check that the page_routes array is not empty
827
-        if (empty($this->_page_routes)) {
828
-            // user error msg
829
-            $error_msg = sprintf(
830
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
831
-                $this->_admin_page_title
832
-            );
833
-            // developer error msg
834
-            $error_msg .= '||' . $error_msg . esc_html__(
835
-                ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
836
-                'event_espresso'
837
-            );
838
-            throw new EE_Error($error_msg);
839
-        }
840
-        // and that the requested page route exists
841
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
842
-            $this->_route        = $this->_page_routes[$this->_req_action];
843
-            $this->_route_config = isset($this->_page_config[$this->_req_action])
844
-                ? $this->_page_config[$this->_req_action] : array();
845
-        } else {
846
-            // user error msg
847
-            $error_msg = sprintf(
848
-                esc_html__(
849
-                        'The requested page route does not exist for the %s admin page.',
850
-                        'event_espresso'
851
-                ),
852
-                $this->_admin_page_title
853
-            );
854
-            // developer error msg
855
-            $error_msg .= '||' . $error_msg . sprintf(
856
-                    esc_html__(
857
-                        ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
858
-                        'event_espresso'
859
-                    ),
860
-                    $this->_req_action
861
-                );
862
-            throw new EE_Error($error_msg);
863
-        }
864
-        // and that a default route exists
865
-        if (! array_key_exists('default', $this->_page_routes)) {
866
-            // user error msg
867
-            $error_msg = sprintf(
868
-                esc_html__(
869
-                        'A default page route has not been set for the % admin page.',
870
-                        'event_espresso'
871
-                ),
872
-                $this->_admin_page_title
873
-            );
874
-            // developer error msg
875
-            $error_msg .= '||' . $error_msg . esc_html__(
876
-                ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
877
-                'event_espresso'
878
-            );
879
-            throw new EE_Error($error_msg);
880
-        }
881
-        //first lets' catch if the UI request has EVER been set.
882
-        if ($this->_is_UI_request === null) {
883
-            //lets set if this is a UI request or not.
884
-            $this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
885
-            //wait a minute... we might have a noheader in the route array
886
-            $this->_is_UI_request = is_array($this->_route)
887
-                                    && isset($this->_route['noheader'])
888
-                                    && $this->_route['noheader'] ? false : $this->_is_UI_request;
889
-        }
890
-        $this->_set_current_labels();
891
-        return true;
892
-    }
893
-
894
-
895
-
896
-    /**
897
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
898
-     *
899
-     * @param  string $route the route name we're verifying
900
-     * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
901
-     * @throws EE_Error
902
-     */
903
-    protected function _verify_route($route)
904
-    {
905
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
906
-            return true;
907
-        }
908
-        // user error msg
909
-        $error_msg = sprintf(
910
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
911
-            $this->_admin_page_title
912
-        );
913
-        // developer error msg
914
-        $error_msg .= '||' . $error_msg . sprintf(
915
-                esc_html__(
916
-                    ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
917
-                    'event_espresso'
918
-                ),
919
-                $route
920
-            );
921
-        throw new EE_Error($error_msg);
922
-    }
923
-
924
-
925
-
926
-    /**
927
-     * perform nonce verification
928
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
929
-     * using this method (and save retyping!)
930
-     *
931
-     * @param  string $nonce     The nonce sent
932
-     * @param  string $nonce_ref The nonce reference string (name0)
933
-     * @return void
934
-     * @throws EE_Error
935
-     */
936
-    protected function _verify_nonce($nonce, $nonce_ref)
937
-    {
938
-        // verify nonce against expected value
939
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
940
-            // these are not the droids you are looking for !!!
941
-            $msg = sprintf(
942
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
943
-                '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
944
-                '</a>'
945
-            );
946
-            if (WP_DEBUG) {
947
-                $msg .= "\n  " . sprintf(
948
-                        esc_html__(
949
-                            'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
950
-                            'event_espresso'
951
-                        ),
952
-                        __CLASS__
953
-                    );
954
-            }
955
-            if (! defined('DOING_AJAX')) {
956
-                wp_die($msg);
957
-            } else {
958
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
959
-                $this->_return_json();
960
-            }
961
-        }
962
-    }
963
-
964
-
965
-
966
-    /**
967
-     * _route_admin_request()
968
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
969
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
970
-     * in the page routes and then will try to load the corresponding method.
971
-     *
972
-     * @return void
973
-     * @throws EE_Error
974
-     * @throws InvalidArgumentException
975
-     * @throws InvalidDataTypeException
976
-     * @throws InvalidInterfaceException
977
-     * @throws ReflectionException
978
-     */
979
-    protected function _route_admin_request()
980
-    {
981
-        if (! $this->_is_UI_request) {
982
-            $this->_verify_routes();
983
-        }
984
-        $nonce_check = isset($this->_route_config['require_nonce'])
985
-            ? $this->_route_config['require_nonce']
986
-            : true;
987
-        if ($this->_req_action !== 'default' && $nonce_check) {
988
-            // set nonce from post data
989
-            $nonce = isset($this->_req_data[$this->_req_nonce])
990
-                ? sanitize_text_field($this->_req_data[$this->_req_nonce])
991
-                : '';
992
-            $this->_verify_nonce($nonce, $this->_req_nonce);
993
-        }
994
-        //set the nav_tabs array but ONLY if this is  UI_request
995
-        if ($this->_is_UI_request) {
996
-            $this->_set_nav_tabs();
997
-        }
998
-        // grab callback function
999
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
1000
-        // check if callback has args
1001
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
1002
-        $error_msg = '';
1003
-        // action right before calling route
1004
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1005
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1006
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1007
-        }
1008
-        // right before calling the route, let's remove _wp_http_referer from the
1009
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
1010
-        $_SERVER['REQUEST_URI'] = remove_query_arg(
1011
-                '_wp_http_referer',
1012
-                wp_unslash($_SERVER['REQUEST_URI'])
1013
-        );
1014
-        if (! empty($func)) {
1015
-            if (is_array($func)) {
1016
-                list($class, $method) = $func;
1017
-            } elseif (strpos($func, '::') !== false) {
1018
-                list($class, $method) = explode('::', $func);
1019
-            } else {
1020
-                $class  = $this;
1021
-                $method = $func;
1022
-            }
1023
-            if (! (is_object($class) && $class === $this)) {
1024
-                // send along this admin page object for access by addons.
1025
-                $args['admin_page_object'] = $this;
1026
-            }
1027
-            if (
1028
-                //is it a method on a class that doesn't work?
1029
-                (
1030
-                    (
1031
-                        method_exists($class, $method)
1032
-                        && call_user_func_array(array($class, $method), $args) === false
1033
-                    )
1034
-                    && (
1035
-                        //is it a standalone function that doesn't work?
1036
-                        function_exists($method)
1037
-                        && call_user_func_array(
1038
-                            $func,
1039
-                            array_merge(array('admin_page_object' => $this), $args)
1040
-                           ) === false
1041
-                    )
1042
-                )
1043
-                || (
1044
-                    //is it neither a class method NOR a standalone function?
1045
-                    ! method_exists($class, $method)
1046
-                    && ! function_exists($method)
1047
-                )
1048
-            ) {
1049
-                // user error msg
1050
-                $error_msg = esc_html__(
1051
-                    'An error occurred. The  requested page route could not be found.',
1052
-                    'event_espresso'
1053
-                );
1054
-                // developer error msg
1055
-                $error_msg .= '||';
1056
-                $error_msg .= sprintf(
1057
-                    esc_html__(
1058
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1059
-                        'event_espresso'
1060
-                    ),
1061
-                    $method
1062
-                );
1063
-            }
1064
-            if (! empty($error_msg)) {
1065
-                throw new EE_Error($error_msg);
1066
-            }
1067
-        }
1068
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1069
-        // then we need to reset the routing properties to the new route.
1070
-        //now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1071
-        if ($this->_is_UI_request === false
1072
-            && is_array($this->_route)
1073
-            && ! empty($this->_route['headers_sent_route'])
1074
-        ) {
1075
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1076
-        }
1077
-    }
1078
-
1079
-
1080
-
1081
-    /**
1082
-     * This method just allows the resetting of page properties in the case where a no headers
1083
-     * route redirects to a headers route in its route config.
1084
-     *
1085
-     * @since   4.3.0
1086
-     * @param  string $new_route New (non header) route to redirect to.
1087
-     * @return   void
1088
-     * @throws ReflectionException
1089
-     * @throws InvalidArgumentException
1090
-     * @throws InvalidInterfaceException
1091
-     * @throws InvalidDataTypeException
1092
-     * @throws EE_Error
1093
-     */
1094
-    protected function _reset_routing_properties($new_route)
1095
-    {
1096
-        $this->_is_UI_request = true;
1097
-        //now we set the current route to whatever the headers_sent_route is set at
1098
-        $this->_req_data['action'] = $new_route;
1099
-        //rerun page setup
1100
-        $this->_page_setup();
1101
-    }
1102
-
1103
-
1104
-
1105
-    /**
1106
-     * _add_query_arg
1107
-     * adds nonce to array of arguments then calls WP add_query_arg function
1108
-     *(internally just uses EEH_URL's function with the same name)
1109
-     *
1110
-     * @param array  $args
1111
-     * @param string $url
1112
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1113
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1114
-     *                                        Example usage: If the current page is:
1115
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1116
-     *                                        &action=default&event_id=20&month_range=March%202015
1117
-     *                                        &_wpnonce=5467821
1118
-     *                                        and you call:
1119
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1120
-     *                                        array(
1121
-     *                                        'action' => 'resend_something',
1122
-     *                                        'page=>espresso_registrations'
1123
-     *                                        ),
1124
-     *                                        $some_url,
1125
-     *                                        true
1126
-     *                                        );
1127
-     *                                        It will produce a url in this structure:
1128
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1129
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1130
-     *                                        month_range]=March%202015
1131
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1132
-     * @return string
1133
-     */
1134
-    public static function add_query_args_and_nonce(
1135
-        $args = array(),
1136
-        $url = false,
1137
-        $sticky = false,
1138
-        $exclude_nonce = false
1139
-    ) {
1140
-        //if there is a _wp_http_referer include the values from the request but only if sticky = true
1141
-        if ($sticky) {
1142
-            $request = $_REQUEST;
1143
-            unset($request['_wp_http_referer']);
1144
-            unset($request['wp_referer']);
1145
-            foreach ($request as $key => $value) {
1146
-                //do not add nonces
1147
-                if (strpos($key, 'nonce') !== false) {
1148
-                    continue;
1149
-                }
1150
-                $args['wp_referer[' . $key . ']'] = $value;
1151
-            }
1152
-        }
1153
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1154
-    }
1155
-
1156
-
1157
-
1158
-    /**
1159
-     * This returns a generated link that will load the related help tab.
1160
-     *
1161
-     * @param  string $help_tab_id the id for the connected help tab
1162
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1163
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1164
-     * @uses EEH_Template::get_help_tab_link()
1165
-     * @return string              generated link
1166
-     */
1167
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1168
-    {
1169
-        return EEH_Template::get_help_tab_link(
1170
-            $help_tab_id,
1171
-            $this->page_slug,
1172
-            $this->_req_action,
1173
-            $icon_style,
1174
-            $help_text
1175
-        );
1176
-    }
1177
-
1178
-
1179
-
1180
-    /**
1181
-     * _add_help_tabs
1182
-     * Note child classes define their help tabs within the page_config array.
1183
-     *
1184
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1185
-     * @return void
1186
-     * @throws DomainException
1187
-     * @throws EE_Error
1188
-     */
1189
-    protected function _add_help_tabs()
1190
-    {
1191
-        $tour_buttons = '';
1192
-        if (isset($this->_page_config[$this->_req_action])) {
1193
-            $config = $this->_page_config[$this->_req_action];
1194
-            //is there a help tour for the current route?  if there is let's setup the tour buttons
1195
-            if (isset($this->_help_tour[$this->_req_action])) {
1196
-                $tb           = array();
1197
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1198
-                foreach ($this->_help_tour['tours'] as $tour) {
1199
-                    //if this is the end tour then we don't need to setup a button
1200
-                    if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1201
-                        continue;
1202
-                    }
1203
-                    $tb[] = '<button id="trigger-tour-'
1204
-                            . $tour->get_slug()
1205
-                            . '" class="button-primary trigger-ee-help-tour">'
1206
-                            . $tour->get_label()
1207
-                            . '</button>';
1208
-                }
1209
-                $tour_buttons .= implode('<br />', $tb);
1210
-                $tour_buttons .= '</div></div>';
1211
-            }
1212
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1213
-            if (is_array($config) && isset($config['help_sidebar'])) {
1214
-                //check that the callback given is valid
1215
-                if (! method_exists($this, $config['help_sidebar'])) {
1216
-                    throw new EE_Error(
1217
-                        sprintf(
1218
-                            esc_html__(
1219
-                                'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1220
-                                'event_espresso'
1221
-                            ),
1222
-                            $config['help_sidebar'],
1223
-                            get_class($this)
1224
-                        )
1225
-                    );
1226
-                }
1227
-                $content = apply_filters(
1228
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1229
-                    $this->{$config['help_sidebar']}()
1230
-                );
1231
-                $content .= $tour_buttons; //add help tour buttons.
1232
-                //do we have any help tours setup?  Cause if we do we want to add the buttons
1233
-                $this->_current_screen->set_help_sidebar($content);
1234
-            }
1235
-            //if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1236
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1237
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1238
-            }
1239
-            //handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1240
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1241
-                $_ht['id']      = $this->page_slug;
1242
-                $_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1243
-                $_ht['content'] = '<p>' . esc_html__(
1244
-                        'The buttons to the right allow you to start/restart any help tours available for this page',
1245
-                        'event_espresso'
1246
-                    ) . '</p>';
1247
-                $this->_current_screen->add_help_tab($_ht);
1248
-            }
1249
-            if (! isset($config['help_tabs'])) {
1250
-                return;
1251
-            } //no help tabs for this route
1252
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1253
-                //we're here so there ARE help tabs!
1254
-                //make sure we've got what we need
1255
-                if (! isset($cfg['title'])) {
1256
-                    throw new EE_Error(
1257
-                        esc_html__(
1258
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1259
-                            'event_espresso'
1260
-                        )
1261
-                    );
1262
-                }
1263
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1264
-                    throw new EE_Error(
1265
-                        esc_html__(
1266
-                            'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1267
-                            'event_espresso'
1268
-                        )
1269
-                    );
1270
-                }
1271
-                //first priority goes to content.
1272
-                if (! empty($cfg['content'])) {
1273
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1274
-                    //second priority goes to filename
1275
-                } elseif (! empty($cfg['filename'])) {
1276
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1277
-                    //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1278
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1279
-                                                             . basename($this->_get_dir())
1280
-                                                             . '/help_tabs/'
1281
-                                                             . $cfg['filename']
1282
-                                                             . '.help_tab.php' : $file_path;
1283
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1284
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1285
-                        EE_Error::add_error(
1286
-                            sprintf(
1287
-                                esc_html__(
1288
-                                    'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1289
-                                    'event_espresso'
1290
-                                ),
1291
-                                $tab_id,
1292
-                                key($config),
1293
-                                $file_path
1294
-                            ),
1295
-                            __FILE__,
1296
-                            __FUNCTION__,
1297
-                            __LINE__
1298
-                        );
1299
-                        return;
1300
-                    }
1301
-                    $template_args['admin_page_obj'] = $this;
1302
-                    $content = EEH_Template::display_template(
1303
-                        $file_path,
1304
-                        $template_args,
1305
-                        true
1306
-                    );
1307
-                } else {
1308
-                    $content = '';
1309
-                }
1310
-                //check if callback is valid
1311
-                if (
1312
-                    empty($content) && (
1313
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1314
-                    )
1315
-                ) {
1316
-                    EE_Error::add_error(
1317
-                        sprintf(
1318
-                            esc_html__(
1319
-                                'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1320
-                                'event_espresso'
1321
-                            ),
1322
-                            $cfg['title']
1323
-                        ),
1324
-                        __FILE__,
1325
-                        __FUNCTION__,
1326
-                        __LINE__
1327
-                    );
1328
-                    return;
1329
-                }
1330
-                //setup config array for help tab method
1331
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1332
-                $_ht = array(
1333
-                    'id'       => $id,
1334
-                    'title'    => $cfg['title'],
1335
-                    'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1336
-                    'content'  => $content,
1337
-                );
1338
-                $this->_current_screen->add_help_tab($_ht);
1339
-            }
1340
-        }
1341
-    }
1342
-
1343
-
1344
-
1345
-    /**
1346
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1347
-     * an array with properties for setting up usage of the joyride plugin
1348
-     *
1349
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1350
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1351
-     *         _set_page_config() comments
1352
-     * @return void
1353
-     * @throws EE_Error
1354
-     * @throws InvalidArgumentException
1355
-     * @throws InvalidDataTypeException
1356
-     * @throws InvalidInterfaceException
1357
-     */
1358
-    protected function _add_help_tour()
1359
-    {
1360
-        $tours            = array();
1361
-        $this->_help_tour = array();
1362
-        //exit early if help tours are turned off globally
1363
-        if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1364
-            || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1365
-        ) {
1366
-            return;
1367
-        }
1368
-        //loop through _page_config to find any help_tour defined
1369
-        foreach ($this->_page_config as $route => $config) {
1370
-            //we're only going to set things up for this route
1371
-            if ($route !== $this->_req_action) {
1372
-                continue;
1373
-            }
1374
-            if (isset($config['help_tour'])) {
1375
-                foreach ($config['help_tour'] as $tour) {
1376
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1377
-                    // let's see if we can get that file...
1378
-                    // if not its possible this is a decaf route not set in caffeinated
1379
-                    // so lets try and get the caffeinated equivalent
1380
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1381
-                                                             . basename($this->_get_dir())
1382
-                                                             . '/help_tours/'
1383
-                                                             . $tour
1384
-                                                             . '.class.php' : $file_path;
1385
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1386
-                    if (! is_readable($file_path)) {
1387
-                        EE_Error::add_error(
1388
-                            sprintf(
1389
-                                esc_html__(
1390
-                                    'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1391
-                                    'event_espresso'
1392
-                                ),
1393
-                                $file_path,
1394
-                                $tour
1395
-                            ),
1396
-                            __FILE__,
1397
-                            __FUNCTION__,
1398
-                            __LINE__
1399
-                        );
1400
-                        return;
1401
-                    }
1402
-                    require_once $file_path;
1403
-                    if (! class_exists($tour)) {
1404
-                        $error_msg[] = sprintf(
1405
-                            esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1406
-                            $tour
1407
-                        );
1408
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(
1409
-                                esc_html__(
1410
-                                    'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1411
-                                    'event_espresso'
1412
-                                ),
1413
-                                $tour,
1414
-                                '<br />',
1415
-                                $tour,
1416
-                                $this->_req_action,
1417
-                                get_class($this)
1418
-                            );
1419
-                        throw new EE_Error(implode('||', $error_msg));
1420
-                    }
1421
-                    $tour_obj                   = new $tour($this->_is_caf);
1422
-                    $tours[]                    = $tour_obj;
1423
-                    $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1424
-                }
1425
-                //let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1426
-                $end_stop_tour              = new EE_Help_Tour_final_stop($this->_is_caf);
1427
-                $tours[]                    = $end_stop_tour;
1428
-                $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1429
-            }
1430
-        }
1431
-        if (! empty($tours)) {
1432
-            $this->_help_tour['tours'] = $tours;
1433
-        }
1434
-        // that's it!  Now that the $_help_tours property is set (or not)
1435
-        // the scripts and html should be taken care of automatically.
1436
-    }
1437
-
1438
-
1439
-
1440
-    /**
1441
-     * This simply sets up any qtips that have been defined in the page config
1442
-     *
1443
-     * @return void
1444
-     */
1445
-    protected function _add_qtips()
1446
-    {
1447
-        if (isset($this->_route_config['qtips'])) {
1448
-            $qtips = (array)$this->_route_config['qtips'];
1449
-            //load qtip loader
1450
-            $path = array(
1451
-                $this->_get_dir() . '/qtips/',
1452
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1453
-            );
1454
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1455
-        }
1456
-    }
1457
-
1458
-
1459
-
1460
-    /**
1461
-     * _set_nav_tabs
1462
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1463
-     * wish to add additional tabs or modify accordingly.
1464
-     *
1465
-     * @return void
1466
-     * @throws InvalidArgumentException
1467
-     * @throws InvalidInterfaceException
1468
-     * @throws InvalidDataTypeException
1469
-     */
1470
-    protected function _set_nav_tabs()
1471
-    {
1472
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1473
-        $i = 0;
1474
-        foreach ($this->_page_config as $slug => $config) {
1475
-            if (
1476
-                ! is_array($config)
1477
-                || (
1478
-                    is_array($config)
1479
-                    && (
1480
-                        (isset($config['nav']) && ! $config['nav'])
1481
-                        || ! isset($config['nav'])
1482
-                    )
1483
-                )
1484
-            ) {
1485
-                continue;
1486
-            }
1487
-            //no nav tab for this config
1488
-            //check for persistent flag
1489
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1490
-                // nav tab is only to appear when route requested.
1491
-                continue;
1492
-            }
1493
-            if (! $this->check_user_access($slug, true)) {
1494
-                // no nav tab because current user does not have access.
1495
-                continue;
1496
-            }
1497
-            $css_class              = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1498
-            $this->_nav_tabs[$slug] = array(
1499
-                'url'       => isset($config['nav']['url'])
1500
-                    ? $config['nav']['url']
1501
-                    : self::add_query_args_and_nonce(
1502
-                        array('action' => $slug),
1503
-                        $this->_admin_base_url
1504
-                    ),
1505
-                'link_text' => isset($config['nav']['label'])
1506
-                    ? $config['nav']['label']
1507
-                    : ucwords(
1508
-                        str_replace('_', ' ', $slug)
1509
-                    ),
1510
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1511
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1512
-            );
1513
-            $i++;
1514
-        }
1515
-        //if $this->_nav_tabs is empty then lets set the default
1516
-        if (empty($this->_nav_tabs)) {
1517
-            $this->_nav_tabs[$this->_default_nav_tab_name] = array(
1518
-                'url'       => $this->_admin_base_url,
1519
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1520
-                'css_class' => 'nav-tab-active',
1521
-                'order'     => 10,
1522
-            );
1523
-        }
1524
-        //now let's sort the tabs according to order
1525
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1526
-    }
1527
-
1528
-
1529
-
1530
-    /**
1531
-     * _set_current_labels
1532
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1533
-     * property array
1534
-     *
1535
-     * @return void
1536
-     */
1537
-    private function _set_current_labels()
1538
-    {
1539
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1540
-            foreach ($this->_route_config['labels'] as $label => $text) {
1541
-                if (is_array($text)) {
1542
-                    foreach ($text as $sublabel => $subtext) {
1543
-                        $this->_labels[$label][$sublabel] = $subtext;
1544
-                    }
1545
-                } else {
1546
-                    $this->_labels[$label] = $text;
1547
-                }
1548
-            }
1549
-        }
1550
-    }
1551
-
1552
-
1553
-
1554
-    /**
1555
-     *        verifies user access for this admin page
1556
-     *
1557
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1558
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1559
-     *                               return false if verify fail.
1560
-     * @return bool
1561
-     * @throws InvalidArgumentException
1562
-     * @throws InvalidDataTypeException
1563
-     * @throws InvalidInterfaceException
1564
-     */
1565
-    public function check_user_access($route_to_check = '', $verify_only = false)
1566
-    {
1567
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1568
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1569
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1570
-                          && is_array(
1571
-                              $this->_page_routes[$route_to_check]
1572
-                          )
1573
-                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1574
-            ? $this->_page_routes[$route_to_check]['capability'] : null;
1575
-        if (empty($capability) && empty($route_to_check)) {
1576
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1577
-                : $this->_route['capability'];
1578
-        } else {
1579
-            $capability = empty($capability) ? 'manage_options' : $capability;
1580
-        }
1581
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1582
-        if (
1583
-            ! defined('DOING_AJAX')
1584
-            && (
1585
-                ! function_exists('is_admin')
1586
-                || ! EE_Registry::instance()->CAP->current_user_can(
1587
-                    $capability,
1588
-                    $this->page_slug
1589
-                    . '_'
1590
-                    . $route_to_check,
1591
-                    $id
1592
-                )
1593
-            )
1594
-        ) {
1595
-            if ($verify_only) {
1596
-                return false;
1597
-            }
1598
-            if (is_user_logged_in()) {
1599
-                wp_die(__('You do not have access to this route.', 'event_espresso'));
1600
-            } else {
1601
-                return false;
1602
-            }
1603
-        }
1604
-        return true;
1605
-    }
1606
-
1607
-
1608
-
1609
-    /**
1610
-     * admin_init_global
1611
-     * This runs all the code that we want executed within the WP admin_init hook.
1612
-     * This method executes for ALL EE Admin pages.
1613
-     *
1614
-     * @return void
1615
-     */
1616
-    public function admin_init_global()
1617
-    {
1618
-    }
1619
-
1620
-
1621
-
1622
-    /**
1623
-     * wp_loaded_global
1624
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1625
-     * EE_Admin page and will execute on every EE Admin Page load
1626
-     *
1627
-     * @return void
1628
-     */
1629
-    public function wp_loaded()
1630
-    {
1631
-    }
1632
-
1633
-
1634
-
1635
-    /**
1636
-     * admin_notices
1637
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1638
-     * ALL EE_Admin pages.
1639
-     *
1640
-     * @return void
1641
-     */
1642
-    public function admin_notices_global()
1643
-    {
1644
-        $this->_display_no_javascript_warning();
1645
-        $this->_display_espresso_notices();
1646
-    }
1647
-
1648
-
1649
-
1650
-    public function network_admin_notices_global()
1651
-    {
1652
-        $this->_display_no_javascript_warning();
1653
-        $this->_display_espresso_notices();
1654
-    }
1655
-
1656
-
1657
-
1658
-    /**
1659
-     * admin_footer_scripts_global
1660
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1661
-     * will apply on ALL EE_Admin pages.
1662
-     *
1663
-     * @return void
1664
-     */
1665
-    public function admin_footer_scripts_global()
1666
-    {
1667
-        $this->_add_admin_page_ajax_loading_img();
1668
-        $this->_add_admin_page_overlay();
1669
-        //if metaboxes are present we need to add the nonce field
1670
-        if (
1671
-             isset($this->_route_config['metaboxes'])
1672
-             || isset($this->_route_config['list_table'])
1673
-             || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1674
-        ) {
1675
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1676
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1677
-        }
1678
-    }
1679
-
1680
-
1681
-
1682
-    /**
1683
-     * admin_footer_global
1684
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1685
-     * ALL EE_Admin Pages.
1686
-     *
1687
-     * @return void
1688
-     * @throws EE_Error
1689
-     */
1690
-    public function admin_footer_global()
1691
-    {
1692
-        //dialog container for dialog helper
1693
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1694
-        $d_cont .= '<div class="ee-notices"></div>';
1695
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1696
-        $d_cont .= '</div>';
1697
-        echo $d_cont;
1698
-        //help tour stuff?
1699
-        if (isset($this->_help_tour[$this->_req_action])) {
1700
-            echo implode('<br />', $this->_help_tour[$this->_req_action]);
1701
-        }
1702
-        //current set timezone for timezone js
1703
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1704
-    }
1705
-
1706
-
1707
-
1708
-    /**
1709
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1710
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1711
-     * help popups then in your templates or your content you set "triggers" for the content using the
1712
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1713
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1714
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1715
-     * for the
1716
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1717
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1718
-     *    'help_trigger_id' => array(
1719
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1720
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1721
-     *    )
1722
-     * );
1723
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1724
-     *
1725
-     * @param array $help_array
1726
-     * @param bool  $display
1727
-     * @return string content
1728
-     * @throws DomainException
1729
-     * @throws EE_Error
1730
-     */
1731
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1732
-    {
1733
-        $content       = '';
1734
-        $help_array    = empty($help_array) ? $this->_get_help_content() : $help_array;
1735
-        //loop through the array and setup content
1736
-        foreach ($help_array as $trigger => $help) {
1737
-            //make sure the array is setup properly
1738
-            if (! isset($help['title']) || ! isset($help['content'])) {
1739
-                throw new EE_Error(
1740
-                    esc_html__(
1741
-                        'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1742
-                        'event_espresso'
1743
-                    )
1744
-                );
1745
-            }
1746
-            //we're good so let'd setup the template vars and then assign parsed template content to our content.
1747
-            $template_args = array(
1748
-                'help_popup_id'      => $trigger,
1749
-                'help_popup_title'   => $help['title'],
1750
-                'help_popup_content' => $help['content'],
1751
-            );
1752
-            $content       .= EEH_Template::display_template(
1753
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1754
-                $template_args,
1755
-                true
1756
-            );
1757
-        }
1758
-        if ($display) {
1759
-            echo $content;
1760
-            return '';
1761
-        }
1762
-        return $content;
1763
-    }
1764
-
1765
-
1766
-
1767
-    /**
1768
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1769
-     *
1770
-     * @return array properly formatted array for help popup content
1771
-     * @throws EE_Error
1772
-     */
1773
-    private function _get_help_content()
1774
-    {
1775
-        //what is the method we're looking for?
1776
-        $method_name = '_help_popup_content_' . $this->_req_action;
1777
-        //if method doesn't exist let's get out.
1778
-        if (! method_exists($this, $method_name)) {
1779
-            return array();
1780
-        }
1781
-        //k we're good to go let's retrieve the help array
1782
-        $help_array = call_user_func(array($this, $method_name));
1783
-        //make sure we've got an array!
1784
-        if (! is_array($help_array)) {
1785
-            throw new EE_Error(
1786
-                esc_html__(
1787
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1788
-                    'event_espresso'
1789
-                )
1790
-            );
1791
-        }
1792
-        return $help_array;
1793
-    }
1794
-
1795
-
1796
-
1797
-    /**
1798
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1799
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1800
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1801
-     *
1802
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1803
-     * @param boolean $display    if false then we return the trigger string
1804
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1805
-     * @return string
1806
-     * @throws DomainException
1807
-     * @throws EE_Error
1808
-     */
1809
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1810
-    {
1811
-        if (defined('DOING_AJAX')) {
1812
-            return '';
1813
-        }
1814
-        //let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1815
-        $help_array   = $this->_get_help_content();
1816
-        $help_content = '';
1817
-        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1818
-            $help_array[$trigger_id] = array(
1819
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1820
-                'content' => esc_html__(
1821
-                    'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1822
-                    'event_espresso'
1823
-                ),
1824
-            );
1825
-            $help_content            = $this->_set_help_popup_content($help_array, false);
1826
-        }
1827
-        //let's setup the trigger
1828
-        $content = '<a class="ee-dialog" href="?height='
1829
-                   . $dimensions[0]
1830
-                   . '&width='
1831
-                   . $dimensions[1]
1832
-                   . '&inlineId='
1833
-                   . $trigger_id
1834
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1835
-        $content .= $help_content;
1836
-        if ($display) {
1837
-            echo $content;
1838
-            return  '';
1839
-        }
1840
-        return $content;
1841
-    }
1842
-
1843
-
1844
-
1845
-    /**
1846
-     * _add_global_screen_options
1847
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1848
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1849
-     *
1850
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1851
-     *         see also WP_Screen object documents...
1852
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1853
-     * @abstract
1854
-     * @return void
1855
-     */
1856
-    private function _add_global_screen_options()
1857
-    {
1858
-    }
1859
-
1860
-
1861
-
1862
-    /**
1863
-     * _add_global_feature_pointers
1864
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1865
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1866
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1867
-     *
1868
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1869
-     *         extended) also see:
1870
-     * @link   http://eamann.com/tech/wordpress-portland/
1871
-     * @abstract
1872
-     * @return void
1873
-     */
1874
-    private function _add_global_feature_pointers()
1875
-    {
1876
-    }
1877
-
1878
-
1879
-
1880
-    /**
1881
-     * load_global_scripts_styles
1882
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1883
-     *
1884
-     * @return void
1885
-     * @throws EE_Error
1886
-     */
1887
-    public function load_global_scripts_styles()
1888
-    {
1889
-        /** STYLES **/
1890
-        // add debugging styles
1891
-        if (WP_DEBUG) {
1892
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1893
-        }
1894
-        // register all styles
1895
-        wp_register_style(
1896
-            'espresso-ui-theme',
1897
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1898
-            array(),
1899
-            EVENT_ESPRESSO_VERSION
1900
-        );
1901
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1902
-        //helpers styles
1903
-        wp_register_style(
1904
-            'ee-text-links',
1905
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1906
-            array(),
1907
-            EVENT_ESPRESSO_VERSION
1908
-        );
1909
-        /** SCRIPTS **/
1910
-        //register all scripts
1911
-        wp_register_script(
1912
-            'ee-dialog',
1913
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1914
-            array('jquery', 'jquery-ui-draggable'),
1915
-            EVENT_ESPRESSO_VERSION,
1916
-            true
1917
-        );
1918
-        wp_register_script(
1919
-            'ee_admin_js',
1920
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1921
-            array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1922
-            EVENT_ESPRESSO_VERSION,
1923
-            true
1924
-        );
1925
-        wp_register_script(
1926
-            'jquery-ui-timepicker-addon',
1927
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1928
-            array('jquery-ui-datepicker', 'jquery-ui-slider'),
1929
-            EVENT_ESPRESSO_VERSION,
1930
-            true
1931
-        );
1932
-        add_filter('FHEE_load_joyride', '__return_true');
1933
-        //script for sorting tables
1934
-        wp_register_script(
1935
-            'espresso_ajax_table_sorting',
1936
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1937
-            array('ee_admin_js', 'jquery-ui-sortable'),
1938
-            EVENT_ESPRESSO_VERSION,
1939
-            true
1940
-        );
1941
-        //script for parsing uri's
1942
-        wp_register_script(
1943
-            'ee-parse-uri',
1944
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1945
-            array(),
1946
-            EVENT_ESPRESSO_VERSION,
1947
-            true
1948
-        );
1949
-        //and parsing associative serialized form elements
1950
-        wp_register_script(
1951
-            'ee-serialize-full-array',
1952
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1953
-            array('jquery'),
1954
-            EVENT_ESPRESSO_VERSION,
1955
-            true
1956
-        );
1957
-        //helpers scripts
1958
-        wp_register_script(
1959
-            'ee-text-links',
1960
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1961
-            array('jquery'),
1962
-            EVENT_ESPRESSO_VERSION,
1963
-            true
1964
-        );
1965
-        wp_register_script(
1966
-            'ee-moment-core',
1967
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1968
-            array(),
1969
-            EVENT_ESPRESSO_VERSION,
1970
-            true
1971
-        );
1972
-        wp_register_script(
1973
-            'ee-moment',
1974
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1975
-            array('ee-moment-core'),
1976
-            EVENT_ESPRESSO_VERSION,
1977
-            true
1978
-        );
1979
-        wp_register_script(
1980
-            'ee-datepicker',
1981
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1982
-            array('jquery-ui-timepicker-addon', 'ee-moment'),
1983
-            EVENT_ESPRESSO_VERSION,
1984
-            true
1985
-        );
1986
-        //google charts
1987
-        wp_register_script(
1988
-            'google-charts',
1989
-            'https://www.gstatic.com/charts/loader.js',
1990
-            array(),
1991
-            EVENT_ESPRESSO_VERSION,
1992
-            false
1993
-        );
1994
-        // ENQUEUE ALL BASICS BY DEFAULT
1995
-        wp_enqueue_style('ee-admin-css');
1996
-        wp_enqueue_script('ee_admin_js');
1997
-        wp_enqueue_script('ee-accounting');
1998
-        wp_enqueue_script('jquery-validate');
1999
-        //taking care of metaboxes
2000
-        if (
2001
-            empty($this->_cpt_route)
2002
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2003
-        ) {
2004
-            wp_enqueue_script('dashboard');
2005
-        }
2006
-        // LOCALIZED DATA
2007
-        //localize script for ajax lazy loading
2008
-        $lazy_loader_container_ids = apply_filters(
2009
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2010
-            array('espresso_news_post_box_content')
2011
-        );
2012
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2013
-        /**
2014
-         * help tour stuff
2015
-         */
2016
-        if (! empty($this->_help_tour)) {
2017
-            //register the js for kicking things off
2018
-            wp_enqueue_script(
2019
-                'ee-help-tour',
2020
-                EE_ADMIN_URL . 'assets/ee-help-tour.js',
2021
-                array('jquery-joyride'),
2022
-                EVENT_ESPRESSO_VERSION,
2023
-                true
2024
-            );
2025
-            $tours = array();
2026
-            //setup tours for the js tour object
2027
-            foreach ($this->_help_tour['tours'] as $tour) {
2028
-                if ($tour instanceof EE_Help_Tour) {
2029
-                    $tours[] = array(
2030
-                        'id'      => $tour->get_slug(),
2031
-                        'options' => $tour->get_options(),
2032
-                    );
2033
-                }
2034
-            }
2035
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2036
-            //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2037
-        }
2038
-    }
2039
-
2040
-
2041
-
2042
-    /**
2043
-     *        admin_footer_scripts_eei18n_js_strings
2044
-     *
2045
-     * @return        void
2046
-     */
2047
-    public function admin_footer_scripts_eei18n_js_strings()
2048
-    {
2049
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2050
-        EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2051
-            'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2052
-            'event_espresso'
2053
-        );
2054
-        EE_Registry::$i18n_js_strings['January']        = esc_html__('January', 'event_espresso');
2055
-        EE_Registry::$i18n_js_strings['February']       = esc_html__('February', 'event_espresso');
2056
-        EE_Registry::$i18n_js_strings['March']          = esc_html__('March', 'event_espresso');
2057
-        EE_Registry::$i18n_js_strings['April']          = esc_html__('April', 'event_espresso');
2058
-        EE_Registry::$i18n_js_strings['May']            = esc_html__('May', 'event_espresso');
2059
-        EE_Registry::$i18n_js_strings['June']           = esc_html__('June', 'event_espresso');
2060
-        EE_Registry::$i18n_js_strings['July']           = esc_html__('July', 'event_espresso');
2061
-        EE_Registry::$i18n_js_strings['August']         = esc_html__('August', 'event_espresso');
2062
-        EE_Registry::$i18n_js_strings['September']      = esc_html__('September', 'event_espresso');
2063
-        EE_Registry::$i18n_js_strings['October']        = esc_html__('October', 'event_espresso');
2064
-        EE_Registry::$i18n_js_strings['November']       = esc_html__('November', 'event_espresso');
2065
-        EE_Registry::$i18n_js_strings['December']       = esc_html__('December', 'event_espresso');
2066
-        EE_Registry::$i18n_js_strings['Jan']            = esc_html__('Jan', 'event_espresso');
2067
-        EE_Registry::$i18n_js_strings['Feb']            = esc_html__('Feb', 'event_espresso');
2068
-        EE_Registry::$i18n_js_strings['Mar']            = esc_html__('Mar', 'event_espresso');
2069
-        EE_Registry::$i18n_js_strings['Apr']            = esc_html__('Apr', 'event_espresso');
2070
-        EE_Registry::$i18n_js_strings['May']            = esc_html__('May', 'event_espresso');
2071
-        EE_Registry::$i18n_js_strings['Jun']            = esc_html__('Jun', 'event_espresso');
2072
-        EE_Registry::$i18n_js_strings['Jul']            = esc_html__('Jul', 'event_espresso');
2073
-        EE_Registry::$i18n_js_strings['Aug']            = esc_html__('Aug', 'event_espresso');
2074
-        EE_Registry::$i18n_js_strings['Sep']            = esc_html__('Sep', 'event_espresso');
2075
-        EE_Registry::$i18n_js_strings['Oct']            = esc_html__('Oct', 'event_espresso');
2076
-        EE_Registry::$i18n_js_strings['Nov']            = esc_html__('Nov', 'event_espresso');
2077
-        EE_Registry::$i18n_js_strings['Dec']            = esc_html__('Dec', 'event_espresso');
2078
-        EE_Registry::$i18n_js_strings['Sunday']         = esc_html__('Sunday', 'event_espresso');
2079
-        EE_Registry::$i18n_js_strings['Monday']         = esc_html__('Monday', 'event_espresso');
2080
-        EE_Registry::$i18n_js_strings['Tuesday']        = esc_html__('Tuesday', 'event_espresso');
2081
-        EE_Registry::$i18n_js_strings['Wednesday']      = esc_html__('Wednesday', 'event_espresso');
2082
-        EE_Registry::$i18n_js_strings['Thursday']       = esc_html__('Thursday', 'event_espresso');
2083
-        EE_Registry::$i18n_js_strings['Friday']         = esc_html__('Friday', 'event_espresso');
2084
-        EE_Registry::$i18n_js_strings['Saturday']       = esc_html__('Saturday', 'event_espresso');
2085
-        EE_Registry::$i18n_js_strings['Sun']            = esc_html__('Sun', 'event_espresso');
2086
-        EE_Registry::$i18n_js_strings['Mon']            = esc_html__('Mon', 'event_espresso');
2087
-        EE_Registry::$i18n_js_strings['Tue']            = esc_html__('Tue', 'event_espresso');
2088
-        EE_Registry::$i18n_js_strings['Wed']            = esc_html__('Wed', 'event_espresso');
2089
-        EE_Registry::$i18n_js_strings['Thu']            = esc_html__('Thu', 'event_espresso');
2090
-        EE_Registry::$i18n_js_strings['Fri']            = esc_html__('Fri', 'event_espresso');
2091
-        EE_Registry::$i18n_js_strings['Sat']            = esc_html__('Sat', 'event_espresso');
2092
-    }
2093
-
2094
-
2095
-
2096
-    /**
2097
-     *        load enhanced xdebug styles for ppl with failing eyesight
2098
-     *
2099
-     * @return        void
2100
-     */
2101
-    public function add_xdebug_style()
2102
-    {
2103
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2104
-    }
2105
-
2106
-
2107
-    /************************/
2108
-    /** LIST TABLE METHODS **/
2109
-    /************************/
2110
-    /**
2111
-     * this sets up the list table if the current view requires it.
2112
-     *
2113
-     * @return void
2114
-     * @throws EE_Error
2115
-     */
2116
-    protected function _set_list_table()
2117
-    {
2118
-        //first is this a list_table view?
2119
-        if (! isset($this->_route_config['list_table'])) {
2120
-            return;
2121
-        } //not a list_table view so get out.
2122
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2123
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2124
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2125
-            //user error msg
2126
-            $error_msg = esc_html__(
2127
-                'An error occurred. The requested list table views could not be found.',
2128
-                'event_espresso'
2129
-            );
2130
-            //developer error msg
2131
-            $error_msg .= '||' . sprintf(
2132
-                    esc_html__(
2133
-                        'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2134
-                        'event_espresso'
2135
-                    ),
2136
-                    $this->_req_action,
2137
-                    $list_table_view
2138
-                );
2139
-            throw new EE_Error($error_msg);
2140
-        }
2141
-        //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2142
-        $this->_views = apply_filters(
2143
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2144
-            $this->_views
2145
-        );
2146
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2147
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2148
-        $this->_set_list_table_view();
2149
-        $this->_set_list_table_object();
2150
-    }
2151
-
2152
-
2153
-
2154
-    /**
2155
-     * set current view for List Table
2156
-     *
2157
-     * @return void
2158
-     */
2159
-    protected function _set_list_table_view()
2160
-    {
2161
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2162
-        // looking at active items or dumpster diving ?
2163
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2164
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2165
-        } else {
2166
-            $this->_view = sanitize_key($this->_req_data['status']);
2167
-        }
2168
-    }
2169
-
2170
-
2171
-
2172
-    /**
2173
-     * _set_list_table_object
2174
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2175
-     *
2176
-     * @throws EE_Error
2177
-     */
2178
-    protected function _set_list_table_object()
2179
-    {
2180
-        if (isset($this->_route_config['list_table'])) {
2181
-            if (! class_exists($this->_route_config['list_table'])) {
2182
-                throw new EE_Error(
2183
-                    sprintf(
2184
-                        esc_html__(
2185
-                            'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2186
-                            'event_espresso'
2187
-                        ),
2188
-                        $this->_route_config['list_table'],
2189
-                        get_class($this)
2190
-                    )
2191
-                );
2192
-            }
2193
-            $list_table               = $this->_route_config['list_table'];
2194
-            $this->_list_table_object = new $list_table($this);
2195
-        }
2196
-    }
2197
-
2198
-
2199
-
2200
-    /**
2201
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2202
-     *
2203
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2204
-     *                                                    urls.  The array should be indexed by the view it is being
2205
-     *                                                    added to.
2206
-     * @return array
2207
-     */
2208
-    public function get_list_table_view_RLs($extra_query_args = array())
2209
-    {
2210
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2211
-        if (empty($this->_views)) {
2212
-            $this->_views = array();
2213
-        }
2214
-        // cycle thru views
2215
-        foreach ($this->_views as $key => $view) {
2216
-            $query_args = array();
2217
-            // check for current view
2218
-            $this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2219
-            $query_args['action']                      = $this->_req_action;
2220
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2221
-            $query_args['status']                      = $view['slug'];
2222
-            //merge any other arguments sent in.
2223
-            if (isset($extra_query_args[$view['slug']])) {
2224
-                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2225
-            }
2226
-            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2227
-        }
2228
-        return $this->_views;
2229
-    }
2230
-
2231
-
2232
-
2233
-    /**
2234
-     * _entries_per_page_dropdown
2235
-     * generates a drop down box for selecting the number of visible rows in an admin page list table
2236
-     *
2237
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2238
-     *         WP does it.
2239
-     * @param int $max_entries total number of rows in the table
2240
-     * @return string
2241
-     */
2242
-    protected function _entries_per_page_dropdown($max_entries = 0)
2243
-    {
2244
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2245
-        $values   = array(10, 25, 50, 100);
2246
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2247
-        if ($max_entries) {
2248
-            $values[] = $max_entries;
2249
-            sort($values);
2250
-        }
2251
-        $entries_per_page_dropdown = '
125
+	/**
126
+	 * @var string $_req_action
127
+	 */
128
+	protected $_req_action;
129
+
130
+	/**
131
+	 * @var string $_req_nonce
132
+	 */
133
+	protected $_req_nonce;
134
+
135
+	//search related
136
+	protected $_search_btn_label;
137
+
138
+	protected $_search_box_callback;
139
+
140
+	/**
141
+	 * WP Current Screen object
142
+	 *
143
+	 * @var WP_Screen
144
+	 */
145
+	protected $_current_screen;
146
+
147
+	//for holding EE_Admin_Hooks object when needed (set via set_hook_object())
148
+	protected $_hook_obj;
149
+
150
+	//for holding incoming request data
151
+	protected $_req_data;
152
+
153
+	// yes / no array for admin form fields
154
+	protected $_yes_no_values = array();
155
+
156
+	//some default things shared by all child classes
157
+	protected $_default_espresso_metaboxes;
158
+
159
+	/**
160
+	 *    EE_Registry Object
161
+	 *
162
+	 * @var    EE_Registry
163
+	 */
164
+	protected $EE = null;
165
+
166
+
167
+
168
+	/**
169
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
170
+	 *
171
+	 * @var boolean
172
+	 */
173
+	protected $_is_caf = false;
174
+
175
+
176
+
177
+	/**
178
+	 * @Constructor
179
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
+	 * @throws EE_Error
181
+	 * @throws InvalidArgumentException
182
+	 * @throws ReflectionException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws InvalidInterfaceException
185
+	 */
186
+	public function __construct($routing = true)
187
+	{
188
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
189
+			$this->_is_caf = true;
190
+		}
191
+		$this->_yes_no_values = array(
192
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
193
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
194
+		);
195
+		//set the _req_data property.
196
+		$this->_req_data = array_merge($_GET, $_POST);
197
+		//routing enabled?
198
+		$this->_routing = $routing;
199
+		//set initial page props (child method)
200
+		$this->_init_page_props();
201
+		//set global defaults
202
+		$this->_set_defaults();
203
+		//set early because incoming requests could be ajax related and we need to register those hooks.
204
+		$this->_global_ajax_hooks();
205
+		$this->_ajax_hooks();
206
+		//other_page_hooks have to be early too.
207
+		$this->_do_other_page_hooks();
208
+		//This just allows us to have extending classes do something specific
209
+		// before the parent constructor runs _page_setup().
210
+		if (method_exists($this, '_before_page_setup')) {
211
+			$this->_before_page_setup();
212
+		}
213
+		//set up page dependencies
214
+		$this->_page_setup();
215
+	}
216
+
217
+
218
+
219
+	/**
220
+	 * _init_page_props
221
+	 * Child classes use to set at least the following properties:
222
+	 * $page_slug.
223
+	 * $page_label.
224
+	 *
225
+	 * @abstract
226
+	 * @return void
227
+	 */
228
+	abstract protected function _init_page_props();
229
+
230
+
231
+
232
+	/**
233
+	 * _ajax_hooks
234
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
235
+	 * Note: within the ajax callback methods.
236
+	 *
237
+	 * @abstract
238
+	 * @return void
239
+	 */
240
+	abstract protected function _ajax_hooks();
241
+
242
+
243
+
244
+	/**
245
+	 * _define_page_props
246
+	 * child classes define page properties in here.  Must include at least:
247
+	 * $_admin_base_url = base_url for all admin pages
248
+	 * $_admin_page_title = default admin_page_title for admin pages
249
+	 * $_labels = array of default labels for various automatically generated elements:
250
+	 *    array(
251
+	 *        'buttons' => array(
252
+	 *            'add' => esc_html__('label for add new button'),
253
+	 *            'edit' => esc_html__('label for edit button'),
254
+	 *            'delete' => esc_html__('label for delete button')
255
+	 *            )
256
+	 *        )
257
+	 *
258
+	 * @abstract
259
+	 * @return void
260
+	 */
261
+	abstract protected function _define_page_props();
262
+
263
+
264
+
265
+	/**
266
+	 * _set_page_routes
267
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
268
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
269
+	 * have a 'default' route. Here's the format
270
+	 * $this->_page_routes = array(
271
+	 *        'default' => array(
272
+	 *            'func' => '_default_method_handling_route',
273
+	 *            'args' => array('array','of','args'),
274
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
275
+	 *            ajax request, backend processing)
276
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
277
+	 *            headers route after.  The string you enter here should match the defined route reference for a
278
+	 *            headers sent route.
279
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
280
+	 *            this route.
281
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
282
+	 *            checks).
283
+	 *        ),
284
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
285
+	 *        handling method.
286
+	 *        )
287
+	 * )
288
+	 *
289
+	 * @abstract
290
+	 * @return void
291
+	 */
292
+	abstract protected function _set_page_routes();
293
+
294
+
295
+
296
+	/**
297
+	 * _set_page_config
298
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
299
+	 * array corresponds to the page_route for the loaded page. Format:
300
+	 * $this->_page_config = array(
301
+	 *        'default' => array(
302
+	 *            'labels' => array(
303
+	 *                'buttons' => array(
304
+	 *                    'add' => esc_html__('label for adding item'),
305
+	 *                    'edit' => esc_html__('label for editing item'),
306
+	 *                    'delete' => esc_html__('label for deleting item')
307
+	 *                ),
308
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
309
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
310
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
311
+	 *            _define_page_props() method
312
+	 *            'nav' => array(
313
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
314
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
315
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
316
+	 *                'order' => 10, //required to indicate tab position.
317
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
318
+	 *                displayed then add this parameter.
319
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
320
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
321
+	 *            metaboxes set for eventespresso admin pages.
322
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
323
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
324
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
325
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
326
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
327
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
328
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
329
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
330
+	 *            want to display.
331
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
332
+	 *                'tab_id' => array(
333
+	 *                    'title' => 'tab_title',
334
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
335
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
336
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
337
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
338
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
339
+	 *                    attempt to use the callback which should match the name of a method in the class
340
+	 *                    ),
341
+	 *                'tab2_id' => array(
342
+	 *                    'title' => 'tab2 title',
343
+	 *                    'filename' => 'file_name_2'
344
+	 *                    'callback' => 'callback_method_for_content',
345
+	 *                 ),
346
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
347
+	 *            help tab area on an admin page. @link
348
+	 *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
349
+	 *            'help_tour' => array(
350
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
351
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
352
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
353
+	 *            ),
354
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
355
+	 *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
356
+	 *            just set
357
+	 *            'require_nonce' to FALSE
358
+	 *            )
359
+	 * )
360
+	 *
361
+	 * @abstract
362
+	 * @return void
363
+	 */
364
+	abstract protected function _set_page_config();
365
+
366
+
367
+
368
+
369
+
370
+	/** end sample help_tour methods **/
371
+	/**
372
+	 * _add_screen_options
373
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
374
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
375
+	 * to a particular view.
376
+	 *
377
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
378
+	 *         see also WP_Screen object documents...
379
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
380
+	 * @abstract
381
+	 * @return void
382
+	 */
383
+	abstract protected function _add_screen_options();
384
+
385
+
386
+
387
+	/**
388
+	 * _add_feature_pointers
389
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
390
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
391
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
392
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
393
+	 * extended) also see:
394
+	 *
395
+	 * @link   http://eamann.com/tech/wordpress-portland/
396
+	 * @abstract
397
+	 * @return void
398
+	 */
399
+	abstract protected function _add_feature_pointers();
400
+
401
+
402
+
403
+	/**
404
+	 * load_scripts_styles
405
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
406
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
407
+	 * scripts/styles per view by putting them in a dynamic function in this format
408
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
409
+	 *
410
+	 * @abstract
411
+	 * @return void
412
+	 */
413
+	abstract public function load_scripts_styles();
414
+
415
+
416
+
417
+	/**
418
+	 * admin_init
419
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
420
+	 * all pages/views loaded by child class.
421
+	 *
422
+	 * @abstract
423
+	 * @return void
424
+	 */
425
+	abstract public function admin_init();
426
+
427
+
428
+
429
+	/**
430
+	 * admin_notices
431
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
432
+	 * all pages/views loaded by child class.
433
+	 *
434
+	 * @abstract
435
+	 * @return void
436
+	 */
437
+	abstract public function admin_notices();
438
+
439
+
440
+
441
+	/**
442
+	 * admin_footer_scripts
443
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
444
+	 * will apply to all pages/views loaded by child class.
445
+	 *
446
+	 * @return void
447
+	 */
448
+	abstract public function admin_footer_scripts();
449
+
450
+
451
+
452
+	/**
453
+	 * admin_footer
454
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
455
+	 * apply to all pages/views loaded by child class.
456
+	 *
457
+	 * @return void
458
+	 */
459
+	public function admin_footer()
460
+	{
461
+	}
462
+
463
+
464
+
465
+	/**
466
+	 * _global_ajax_hooks
467
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
468
+	 * Note: within the ajax callback methods.
469
+	 *
470
+	 * @abstract
471
+	 * @return void
472
+	 */
473
+	protected function _global_ajax_hooks()
474
+	{
475
+		//for lazy loading of metabox content
476
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
477
+	}
478
+
479
+
480
+
481
+	public function ajax_metabox_content()
482
+	{
483
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
484
+		$url       = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
485
+		self::cached_rss_display($contentid, $url);
486
+		wp_die();
487
+	}
488
+
489
+
490
+
491
+	/**
492
+	 * _page_setup
493
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
494
+	 * doesn't match the object.
495
+	 *
496
+	 * @final
497
+	 * @return void
498
+	 * @throws EE_Error
499
+	 * @throws InvalidArgumentException
500
+	 * @throws ReflectionException
501
+	 * @throws InvalidDataTypeException
502
+	 * @throws InvalidInterfaceException
503
+	 */
504
+	final protected function _page_setup()
505
+	{
506
+		//requires?
507
+		//admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
508
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
509
+		//next verify if we need to load anything...
510
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
511
+		$this->page_folder   = strtolower(
512
+			str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
513
+		);
514
+		global $ee_menu_slugs;
515
+		$ee_menu_slugs = (array)$ee_menu_slugs;
516
+		if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))) {
517
+			return;
518
+		}
519
+		// becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
520
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
521
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
522
+				? $this->_req_data['action2']
523
+				: $this->_req_data['action'];
524
+		}
525
+		// then set blank or -1 action values to 'default'
526
+		$this->_req_action = isset($this->_req_data['action'])
527
+							 && ! empty($this->_req_data['action'])
528
+							 && $this->_req_data['action'] !== '-1'
529
+			? sanitize_key($this->_req_data['action'])
530
+			: 'default';
531
+		// if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
532
+		//  This covers cases where we're coming in from a list table that isn't on the default route.
533
+		$this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
534
+			? $this->_req_data['route'] : $this->_req_action;
535
+		//however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
536
+		$this->_req_action   = defined('DOING_AJAX') && isset($this->_req_data['route'])
537
+			? $this->_req_data['route']
538
+			: $this->_req_action;
539
+		$this->_current_view = $this->_req_action;
540
+		$this->_req_nonce    = $this->_req_action . '_nonce';
541
+		$this->_define_page_props();
542
+		$this->_current_page_view_url = add_query_arg(
543
+			array('page' => $this->_current_page, 'action' => $this->_current_view),
544
+			$this->_admin_base_url
545
+		);
546
+		//default things
547
+		$this->_default_espresso_metaboxes = array(
548
+			'_espresso_news_post_box',
549
+			'_espresso_links_post_box',
550
+			'_espresso_ratings_request',
551
+			'_espresso_sponsors_post_box',
552
+		);
553
+		//set page configs
554
+		$this->_set_page_routes();
555
+		$this->_set_page_config();
556
+		//let's include any referrer data in our default_query_args for this route for "stickiness".
557
+		if (isset($this->_req_data['wp_referer'])) {
558
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
559
+		}
560
+		//for caffeinated and other extended functionality.
561
+		//  If there is a _extend_page_config method
562
+		// then let's run that to modify the all the various page configuration arrays
563
+		if (method_exists($this, '_extend_page_config')) {
564
+			$this->_extend_page_config();
565
+		}
566
+		//for CPT and other extended functionality.
567
+		// If there is an _extend_page_config_for_cpt
568
+		// then let's run that to modify all the various page configuration arrays.
569
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
570
+			$this->_extend_page_config_for_cpt();
571
+		}
572
+		//filter routes and page_config so addons can add their stuff. Filtering done per class
573
+		$this->_page_routes = apply_filters(
574
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
575
+			$this->_page_routes,
576
+			$this
577
+		);
578
+		$this->_page_config = apply_filters(
579
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
580
+			$this->_page_config,
581
+			$this
582
+		);
583
+		//if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
584
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
585
+		if (
586
+			method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)
587
+		) {
588
+			add_action(
589
+				'AHEE__EE_Admin_Page__route_admin_request',
590
+				array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
591
+				10,
592
+				2
593
+			);
594
+		}
595
+		//next route only if routing enabled
596
+		if ($this->_routing && ! defined('DOING_AJAX')) {
597
+			$this->_verify_routes();
598
+			//next let's just check user_access and kill if no access
599
+			$this->check_user_access();
600
+			if ($this->_is_UI_request) {
601
+				//admin_init stuff - global, all views for this page class, specific view
602
+				add_action('admin_init', array($this, 'admin_init'), 10);
603
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
604
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
605
+				}
606
+			} else {
607
+				//hijack regular WP loading and route admin request immediately
608
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
609
+				$this->route_admin_request();
610
+			}
611
+		}
612
+	}
613
+
614
+
615
+
616
+	/**
617
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
618
+	 *
619
+	 * @return void
620
+	 * @throws ReflectionException
621
+	 * @throws EE_Error
622
+	 */
623
+	private function _do_other_page_hooks()
624
+	{
625
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
626
+		foreach ($registered_pages as $page) {
627
+			//now let's setup the file name and class that should be present
628
+			$classname = str_replace('.class.php', '', $page);
629
+			//autoloaders should take care of loading file
630
+			if (! class_exists($classname)) {
631
+				$error_msg[] = sprintf(
632
+					esc_html__(
633
+						'Something went wrong with loading the %s admin hooks page.',
634
+						'event_espresso'
635
+					),
636
+					$page
637
+				);
638
+				$error_msg[] = $error_msg[0]
639
+							   . "\r\n"
640
+							   . sprintf(
641
+								   esc_html__(
642
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
643
+									   'event_espresso'
644
+								   ),
645
+								   $page,
646
+								   '<br />',
647
+								   '<strong>' . $classname . '</strong>'
648
+							   );
649
+				throw new EE_Error(implode('||', $error_msg));
650
+			}
651
+			$a = new ReflectionClass($classname);
652
+			//notice we are passing the instance of this class to the hook object.
653
+			$hookobj[] = $a->newInstance($this);
654
+		}
655
+	}
656
+
657
+
658
+
659
+	public function load_page_dependencies()
660
+	{
661
+		try {
662
+			$this->_load_page_dependencies();
663
+		} catch (EE_Error $e) {
664
+			$e->get_error();
665
+		}
666
+	}
667
+
668
+
669
+
670
+	/**
671
+	 * load_page_dependencies
672
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
673
+	 *
674
+	 * @return void
675
+	 * @throws DomainException
676
+	 * @throws EE_Error
677
+	 * @throws InvalidArgumentException
678
+	 * @throws InvalidDataTypeException
679
+	 * @throws InvalidInterfaceException
680
+	 * @throws ReflectionException
681
+	 */
682
+	protected function _load_page_dependencies()
683
+	{
684
+		//let's set the current_screen and screen options to override what WP set
685
+		$this->_current_screen = get_current_screen();
686
+		//load admin_notices - global, page class, and view specific
687
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
688
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
689
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
690
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
691
+		}
692
+		//load network admin_notices - global, page class, and view specific
693
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
694
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
695
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
696
+		}
697
+		//this will save any per_page screen options if they are present
698
+		$this->_set_per_page_screen_options();
699
+		//setup list table properties
700
+		$this->_set_list_table();
701
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
702
+		// However in some cases the metaboxes will need to be added within a route handling callback.
703
+		$this->_add_registered_meta_boxes();
704
+		$this->_add_screen_columns();
705
+		//add screen options - global, page child class, and view specific
706
+		$this->_add_global_screen_options();
707
+		$this->_add_screen_options();
708
+		$add_screen_options  = "_add_screen_options_{$this->_current_view}";
709
+		if (method_exists($this, $add_screen_options )) {
710
+			$this->{$add_screen_options}();
711
+		}
712
+		//add help tab(s) and tours- set via page_config and qtips.
713
+		$this->_add_help_tour();
714
+		$this->_add_help_tabs();
715
+		$this->_add_qtips();
716
+		//add feature_pointers - global, page child class, and view specific
717
+		$this->_add_feature_pointers();
718
+		$this->_add_global_feature_pointers();
719
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
720
+		if (method_exists($this, $add_feature_pointer )) {
721
+			$this->{$add_feature_pointer}();
722
+		}
723
+		//enqueue scripts/styles - global, page class, and view specific
724
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
725
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
726
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
727
+			add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
728
+		}
729
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
730
+		// admin_print_footer_scripts - global, page child class, and view specific.
731
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
732
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
733
+		// is a good use case. Notice the late priority we're giving these
734
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
735
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
736
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
737
+			add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
738
+		}
739
+		//admin footer scripts
740
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
741
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
742
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
743
+			add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
744
+		}
745
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
746
+		//targeted hook
747
+		do_action(
748
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
749
+
750
+		);
751
+	}
752
+
753
+
754
+
755
+	/**
756
+	 * _set_defaults
757
+	 * This sets some global defaults for class properties.
758
+	 */
759
+	private function _set_defaults()
760
+	{
761
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
762
+		$this->_event = $this->_template_path = $this->_column_template_path = null;
763
+		$this->_nav_tabs = $this->_views = $this->_page_routes = array();
764
+		$this->_page_config = $this->_default_route_query_args = array();
765
+		$this->_default_nav_tab_name = 'overview';
766
+		//init template args
767
+		$this->_template_args = array(
768
+			'admin_page_header'  => '',
769
+			'admin_page_content' => '',
770
+			'post_body_content'  => '',
771
+			'before_list_table'  => '',
772
+			'after_list_table'   => '',
773
+		);
774
+	}
775
+
776
+
777
+
778
+	/**
779
+	 * route_admin_request
780
+	 *
781
+	 * @see    _route_admin_request()
782
+	 * @return exception|void error
783
+	 * @throws InvalidArgumentException
784
+	 * @throws InvalidInterfaceException
785
+	 * @throws InvalidDataTypeException
786
+	 * @throws EE_Error
787
+	 * @throws ReflectionException
788
+	 */
789
+	public function route_admin_request()
790
+	{
791
+		try {
792
+			$this->_route_admin_request();
793
+		} catch (EE_Error $e) {
794
+			$e->get_error();
795
+		}
796
+	}
797
+
798
+
799
+
800
+	public function set_wp_page_slug($wp_page_slug)
801
+	{
802
+		$this->_wp_page_slug = $wp_page_slug;
803
+		//if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
804
+		if (is_network_admin()) {
805
+			$this->_wp_page_slug .= '-network';
806
+		}
807
+	}
808
+
809
+
810
+
811
+	/**
812
+	 * _verify_routes
813
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
814
+	 * we know if we need to drop out.
815
+	 *
816
+	 * @return bool
817
+	 * @throws EE_Error
818
+	 */
819
+	protected function _verify_routes()
820
+	{
821
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
822
+		if (! $this->_current_page && ! defined('DOING_AJAX')) {
823
+			return false;
824
+		}
825
+		$this->_route = false;
826
+		// check that the page_routes array is not empty
827
+		if (empty($this->_page_routes)) {
828
+			// user error msg
829
+			$error_msg = sprintf(
830
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
831
+				$this->_admin_page_title
832
+			);
833
+			// developer error msg
834
+			$error_msg .= '||' . $error_msg . esc_html__(
835
+				' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
836
+				'event_espresso'
837
+			);
838
+			throw new EE_Error($error_msg);
839
+		}
840
+		// and that the requested page route exists
841
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
842
+			$this->_route        = $this->_page_routes[$this->_req_action];
843
+			$this->_route_config = isset($this->_page_config[$this->_req_action])
844
+				? $this->_page_config[$this->_req_action] : array();
845
+		} else {
846
+			// user error msg
847
+			$error_msg = sprintf(
848
+				esc_html__(
849
+						'The requested page route does not exist for the %s admin page.',
850
+						'event_espresso'
851
+				),
852
+				$this->_admin_page_title
853
+			);
854
+			// developer error msg
855
+			$error_msg .= '||' . $error_msg . sprintf(
856
+					esc_html__(
857
+						' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
858
+						'event_espresso'
859
+					),
860
+					$this->_req_action
861
+				);
862
+			throw new EE_Error($error_msg);
863
+		}
864
+		// and that a default route exists
865
+		if (! array_key_exists('default', $this->_page_routes)) {
866
+			// user error msg
867
+			$error_msg = sprintf(
868
+				esc_html__(
869
+						'A default page route has not been set for the % admin page.',
870
+						'event_espresso'
871
+				),
872
+				$this->_admin_page_title
873
+			);
874
+			// developer error msg
875
+			$error_msg .= '||' . $error_msg . esc_html__(
876
+				' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
877
+				'event_espresso'
878
+			);
879
+			throw new EE_Error($error_msg);
880
+		}
881
+		//first lets' catch if the UI request has EVER been set.
882
+		if ($this->_is_UI_request === null) {
883
+			//lets set if this is a UI request or not.
884
+			$this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
885
+			//wait a minute... we might have a noheader in the route array
886
+			$this->_is_UI_request = is_array($this->_route)
887
+									&& isset($this->_route['noheader'])
888
+									&& $this->_route['noheader'] ? false : $this->_is_UI_request;
889
+		}
890
+		$this->_set_current_labels();
891
+		return true;
892
+	}
893
+
894
+
895
+
896
+	/**
897
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
898
+	 *
899
+	 * @param  string $route the route name we're verifying
900
+	 * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
901
+	 * @throws EE_Error
902
+	 */
903
+	protected function _verify_route($route)
904
+	{
905
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
906
+			return true;
907
+		}
908
+		// user error msg
909
+		$error_msg = sprintf(
910
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
911
+			$this->_admin_page_title
912
+		);
913
+		// developer error msg
914
+		$error_msg .= '||' . $error_msg . sprintf(
915
+				esc_html__(
916
+					' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
917
+					'event_espresso'
918
+				),
919
+				$route
920
+			);
921
+		throw new EE_Error($error_msg);
922
+	}
923
+
924
+
925
+
926
+	/**
927
+	 * perform nonce verification
928
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
929
+	 * using this method (and save retyping!)
930
+	 *
931
+	 * @param  string $nonce     The nonce sent
932
+	 * @param  string $nonce_ref The nonce reference string (name0)
933
+	 * @return void
934
+	 * @throws EE_Error
935
+	 */
936
+	protected function _verify_nonce($nonce, $nonce_ref)
937
+	{
938
+		// verify nonce against expected value
939
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
940
+			// these are not the droids you are looking for !!!
941
+			$msg = sprintf(
942
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
943
+				'<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
944
+				'</a>'
945
+			);
946
+			if (WP_DEBUG) {
947
+				$msg .= "\n  " . sprintf(
948
+						esc_html__(
949
+							'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
950
+							'event_espresso'
951
+						),
952
+						__CLASS__
953
+					);
954
+			}
955
+			if (! defined('DOING_AJAX')) {
956
+				wp_die($msg);
957
+			} else {
958
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
959
+				$this->_return_json();
960
+			}
961
+		}
962
+	}
963
+
964
+
965
+
966
+	/**
967
+	 * _route_admin_request()
968
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
969
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
970
+	 * in the page routes and then will try to load the corresponding method.
971
+	 *
972
+	 * @return void
973
+	 * @throws EE_Error
974
+	 * @throws InvalidArgumentException
975
+	 * @throws InvalidDataTypeException
976
+	 * @throws InvalidInterfaceException
977
+	 * @throws ReflectionException
978
+	 */
979
+	protected function _route_admin_request()
980
+	{
981
+		if (! $this->_is_UI_request) {
982
+			$this->_verify_routes();
983
+		}
984
+		$nonce_check = isset($this->_route_config['require_nonce'])
985
+			? $this->_route_config['require_nonce']
986
+			: true;
987
+		if ($this->_req_action !== 'default' && $nonce_check) {
988
+			// set nonce from post data
989
+			$nonce = isset($this->_req_data[$this->_req_nonce])
990
+				? sanitize_text_field($this->_req_data[$this->_req_nonce])
991
+				: '';
992
+			$this->_verify_nonce($nonce, $this->_req_nonce);
993
+		}
994
+		//set the nav_tabs array but ONLY if this is  UI_request
995
+		if ($this->_is_UI_request) {
996
+			$this->_set_nav_tabs();
997
+		}
998
+		// grab callback function
999
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
1000
+		// check if callback has args
1001
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
1002
+		$error_msg = '';
1003
+		// action right before calling route
1004
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1005
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1006
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1007
+		}
1008
+		// right before calling the route, let's remove _wp_http_referer from the
1009
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
1010
+		$_SERVER['REQUEST_URI'] = remove_query_arg(
1011
+				'_wp_http_referer',
1012
+				wp_unslash($_SERVER['REQUEST_URI'])
1013
+		);
1014
+		if (! empty($func)) {
1015
+			if (is_array($func)) {
1016
+				list($class, $method) = $func;
1017
+			} elseif (strpos($func, '::') !== false) {
1018
+				list($class, $method) = explode('::', $func);
1019
+			} else {
1020
+				$class  = $this;
1021
+				$method = $func;
1022
+			}
1023
+			if (! (is_object($class) && $class === $this)) {
1024
+				// send along this admin page object for access by addons.
1025
+				$args['admin_page_object'] = $this;
1026
+			}
1027
+			if (
1028
+				//is it a method on a class that doesn't work?
1029
+				(
1030
+					(
1031
+						method_exists($class, $method)
1032
+						&& call_user_func_array(array($class, $method), $args) === false
1033
+					)
1034
+					&& (
1035
+						//is it a standalone function that doesn't work?
1036
+						function_exists($method)
1037
+						&& call_user_func_array(
1038
+							$func,
1039
+							array_merge(array('admin_page_object' => $this), $args)
1040
+						   ) === false
1041
+					)
1042
+				)
1043
+				|| (
1044
+					//is it neither a class method NOR a standalone function?
1045
+					! method_exists($class, $method)
1046
+					&& ! function_exists($method)
1047
+				)
1048
+			) {
1049
+				// user error msg
1050
+				$error_msg = esc_html__(
1051
+					'An error occurred. The  requested page route could not be found.',
1052
+					'event_espresso'
1053
+				);
1054
+				// developer error msg
1055
+				$error_msg .= '||';
1056
+				$error_msg .= sprintf(
1057
+					esc_html__(
1058
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1059
+						'event_espresso'
1060
+					),
1061
+					$method
1062
+				);
1063
+			}
1064
+			if (! empty($error_msg)) {
1065
+				throw new EE_Error($error_msg);
1066
+			}
1067
+		}
1068
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1069
+		// then we need to reset the routing properties to the new route.
1070
+		//now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1071
+		if ($this->_is_UI_request === false
1072
+			&& is_array($this->_route)
1073
+			&& ! empty($this->_route['headers_sent_route'])
1074
+		) {
1075
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1076
+		}
1077
+	}
1078
+
1079
+
1080
+
1081
+	/**
1082
+	 * This method just allows the resetting of page properties in the case where a no headers
1083
+	 * route redirects to a headers route in its route config.
1084
+	 *
1085
+	 * @since   4.3.0
1086
+	 * @param  string $new_route New (non header) route to redirect to.
1087
+	 * @return   void
1088
+	 * @throws ReflectionException
1089
+	 * @throws InvalidArgumentException
1090
+	 * @throws InvalidInterfaceException
1091
+	 * @throws InvalidDataTypeException
1092
+	 * @throws EE_Error
1093
+	 */
1094
+	protected function _reset_routing_properties($new_route)
1095
+	{
1096
+		$this->_is_UI_request = true;
1097
+		//now we set the current route to whatever the headers_sent_route is set at
1098
+		$this->_req_data['action'] = $new_route;
1099
+		//rerun page setup
1100
+		$this->_page_setup();
1101
+	}
1102
+
1103
+
1104
+
1105
+	/**
1106
+	 * _add_query_arg
1107
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1108
+	 *(internally just uses EEH_URL's function with the same name)
1109
+	 *
1110
+	 * @param array  $args
1111
+	 * @param string $url
1112
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1113
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1114
+	 *                                        Example usage: If the current page is:
1115
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1116
+	 *                                        &action=default&event_id=20&month_range=March%202015
1117
+	 *                                        &_wpnonce=5467821
1118
+	 *                                        and you call:
1119
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1120
+	 *                                        array(
1121
+	 *                                        'action' => 'resend_something',
1122
+	 *                                        'page=>espresso_registrations'
1123
+	 *                                        ),
1124
+	 *                                        $some_url,
1125
+	 *                                        true
1126
+	 *                                        );
1127
+	 *                                        It will produce a url in this structure:
1128
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1129
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1130
+	 *                                        month_range]=March%202015
1131
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1132
+	 * @return string
1133
+	 */
1134
+	public static function add_query_args_and_nonce(
1135
+		$args = array(),
1136
+		$url = false,
1137
+		$sticky = false,
1138
+		$exclude_nonce = false
1139
+	) {
1140
+		//if there is a _wp_http_referer include the values from the request but only if sticky = true
1141
+		if ($sticky) {
1142
+			$request = $_REQUEST;
1143
+			unset($request['_wp_http_referer']);
1144
+			unset($request['wp_referer']);
1145
+			foreach ($request as $key => $value) {
1146
+				//do not add nonces
1147
+				if (strpos($key, 'nonce') !== false) {
1148
+					continue;
1149
+				}
1150
+				$args['wp_referer[' . $key . ']'] = $value;
1151
+			}
1152
+		}
1153
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1154
+	}
1155
+
1156
+
1157
+
1158
+	/**
1159
+	 * This returns a generated link that will load the related help tab.
1160
+	 *
1161
+	 * @param  string $help_tab_id the id for the connected help tab
1162
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1163
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1164
+	 * @uses EEH_Template::get_help_tab_link()
1165
+	 * @return string              generated link
1166
+	 */
1167
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1168
+	{
1169
+		return EEH_Template::get_help_tab_link(
1170
+			$help_tab_id,
1171
+			$this->page_slug,
1172
+			$this->_req_action,
1173
+			$icon_style,
1174
+			$help_text
1175
+		);
1176
+	}
1177
+
1178
+
1179
+
1180
+	/**
1181
+	 * _add_help_tabs
1182
+	 * Note child classes define their help tabs within the page_config array.
1183
+	 *
1184
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1185
+	 * @return void
1186
+	 * @throws DomainException
1187
+	 * @throws EE_Error
1188
+	 */
1189
+	protected function _add_help_tabs()
1190
+	{
1191
+		$tour_buttons = '';
1192
+		if (isset($this->_page_config[$this->_req_action])) {
1193
+			$config = $this->_page_config[$this->_req_action];
1194
+			//is there a help tour for the current route?  if there is let's setup the tour buttons
1195
+			if (isset($this->_help_tour[$this->_req_action])) {
1196
+				$tb           = array();
1197
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1198
+				foreach ($this->_help_tour['tours'] as $tour) {
1199
+					//if this is the end tour then we don't need to setup a button
1200
+					if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1201
+						continue;
1202
+					}
1203
+					$tb[] = '<button id="trigger-tour-'
1204
+							. $tour->get_slug()
1205
+							. '" class="button-primary trigger-ee-help-tour">'
1206
+							. $tour->get_label()
1207
+							. '</button>';
1208
+				}
1209
+				$tour_buttons .= implode('<br />', $tb);
1210
+				$tour_buttons .= '</div></div>';
1211
+			}
1212
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1213
+			if (is_array($config) && isset($config['help_sidebar'])) {
1214
+				//check that the callback given is valid
1215
+				if (! method_exists($this, $config['help_sidebar'])) {
1216
+					throw new EE_Error(
1217
+						sprintf(
1218
+							esc_html__(
1219
+								'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1220
+								'event_espresso'
1221
+							),
1222
+							$config['help_sidebar'],
1223
+							get_class($this)
1224
+						)
1225
+					);
1226
+				}
1227
+				$content = apply_filters(
1228
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1229
+					$this->{$config['help_sidebar']}()
1230
+				);
1231
+				$content .= $tour_buttons; //add help tour buttons.
1232
+				//do we have any help tours setup?  Cause if we do we want to add the buttons
1233
+				$this->_current_screen->set_help_sidebar($content);
1234
+			}
1235
+			//if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1236
+			if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1237
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1238
+			}
1239
+			//handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1240
+			if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1241
+				$_ht['id']      = $this->page_slug;
1242
+				$_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1243
+				$_ht['content'] = '<p>' . esc_html__(
1244
+						'The buttons to the right allow you to start/restart any help tours available for this page',
1245
+						'event_espresso'
1246
+					) . '</p>';
1247
+				$this->_current_screen->add_help_tab($_ht);
1248
+			}
1249
+			if (! isset($config['help_tabs'])) {
1250
+				return;
1251
+			} //no help tabs for this route
1252
+			foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1253
+				//we're here so there ARE help tabs!
1254
+				//make sure we've got what we need
1255
+				if (! isset($cfg['title'])) {
1256
+					throw new EE_Error(
1257
+						esc_html__(
1258
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1259
+							'event_espresso'
1260
+						)
1261
+					);
1262
+				}
1263
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1264
+					throw new EE_Error(
1265
+						esc_html__(
1266
+							'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1267
+							'event_espresso'
1268
+						)
1269
+					);
1270
+				}
1271
+				//first priority goes to content.
1272
+				if (! empty($cfg['content'])) {
1273
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1274
+					//second priority goes to filename
1275
+				} elseif (! empty($cfg['filename'])) {
1276
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1277
+					//it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1278
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1279
+															 . basename($this->_get_dir())
1280
+															 . '/help_tabs/'
1281
+															 . $cfg['filename']
1282
+															 . '.help_tab.php' : $file_path;
1283
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1284
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1285
+						EE_Error::add_error(
1286
+							sprintf(
1287
+								esc_html__(
1288
+									'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1289
+									'event_espresso'
1290
+								),
1291
+								$tab_id,
1292
+								key($config),
1293
+								$file_path
1294
+							),
1295
+							__FILE__,
1296
+							__FUNCTION__,
1297
+							__LINE__
1298
+						);
1299
+						return;
1300
+					}
1301
+					$template_args['admin_page_obj'] = $this;
1302
+					$content = EEH_Template::display_template(
1303
+						$file_path,
1304
+						$template_args,
1305
+						true
1306
+					);
1307
+				} else {
1308
+					$content = '';
1309
+				}
1310
+				//check if callback is valid
1311
+				if (
1312
+					empty($content) && (
1313
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1314
+					)
1315
+				) {
1316
+					EE_Error::add_error(
1317
+						sprintf(
1318
+							esc_html__(
1319
+								'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1320
+								'event_espresso'
1321
+							),
1322
+							$cfg['title']
1323
+						),
1324
+						__FILE__,
1325
+						__FUNCTION__,
1326
+						__LINE__
1327
+					);
1328
+					return;
1329
+				}
1330
+				//setup config array for help tab method
1331
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1332
+				$_ht = array(
1333
+					'id'       => $id,
1334
+					'title'    => $cfg['title'],
1335
+					'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1336
+					'content'  => $content,
1337
+				);
1338
+				$this->_current_screen->add_help_tab($_ht);
1339
+			}
1340
+		}
1341
+	}
1342
+
1343
+
1344
+
1345
+	/**
1346
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1347
+	 * an array with properties for setting up usage of the joyride plugin
1348
+	 *
1349
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1350
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1351
+	 *         _set_page_config() comments
1352
+	 * @return void
1353
+	 * @throws EE_Error
1354
+	 * @throws InvalidArgumentException
1355
+	 * @throws InvalidDataTypeException
1356
+	 * @throws InvalidInterfaceException
1357
+	 */
1358
+	protected function _add_help_tour()
1359
+	{
1360
+		$tours            = array();
1361
+		$this->_help_tour = array();
1362
+		//exit early if help tours are turned off globally
1363
+		if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1364
+			|| ! EE_Registry::instance()->CFG->admin->help_tour_activation
1365
+		) {
1366
+			return;
1367
+		}
1368
+		//loop through _page_config to find any help_tour defined
1369
+		foreach ($this->_page_config as $route => $config) {
1370
+			//we're only going to set things up for this route
1371
+			if ($route !== $this->_req_action) {
1372
+				continue;
1373
+			}
1374
+			if (isset($config['help_tour'])) {
1375
+				foreach ($config['help_tour'] as $tour) {
1376
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1377
+					// let's see if we can get that file...
1378
+					// if not its possible this is a decaf route not set in caffeinated
1379
+					// so lets try and get the caffeinated equivalent
1380
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1381
+															 . basename($this->_get_dir())
1382
+															 . '/help_tours/'
1383
+															 . $tour
1384
+															 . '.class.php' : $file_path;
1385
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1386
+					if (! is_readable($file_path)) {
1387
+						EE_Error::add_error(
1388
+							sprintf(
1389
+								esc_html__(
1390
+									'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1391
+									'event_espresso'
1392
+								),
1393
+								$file_path,
1394
+								$tour
1395
+							),
1396
+							__FILE__,
1397
+							__FUNCTION__,
1398
+							__LINE__
1399
+						);
1400
+						return;
1401
+					}
1402
+					require_once $file_path;
1403
+					if (! class_exists($tour)) {
1404
+						$error_msg[] = sprintf(
1405
+							esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1406
+							$tour
1407
+						);
1408
+						$error_msg[] = $error_msg[0] . "\r\n" . sprintf(
1409
+								esc_html__(
1410
+									'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1411
+									'event_espresso'
1412
+								),
1413
+								$tour,
1414
+								'<br />',
1415
+								$tour,
1416
+								$this->_req_action,
1417
+								get_class($this)
1418
+							);
1419
+						throw new EE_Error(implode('||', $error_msg));
1420
+					}
1421
+					$tour_obj                   = new $tour($this->_is_caf);
1422
+					$tours[]                    = $tour_obj;
1423
+					$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1424
+				}
1425
+				//let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1426
+				$end_stop_tour              = new EE_Help_Tour_final_stop($this->_is_caf);
1427
+				$tours[]                    = $end_stop_tour;
1428
+				$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1429
+			}
1430
+		}
1431
+		if (! empty($tours)) {
1432
+			$this->_help_tour['tours'] = $tours;
1433
+		}
1434
+		// that's it!  Now that the $_help_tours property is set (or not)
1435
+		// the scripts and html should be taken care of automatically.
1436
+	}
1437
+
1438
+
1439
+
1440
+	/**
1441
+	 * This simply sets up any qtips that have been defined in the page config
1442
+	 *
1443
+	 * @return void
1444
+	 */
1445
+	protected function _add_qtips()
1446
+	{
1447
+		if (isset($this->_route_config['qtips'])) {
1448
+			$qtips = (array)$this->_route_config['qtips'];
1449
+			//load qtip loader
1450
+			$path = array(
1451
+				$this->_get_dir() . '/qtips/',
1452
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1453
+			);
1454
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1455
+		}
1456
+	}
1457
+
1458
+
1459
+
1460
+	/**
1461
+	 * _set_nav_tabs
1462
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1463
+	 * wish to add additional tabs or modify accordingly.
1464
+	 *
1465
+	 * @return void
1466
+	 * @throws InvalidArgumentException
1467
+	 * @throws InvalidInterfaceException
1468
+	 * @throws InvalidDataTypeException
1469
+	 */
1470
+	protected function _set_nav_tabs()
1471
+	{
1472
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1473
+		$i = 0;
1474
+		foreach ($this->_page_config as $slug => $config) {
1475
+			if (
1476
+				! is_array($config)
1477
+				|| (
1478
+					is_array($config)
1479
+					&& (
1480
+						(isset($config['nav']) && ! $config['nav'])
1481
+						|| ! isset($config['nav'])
1482
+					)
1483
+				)
1484
+			) {
1485
+				continue;
1486
+			}
1487
+			//no nav tab for this config
1488
+			//check for persistent flag
1489
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1490
+				// nav tab is only to appear when route requested.
1491
+				continue;
1492
+			}
1493
+			if (! $this->check_user_access($slug, true)) {
1494
+				// no nav tab because current user does not have access.
1495
+				continue;
1496
+			}
1497
+			$css_class              = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1498
+			$this->_nav_tabs[$slug] = array(
1499
+				'url'       => isset($config['nav']['url'])
1500
+					? $config['nav']['url']
1501
+					: self::add_query_args_and_nonce(
1502
+						array('action' => $slug),
1503
+						$this->_admin_base_url
1504
+					),
1505
+				'link_text' => isset($config['nav']['label'])
1506
+					? $config['nav']['label']
1507
+					: ucwords(
1508
+						str_replace('_', ' ', $slug)
1509
+					),
1510
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1511
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1512
+			);
1513
+			$i++;
1514
+		}
1515
+		//if $this->_nav_tabs is empty then lets set the default
1516
+		if (empty($this->_nav_tabs)) {
1517
+			$this->_nav_tabs[$this->_default_nav_tab_name] = array(
1518
+				'url'       => $this->_admin_base_url,
1519
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1520
+				'css_class' => 'nav-tab-active',
1521
+				'order'     => 10,
1522
+			);
1523
+		}
1524
+		//now let's sort the tabs according to order
1525
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1526
+	}
1527
+
1528
+
1529
+
1530
+	/**
1531
+	 * _set_current_labels
1532
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1533
+	 * property array
1534
+	 *
1535
+	 * @return void
1536
+	 */
1537
+	private function _set_current_labels()
1538
+	{
1539
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1540
+			foreach ($this->_route_config['labels'] as $label => $text) {
1541
+				if (is_array($text)) {
1542
+					foreach ($text as $sublabel => $subtext) {
1543
+						$this->_labels[$label][$sublabel] = $subtext;
1544
+					}
1545
+				} else {
1546
+					$this->_labels[$label] = $text;
1547
+				}
1548
+			}
1549
+		}
1550
+	}
1551
+
1552
+
1553
+
1554
+	/**
1555
+	 *        verifies user access for this admin page
1556
+	 *
1557
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1558
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1559
+	 *                               return false if verify fail.
1560
+	 * @return bool
1561
+	 * @throws InvalidArgumentException
1562
+	 * @throws InvalidDataTypeException
1563
+	 * @throws InvalidInterfaceException
1564
+	 */
1565
+	public function check_user_access($route_to_check = '', $verify_only = false)
1566
+	{
1567
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1568
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1569
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1570
+						  && is_array(
1571
+							  $this->_page_routes[$route_to_check]
1572
+						  )
1573
+						  && ! empty($this->_page_routes[$route_to_check]['capability'])
1574
+			? $this->_page_routes[$route_to_check]['capability'] : null;
1575
+		if (empty($capability) && empty($route_to_check)) {
1576
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1577
+				: $this->_route['capability'];
1578
+		} else {
1579
+			$capability = empty($capability) ? 'manage_options' : $capability;
1580
+		}
1581
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1582
+		if (
1583
+			! defined('DOING_AJAX')
1584
+			&& (
1585
+				! function_exists('is_admin')
1586
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1587
+					$capability,
1588
+					$this->page_slug
1589
+					. '_'
1590
+					. $route_to_check,
1591
+					$id
1592
+				)
1593
+			)
1594
+		) {
1595
+			if ($verify_only) {
1596
+				return false;
1597
+			}
1598
+			if (is_user_logged_in()) {
1599
+				wp_die(__('You do not have access to this route.', 'event_espresso'));
1600
+			} else {
1601
+				return false;
1602
+			}
1603
+		}
1604
+		return true;
1605
+	}
1606
+
1607
+
1608
+
1609
+	/**
1610
+	 * admin_init_global
1611
+	 * This runs all the code that we want executed within the WP admin_init hook.
1612
+	 * This method executes for ALL EE Admin pages.
1613
+	 *
1614
+	 * @return void
1615
+	 */
1616
+	public function admin_init_global()
1617
+	{
1618
+	}
1619
+
1620
+
1621
+
1622
+	/**
1623
+	 * wp_loaded_global
1624
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1625
+	 * EE_Admin page and will execute on every EE Admin Page load
1626
+	 *
1627
+	 * @return void
1628
+	 */
1629
+	public function wp_loaded()
1630
+	{
1631
+	}
1632
+
1633
+
1634
+
1635
+	/**
1636
+	 * admin_notices
1637
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1638
+	 * ALL EE_Admin pages.
1639
+	 *
1640
+	 * @return void
1641
+	 */
1642
+	public function admin_notices_global()
1643
+	{
1644
+		$this->_display_no_javascript_warning();
1645
+		$this->_display_espresso_notices();
1646
+	}
1647
+
1648
+
1649
+
1650
+	public function network_admin_notices_global()
1651
+	{
1652
+		$this->_display_no_javascript_warning();
1653
+		$this->_display_espresso_notices();
1654
+	}
1655
+
1656
+
1657
+
1658
+	/**
1659
+	 * admin_footer_scripts_global
1660
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1661
+	 * will apply on ALL EE_Admin pages.
1662
+	 *
1663
+	 * @return void
1664
+	 */
1665
+	public function admin_footer_scripts_global()
1666
+	{
1667
+		$this->_add_admin_page_ajax_loading_img();
1668
+		$this->_add_admin_page_overlay();
1669
+		//if metaboxes are present we need to add the nonce field
1670
+		if (
1671
+			 isset($this->_route_config['metaboxes'])
1672
+			 || isset($this->_route_config['list_table'])
1673
+			 || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1674
+		) {
1675
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1676
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1677
+		}
1678
+	}
1679
+
1680
+
1681
+
1682
+	/**
1683
+	 * admin_footer_global
1684
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1685
+	 * ALL EE_Admin Pages.
1686
+	 *
1687
+	 * @return void
1688
+	 * @throws EE_Error
1689
+	 */
1690
+	public function admin_footer_global()
1691
+	{
1692
+		//dialog container for dialog helper
1693
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1694
+		$d_cont .= '<div class="ee-notices"></div>';
1695
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1696
+		$d_cont .= '</div>';
1697
+		echo $d_cont;
1698
+		//help tour stuff?
1699
+		if (isset($this->_help_tour[$this->_req_action])) {
1700
+			echo implode('<br />', $this->_help_tour[$this->_req_action]);
1701
+		}
1702
+		//current set timezone for timezone js
1703
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1704
+	}
1705
+
1706
+
1707
+
1708
+	/**
1709
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1710
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1711
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1712
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1713
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1714
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1715
+	 * for the
1716
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1717
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1718
+	 *    'help_trigger_id' => array(
1719
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1720
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1721
+	 *    )
1722
+	 * );
1723
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1724
+	 *
1725
+	 * @param array $help_array
1726
+	 * @param bool  $display
1727
+	 * @return string content
1728
+	 * @throws DomainException
1729
+	 * @throws EE_Error
1730
+	 */
1731
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1732
+	{
1733
+		$content       = '';
1734
+		$help_array    = empty($help_array) ? $this->_get_help_content() : $help_array;
1735
+		//loop through the array and setup content
1736
+		foreach ($help_array as $trigger => $help) {
1737
+			//make sure the array is setup properly
1738
+			if (! isset($help['title']) || ! isset($help['content'])) {
1739
+				throw new EE_Error(
1740
+					esc_html__(
1741
+						'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1742
+						'event_espresso'
1743
+					)
1744
+				);
1745
+			}
1746
+			//we're good so let'd setup the template vars and then assign parsed template content to our content.
1747
+			$template_args = array(
1748
+				'help_popup_id'      => $trigger,
1749
+				'help_popup_title'   => $help['title'],
1750
+				'help_popup_content' => $help['content'],
1751
+			);
1752
+			$content       .= EEH_Template::display_template(
1753
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1754
+				$template_args,
1755
+				true
1756
+			);
1757
+		}
1758
+		if ($display) {
1759
+			echo $content;
1760
+			return '';
1761
+		}
1762
+		return $content;
1763
+	}
1764
+
1765
+
1766
+
1767
+	/**
1768
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1769
+	 *
1770
+	 * @return array properly formatted array for help popup content
1771
+	 * @throws EE_Error
1772
+	 */
1773
+	private function _get_help_content()
1774
+	{
1775
+		//what is the method we're looking for?
1776
+		$method_name = '_help_popup_content_' . $this->_req_action;
1777
+		//if method doesn't exist let's get out.
1778
+		if (! method_exists($this, $method_name)) {
1779
+			return array();
1780
+		}
1781
+		//k we're good to go let's retrieve the help array
1782
+		$help_array = call_user_func(array($this, $method_name));
1783
+		//make sure we've got an array!
1784
+		if (! is_array($help_array)) {
1785
+			throw new EE_Error(
1786
+				esc_html__(
1787
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1788
+					'event_espresso'
1789
+				)
1790
+			);
1791
+		}
1792
+		return $help_array;
1793
+	}
1794
+
1795
+
1796
+
1797
+	/**
1798
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1799
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1800
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1801
+	 *
1802
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1803
+	 * @param boolean $display    if false then we return the trigger string
1804
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1805
+	 * @return string
1806
+	 * @throws DomainException
1807
+	 * @throws EE_Error
1808
+	 */
1809
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1810
+	{
1811
+		if (defined('DOING_AJAX')) {
1812
+			return '';
1813
+		}
1814
+		//let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1815
+		$help_array   = $this->_get_help_content();
1816
+		$help_content = '';
1817
+		if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1818
+			$help_array[$trigger_id] = array(
1819
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1820
+				'content' => esc_html__(
1821
+					'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1822
+					'event_espresso'
1823
+				),
1824
+			);
1825
+			$help_content            = $this->_set_help_popup_content($help_array, false);
1826
+		}
1827
+		//let's setup the trigger
1828
+		$content = '<a class="ee-dialog" href="?height='
1829
+				   . $dimensions[0]
1830
+				   . '&width='
1831
+				   . $dimensions[1]
1832
+				   . '&inlineId='
1833
+				   . $trigger_id
1834
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1835
+		$content .= $help_content;
1836
+		if ($display) {
1837
+			echo $content;
1838
+			return  '';
1839
+		}
1840
+		return $content;
1841
+	}
1842
+
1843
+
1844
+
1845
+	/**
1846
+	 * _add_global_screen_options
1847
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1848
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1849
+	 *
1850
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1851
+	 *         see also WP_Screen object documents...
1852
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1853
+	 * @abstract
1854
+	 * @return void
1855
+	 */
1856
+	private function _add_global_screen_options()
1857
+	{
1858
+	}
1859
+
1860
+
1861
+
1862
+	/**
1863
+	 * _add_global_feature_pointers
1864
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1865
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1866
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1867
+	 *
1868
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1869
+	 *         extended) also see:
1870
+	 * @link   http://eamann.com/tech/wordpress-portland/
1871
+	 * @abstract
1872
+	 * @return void
1873
+	 */
1874
+	private function _add_global_feature_pointers()
1875
+	{
1876
+	}
1877
+
1878
+
1879
+
1880
+	/**
1881
+	 * load_global_scripts_styles
1882
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1883
+	 *
1884
+	 * @return void
1885
+	 * @throws EE_Error
1886
+	 */
1887
+	public function load_global_scripts_styles()
1888
+	{
1889
+		/** STYLES **/
1890
+		// add debugging styles
1891
+		if (WP_DEBUG) {
1892
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1893
+		}
1894
+		// register all styles
1895
+		wp_register_style(
1896
+			'espresso-ui-theme',
1897
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1898
+			array(),
1899
+			EVENT_ESPRESSO_VERSION
1900
+		);
1901
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1902
+		//helpers styles
1903
+		wp_register_style(
1904
+			'ee-text-links',
1905
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1906
+			array(),
1907
+			EVENT_ESPRESSO_VERSION
1908
+		);
1909
+		/** SCRIPTS **/
1910
+		//register all scripts
1911
+		wp_register_script(
1912
+			'ee-dialog',
1913
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1914
+			array('jquery', 'jquery-ui-draggable'),
1915
+			EVENT_ESPRESSO_VERSION,
1916
+			true
1917
+		);
1918
+		wp_register_script(
1919
+			'ee_admin_js',
1920
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1921
+			array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1922
+			EVENT_ESPRESSO_VERSION,
1923
+			true
1924
+		);
1925
+		wp_register_script(
1926
+			'jquery-ui-timepicker-addon',
1927
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1928
+			array('jquery-ui-datepicker', 'jquery-ui-slider'),
1929
+			EVENT_ESPRESSO_VERSION,
1930
+			true
1931
+		);
1932
+		add_filter('FHEE_load_joyride', '__return_true');
1933
+		//script for sorting tables
1934
+		wp_register_script(
1935
+			'espresso_ajax_table_sorting',
1936
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1937
+			array('ee_admin_js', 'jquery-ui-sortable'),
1938
+			EVENT_ESPRESSO_VERSION,
1939
+			true
1940
+		);
1941
+		//script for parsing uri's
1942
+		wp_register_script(
1943
+			'ee-parse-uri',
1944
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1945
+			array(),
1946
+			EVENT_ESPRESSO_VERSION,
1947
+			true
1948
+		);
1949
+		//and parsing associative serialized form elements
1950
+		wp_register_script(
1951
+			'ee-serialize-full-array',
1952
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1953
+			array('jquery'),
1954
+			EVENT_ESPRESSO_VERSION,
1955
+			true
1956
+		);
1957
+		//helpers scripts
1958
+		wp_register_script(
1959
+			'ee-text-links',
1960
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1961
+			array('jquery'),
1962
+			EVENT_ESPRESSO_VERSION,
1963
+			true
1964
+		);
1965
+		wp_register_script(
1966
+			'ee-moment-core',
1967
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1968
+			array(),
1969
+			EVENT_ESPRESSO_VERSION,
1970
+			true
1971
+		);
1972
+		wp_register_script(
1973
+			'ee-moment',
1974
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1975
+			array('ee-moment-core'),
1976
+			EVENT_ESPRESSO_VERSION,
1977
+			true
1978
+		);
1979
+		wp_register_script(
1980
+			'ee-datepicker',
1981
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1982
+			array('jquery-ui-timepicker-addon', 'ee-moment'),
1983
+			EVENT_ESPRESSO_VERSION,
1984
+			true
1985
+		);
1986
+		//google charts
1987
+		wp_register_script(
1988
+			'google-charts',
1989
+			'https://www.gstatic.com/charts/loader.js',
1990
+			array(),
1991
+			EVENT_ESPRESSO_VERSION,
1992
+			false
1993
+		);
1994
+		// ENQUEUE ALL BASICS BY DEFAULT
1995
+		wp_enqueue_style('ee-admin-css');
1996
+		wp_enqueue_script('ee_admin_js');
1997
+		wp_enqueue_script('ee-accounting');
1998
+		wp_enqueue_script('jquery-validate');
1999
+		//taking care of metaboxes
2000
+		if (
2001
+			empty($this->_cpt_route)
2002
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2003
+		) {
2004
+			wp_enqueue_script('dashboard');
2005
+		}
2006
+		// LOCALIZED DATA
2007
+		//localize script for ajax lazy loading
2008
+		$lazy_loader_container_ids = apply_filters(
2009
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2010
+			array('espresso_news_post_box_content')
2011
+		);
2012
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2013
+		/**
2014
+		 * help tour stuff
2015
+		 */
2016
+		if (! empty($this->_help_tour)) {
2017
+			//register the js for kicking things off
2018
+			wp_enqueue_script(
2019
+				'ee-help-tour',
2020
+				EE_ADMIN_URL . 'assets/ee-help-tour.js',
2021
+				array('jquery-joyride'),
2022
+				EVENT_ESPRESSO_VERSION,
2023
+				true
2024
+			);
2025
+			$tours = array();
2026
+			//setup tours for the js tour object
2027
+			foreach ($this->_help_tour['tours'] as $tour) {
2028
+				if ($tour instanceof EE_Help_Tour) {
2029
+					$tours[] = array(
2030
+						'id'      => $tour->get_slug(),
2031
+						'options' => $tour->get_options(),
2032
+					);
2033
+				}
2034
+			}
2035
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2036
+			//admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2037
+		}
2038
+	}
2039
+
2040
+
2041
+
2042
+	/**
2043
+	 *        admin_footer_scripts_eei18n_js_strings
2044
+	 *
2045
+	 * @return        void
2046
+	 */
2047
+	public function admin_footer_scripts_eei18n_js_strings()
2048
+	{
2049
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2050
+		EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2051
+			'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2052
+			'event_espresso'
2053
+		);
2054
+		EE_Registry::$i18n_js_strings['January']        = esc_html__('January', 'event_espresso');
2055
+		EE_Registry::$i18n_js_strings['February']       = esc_html__('February', 'event_espresso');
2056
+		EE_Registry::$i18n_js_strings['March']          = esc_html__('March', 'event_espresso');
2057
+		EE_Registry::$i18n_js_strings['April']          = esc_html__('April', 'event_espresso');
2058
+		EE_Registry::$i18n_js_strings['May']            = esc_html__('May', 'event_espresso');
2059
+		EE_Registry::$i18n_js_strings['June']           = esc_html__('June', 'event_espresso');
2060
+		EE_Registry::$i18n_js_strings['July']           = esc_html__('July', 'event_espresso');
2061
+		EE_Registry::$i18n_js_strings['August']         = esc_html__('August', 'event_espresso');
2062
+		EE_Registry::$i18n_js_strings['September']      = esc_html__('September', 'event_espresso');
2063
+		EE_Registry::$i18n_js_strings['October']        = esc_html__('October', 'event_espresso');
2064
+		EE_Registry::$i18n_js_strings['November']       = esc_html__('November', 'event_espresso');
2065
+		EE_Registry::$i18n_js_strings['December']       = esc_html__('December', 'event_espresso');
2066
+		EE_Registry::$i18n_js_strings['Jan']            = esc_html__('Jan', 'event_espresso');
2067
+		EE_Registry::$i18n_js_strings['Feb']            = esc_html__('Feb', 'event_espresso');
2068
+		EE_Registry::$i18n_js_strings['Mar']            = esc_html__('Mar', 'event_espresso');
2069
+		EE_Registry::$i18n_js_strings['Apr']            = esc_html__('Apr', 'event_espresso');
2070
+		EE_Registry::$i18n_js_strings['May']            = esc_html__('May', 'event_espresso');
2071
+		EE_Registry::$i18n_js_strings['Jun']            = esc_html__('Jun', 'event_espresso');
2072
+		EE_Registry::$i18n_js_strings['Jul']            = esc_html__('Jul', 'event_espresso');
2073
+		EE_Registry::$i18n_js_strings['Aug']            = esc_html__('Aug', 'event_espresso');
2074
+		EE_Registry::$i18n_js_strings['Sep']            = esc_html__('Sep', 'event_espresso');
2075
+		EE_Registry::$i18n_js_strings['Oct']            = esc_html__('Oct', 'event_espresso');
2076
+		EE_Registry::$i18n_js_strings['Nov']            = esc_html__('Nov', 'event_espresso');
2077
+		EE_Registry::$i18n_js_strings['Dec']            = esc_html__('Dec', 'event_espresso');
2078
+		EE_Registry::$i18n_js_strings['Sunday']         = esc_html__('Sunday', 'event_espresso');
2079
+		EE_Registry::$i18n_js_strings['Monday']         = esc_html__('Monday', 'event_espresso');
2080
+		EE_Registry::$i18n_js_strings['Tuesday']        = esc_html__('Tuesday', 'event_espresso');
2081
+		EE_Registry::$i18n_js_strings['Wednesday']      = esc_html__('Wednesday', 'event_espresso');
2082
+		EE_Registry::$i18n_js_strings['Thursday']       = esc_html__('Thursday', 'event_espresso');
2083
+		EE_Registry::$i18n_js_strings['Friday']         = esc_html__('Friday', 'event_espresso');
2084
+		EE_Registry::$i18n_js_strings['Saturday']       = esc_html__('Saturday', 'event_espresso');
2085
+		EE_Registry::$i18n_js_strings['Sun']            = esc_html__('Sun', 'event_espresso');
2086
+		EE_Registry::$i18n_js_strings['Mon']            = esc_html__('Mon', 'event_espresso');
2087
+		EE_Registry::$i18n_js_strings['Tue']            = esc_html__('Tue', 'event_espresso');
2088
+		EE_Registry::$i18n_js_strings['Wed']            = esc_html__('Wed', 'event_espresso');
2089
+		EE_Registry::$i18n_js_strings['Thu']            = esc_html__('Thu', 'event_espresso');
2090
+		EE_Registry::$i18n_js_strings['Fri']            = esc_html__('Fri', 'event_espresso');
2091
+		EE_Registry::$i18n_js_strings['Sat']            = esc_html__('Sat', 'event_espresso');
2092
+	}
2093
+
2094
+
2095
+
2096
+	/**
2097
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2098
+	 *
2099
+	 * @return        void
2100
+	 */
2101
+	public function add_xdebug_style()
2102
+	{
2103
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2104
+	}
2105
+
2106
+
2107
+	/************************/
2108
+	/** LIST TABLE METHODS **/
2109
+	/************************/
2110
+	/**
2111
+	 * this sets up the list table if the current view requires it.
2112
+	 *
2113
+	 * @return void
2114
+	 * @throws EE_Error
2115
+	 */
2116
+	protected function _set_list_table()
2117
+	{
2118
+		//first is this a list_table view?
2119
+		if (! isset($this->_route_config['list_table'])) {
2120
+			return;
2121
+		} //not a list_table view so get out.
2122
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2123
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2124
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2125
+			//user error msg
2126
+			$error_msg = esc_html__(
2127
+				'An error occurred. The requested list table views could not be found.',
2128
+				'event_espresso'
2129
+			);
2130
+			//developer error msg
2131
+			$error_msg .= '||' . sprintf(
2132
+					esc_html__(
2133
+						'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2134
+						'event_espresso'
2135
+					),
2136
+					$this->_req_action,
2137
+					$list_table_view
2138
+				);
2139
+			throw new EE_Error($error_msg);
2140
+		}
2141
+		//let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2142
+		$this->_views = apply_filters(
2143
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2144
+			$this->_views
2145
+		);
2146
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2147
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2148
+		$this->_set_list_table_view();
2149
+		$this->_set_list_table_object();
2150
+	}
2151
+
2152
+
2153
+
2154
+	/**
2155
+	 * set current view for List Table
2156
+	 *
2157
+	 * @return void
2158
+	 */
2159
+	protected function _set_list_table_view()
2160
+	{
2161
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2162
+		// looking at active items or dumpster diving ?
2163
+		if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2164
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2165
+		} else {
2166
+			$this->_view = sanitize_key($this->_req_data['status']);
2167
+		}
2168
+	}
2169
+
2170
+
2171
+
2172
+	/**
2173
+	 * _set_list_table_object
2174
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2175
+	 *
2176
+	 * @throws EE_Error
2177
+	 */
2178
+	protected function _set_list_table_object()
2179
+	{
2180
+		if (isset($this->_route_config['list_table'])) {
2181
+			if (! class_exists($this->_route_config['list_table'])) {
2182
+				throw new EE_Error(
2183
+					sprintf(
2184
+						esc_html__(
2185
+							'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2186
+							'event_espresso'
2187
+						),
2188
+						$this->_route_config['list_table'],
2189
+						get_class($this)
2190
+					)
2191
+				);
2192
+			}
2193
+			$list_table               = $this->_route_config['list_table'];
2194
+			$this->_list_table_object = new $list_table($this);
2195
+		}
2196
+	}
2197
+
2198
+
2199
+
2200
+	/**
2201
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2202
+	 *
2203
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2204
+	 *                                                    urls.  The array should be indexed by the view it is being
2205
+	 *                                                    added to.
2206
+	 * @return array
2207
+	 */
2208
+	public function get_list_table_view_RLs($extra_query_args = array())
2209
+	{
2210
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2211
+		if (empty($this->_views)) {
2212
+			$this->_views = array();
2213
+		}
2214
+		// cycle thru views
2215
+		foreach ($this->_views as $key => $view) {
2216
+			$query_args = array();
2217
+			// check for current view
2218
+			$this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2219
+			$query_args['action']                      = $this->_req_action;
2220
+			$query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2221
+			$query_args['status']                      = $view['slug'];
2222
+			//merge any other arguments sent in.
2223
+			if (isset($extra_query_args[$view['slug']])) {
2224
+				$query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2225
+			}
2226
+			$this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2227
+		}
2228
+		return $this->_views;
2229
+	}
2230
+
2231
+
2232
+
2233
+	/**
2234
+	 * _entries_per_page_dropdown
2235
+	 * generates a drop down box for selecting the number of visible rows in an admin page list table
2236
+	 *
2237
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2238
+	 *         WP does it.
2239
+	 * @param int $max_entries total number of rows in the table
2240
+	 * @return string
2241
+	 */
2242
+	protected function _entries_per_page_dropdown($max_entries = 0)
2243
+	{
2244
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2245
+		$values   = array(10, 25, 50, 100);
2246
+		$per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2247
+		if ($max_entries) {
2248
+			$values[] = $max_entries;
2249
+			sort($values);
2250
+		}
2251
+		$entries_per_page_dropdown = '
2252 2252
 			<div id="entries-per-page-dv" class="alignleft actions">
2253 2253
 				<label class="hide-if-no-js">
2254 2254
 					Show
2255 2255
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2256
-        foreach ($values as $value) {
2257
-            if ($value < $max_entries) {
2258
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2259
-                $entries_per_page_dropdown .= '
2256
+		foreach ($values as $value) {
2257
+			if ($value < $max_entries) {
2258
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2259
+				$entries_per_page_dropdown .= '
2260 2260
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2261
-            }
2262
-        }
2263
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2264
-        $entries_per_page_dropdown .= '
2261
+			}
2262
+		}
2263
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2264
+		$entries_per_page_dropdown .= '
2265 2265
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2266
-        $entries_per_page_dropdown .= '
2266
+		$entries_per_page_dropdown .= '
2267 2267
 					</select>
2268 2268
 					entries
2269 2269
 				</label>
2270 2270
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2271 2271
 			</div>
2272 2272
 		';
2273
-        return $entries_per_page_dropdown;
2274
-    }
2275
-
2276
-
2277
-
2278
-    /**
2279
-     *        _set_search_attributes
2280
-     *
2281
-     * @return        void
2282
-     */
2283
-    public function _set_search_attributes()
2284
-    {
2285
-        $this->_template_args['search']['btn_label'] = sprintf(
2286
-            esc_html__('Search %s', 'event_espresso'),
2287
-            empty($this->_search_btn_label) ? $this->page_label
2288
-                : $this->_search_btn_label
2289
-        );
2290
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2291
-    }
2292
-
2293
-
2294
-
2295
-    /*** END LIST TABLE METHODS **/
2296
-
2297
-
2298
-
2299
-    /**
2300
-     * _add_registered_metaboxes
2301
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2302
-     *
2303
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2304
-     * @return void
2305
-     * @throws EE_Error
2306
-     */
2307
-    private function _add_registered_meta_boxes()
2308
-    {
2309
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2310
-        //we only add meta boxes if the page_route calls for it
2311
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2312
-            && is_array(
2313
-                $this->_route_config['metaboxes']
2314
-            )
2315
-        ) {
2316
-            // this simply loops through the callbacks provided
2317
-            // and checks if there is a corresponding callback registered by the child
2318
-            // if there is then we go ahead and process the metabox loader.
2319
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2320
-                // first check for Closures
2321
-                if ($metabox_callback instanceof Closure) {
2322
-                    $result = $metabox_callback();
2323
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2324
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2325
-                } else {
2326
-                    $result = call_user_func(array($this, &$metabox_callback));
2327
-                }
2328
-                if ($result === false) {
2329
-                    // user error msg
2330
-                    $error_msg = esc_html__(
2331
-                            'An error occurred. The  requested metabox could not be found.',
2332
-                            'event_espresso'
2333
-                    );
2334
-                    // developer error msg
2335
-                    $error_msg .= '||' . sprintf(
2336
-                            esc_html__(
2337
-                                'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2338
-                                'event_espresso'
2339
-                            ),
2340
-                            $metabox_callback
2341
-                        );
2342
-                    throw new EE_Error($error_msg);
2343
-                }
2344
-            }
2345
-        }
2346
-    }
2347
-
2348
-
2349
-
2350
-    /**
2351
-     * _add_screen_columns
2352
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2353
-     * the dynamic column template and we'll setup the column options for the page.
2354
-     *
2355
-     * @return void
2356
-     */
2357
-    private function _add_screen_columns()
2358
-    {
2359
-        if (
2360
-            is_array($this->_route_config)
2361
-            && isset($this->_route_config['columns'])
2362
-            && is_array($this->_route_config['columns'])
2363
-            && count($this->_route_config['columns']) === 2
2364
-        ) {
2365
-            add_screen_option(
2366
-                'layout_columns',
2367
-                array(
2368
-                    'max'     => (int)$this->_route_config['columns'][0],
2369
-                    'default' => (int)$this->_route_config['columns'][1],
2370
-                )
2371
-            );
2372
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2373
-            $screen_id                                           = $this->_current_screen->id;
2374
-            $screen_columns                                      = (int)get_user_option("screen_layout_{$screen_id}");
2375
-            $total_columns                                       = ! empty($screen_columns)
2376
-                ? $screen_columns
2377
-                : $this->_route_config['columns'][1];
2378
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2379
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2380
-            $this->_template_args['screen']                      = $this->_current_screen;
2381
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2382
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2383
-            // finally if we don't have has_metaboxes set in the route config
2384
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2385
-            $this->_route_config['has_metaboxes'] = true;
2386
-        }
2387
-    }
2388
-
2389
-
2390
-
2391
-    /** GLOBALLY AVAILABLE METABOXES **/
2392
-
2393
-
2394
-    /**
2395
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2396
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2397
-     * these get loaded on.
2398
-     */
2399
-    private function _espresso_news_post_box()
2400
-    {
2401
-        $news_box_title = apply_filters(
2402
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2403
-            esc_html__('New @ Event Espresso', 'event_espresso')
2404
-        );
2405
-        add_meta_box(
2406
-            'espresso_news_post_box',
2407
-            $news_box_title,
2408
-            array(
2409
-                $this,
2410
-                'espresso_news_post_box',
2411
-            ),
2412
-            $this->_wp_page_slug,
2413
-            'side'
2414
-        );
2415
-    }
2416
-
2417
-
2418
-
2419
-    /**
2420
-     * Code for setting up espresso ratings request metabox.
2421
-     */
2422
-    protected function _espresso_ratings_request()
2423
-    {
2424
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2425
-            return;
2426
-        }
2427
-        $ratings_box_title = apply_filters(
2428
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2429
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2430
-        );
2431
-        add_meta_box(
2432
-            'espresso_ratings_request',
2433
-            $ratings_box_title,
2434
-            array(
2435
-                $this,
2436
-                'espresso_ratings_request',
2437
-            ),
2438
-            $this->_wp_page_slug,
2439
-            'side'
2440
-        );
2441
-    }
2442
-
2443
-
2444
-
2445
-    /**
2446
-     * Code for setting up espresso ratings request metabox content.
2447
-     *
2448
-     * @throws DomainException
2449
-     */
2450
-    public function espresso_ratings_request()
2451
-    {
2452
-        EEH_Template::display_template(
2453
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2454
-                array()
2455
-        );
2456
-    }
2457
-
2458
-
2459
-
2460
-    public static function cached_rss_display($rss_id, $url)
2461
-    {
2462
-        $loading    = '<p class="widget-loading hide-if-no-js">'
2463
-                      . __('Loading&#8230;')
2464
-                      . '</p><p class="hide-if-js">'
2465
-                      . esc_html__('This widget requires JavaScript.')
2466
-                      . '</p>';
2467
-        $pre        = '<div class="espresso-rss-display">' . "\n\t";
2468
-        $pre        .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2469
-        $post       = '</div>' . "\n";
2470
-        $cache_key  = 'ee_rss_' . md5($rss_id);
2471
-        $output = get_transient($cache_key);
2472
-        if ($output !== false) {
2473
-            echo $pre . $output . $post;
2474
-            return true;
2475
-        }
2476
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2477
-            echo $pre . $loading . $post;
2478
-            return false;
2479
-        }
2480
-        ob_start();
2481
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2482
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2483
-        return true;
2484
-    }
2485
-
2486
-
2487
-
2488
-    public function espresso_news_post_box()
2489
-    {
2490
-        ?>
2273
+		return $entries_per_page_dropdown;
2274
+	}
2275
+
2276
+
2277
+
2278
+	/**
2279
+	 *        _set_search_attributes
2280
+	 *
2281
+	 * @return        void
2282
+	 */
2283
+	public function _set_search_attributes()
2284
+	{
2285
+		$this->_template_args['search']['btn_label'] = sprintf(
2286
+			esc_html__('Search %s', 'event_espresso'),
2287
+			empty($this->_search_btn_label) ? $this->page_label
2288
+				: $this->_search_btn_label
2289
+		);
2290
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2291
+	}
2292
+
2293
+
2294
+
2295
+	/*** END LIST TABLE METHODS **/
2296
+
2297
+
2298
+
2299
+	/**
2300
+	 * _add_registered_metaboxes
2301
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2302
+	 *
2303
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2304
+	 * @return void
2305
+	 * @throws EE_Error
2306
+	 */
2307
+	private function _add_registered_meta_boxes()
2308
+	{
2309
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2310
+		//we only add meta boxes if the page_route calls for it
2311
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2312
+			&& is_array(
2313
+				$this->_route_config['metaboxes']
2314
+			)
2315
+		) {
2316
+			// this simply loops through the callbacks provided
2317
+			// and checks if there is a corresponding callback registered by the child
2318
+			// if there is then we go ahead and process the metabox loader.
2319
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2320
+				// first check for Closures
2321
+				if ($metabox_callback instanceof Closure) {
2322
+					$result = $metabox_callback();
2323
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2324
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2325
+				} else {
2326
+					$result = call_user_func(array($this, &$metabox_callback));
2327
+				}
2328
+				if ($result === false) {
2329
+					// user error msg
2330
+					$error_msg = esc_html__(
2331
+							'An error occurred. The  requested metabox could not be found.',
2332
+							'event_espresso'
2333
+					);
2334
+					// developer error msg
2335
+					$error_msg .= '||' . sprintf(
2336
+							esc_html__(
2337
+								'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2338
+								'event_espresso'
2339
+							),
2340
+							$metabox_callback
2341
+						);
2342
+					throw new EE_Error($error_msg);
2343
+				}
2344
+			}
2345
+		}
2346
+	}
2347
+
2348
+
2349
+
2350
+	/**
2351
+	 * _add_screen_columns
2352
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2353
+	 * the dynamic column template and we'll setup the column options for the page.
2354
+	 *
2355
+	 * @return void
2356
+	 */
2357
+	private function _add_screen_columns()
2358
+	{
2359
+		if (
2360
+			is_array($this->_route_config)
2361
+			&& isset($this->_route_config['columns'])
2362
+			&& is_array($this->_route_config['columns'])
2363
+			&& count($this->_route_config['columns']) === 2
2364
+		) {
2365
+			add_screen_option(
2366
+				'layout_columns',
2367
+				array(
2368
+					'max'     => (int)$this->_route_config['columns'][0],
2369
+					'default' => (int)$this->_route_config['columns'][1],
2370
+				)
2371
+			);
2372
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2373
+			$screen_id                                           = $this->_current_screen->id;
2374
+			$screen_columns                                      = (int)get_user_option("screen_layout_{$screen_id}");
2375
+			$total_columns                                       = ! empty($screen_columns)
2376
+				? $screen_columns
2377
+				: $this->_route_config['columns'][1];
2378
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2379
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2380
+			$this->_template_args['screen']                      = $this->_current_screen;
2381
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2382
+																   . 'admin_details_metabox_column_wrapper.template.php';
2383
+			// finally if we don't have has_metaboxes set in the route config
2384
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2385
+			$this->_route_config['has_metaboxes'] = true;
2386
+		}
2387
+	}
2388
+
2389
+
2390
+
2391
+	/** GLOBALLY AVAILABLE METABOXES **/
2392
+
2393
+
2394
+	/**
2395
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2396
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2397
+	 * these get loaded on.
2398
+	 */
2399
+	private function _espresso_news_post_box()
2400
+	{
2401
+		$news_box_title = apply_filters(
2402
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2403
+			esc_html__('New @ Event Espresso', 'event_espresso')
2404
+		);
2405
+		add_meta_box(
2406
+			'espresso_news_post_box',
2407
+			$news_box_title,
2408
+			array(
2409
+				$this,
2410
+				'espresso_news_post_box',
2411
+			),
2412
+			$this->_wp_page_slug,
2413
+			'side'
2414
+		);
2415
+	}
2416
+
2417
+
2418
+
2419
+	/**
2420
+	 * Code for setting up espresso ratings request metabox.
2421
+	 */
2422
+	protected function _espresso_ratings_request()
2423
+	{
2424
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2425
+			return;
2426
+		}
2427
+		$ratings_box_title = apply_filters(
2428
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2429
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2430
+		);
2431
+		add_meta_box(
2432
+			'espresso_ratings_request',
2433
+			$ratings_box_title,
2434
+			array(
2435
+				$this,
2436
+				'espresso_ratings_request',
2437
+			),
2438
+			$this->_wp_page_slug,
2439
+			'side'
2440
+		);
2441
+	}
2442
+
2443
+
2444
+
2445
+	/**
2446
+	 * Code for setting up espresso ratings request metabox content.
2447
+	 *
2448
+	 * @throws DomainException
2449
+	 */
2450
+	public function espresso_ratings_request()
2451
+	{
2452
+		EEH_Template::display_template(
2453
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2454
+				array()
2455
+		);
2456
+	}
2457
+
2458
+
2459
+
2460
+	public static function cached_rss_display($rss_id, $url)
2461
+	{
2462
+		$loading    = '<p class="widget-loading hide-if-no-js">'
2463
+					  . __('Loading&#8230;')
2464
+					  . '</p><p class="hide-if-js">'
2465
+					  . esc_html__('This widget requires JavaScript.')
2466
+					  . '</p>';
2467
+		$pre        = '<div class="espresso-rss-display">' . "\n\t";
2468
+		$pre        .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2469
+		$post       = '</div>' . "\n";
2470
+		$cache_key  = 'ee_rss_' . md5($rss_id);
2471
+		$output = get_transient($cache_key);
2472
+		if ($output !== false) {
2473
+			echo $pre . $output . $post;
2474
+			return true;
2475
+		}
2476
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2477
+			echo $pre . $loading . $post;
2478
+			return false;
2479
+		}
2480
+		ob_start();
2481
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2482
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2483
+		return true;
2484
+	}
2485
+
2486
+
2487
+
2488
+	public function espresso_news_post_box()
2489
+	{
2490
+		?>
2491 2491
         <div class="padding">
2492 2492
             <div id="espresso_news_post_box_content" class="infolinks">
2493 2493
                 <?php
2494
-                // Get RSS Feed(s)
2495
-                self::cached_rss_display(
2496
-                    'espresso_news_post_box_content',
2497
-                    urlencode(
2498
-                        apply_filters(
2499
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2500
-                            'http://eventespresso.com/feed/'
2501
-                        )
2502
-                    )
2503
-                );
2504
-                ?>
2494
+				// Get RSS Feed(s)
2495
+				self::cached_rss_display(
2496
+					'espresso_news_post_box_content',
2497
+					urlencode(
2498
+						apply_filters(
2499
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2500
+							'http://eventespresso.com/feed/'
2501
+						)
2502
+					)
2503
+				);
2504
+				?>
2505 2505
             </div>
2506 2506
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2507 2507
         </div>
2508 2508
         <?php
2509
-    }
2510
-
2511
-
2512
-
2513
-    private function _espresso_links_post_box()
2514
-    {
2515
-        //Hiding until we actually have content to put in here...
2516
-        //add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2517
-    }
2518
-
2519
-
2520
-
2521
-    public function espresso_links_post_box()
2522
-    {
2523
-        //Hiding until we actually have content to put in here...
2524
-        // EEH_Template::display_template(
2525
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2526
-        // );
2527
-    }
2528
-
2529
-
2530
-
2531
-    protected function _espresso_sponsors_post_box()
2532
-    {
2533
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2534
-            add_meta_box(
2535
-                'espresso_sponsors_post_box',
2536
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2537
-                array($this, 'espresso_sponsors_post_box'),
2538
-                $this->_wp_page_slug,
2539
-                'side'
2540
-            );
2541
-        }
2542
-    }
2543
-
2544
-
2545
-
2546
-    public function espresso_sponsors_post_box()
2547
-    {
2548
-        EEH_Template::display_template(
2549
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2550
-        );
2551
-    }
2552
-
2553
-
2554
-
2555
-    private function _publish_post_box()
2556
-    {
2557
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2558
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2559
-        // then we'll use that for the metabox label.
2560
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2561
-        if (! empty($this->_labels['publishbox'])) {
2562
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2563
-                : $this->_labels['publishbox'];
2564
-        } else {
2565
-            $box_label = esc_html__('Publish', 'event_espresso');
2566
-        }
2567
-        $box_label = apply_filters(
2568
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2569
-            $box_label,
2570
-            $this->_req_action,
2571
-            $this
2572
-        );
2573
-        add_meta_box(
2574
-            $meta_box_ref,
2575
-            $box_label,
2576
-            array($this, 'editor_overview'),
2577
-            $this->_current_screen->id,
2578
-            'side',
2579
-            'high'
2580
-        );
2581
-    }
2582
-
2583
-
2584
-
2585
-    public function editor_overview()
2586
-    {
2587
-        //if we have extra content set let's add it in if not make sure its empty
2588
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2589
-            ? $this->_template_args['publish_box_extra_content']
2590
-            : '';
2591
-        echo EEH_Template::display_template(
2592
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2593
-            $this->_template_args,
2594
-            true
2595
-        );
2596
-    }
2597
-
2598
-
2599
-    /** end of globally available metaboxes section **/
2600
-
2601
-
2602
-
2603
-    /**
2604
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2605
-     * protected method.
2606
-     *
2607
-     * @see   $this->_set_publish_post_box_vars for param details
2608
-     * @since 4.6.0
2609
-     * @param string $name
2610
-     * @param int    $id
2611
-     * @param bool   $delete
2612
-     * @param string $save_close_redirect_URL
2613
-     * @param bool   $both_btns
2614
-     * @throws EE_Error
2615
-     * @throws InvalidArgumentException
2616
-     * @throws InvalidDataTypeException
2617
-     * @throws InvalidInterfaceException
2618
-     */
2619
-    public function set_publish_post_box_vars(
2620
-        $name = '',
2621
-        $id = 0,
2622
-        $delete = false,
2623
-        $save_close_redirect_URL = '',
2624
-        $both_btns = true
2625
-    ) {
2626
-        $this->_set_publish_post_box_vars(
2627
-            $name,
2628
-            $id,
2629
-            $delete,
2630
-            $save_close_redirect_URL,
2631
-            $both_btns
2632
-        );
2633
-    }
2634
-
2635
-
2636
-
2637
-    /**
2638
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2639
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2640
-     * save, and save and close buttons to work properly, then you will want to include a
2641
-     * values for the name and id arguments.
2642
-     *
2643
-     * @todo  Add in validation for name/id arguments.
2644
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2645
-     * @param    int     $id                      id attached to the item published
2646
-     * @param    string  $delete                  page route callback for the delete action
2647
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2648
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2649
-     *                                            the Save button
2650
-     * @throws EE_Error
2651
-     * @throws InvalidArgumentException
2652
-     * @throws InvalidDataTypeException
2653
-     * @throws InvalidInterfaceException
2654
-     */
2655
-    protected function _set_publish_post_box_vars(
2656
-        $name = '',
2657
-        $id = 0,
2658
-        $delete = '',
2659
-        $save_close_redirect_URL = '',
2660
-        $both_btns = true
2661
-    ) {
2662
-        // if Save & Close, use a custom redirect URL or default to the main page?
2663
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2664
-            ? $save_close_redirect_URL
2665
-            : $this->_admin_base_url;
2666
-        // create the Save & Close and Save buttons
2667
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2668
-        //if we have extra content set let's add it in if not make sure its empty
2669
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2670
-            ? $this->_template_args['publish_box_extra_content']
2671
-            : '';
2672
-        if ($delete && ! empty($id)) {
2673
-            //make sure we have a default if just true is sent.
2674
-            $delete           = ! empty($delete) ? $delete : 'delete';
2675
-            $delete_link_args = array($name => $id);
2676
-            $delete           = $this->get_action_link_or_button(
2677
-                $delete,
2678
-                $delete,
2679
-                $delete_link_args,
2680
-                'submitdelete deletion',
2681
-                '',
2682
-                false
2683
-            );
2684
-        }
2685
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2686
-        if (! empty($name) && ! empty($id)) {
2687
-            $hidden_field_arr[$name] = array(
2688
-                'type'  => 'hidden',
2689
-                'value' => $id,
2690
-            );
2691
-            $hf                      = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2692
-        } else {
2693
-            $hf = '';
2694
-        }
2695
-        // add hidden field
2696
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2697
-            ? $hf[$name]['field']
2698
-            : $hf;
2699
-    }
2700
-
2701
-
2702
-
2703
-    /**
2704
-     * displays an error message to ppl who have javascript disabled
2705
-     *
2706
-     * @return void
2707
-     */
2708
-    private function _display_no_javascript_warning()
2709
-    {
2710
-        ?>
2509
+	}
2510
+
2511
+
2512
+
2513
+	private function _espresso_links_post_box()
2514
+	{
2515
+		//Hiding until we actually have content to put in here...
2516
+		//add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2517
+	}
2518
+
2519
+
2520
+
2521
+	public function espresso_links_post_box()
2522
+	{
2523
+		//Hiding until we actually have content to put in here...
2524
+		// EEH_Template::display_template(
2525
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2526
+		// );
2527
+	}
2528
+
2529
+
2530
+
2531
+	protected function _espresso_sponsors_post_box()
2532
+	{
2533
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2534
+			add_meta_box(
2535
+				'espresso_sponsors_post_box',
2536
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2537
+				array($this, 'espresso_sponsors_post_box'),
2538
+				$this->_wp_page_slug,
2539
+				'side'
2540
+			);
2541
+		}
2542
+	}
2543
+
2544
+
2545
+
2546
+	public function espresso_sponsors_post_box()
2547
+	{
2548
+		EEH_Template::display_template(
2549
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2550
+		);
2551
+	}
2552
+
2553
+
2554
+
2555
+	private function _publish_post_box()
2556
+	{
2557
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2558
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2559
+		// then we'll use that for the metabox label.
2560
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2561
+		if (! empty($this->_labels['publishbox'])) {
2562
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2563
+				: $this->_labels['publishbox'];
2564
+		} else {
2565
+			$box_label = esc_html__('Publish', 'event_espresso');
2566
+		}
2567
+		$box_label = apply_filters(
2568
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2569
+			$box_label,
2570
+			$this->_req_action,
2571
+			$this
2572
+		);
2573
+		add_meta_box(
2574
+			$meta_box_ref,
2575
+			$box_label,
2576
+			array($this, 'editor_overview'),
2577
+			$this->_current_screen->id,
2578
+			'side',
2579
+			'high'
2580
+		);
2581
+	}
2582
+
2583
+
2584
+
2585
+	public function editor_overview()
2586
+	{
2587
+		//if we have extra content set let's add it in if not make sure its empty
2588
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2589
+			? $this->_template_args['publish_box_extra_content']
2590
+			: '';
2591
+		echo EEH_Template::display_template(
2592
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2593
+			$this->_template_args,
2594
+			true
2595
+		);
2596
+	}
2597
+
2598
+
2599
+	/** end of globally available metaboxes section **/
2600
+
2601
+
2602
+
2603
+	/**
2604
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2605
+	 * protected method.
2606
+	 *
2607
+	 * @see   $this->_set_publish_post_box_vars for param details
2608
+	 * @since 4.6.0
2609
+	 * @param string $name
2610
+	 * @param int    $id
2611
+	 * @param bool   $delete
2612
+	 * @param string $save_close_redirect_URL
2613
+	 * @param bool   $both_btns
2614
+	 * @throws EE_Error
2615
+	 * @throws InvalidArgumentException
2616
+	 * @throws InvalidDataTypeException
2617
+	 * @throws InvalidInterfaceException
2618
+	 */
2619
+	public function set_publish_post_box_vars(
2620
+		$name = '',
2621
+		$id = 0,
2622
+		$delete = false,
2623
+		$save_close_redirect_URL = '',
2624
+		$both_btns = true
2625
+	) {
2626
+		$this->_set_publish_post_box_vars(
2627
+			$name,
2628
+			$id,
2629
+			$delete,
2630
+			$save_close_redirect_URL,
2631
+			$both_btns
2632
+		);
2633
+	}
2634
+
2635
+
2636
+
2637
+	/**
2638
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2639
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2640
+	 * save, and save and close buttons to work properly, then you will want to include a
2641
+	 * values for the name and id arguments.
2642
+	 *
2643
+	 * @todo  Add in validation for name/id arguments.
2644
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2645
+	 * @param    int     $id                      id attached to the item published
2646
+	 * @param    string  $delete                  page route callback for the delete action
2647
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2648
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2649
+	 *                                            the Save button
2650
+	 * @throws EE_Error
2651
+	 * @throws InvalidArgumentException
2652
+	 * @throws InvalidDataTypeException
2653
+	 * @throws InvalidInterfaceException
2654
+	 */
2655
+	protected function _set_publish_post_box_vars(
2656
+		$name = '',
2657
+		$id = 0,
2658
+		$delete = '',
2659
+		$save_close_redirect_URL = '',
2660
+		$both_btns = true
2661
+	) {
2662
+		// if Save & Close, use a custom redirect URL or default to the main page?
2663
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2664
+			? $save_close_redirect_URL
2665
+			: $this->_admin_base_url;
2666
+		// create the Save & Close and Save buttons
2667
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2668
+		//if we have extra content set let's add it in if not make sure its empty
2669
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2670
+			? $this->_template_args['publish_box_extra_content']
2671
+			: '';
2672
+		if ($delete && ! empty($id)) {
2673
+			//make sure we have a default if just true is sent.
2674
+			$delete           = ! empty($delete) ? $delete : 'delete';
2675
+			$delete_link_args = array($name => $id);
2676
+			$delete           = $this->get_action_link_or_button(
2677
+				$delete,
2678
+				$delete,
2679
+				$delete_link_args,
2680
+				'submitdelete deletion',
2681
+				'',
2682
+				false
2683
+			);
2684
+		}
2685
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2686
+		if (! empty($name) && ! empty($id)) {
2687
+			$hidden_field_arr[$name] = array(
2688
+				'type'  => 'hidden',
2689
+				'value' => $id,
2690
+			);
2691
+			$hf                      = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2692
+		} else {
2693
+			$hf = '';
2694
+		}
2695
+		// add hidden field
2696
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2697
+			? $hf[$name]['field']
2698
+			: $hf;
2699
+	}
2700
+
2701
+
2702
+
2703
+	/**
2704
+	 * displays an error message to ppl who have javascript disabled
2705
+	 *
2706
+	 * @return void
2707
+	 */
2708
+	private function _display_no_javascript_warning()
2709
+	{
2710
+		?>
2711 2711
         <noscript>
2712 2712
             <div id="no-js-message" class="error">
2713 2713
                 <p style="font-size:1.3em;">
2714 2714
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2715 2715
                     <?php esc_html_e(
2716
-                        'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2717
-                        'event_espresso'
2718
-                    ); ?>
2716
+						'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2717
+						'event_espresso'
2718
+					); ?>
2719 2719
                 </p>
2720 2720
             </div>
2721 2721
         </noscript>
2722 2722
         <?php
2723
-    }
2723
+	}
2724 2724
 
2725 2725
 
2726 2726
 
2727
-    /**
2728
-     * displays espresso success and/or error notices
2729
-     *
2730
-     * @return void
2731
-     */
2732
-    private function _display_espresso_notices()
2733
-    {
2734
-        $notices = $this->_get_transient(true);
2735
-        echo stripslashes($notices);
2736
-    }
2727
+	/**
2728
+	 * displays espresso success and/or error notices
2729
+	 *
2730
+	 * @return void
2731
+	 */
2732
+	private function _display_espresso_notices()
2733
+	{
2734
+		$notices = $this->_get_transient(true);
2735
+		echo stripslashes($notices);
2736
+	}
2737 2737
 
2738 2738
 
2739 2739
 
2740
-    /**
2741
-     * spinny things pacify the masses
2742
-     *
2743
-     * @return void
2744
-     */
2745
-    protected function _add_admin_page_ajax_loading_img()
2746
-    {
2747
-        ?>
2740
+	/**
2741
+	 * spinny things pacify the masses
2742
+	 *
2743
+	 * @return void
2744
+	 */
2745
+	protected function _add_admin_page_ajax_loading_img()
2746
+	{
2747
+		?>
2748 2748
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2749 2749
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php esc_html_e(
2750
-                    'loading...',
2751
-                    'event_espresso'
2752
-                ); ?></span>
2750
+					'loading...',
2751
+					'event_espresso'
2752
+				); ?></span>
2753 2753
         </div>
2754 2754
         <?php
2755
-    }
2755
+	}
2756 2756
 
2757 2757
 
2758 2758
 
2759
-    /**
2760
-     * add admin page overlay for modal boxes
2761
-     *
2762
-     * @return void
2763
-     */
2764
-    protected function _add_admin_page_overlay()
2765
-    {
2766
-        ?>
2759
+	/**
2760
+	 * add admin page overlay for modal boxes
2761
+	 *
2762
+	 * @return void
2763
+	 */
2764
+	protected function _add_admin_page_overlay()
2765
+	{
2766
+		?>
2767 2767
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2768 2768
         <?php
2769
-    }
2770
-
2771
-
2772
-
2773
-    /**
2774
-     * facade for add_meta_box
2775
-     *
2776
-     * @param string  $action        where the metabox get's displayed
2777
-     * @param string  $title         Title of Metabox (output in metabox header)
2778
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2779
-     *                               instead of the one created in here.
2780
-     * @param array   $callback_args an array of args supplied for the metabox
2781
-     * @param string  $column        what metabox column
2782
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2783
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2784
-     *                               created but just set our own callback for wp's add_meta_box.
2785
-     * @throws \DomainException
2786
-     */
2787
-    public function _add_admin_page_meta_box(
2788
-        $action,
2789
-        $title,
2790
-        $callback,
2791
-        $callback_args,
2792
-        $column = 'normal',
2793
-        $priority = 'high',
2794
-        $create_func = true
2795
-    ) {
2796
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2797
-        //if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2798
-        if (empty($callback_args) && $create_func) {
2799
-            $callback_args = array(
2800
-                'template_path' => $this->_template_path,
2801
-                'template_args' => $this->_template_args,
2802
-            );
2803
-        }
2804
-        //if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2805
-        $call_back_func = $create_func
2806
-            ? function ($post, $metabox)
2807
-            {
2808
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2809
-                echo EEH_Template::display_template(
2810
-                    $metabox['args']['template_path'],
2811
-                    $metabox['args']['template_args'],
2812
-                    true
2813
-                );
2814
-            }
2815
-            : $callback;
2816
-        add_meta_box(
2817
-            str_replace('_', '-', $action) . '-mbox',
2818
-            $title,
2819
-            $call_back_func,
2820
-            $this->_wp_page_slug,
2821
-            $column,
2822
-            $priority,
2823
-            $callback_args
2824
-        );
2825
-    }
2826
-
2827
-
2828
-
2829
-    /**
2830
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2831
-     *
2832
-     * @throws DomainException
2833
-     * @throws EE_Error
2834
-     */
2835
-    public function display_admin_page_with_metabox_columns()
2836
-    {
2837
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2838
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2839
-            $this->_column_template_path,
2840
-            $this->_template_args,
2841
-            true
2842
-        );
2843
-        //the final wrapper
2844
-        $this->admin_page_wrapper();
2845
-    }
2846
-
2847
-
2848
-
2849
-    /**
2850
-     * generates  HTML wrapper for an admin details page
2851
-     *
2852
-     * @return void
2853
-     * @throws EE_Error
2854
-     * @throws DomainException
2855
-     */
2856
-    public function display_admin_page_with_sidebar()
2857
-    {
2858
-        $this->_display_admin_page(true);
2859
-    }
2860
-
2861
-
2862
-
2863
-    /**
2864
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2865
-     *
2866
-     * @return void
2867
-     * @throws EE_Error
2868
-     * @throws DomainException
2869
-     */
2870
-    public function display_admin_page_with_no_sidebar()
2871
-    {
2872
-        $this->_display_admin_page();
2873
-    }
2874
-
2875
-
2876
-
2877
-    /**
2878
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2879
-     *
2880
-     * @return void
2881
-     * @throws EE_Error
2882
-     * @throws DomainException
2883
-     */
2884
-    public function display_about_admin_page()
2885
-    {
2886
-        $this->_display_admin_page(false, true);
2887
-    }
2888
-
2889
-
2890
-
2891
-    /**
2892
-     * display_admin_page
2893
-     * contains the code for actually displaying an admin page
2894
-     *
2895
-     * @param  boolean $sidebar true with sidebar, false without
2896
-     * @param  boolean $about   use the about admin wrapper instead of the default.
2897
-     * @return void
2898
-     * @throws DomainException
2899
-     * @throws EE_Error
2900
-     */
2901
-    private function _display_admin_page($sidebar = false, $about = false)
2902
-    {
2903
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2904
-        //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2905
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2906
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2907
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2908
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2909
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2910
-            ? 'poststuff'
2911
-            : 'espresso-default-admin';
2912
-        $template_path                                     = $sidebar
2913
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2914
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2915
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2916
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2917
-        }
2918
-        $template_path                                     = ! empty($this->_column_template_path)
2919
-            ? $this->_column_template_path : $template_path;
2920
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2921
-            ? $this->_template_args['admin_page_content']
2922
-            : '';
2923
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2924
-            ? $this->_template_args['before_admin_page_content']
2925
-            : '';
2926
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2927
-            ? $this->_template_args['after_admin_page_content']
2928
-            : '';
2929
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2930
-            $template_path,
2931
-            $this->_template_args,
2932
-            true
2933
-        );
2934
-        // the final template wrapper
2935
-        $this->admin_page_wrapper($about);
2936
-    }
2937
-
2938
-
2939
-
2940
-    /**
2941
-     * This is used to display caf preview pages.
2942
-     *
2943
-     * @since 4.3.2
2944
-     * @param string $utm_campaign_source what is the key used for google analytics link
2945
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2946
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2947
-     * @return void
2948
-     * @throws DomainException
2949
-     * @throws EE_Error
2950
-     * @throws InvalidArgumentException
2951
-     * @throws InvalidDataTypeException
2952
-     * @throws InvalidInterfaceException
2953
-     */
2954
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2955
-    {
2956
-        //let's generate a default preview action button if there isn't one already present.
2957
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2958
-            'Upgrade to Event Espresso 4 Right Now',
2959
-            'event_espresso'
2960
-        );
2961
-        $buy_now_url                                   = add_query_arg(
2962
-            array(
2963
-                'ee_ver'       => 'ee4',
2964
-                'utm_source'   => 'ee4_plugin_admin',
2965
-                'utm_medium'   => 'link',
2966
-                'utm_campaign' => $utm_campaign_source,
2967
-                'utm_content'  => 'buy_now_button',
2968
-            ),
2969
-            'http://eventespresso.com/pricing/'
2970
-        );
2971
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2972
-            ? $this->get_action_link_or_button(
2973
-                '',
2974
-                'buy_now',
2975
-                array(),
2976
-                'button-primary button-large',
2977
-                $buy_now_url,
2978
-                true
2979
-            )
2980
-            : $this->_template_args['preview_action_button'];
2981
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2982
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2983
-            $this->_template_args,
2984
-            true
2985
-        );
2986
-        $this->_display_admin_page($display_sidebar);
2987
-    }
2988
-
2989
-
2990
-
2991
-    /**
2992
-     * display_admin_list_table_page_with_sidebar
2993
-     * generates HTML wrapper for an admin_page with list_table
2994
-     *
2995
-     * @return void
2996
-     * @throws EE_Error
2997
-     * @throws DomainException
2998
-     */
2999
-    public function display_admin_list_table_page_with_sidebar()
3000
-    {
3001
-        $this->_display_admin_list_table_page(true);
3002
-    }
3003
-
3004
-
3005
-
3006
-    /**
3007
-     * display_admin_list_table_page_with_no_sidebar
3008
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
3009
-     *
3010
-     * @return void
3011
-     * @throws EE_Error
3012
-     * @throws DomainException
3013
-     */
3014
-    public function display_admin_list_table_page_with_no_sidebar()
3015
-    {
3016
-        $this->_display_admin_list_table_page();
3017
-    }
3018
-
3019
-
3020
-
3021
-    /**
3022
-     * generates html wrapper for an admin_list_table page
3023
-     *
3024
-     * @param boolean $sidebar whether to display with sidebar or not.
3025
-     * @return void
3026
-     * @throws DomainException
3027
-     * @throws EE_Error
3028
-     */
3029
-    private function _display_admin_list_table_page($sidebar = false)
3030
-    {
3031
-        //setup search attributes
3032
-        $this->_set_search_attributes();
3033
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
3034
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3035
-        $this->_template_args['table_url']        = defined('DOING_AJAX')
3036
-            ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
3037
-            : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
3038
-        $this->_template_args['list_table']       = $this->_list_table_object;
3039
-        $this->_template_args['current_route']    = $this->_req_action;
3040
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3041
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3042
-        if (! empty($ajax_sorting_callback)) {
3043
-            $sortable_list_table_form_fields = wp_nonce_field(
3044
-                $ajax_sorting_callback . '_nonce',
3045
-                $ajax_sorting_callback . '_nonce',
3046
-                false,
3047
-                false
3048
-            );
3049
-            //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
3050
-            //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
3051
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3052
-                                                . $this->page_slug
3053
-                                                . '" />';
3054
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3055
-                                                . $ajax_sorting_callback
3056
-                                                . '" />';
3057
-        } else {
3058
-            $sortable_list_table_form_fields = '';
3059
-        }
3060
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3061
-        $hidden_form_fields                                      = isset($this->_template_args['list_table_hidden_fields'])
3062
-            ? $this->_template_args['list_table_hidden_fields']
3063
-            : '';
3064
-        $nonce_ref                                               = $this->_req_action . '_nonce';
3065
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
3066
-                                                                    . $nonce_ref
3067
-                                                                    . '" value="'
3068
-                                                                    . wp_create_nonce($nonce_ref)
3069
-                                                                    . '">';
3070
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3071
-        //display message about search results?
3072
-        $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
3073
-            ? '<p class="ee-search-results">' . sprintf(
3074
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3075
-                trim($this->_req_data['s'], '%')
3076
-            ) . '</p>'
3077
-            : '';
3078
-        // filter before_list_table template arg
3079
-        $this->_template_args['before_list_table'] = apply_filters(
3080
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3081
-            $this->_template_args['before_list_table'],
3082
-            $this->page_slug,
3083
-            $this->_req_data,
3084
-            $this->_req_action
3085
-        );
3086
-        // convert to array and filter again
3087
-        // arrays are easier to inject new items in a specific location,
3088
-        // but would not be backwards compatible, so we have to add a new filter
3089
-        $this->_template_args['before_list_table'] = implode(
3090
-            " \n",
3091
-            (array)apply_filters(
3092
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3093
-                (array)$this->_template_args['before_list_table'],
3094
-                $this->page_slug,
3095
-                $this->_req_data,
3096
-                $this->_req_action
3097
-            )
3098
-        );
3099
-        // filter after_list_table template arg
3100
-        $this->_template_args['after_list_table'] = apply_filters(
3101
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3102
-            $this->_template_args['after_list_table'],
3103
-            $this->page_slug,
3104
-            $this->_req_data,
3105
-            $this->_req_action
3106
-        );
3107
-        // convert to array and filter again
3108
-        // arrays are easier to inject new items in a specific location,
3109
-        // but would not be backwards compatible, so we have to add a new filter
3110
-        $this->_template_args['after_list_table']   = implode(
3111
-            " \n",
3112
-            (array)apply_filters(
3113
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3114
-                (array)$this->_template_args['after_list_table'],
3115
-                $this->page_slug,
3116
-                $this->_req_data,
3117
-                $this->_req_action
3118
-            )
3119
-        );
3120
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3121
-            $template_path,
3122
-            $this->_template_args,
3123
-            true
3124
-        );
3125
-        // the final template wrapper
3126
-        if ($sidebar) {
3127
-            $this->display_admin_page_with_sidebar();
3128
-        } else {
3129
-            $this->display_admin_page_with_no_sidebar();
3130
-        }
3131
-    }
3132
-
3133
-
3134
-
3135
-    /**
3136
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3137
-     * html string for the legend.
3138
-     * $items are expected in an array in the following format:
3139
-     * $legend_items = array(
3140
-     *        'item_id' => array(
3141
-     *            'icon' => 'http://url_to_icon_being_described.png',
3142
-     *            'desc' => esc_html__('localized description of item');
3143
-     *        )
3144
-     * );
3145
-     *
3146
-     * @param  array $items see above for format of array
3147
-     * @return string html string of legend
3148
-     * @throws DomainException
3149
-     */
3150
-    protected function _display_legend($items)
3151
-    {
3152
-        $this->_template_args['items'] = apply_filters(
3153
-            'FHEE__EE_Admin_Page___display_legend__items',
3154
-            (array)$items,
3155
-            $this
3156
-        );
3157
-        return EEH_Template::display_template(
3158
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3159
-            $this->_template_args,
3160
-            true
3161
-        );
3162
-    }
3163
-
3164
-
3165
-    /**
3166
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3167
-     * The returned json object is created from an array in the following format:
3168
-     * array(
3169
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3170
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3171
-     *  'notices' => '', // - contains any EE_Error formatted notices
3172
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3173
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3174
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3175
-     *  that might be included in here)
3176
-     * )
3177
-     * The json object is populated by whatever is set in the $_template_args property.
3178
-     *
3179
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3180
-     *                                 instead of displayed.
3181
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3182
-     * @return void
3183
-     * @throws EE_Error
3184
-     */
3185
-    protected function _return_json($sticky_notices = false, $notices_arguments = array())
3186
-    {
3187
-        //make sure any EE_Error notices have been handled.
3188
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3189
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3190
-        unset($this->_template_args['data']);
3191
-        $json = array(
3192
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3193
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3194
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3195
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3196
-            'notices'   => EE_Error::get_notices(),
3197
-            'content'   => isset($this->_template_args['admin_page_content'])
3198
-                ? $this->_template_args['admin_page_content'] : '',
3199
-            'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3200
-            'isEEajax'  => true
3201
-            //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3202
-        );
3203
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3204
-        if (null === error_get_last() || ! headers_sent()) {
3205
-            header('Content-Type: application/json; charset=UTF-8');
3206
-        }
3207
-        echo wp_json_encode($json);
3208
-        exit();
3209
-    }
3210
-
3211
-
3212
-
3213
-    /**
3214
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3215
-     *
3216
-     * @return void
3217
-     * @throws EE_Error
3218
-     */
3219
-    public function return_json()
3220
-    {
3221
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3222
-            $this->_return_json();
3223
-        } else {
3224
-            throw new EE_Error(
3225
-                sprintf(
3226
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3227
-                    __FUNCTION__
3228
-                )
3229
-            );
3230
-        }
3231
-    }
3232
-
3233
-
3234
-
3235
-    /**
3236
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3237
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3238
-     *
3239
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3240
-     */
3241
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3242
-    {
3243
-        $this->_hook_obj = $hook_obj;
3244
-    }
3245
-
3246
-
3247
-
3248
-    /**
3249
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3250
-     *
3251
-     * @param  boolean $about whether to use the special about page wrapper or default.
3252
-     * @return void
3253
-     * @throws DomainException
3254
-     * @throws EE_Error
3255
-     */
3256
-    public function admin_page_wrapper($about = false)
3257
-    {
3258
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3259
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3260
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3261
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3262
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3263
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3264
-            isset($this->_template_args['before_admin_page_content'])
3265
-                ? $this->_template_args['before_admin_page_content']
3266
-                : ''
3267
-        );
3268
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3269
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3270
-            isset($this->_template_args['after_admin_page_content'])
3271
-                ? $this->_template_args['after_admin_page_content']
3272
-                : ''
3273
-        );
3274
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3275
-        // load settings page wrapper template
3276
-        $template_path = ! defined('DOING_AJAX')
3277
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3278
-            : EE_ADMIN_TEMPLATE
3279
-              . 'admin_wrapper_ajax.template.php';
3280
-        //about page?
3281
-        $template_path = $about
3282
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3283
-            : $template_path;
3284
-        if (defined('DOING_AJAX')) {
3285
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3286
-                $template_path,
3287
-                $this->_template_args,
3288
-                true
3289
-            );
3290
-            $this->_return_json();
3291
-        } else {
3292
-            EEH_Template::display_template($template_path, $this->_template_args);
3293
-        }
3294
-    }
3295
-
3296
-
3297
-
3298
-    /**
3299
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3300
-     *
3301
-     * @return string html
3302
-     * @throws EE_Error
3303
-     */
3304
-    protected function _get_main_nav_tabs()
3305
-    {
3306
-        // let's generate the html using the EEH_Tabbed_Content helper.
3307
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3308
-        // (rather than setting in the page_routes array)
3309
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3310
-    }
3311
-
3312
-
3313
-
3314
-    /**
3315
-     *        sort nav tabs
3316
-     *
3317
-     * @param $a
3318
-     * @param $b
3319
-     * @return int
3320
-     */
3321
-    private function _sort_nav_tabs($a, $b)
3322
-    {
3323
-        if ($a['order'] === $b['order']) {
3324
-            return 0;
3325
-        }
3326
-        return ($a['order'] < $b['order']) ? -1 : 1;
3327
-    }
3328
-
3329
-
3330
-
3331
-    /**
3332
-     *    generates HTML for the forms used on admin pages
3333
-     *
3334
-     * @param    array $input_vars - array of input field details
3335
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3336
-     *                             use)
3337
-     * @param bool     $id
3338
-     * @return string
3339
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3340
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3341
-     */
3342
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3343
-    {
3344
-        $content = $generator === 'string'
3345
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3346
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3347
-        return $content;
3348
-    }
3349
-
3350
-
3351
-
3352
-    /**
3353
-     * generates the "Save" and "Save & Close" buttons for edit forms
3354
-     *
3355
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3356
-     *                                   Close" button.
3357
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3358
-     *                                   'Save', [1] => 'save & close')
3359
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3360
-     *                                   via the "name" value in the button).  We can also use this to just dump
3361
-     *                                   default actions by submitting some other value.
3362
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3363
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3364
-     *                                   close (normal form handling).
3365
-     */
3366
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3367
-    {
3368
-        //make sure $text and $actions are in an array
3369
-        $text          = (array)$text;
3370
-        $actions       = (array)$actions;
3371
-        $referrer_url  = empty($referrer)
3372
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3373
-              . $_SERVER['REQUEST_URI']
3374
-              . '" />'
3375
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3376
-              . $referrer
3377
-              . '" />';
3378
-        $button_text   = ! empty($text)
3379
-            ? $text
3380
-            : array(
3381
-                esc_html__('Save', 'event_espresso'),
3382
-                esc_html__('Save and Close', 'event_espresso'),
3383
-            );
3384
-        $default_names = array('save', 'save_and_close');
3385
-        //add in a hidden index for the current page (so save and close redirects properly)
3386
-        $this->_template_args['save_buttons'] = $referrer_url;
3387
-        foreach ($button_text as $key => $button) {
3388
-            $ref                                  = $default_names[$key];
3389
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3390
-                                                     . $ref
3391
-                                                     . '" value="'
3392
-                                                     . $button
3393
-                                                     . '" name="'
3394
-                                                     . (! empty($actions) ? $actions[$key] : $ref)
3395
-                                                     . '" id="'
3396
-                                                     . $this->_current_view . '_' . $ref
3397
-                                                     . '" />';
3398
-            if (! $both) {
3399
-                break;
3400
-            }
3401
-        }
3402
-    }
3403
-
3404
-
3405
-
3406
-    /**
3407
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3408
-     *
3409
-     * @see   $this->_set_add_edit_form_tags() for details on params
3410
-     * @since 4.6.0
3411
-     * @param string $route
3412
-     * @param array  $additional_hidden_fields
3413
-     */
3414
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3415
-    {
3416
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3417
-    }
3418
-
3419
-
3420
-
3421
-    /**
3422
-     * set form open and close tags on add/edit pages.
3423
-     *
3424
-     * @param string $route                    the route you want the form to direct to
3425
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3426
-     * @return void
3427
-     */
3428
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3429
-    {
3430
-        if (empty($route)) {
3431
-            $user_msg = esc_html__(
3432
-                'An error occurred. No action was set for this page\'s form.',
3433
-                'event_espresso'
3434
-            );
3435
-            $dev_msg  = $user_msg . "\n" . sprintf(
3436
-                    esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3437
-                    __FUNCTION__,
3438
-                    __CLASS__
3439
-                );
3440
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3441
-        }
3442
-        // open form
3443
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3444
-                                                             . $this->_admin_base_url
3445
-                                                             . '" id="'
3446
-                                                             . $route
3447
-                                                             . '_event_form" >';
3448
-        // add nonce
3449
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3450
-        //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
3451
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3452
-        // add REQUIRED form action
3453
-        $hidden_fields = array(
3454
-            'action' => array('type' => 'hidden', 'value' => $route),
3455
-        );
3456
-        // merge arrays
3457
-        $hidden_fields = is_array($additional_hidden_fields)
3458
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3459
-            : $hidden_fields;
3460
-        // generate form fields
3461
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3462
-        // add fields to form
3463
-        foreach ((array)$form_fields as $field_name => $form_field) {
3464
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3465
-        }
3466
-        // close form
3467
-        $this->_template_args['after_admin_page_content'] = '</form>';
3468
-    }
3469
-
3470
-
3471
-
3472
-    /**
3473
-     * Public Wrapper for _redirect_after_action() method since its
3474
-     * discovered it would be useful for external code to have access.
3475
-     *
3476
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3477
-     * @since 4.5.0
3478
-     * @param bool   $success
3479
-     * @param string $what
3480
-     * @param string $action_desc
3481
-     * @param array  $query_args
3482
-     * @param bool   $override_overwrite
3483
-     * @throws EE_Error
3484
-     */
3485
-    public function redirect_after_action(
3486
-        $success = false,
3487
-        $what = 'item',
3488
-        $action_desc = 'processed',
3489
-        $query_args = array(),
3490
-        $override_overwrite = false
3491
-    ) {
3492
-        $this->_redirect_after_action(
3493
-            $success,
3494
-            $what,
3495
-            $action_desc,
3496
-            $query_args,
3497
-            $override_overwrite
3498
-        );
3499
-    }
3500
-
3501
-
3502
-
3503
-    /**
3504
-     *    _redirect_after_action
3505
-     *
3506
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3507
-     * @param string $what               - what the action was performed on
3508
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3509
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3510
-     *                                   action is completed
3511
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3512
-     *                                   override this so that they show.
3513
-     * @return void
3514
-     * @throws EE_Error
3515
-     */
3516
-    protected function _redirect_after_action(
3517
-        $success = 0,
3518
-        $what = 'item',
3519
-        $action_desc = 'processed',
3520
-        $query_args = array(),
3521
-        $override_overwrite = false
3522
-    ) {
3523
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3524
-        //class name for actions/filters.
3525
-        $classname = get_class($this);
3526
-        // set redirect url.
3527
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3528
-        // otherwise we go with whatever is set as the _admin_base_url
3529
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3530
-        $notices      = EE_Error::get_notices(false);
3531
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3532
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3533
-            EE_Error::overwrite_success();
3534
-        }
3535
-        if (! empty($what) && ! empty($action_desc)  && empty($notices['errors'])) {
3536
-            // how many records affected ? more than one record ? or just one ?
3537
-            if ($success > 1) {
3538
-                // set plural msg
3539
-                EE_Error::add_success(
3540
-                    sprintf(
3541
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3542
-                        $what,
3543
-                        $action_desc
3544
-                    ),
3545
-                    __FILE__,
3546
-                    __FUNCTION__,
3547
-                    __LINE__
3548
-                );
3549
-            } elseif ($success === 1) {
3550
-                // set singular msg
3551
-                EE_Error::add_success(
3552
-                    sprintf(
3553
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3554
-                        $what,
3555
-                        $action_desc
3556
-                    ),
3557
-                    __FILE__,
3558
-                    __FUNCTION__,
3559
-                    __LINE__
3560
-                );
3561
-            }
3562
-        }
3563
-        // check that $query_args isn't something crazy
3564
-        if (! is_array($query_args)) {
3565
-            $query_args = array();
3566
-        }
3567
-        /**
3568
-         * Allow injecting actions before the query_args are modified for possible different
3569
-         * redirections on save and close actions
3570
-         *
3571
-         * @since 4.2.0
3572
-         * @param array $query_args       The original query_args array coming into the
3573
-         *                                method.
3574
-         */
3575
-        do_action(
3576
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3577
-            $query_args
3578
-        );
3579
-        //calculate where we're going (if we have a "save and close" button pushed)
3580
-        if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3581
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3582
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3583
-            // regenerate query args array from referrer URL
3584
-            parse_str($parsed_url['query'], $query_args);
3585
-            // correct page and action will be in the query args now
3586
-            $redirect_url = admin_url('admin.php');
3587
-        }
3588
-        //merge any default query_args set in _default_route_query_args property
3589
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3590
-            $args_to_merge = array();
3591
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3592
-                //is there a wp_referer array in our _default_route_query_args property?
3593
-                if ($query_param === 'wp_referer') {
3594
-                    $query_value = (array)$query_value;
3595
-                    foreach ($query_value as $reference => $value) {
3596
-                        if (strpos($reference, 'nonce') !== false) {
3597
-                            continue;
3598
-                        }
3599
-                        //finally we will override any arguments in the referer with
3600
-                        //what might be set on the _default_route_query_args array.
3601
-                        if (isset($this->_default_route_query_args[$reference])) {
3602
-                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3603
-                        } else {
3604
-                            $args_to_merge[$reference] = urlencode($value);
3605
-                        }
3606
-                    }
3607
-                    continue;
3608
-                }
3609
-                $args_to_merge[$query_param] = $query_value;
3610
-            }
3611
-            //now let's merge these arguments but override with what was specifically sent in to the
3612
-            //redirect.
3613
-            $query_args = array_merge($args_to_merge, $query_args);
3614
-        }
3615
-        $this->_process_notices($query_args);
3616
-        // generate redirect url
3617
-        // if redirecting to anything other than the main page, add a nonce
3618
-        if (isset($query_args['action'])) {
3619
-            // manually generate wp_nonce and merge that with the query vars
3620
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3621
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3622
-        }
3623
-        // we're adding some hooks and filters in here for processing any things just before redirects
3624
-        // (example: an admin page has done an insert or update and we want to run something after that).
3625
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3626
-        $redirect_url = apply_filters(
3627
-            'FHEE_redirect_' . $classname . $this->_req_action,
3628
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3629
-            $query_args
3630
-        );
3631
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3632
-        if (defined('DOING_AJAX')) {
3633
-            $default_data                    = array(
3634
-                'close'        => true,
3635
-                'redirect_url' => $redirect_url,
3636
-                'where'        => 'main',
3637
-                'what'         => 'append',
3638
-            );
3639
-            $this->_template_args['success'] = $success;
3640
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3641
-                $default_data,
3642
-                $this->_template_args['data']
3643
-            ) : $default_data;
3644
-            $this->_return_json();
3645
-        }
3646
-        wp_safe_redirect($redirect_url);
3647
-        exit();
3648
-    }
3649
-
3650
-
3651
-
3652
-    /**
3653
-     * process any notices before redirecting (or returning ajax request)
3654
-     * This method sets the $this->_template_args['notices'] attribute;
3655
-     *
3656
-     * @param  array $query_args        any query args that need to be used for notice transient ('action')
3657
-     * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3658
-     *                                  page_routes haven't been defined yet.
3659
-     * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3660
-     *                                  still save a transient for the notice.
3661
-     * @return void
3662
-     * @throws EE_Error
3663
-     */
3664
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3665
-    {
3666
-        //first let's set individual error properties if doing_ajax and the properties aren't already set.
3667
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3668
-            $notices = EE_Error::get_notices(false);
3669
-            if (empty($this->_template_args['success'])) {
3670
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3671
-            }
3672
-            if (empty($this->_template_args['errors'])) {
3673
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3674
-            }
3675
-            if (empty($this->_template_args['attention'])) {
3676
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3677
-            }
3678
-        }
3679
-        $this->_template_args['notices'] = EE_Error::get_notices();
3680
-        //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3681
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3682
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3683
-            $this->_add_transient(
3684
-                $route,
3685
-                $this->_template_args['notices'],
3686
-                true,
3687
-                $skip_route_verify
3688
-            );
3689
-        }
3690
-    }
3691
-
3692
-
3693
-
3694
-    /**
3695
-     * get_action_link_or_button
3696
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3697
-     *
3698
-     * @param string $action        use this to indicate which action the url is generated with.
3699
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3700
-     *                              property.
3701
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3702
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3703
-     * @param string $base_url      If this is not provided
3704
-     *                              the _admin_base_url will be used as the default for the button base_url.
3705
-     *                              Otherwise this value will be used.
3706
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3707
-     * @return string
3708
-     * @throws InvalidArgumentException
3709
-     * @throws InvalidInterfaceException
3710
-     * @throws InvalidDataTypeException
3711
-     * @throws EE_Error
3712
-     */
3713
-    public function get_action_link_or_button(
3714
-        $action,
3715
-        $type = 'add',
3716
-        $extra_request = array(),
3717
-        $class = 'button-primary',
3718
-        $base_url = '',
3719
-        $exclude_nonce = false
3720
-    ) {
3721
-        //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3722
-        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3723
-            throw new EE_Error(
3724
-                sprintf(
3725
-                    esc_html__(
3726
-                        'There is no page route for given action for the button.  This action was given: %s',
3727
-                        'event_espresso'
3728
-                    ),
3729
-                    $action
3730
-                )
3731
-            );
3732
-        }
3733
-        if (! isset($this->_labels['buttons'][$type])) {
3734
-            throw new EE_Error(
3735
-                sprintf(
3736
-                    __(
3737
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3738
-                        'event_espresso'
3739
-                    ),
3740
-                    $type
3741
-                )
3742
-            );
3743
-        }
3744
-        //finally check user access for this button.
3745
-        $has_access = $this->check_user_access($action, true);
3746
-        if (! $has_access) {
3747
-            return '';
3748
-        }
3749
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3750
-        $query_args = array(
3751
-            'action' => $action,
3752
-        );
3753
-        //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3754
-        if (! empty($extra_request)) {
3755
-            $query_args = array_merge($extra_request, $query_args);
3756
-        }
3757
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3758
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3759
-    }
3760
-
3761
-
3762
-
3763
-    /**
3764
-     * _per_page_screen_option
3765
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3766
-     *
3767
-     * @return void
3768
-     * @throws InvalidArgumentException
3769
-     * @throws InvalidInterfaceException
3770
-     * @throws InvalidDataTypeException
3771
-     */
3772
-    protected function _per_page_screen_option()
3773
-    {
3774
-        $option = 'per_page';
3775
-        $args   = array(
3776
-            'label'   => esc_html__(
3777
-                    apply_filters(
3778
-                        'FHEE__EE_Admin_Page___per_page_screen_options___label',
3779
-                        $this->_admin_page_title,
3780
-                        $this
3781
-                    )
3782
-            ),
3783
-            'default' => (int) apply_filters(
3784
-                    'FHEE__EE_Admin_Page___per_page_screen_options__default',
3785
-                    10
3786
-            ),
3787
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3788
-        );
3789
-        //ONLY add the screen option if the user has access to it.
3790
-        if ($this->check_user_access($this->_current_view, true)) {
3791
-            add_screen_option($option, $args);
3792
-        }
3793
-    }
3794
-
3795
-
3796
-
3797
-    /**
3798
-     * set_per_page_screen_option
3799
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3800
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3801
-     * admin_menu.
3802
-     *
3803
-     * @return void
3804
-     */
3805
-    private function _set_per_page_screen_options()
3806
-    {
3807
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3808
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3809
-            if (! $user = wp_get_current_user()) {
3810
-                return;
3811
-            }
3812
-            $option = $_POST['wp_screen_options']['option'];
3813
-            $value  = $_POST['wp_screen_options']['value'];
3814
-            if ($option != sanitize_key($option)) {
3815
-                return;
3816
-            }
3817
-            $map_option = $option;
3818
-            $option     = str_replace('-', '_', $option);
3819
-            switch ($map_option) {
3820
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3821
-                    $value = (int)$value;
3822
-                    $max_value = apply_filters(
3823
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3824
-                        999,
3825
-                        $this->_current_page,
3826
-                        $this->_current_view
3827
-                    );
3828
-                    if ($value < 1 || $value > $max_value) {
3829
-                        return;
3830
-                    }
3831
-                    break;
3832
-                default:
3833
-                    $value = apply_filters(
3834
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3835
-                        false,
3836
-                        $option,
3837
-                        $value
3838
-                    );
3839
-                    if (false === $value) {
3840
-                        return;
3841
-                    }
3842
-                    break;
3843
-            }
3844
-            update_user_meta($user->ID, $option, $value);
3845
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3846
-            exit;
3847
-        }
3848
-    }
3849
-
3850
-
3851
-
3852
-    /**
3853
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3854
-     *
3855
-     * @param array $data array that will be assigned to template args.
3856
-     */
3857
-    public function set_template_args($data)
3858
-    {
3859
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3860
-    }
3861
-
3862
-
3863
-
3864
-    /**
3865
-     * This makes available the WP transient system for temporarily moving data between routes
3866
-     *
3867
-     * @param string $route             the route that should receive the transient
3868
-     * @param array  $data              the data that gets sent
3869
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3870
-     *                                  normal route transient.
3871
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3872
-     *                                  when we are adding a transient before page_routes have been defined.
3873
-     * @return void
3874
-     * @throws EE_Error
3875
-     */
3876
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3877
-    {
3878
-        $user_id = get_current_user_id();
3879
-        if (! $skip_route_verify) {
3880
-            $this->_verify_route($route);
3881
-        }
3882
-        //now let's set the string for what kind of transient we're setting
3883
-        $transient = $notices
3884
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3885
-            : 'rte_tx_' . $route . '_' . $user_id;
3886
-        $data      = $notices ? array('notices' => $data) : $data;
3887
-        //is there already a transient for this route?  If there is then let's ADD to that transient
3888
-        $existing = is_multisite() && is_network_admin()
3889
-            ? get_site_transient($transient)
3890
-            : get_transient($transient);
3891
-        if ($existing) {
3892
-            $data = array_merge((array)$data, (array)$existing);
3893
-        }
3894
-        if (is_multisite() && is_network_admin()) {
3895
-            set_site_transient($transient, $data, 8);
3896
-        } else {
3897
-            set_transient($transient, $data, 8);
3898
-        }
3899
-    }
3900
-
3901
-
3902
-
3903
-    /**
3904
-     * this retrieves the temporary transient that has been set for moving data between routes.
3905
-     *
3906
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3907
-     * @param string $route
3908
-     * @return mixed data
3909
-     */
3910
-    protected function _get_transient($notices = false, $route = '')
3911
-    {
3912
-        $user_id   = get_current_user_id();
3913
-        $route     = ! $route ? $this->_req_action : $route;
3914
-        $transient = $notices
3915
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3916
-            : 'rte_tx_' . $route . '_' . $user_id;
3917
-        $data      = is_multisite() && is_network_admin()
3918
-            ? get_site_transient($transient)
3919
-            : get_transient($transient);
3920
-        //delete transient after retrieval (just in case it hasn't expired);
3921
-        if (is_multisite() && is_network_admin()) {
3922
-            delete_site_transient($transient);
3923
-        } else {
3924
-            delete_transient($transient);
3925
-        }
3926
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3927
-    }
3928
-
3929
-
3930
-
3931
-    /**
3932
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3933
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3934
-     * default route callback on the EE_Admin page you want it run.)
3935
-     *
3936
-     * @return void
3937
-     */
3938
-    protected function _transient_garbage_collection()
3939
-    {
3940
-        global $wpdb;
3941
-        //retrieve all existing transients
3942
-        $query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3943
-        if ($results = $wpdb->get_results($query)) {
3944
-            foreach ($results as $result) {
3945
-                $transient = str_replace('_transient_', '', $result->option_name);
3946
-                get_transient($transient);
3947
-                if (is_multisite() && is_network_admin()) {
3948
-                    get_site_transient($transient);
3949
-                }
3950
-            }
3951
-        }
3952
-    }
3953
-
3954
-
3955
-
3956
-    /**
3957
-     * get_view
3958
-     *
3959
-     * @return string content of _view property
3960
-     */
3961
-    public function get_view()
3962
-    {
3963
-        return $this->_view;
3964
-    }
3965
-
3966
-
3967
-
3968
-    /**
3969
-     * getter for the protected $_views property
3970
-     *
3971
-     * @return array
3972
-     */
3973
-    public function get_views()
3974
-    {
3975
-        return $this->_views;
3976
-    }
3977
-
3978
-
3979
-
3980
-    /**
3981
-     * get_current_page
3982
-     *
3983
-     * @return string _current_page property value
3984
-     */
3985
-    public function get_current_page()
3986
-    {
3987
-        return $this->_current_page;
3988
-    }
3989
-
3990
-
3991
-
3992
-    /**
3993
-     * get_current_view
3994
-     *
3995
-     * @return string _current_view property value
3996
-     */
3997
-    public function get_current_view()
3998
-    {
3999
-        return $this->_current_view;
4000
-    }
4001
-
4002
-
4003
-
4004
-    /**
4005
-     * get_current_screen
4006
-     *
4007
-     * @return object The current WP_Screen object
4008
-     */
4009
-    public function get_current_screen()
4010
-    {
4011
-        return $this->_current_screen;
4012
-    }
4013
-
4014
-
4015
-
4016
-    /**
4017
-     * get_current_page_view_url
4018
-     *
4019
-     * @return string This returns the url for the current_page_view.
4020
-     */
4021
-    public function get_current_page_view_url()
4022
-    {
4023
-        return $this->_current_page_view_url;
4024
-    }
4025
-
4026
-
4027
-
4028
-    /**
4029
-     * just returns the _req_data property
4030
-     *
4031
-     * @return array
4032
-     */
4033
-    public function get_request_data()
4034
-    {
4035
-        return $this->_req_data;
4036
-    }
4037
-
4038
-
4039
-
4040
-    /**
4041
-     * returns the _req_data protected property
4042
-     *
4043
-     * @return string
4044
-     */
4045
-    public function get_req_action()
4046
-    {
4047
-        return $this->_req_action;
4048
-    }
4049
-
4050
-
4051
-
4052
-    /**
4053
-     * @return bool  value of $_is_caf property
4054
-     */
4055
-    public function is_caf()
4056
-    {
4057
-        return $this->_is_caf;
4058
-    }
4059
-
4060
-
4061
-
4062
-    /**
4063
-     * @return mixed
4064
-     */
4065
-    public function default_espresso_metaboxes()
4066
-    {
4067
-        return $this->_default_espresso_metaboxes;
4068
-    }
4069
-
4070
-
4071
-
4072
-    /**
4073
-     * @return mixed
4074
-     */
4075
-    public function admin_base_url()
4076
-    {
4077
-        return $this->_admin_base_url;
4078
-    }
2769
+	}
2770
+
2771
+
2772
+
2773
+	/**
2774
+	 * facade for add_meta_box
2775
+	 *
2776
+	 * @param string  $action        where the metabox get's displayed
2777
+	 * @param string  $title         Title of Metabox (output in metabox header)
2778
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2779
+	 *                               instead of the one created in here.
2780
+	 * @param array   $callback_args an array of args supplied for the metabox
2781
+	 * @param string  $column        what metabox column
2782
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2783
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2784
+	 *                               created but just set our own callback for wp's add_meta_box.
2785
+	 * @throws \DomainException
2786
+	 */
2787
+	public function _add_admin_page_meta_box(
2788
+		$action,
2789
+		$title,
2790
+		$callback,
2791
+		$callback_args,
2792
+		$column = 'normal',
2793
+		$priority = 'high',
2794
+		$create_func = true
2795
+	) {
2796
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2797
+		//if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2798
+		if (empty($callback_args) && $create_func) {
2799
+			$callback_args = array(
2800
+				'template_path' => $this->_template_path,
2801
+				'template_args' => $this->_template_args,
2802
+			);
2803
+		}
2804
+		//if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2805
+		$call_back_func = $create_func
2806
+			? function ($post, $metabox)
2807
+			{
2808
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2809
+				echo EEH_Template::display_template(
2810
+					$metabox['args']['template_path'],
2811
+					$metabox['args']['template_args'],
2812
+					true
2813
+				);
2814
+			}
2815
+			: $callback;
2816
+		add_meta_box(
2817
+			str_replace('_', '-', $action) . '-mbox',
2818
+			$title,
2819
+			$call_back_func,
2820
+			$this->_wp_page_slug,
2821
+			$column,
2822
+			$priority,
2823
+			$callback_args
2824
+		);
2825
+	}
2826
+
2827
+
2828
+
2829
+	/**
2830
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2831
+	 *
2832
+	 * @throws DomainException
2833
+	 * @throws EE_Error
2834
+	 */
2835
+	public function display_admin_page_with_metabox_columns()
2836
+	{
2837
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2838
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2839
+			$this->_column_template_path,
2840
+			$this->_template_args,
2841
+			true
2842
+		);
2843
+		//the final wrapper
2844
+		$this->admin_page_wrapper();
2845
+	}
2846
+
2847
+
2848
+
2849
+	/**
2850
+	 * generates  HTML wrapper for an admin details page
2851
+	 *
2852
+	 * @return void
2853
+	 * @throws EE_Error
2854
+	 * @throws DomainException
2855
+	 */
2856
+	public function display_admin_page_with_sidebar()
2857
+	{
2858
+		$this->_display_admin_page(true);
2859
+	}
2860
+
2861
+
2862
+
2863
+	/**
2864
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2865
+	 *
2866
+	 * @return void
2867
+	 * @throws EE_Error
2868
+	 * @throws DomainException
2869
+	 */
2870
+	public function display_admin_page_with_no_sidebar()
2871
+	{
2872
+		$this->_display_admin_page();
2873
+	}
2874
+
2875
+
2876
+
2877
+	/**
2878
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2879
+	 *
2880
+	 * @return void
2881
+	 * @throws EE_Error
2882
+	 * @throws DomainException
2883
+	 */
2884
+	public function display_about_admin_page()
2885
+	{
2886
+		$this->_display_admin_page(false, true);
2887
+	}
2888
+
2889
+
2890
+
2891
+	/**
2892
+	 * display_admin_page
2893
+	 * contains the code for actually displaying an admin page
2894
+	 *
2895
+	 * @param  boolean $sidebar true with sidebar, false without
2896
+	 * @param  boolean $about   use the about admin wrapper instead of the default.
2897
+	 * @return void
2898
+	 * @throws DomainException
2899
+	 * @throws EE_Error
2900
+	 */
2901
+	private function _display_admin_page($sidebar = false, $about = false)
2902
+	{
2903
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2904
+		//custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2905
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2906
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2907
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2908
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2909
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2910
+			? 'poststuff'
2911
+			: 'espresso-default-admin';
2912
+		$template_path                                     = $sidebar
2913
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2914
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2915
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2916
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2917
+		}
2918
+		$template_path                                     = ! empty($this->_column_template_path)
2919
+			? $this->_column_template_path : $template_path;
2920
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2921
+			? $this->_template_args['admin_page_content']
2922
+			: '';
2923
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2924
+			? $this->_template_args['before_admin_page_content']
2925
+			: '';
2926
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2927
+			? $this->_template_args['after_admin_page_content']
2928
+			: '';
2929
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2930
+			$template_path,
2931
+			$this->_template_args,
2932
+			true
2933
+		);
2934
+		// the final template wrapper
2935
+		$this->admin_page_wrapper($about);
2936
+	}
2937
+
2938
+
2939
+
2940
+	/**
2941
+	 * This is used to display caf preview pages.
2942
+	 *
2943
+	 * @since 4.3.2
2944
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2945
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2946
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2947
+	 * @return void
2948
+	 * @throws DomainException
2949
+	 * @throws EE_Error
2950
+	 * @throws InvalidArgumentException
2951
+	 * @throws InvalidDataTypeException
2952
+	 * @throws InvalidInterfaceException
2953
+	 */
2954
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2955
+	{
2956
+		//let's generate a default preview action button if there isn't one already present.
2957
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2958
+			'Upgrade to Event Espresso 4 Right Now',
2959
+			'event_espresso'
2960
+		);
2961
+		$buy_now_url                                   = add_query_arg(
2962
+			array(
2963
+				'ee_ver'       => 'ee4',
2964
+				'utm_source'   => 'ee4_plugin_admin',
2965
+				'utm_medium'   => 'link',
2966
+				'utm_campaign' => $utm_campaign_source,
2967
+				'utm_content'  => 'buy_now_button',
2968
+			),
2969
+			'http://eventespresso.com/pricing/'
2970
+		);
2971
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2972
+			? $this->get_action_link_or_button(
2973
+				'',
2974
+				'buy_now',
2975
+				array(),
2976
+				'button-primary button-large',
2977
+				$buy_now_url,
2978
+				true
2979
+			)
2980
+			: $this->_template_args['preview_action_button'];
2981
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2982
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2983
+			$this->_template_args,
2984
+			true
2985
+		);
2986
+		$this->_display_admin_page($display_sidebar);
2987
+	}
2988
+
2989
+
2990
+
2991
+	/**
2992
+	 * display_admin_list_table_page_with_sidebar
2993
+	 * generates HTML wrapper for an admin_page with list_table
2994
+	 *
2995
+	 * @return void
2996
+	 * @throws EE_Error
2997
+	 * @throws DomainException
2998
+	 */
2999
+	public function display_admin_list_table_page_with_sidebar()
3000
+	{
3001
+		$this->_display_admin_list_table_page(true);
3002
+	}
3003
+
3004
+
3005
+
3006
+	/**
3007
+	 * display_admin_list_table_page_with_no_sidebar
3008
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
3009
+	 *
3010
+	 * @return void
3011
+	 * @throws EE_Error
3012
+	 * @throws DomainException
3013
+	 */
3014
+	public function display_admin_list_table_page_with_no_sidebar()
3015
+	{
3016
+		$this->_display_admin_list_table_page();
3017
+	}
3018
+
3019
+
3020
+
3021
+	/**
3022
+	 * generates html wrapper for an admin_list_table page
3023
+	 *
3024
+	 * @param boolean $sidebar whether to display with sidebar or not.
3025
+	 * @return void
3026
+	 * @throws DomainException
3027
+	 * @throws EE_Error
3028
+	 */
3029
+	private function _display_admin_list_table_page($sidebar = false)
3030
+	{
3031
+		//setup search attributes
3032
+		$this->_set_search_attributes();
3033
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
3034
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3035
+		$this->_template_args['table_url']        = defined('DOING_AJAX')
3036
+			? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
3037
+			: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
3038
+		$this->_template_args['list_table']       = $this->_list_table_object;
3039
+		$this->_template_args['current_route']    = $this->_req_action;
3040
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3041
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3042
+		if (! empty($ajax_sorting_callback)) {
3043
+			$sortable_list_table_form_fields = wp_nonce_field(
3044
+				$ajax_sorting_callback . '_nonce',
3045
+				$ajax_sorting_callback . '_nonce',
3046
+				false,
3047
+				false
3048
+			);
3049
+			//			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
3050
+			//			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
3051
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3052
+												. $this->page_slug
3053
+												. '" />';
3054
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3055
+												. $ajax_sorting_callback
3056
+												. '" />';
3057
+		} else {
3058
+			$sortable_list_table_form_fields = '';
3059
+		}
3060
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3061
+		$hidden_form_fields                                      = isset($this->_template_args['list_table_hidden_fields'])
3062
+			? $this->_template_args['list_table_hidden_fields']
3063
+			: '';
3064
+		$nonce_ref                                               = $this->_req_action . '_nonce';
3065
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
3066
+																	. $nonce_ref
3067
+																	. '" value="'
3068
+																	. wp_create_nonce($nonce_ref)
3069
+																	. '">';
3070
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3071
+		//display message about search results?
3072
+		$this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
3073
+			? '<p class="ee-search-results">' . sprintf(
3074
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3075
+				trim($this->_req_data['s'], '%')
3076
+			) . '</p>'
3077
+			: '';
3078
+		// filter before_list_table template arg
3079
+		$this->_template_args['before_list_table'] = apply_filters(
3080
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3081
+			$this->_template_args['before_list_table'],
3082
+			$this->page_slug,
3083
+			$this->_req_data,
3084
+			$this->_req_action
3085
+		);
3086
+		// convert to array and filter again
3087
+		// arrays are easier to inject new items in a specific location,
3088
+		// but would not be backwards compatible, so we have to add a new filter
3089
+		$this->_template_args['before_list_table'] = implode(
3090
+			" \n",
3091
+			(array)apply_filters(
3092
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3093
+				(array)$this->_template_args['before_list_table'],
3094
+				$this->page_slug,
3095
+				$this->_req_data,
3096
+				$this->_req_action
3097
+			)
3098
+		);
3099
+		// filter after_list_table template arg
3100
+		$this->_template_args['after_list_table'] = apply_filters(
3101
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3102
+			$this->_template_args['after_list_table'],
3103
+			$this->page_slug,
3104
+			$this->_req_data,
3105
+			$this->_req_action
3106
+		);
3107
+		// convert to array and filter again
3108
+		// arrays are easier to inject new items in a specific location,
3109
+		// but would not be backwards compatible, so we have to add a new filter
3110
+		$this->_template_args['after_list_table']   = implode(
3111
+			" \n",
3112
+			(array)apply_filters(
3113
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3114
+				(array)$this->_template_args['after_list_table'],
3115
+				$this->page_slug,
3116
+				$this->_req_data,
3117
+				$this->_req_action
3118
+			)
3119
+		);
3120
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3121
+			$template_path,
3122
+			$this->_template_args,
3123
+			true
3124
+		);
3125
+		// the final template wrapper
3126
+		if ($sidebar) {
3127
+			$this->display_admin_page_with_sidebar();
3128
+		} else {
3129
+			$this->display_admin_page_with_no_sidebar();
3130
+		}
3131
+	}
3132
+
3133
+
3134
+
3135
+	/**
3136
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3137
+	 * html string for the legend.
3138
+	 * $items are expected in an array in the following format:
3139
+	 * $legend_items = array(
3140
+	 *        'item_id' => array(
3141
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3142
+	 *            'desc' => esc_html__('localized description of item');
3143
+	 *        )
3144
+	 * );
3145
+	 *
3146
+	 * @param  array $items see above for format of array
3147
+	 * @return string html string of legend
3148
+	 * @throws DomainException
3149
+	 */
3150
+	protected function _display_legend($items)
3151
+	{
3152
+		$this->_template_args['items'] = apply_filters(
3153
+			'FHEE__EE_Admin_Page___display_legend__items',
3154
+			(array)$items,
3155
+			$this
3156
+		);
3157
+		return EEH_Template::display_template(
3158
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3159
+			$this->_template_args,
3160
+			true
3161
+		);
3162
+	}
3163
+
3164
+
3165
+	/**
3166
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3167
+	 * The returned json object is created from an array in the following format:
3168
+	 * array(
3169
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3170
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3171
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3172
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3173
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3174
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3175
+	 *  that might be included in here)
3176
+	 * )
3177
+	 * The json object is populated by whatever is set in the $_template_args property.
3178
+	 *
3179
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3180
+	 *                                 instead of displayed.
3181
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3182
+	 * @return void
3183
+	 * @throws EE_Error
3184
+	 */
3185
+	protected function _return_json($sticky_notices = false, $notices_arguments = array())
3186
+	{
3187
+		//make sure any EE_Error notices have been handled.
3188
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3189
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3190
+		unset($this->_template_args['data']);
3191
+		$json = array(
3192
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3193
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3194
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3195
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3196
+			'notices'   => EE_Error::get_notices(),
3197
+			'content'   => isset($this->_template_args['admin_page_content'])
3198
+				? $this->_template_args['admin_page_content'] : '',
3199
+			'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3200
+			'isEEajax'  => true
3201
+			//special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3202
+		);
3203
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3204
+		if (null === error_get_last() || ! headers_sent()) {
3205
+			header('Content-Type: application/json; charset=UTF-8');
3206
+		}
3207
+		echo wp_json_encode($json);
3208
+		exit();
3209
+	}
3210
+
3211
+
3212
+
3213
+	/**
3214
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3215
+	 *
3216
+	 * @return void
3217
+	 * @throws EE_Error
3218
+	 */
3219
+	public function return_json()
3220
+	{
3221
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3222
+			$this->_return_json();
3223
+		} else {
3224
+			throw new EE_Error(
3225
+				sprintf(
3226
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3227
+					__FUNCTION__
3228
+				)
3229
+			);
3230
+		}
3231
+	}
3232
+
3233
+
3234
+
3235
+	/**
3236
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3237
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3238
+	 *
3239
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3240
+	 */
3241
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3242
+	{
3243
+		$this->_hook_obj = $hook_obj;
3244
+	}
3245
+
3246
+
3247
+
3248
+	/**
3249
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3250
+	 *
3251
+	 * @param  boolean $about whether to use the special about page wrapper or default.
3252
+	 * @return void
3253
+	 * @throws DomainException
3254
+	 * @throws EE_Error
3255
+	 */
3256
+	public function admin_page_wrapper($about = false)
3257
+	{
3258
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3259
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3260
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3261
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3262
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3263
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3264
+			isset($this->_template_args['before_admin_page_content'])
3265
+				? $this->_template_args['before_admin_page_content']
3266
+				: ''
3267
+		);
3268
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3269
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3270
+			isset($this->_template_args['after_admin_page_content'])
3271
+				? $this->_template_args['after_admin_page_content']
3272
+				: ''
3273
+		);
3274
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3275
+		// load settings page wrapper template
3276
+		$template_path = ! defined('DOING_AJAX')
3277
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3278
+			: EE_ADMIN_TEMPLATE
3279
+			  . 'admin_wrapper_ajax.template.php';
3280
+		//about page?
3281
+		$template_path = $about
3282
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3283
+			: $template_path;
3284
+		if (defined('DOING_AJAX')) {
3285
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3286
+				$template_path,
3287
+				$this->_template_args,
3288
+				true
3289
+			);
3290
+			$this->_return_json();
3291
+		} else {
3292
+			EEH_Template::display_template($template_path, $this->_template_args);
3293
+		}
3294
+	}
3295
+
3296
+
3297
+
3298
+	/**
3299
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3300
+	 *
3301
+	 * @return string html
3302
+	 * @throws EE_Error
3303
+	 */
3304
+	protected function _get_main_nav_tabs()
3305
+	{
3306
+		// let's generate the html using the EEH_Tabbed_Content helper.
3307
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3308
+		// (rather than setting in the page_routes array)
3309
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3310
+	}
3311
+
3312
+
3313
+
3314
+	/**
3315
+	 *        sort nav tabs
3316
+	 *
3317
+	 * @param $a
3318
+	 * @param $b
3319
+	 * @return int
3320
+	 */
3321
+	private function _sort_nav_tabs($a, $b)
3322
+	{
3323
+		if ($a['order'] === $b['order']) {
3324
+			return 0;
3325
+		}
3326
+		return ($a['order'] < $b['order']) ? -1 : 1;
3327
+	}
3328
+
3329
+
3330
+
3331
+	/**
3332
+	 *    generates HTML for the forms used on admin pages
3333
+	 *
3334
+	 * @param    array $input_vars - array of input field details
3335
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3336
+	 *                             use)
3337
+	 * @param bool     $id
3338
+	 * @return string
3339
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3340
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3341
+	 */
3342
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3343
+	{
3344
+		$content = $generator === 'string'
3345
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3346
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3347
+		return $content;
3348
+	}
3349
+
3350
+
3351
+
3352
+	/**
3353
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3354
+	 *
3355
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3356
+	 *                                   Close" button.
3357
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3358
+	 *                                   'Save', [1] => 'save & close')
3359
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3360
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3361
+	 *                                   default actions by submitting some other value.
3362
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3363
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3364
+	 *                                   close (normal form handling).
3365
+	 */
3366
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3367
+	{
3368
+		//make sure $text and $actions are in an array
3369
+		$text          = (array)$text;
3370
+		$actions       = (array)$actions;
3371
+		$referrer_url  = empty($referrer)
3372
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3373
+			  . $_SERVER['REQUEST_URI']
3374
+			  . '" />'
3375
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3376
+			  . $referrer
3377
+			  . '" />';
3378
+		$button_text   = ! empty($text)
3379
+			? $text
3380
+			: array(
3381
+				esc_html__('Save', 'event_espresso'),
3382
+				esc_html__('Save and Close', 'event_espresso'),
3383
+			);
3384
+		$default_names = array('save', 'save_and_close');
3385
+		//add in a hidden index for the current page (so save and close redirects properly)
3386
+		$this->_template_args['save_buttons'] = $referrer_url;
3387
+		foreach ($button_text as $key => $button) {
3388
+			$ref                                  = $default_names[$key];
3389
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3390
+													 . $ref
3391
+													 . '" value="'
3392
+													 . $button
3393
+													 . '" name="'
3394
+													 . (! empty($actions) ? $actions[$key] : $ref)
3395
+													 . '" id="'
3396
+													 . $this->_current_view . '_' . $ref
3397
+													 . '" />';
3398
+			if (! $both) {
3399
+				break;
3400
+			}
3401
+		}
3402
+	}
3403
+
3404
+
3405
+
3406
+	/**
3407
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3408
+	 *
3409
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3410
+	 * @since 4.6.0
3411
+	 * @param string $route
3412
+	 * @param array  $additional_hidden_fields
3413
+	 */
3414
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3415
+	{
3416
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3417
+	}
3418
+
3419
+
3420
+
3421
+	/**
3422
+	 * set form open and close tags on add/edit pages.
3423
+	 *
3424
+	 * @param string $route                    the route you want the form to direct to
3425
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3426
+	 * @return void
3427
+	 */
3428
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3429
+	{
3430
+		if (empty($route)) {
3431
+			$user_msg = esc_html__(
3432
+				'An error occurred. No action was set for this page\'s form.',
3433
+				'event_espresso'
3434
+			);
3435
+			$dev_msg  = $user_msg . "\n" . sprintf(
3436
+					esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3437
+					__FUNCTION__,
3438
+					__CLASS__
3439
+				);
3440
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3441
+		}
3442
+		// open form
3443
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3444
+															 . $this->_admin_base_url
3445
+															 . '" id="'
3446
+															 . $route
3447
+															 . '_event_form" >';
3448
+		// add nonce
3449
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3450
+		//		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
3451
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3452
+		// add REQUIRED form action
3453
+		$hidden_fields = array(
3454
+			'action' => array('type' => 'hidden', 'value' => $route),
3455
+		);
3456
+		// merge arrays
3457
+		$hidden_fields = is_array($additional_hidden_fields)
3458
+			? array_merge($hidden_fields, $additional_hidden_fields)
3459
+			: $hidden_fields;
3460
+		// generate form fields
3461
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3462
+		// add fields to form
3463
+		foreach ((array)$form_fields as $field_name => $form_field) {
3464
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3465
+		}
3466
+		// close form
3467
+		$this->_template_args['after_admin_page_content'] = '</form>';
3468
+	}
3469
+
3470
+
3471
+
3472
+	/**
3473
+	 * Public Wrapper for _redirect_after_action() method since its
3474
+	 * discovered it would be useful for external code to have access.
3475
+	 *
3476
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3477
+	 * @since 4.5.0
3478
+	 * @param bool   $success
3479
+	 * @param string $what
3480
+	 * @param string $action_desc
3481
+	 * @param array  $query_args
3482
+	 * @param bool   $override_overwrite
3483
+	 * @throws EE_Error
3484
+	 */
3485
+	public function redirect_after_action(
3486
+		$success = false,
3487
+		$what = 'item',
3488
+		$action_desc = 'processed',
3489
+		$query_args = array(),
3490
+		$override_overwrite = false
3491
+	) {
3492
+		$this->_redirect_after_action(
3493
+			$success,
3494
+			$what,
3495
+			$action_desc,
3496
+			$query_args,
3497
+			$override_overwrite
3498
+		);
3499
+	}
3500
+
3501
+
3502
+
3503
+	/**
3504
+	 *    _redirect_after_action
3505
+	 *
3506
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3507
+	 * @param string $what               - what the action was performed on
3508
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3509
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3510
+	 *                                   action is completed
3511
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3512
+	 *                                   override this so that they show.
3513
+	 * @return void
3514
+	 * @throws EE_Error
3515
+	 */
3516
+	protected function _redirect_after_action(
3517
+		$success = 0,
3518
+		$what = 'item',
3519
+		$action_desc = 'processed',
3520
+		$query_args = array(),
3521
+		$override_overwrite = false
3522
+	) {
3523
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3524
+		//class name for actions/filters.
3525
+		$classname = get_class($this);
3526
+		// set redirect url.
3527
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3528
+		// otherwise we go with whatever is set as the _admin_base_url
3529
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3530
+		$notices      = EE_Error::get_notices(false);
3531
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3532
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3533
+			EE_Error::overwrite_success();
3534
+		}
3535
+		if (! empty($what) && ! empty($action_desc)  && empty($notices['errors'])) {
3536
+			// how many records affected ? more than one record ? or just one ?
3537
+			if ($success > 1) {
3538
+				// set plural msg
3539
+				EE_Error::add_success(
3540
+					sprintf(
3541
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3542
+						$what,
3543
+						$action_desc
3544
+					),
3545
+					__FILE__,
3546
+					__FUNCTION__,
3547
+					__LINE__
3548
+				);
3549
+			} elseif ($success === 1) {
3550
+				// set singular msg
3551
+				EE_Error::add_success(
3552
+					sprintf(
3553
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3554
+						$what,
3555
+						$action_desc
3556
+					),
3557
+					__FILE__,
3558
+					__FUNCTION__,
3559
+					__LINE__
3560
+				);
3561
+			}
3562
+		}
3563
+		// check that $query_args isn't something crazy
3564
+		if (! is_array($query_args)) {
3565
+			$query_args = array();
3566
+		}
3567
+		/**
3568
+		 * Allow injecting actions before the query_args are modified for possible different
3569
+		 * redirections on save and close actions
3570
+		 *
3571
+		 * @since 4.2.0
3572
+		 * @param array $query_args       The original query_args array coming into the
3573
+		 *                                method.
3574
+		 */
3575
+		do_action(
3576
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3577
+			$query_args
3578
+		);
3579
+		//calculate where we're going (if we have a "save and close" button pushed)
3580
+		if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3581
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3582
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3583
+			// regenerate query args array from referrer URL
3584
+			parse_str($parsed_url['query'], $query_args);
3585
+			// correct page and action will be in the query args now
3586
+			$redirect_url = admin_url('admin.php');
3587
+		}
3588
+		//merge any default query_args set in _default_route_query_args property
3589
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3590
+			$args_to_merge = array();
3591
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3592
+				//is there a wp_referer array in our _default_route_query_args property?
3593
+				if ($query_param === 'wp_referer') {
3594
+					$query_value = (array)$query_value;
3595
+					foreach ($query_value as $reference => $value) {
3596
+						if (strpos($reference, 'nonce') !== false) {
3597
+							continue;
3598
+						}
3599
+						//finally we will override any arguments in the referer with
3600
+						//what might be set on the _default_route_query_args array.
3601
+						if (isset($this->_default_route_query_args[$reference])) {
3602
+							$args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3603
+						} else {
3604
+							$args_to_merge[$reference] = urlencode($value);
3605
+						}
3606
+					}
3607
+					continue;
3608
+				}
3609
+				$args_to_merge[$query_param] = $query_value;
3610
+			}
3611
+			//now let's merge these arguments but override with what was specifically sent in to the
3612
+			//redirect.
3613
+			$query_args = array_merge($args_to_merge, $query_args);
3614
+		}
3615
+		$this->_process_notices($query_args);
3616
+		// generate redirect url
3617
+		// if redirecting to anything other than the main page, add a nonce
3618
+		if (isset($query_args['action'])) {
3619
+			// manually generate wp_nonce and merge that with the query vars
3620
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3621
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3622
+		}
3623
+		// we're adding some hooks and filters in here for processing any things just before redirects
3624
+		// (example: an admin page has done an insert or update and we want to run something after that).
3625
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3626
+		$redirect_url = apply_filters(
3627
+			'FHEE_redirect_' . $classname . $this->_req_action,
3628
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3629
+			$query_args
3630
+		);
3631
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3632
+		if (defined('DOING_AJAX')) {
3633
+			$default_data                    = array(
3634
+				'close'        => true,
3635
+				'redirect_url' => $redirect_url,
3636
+				'where'        => 'main',
3637
+				'what'         => 'append',
3638
+			);
3639
+			$this->_template_args['success'] = $success;
3640
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3641
+				$default_data,
3642
+				$this->_template_args['data']
3643
+			) : $default_data;
3644
+			$this->_return_json();
3645
+		}
3646
+		wp_safe_redirect($redirect_url);
3647
+		exit();
3648
+	}
3649
+
3650
+
3651
+
3652
+	/**
3653
+	 * process any notices before redirecting (or returning ajax request)
3654
+	 * This method sets the $this->_template_args['notices'] attribute;
3655
+	 *
3656
+	 * @param  array $query_args        any query args that need to be used for notice transient ('action')
3657
+	 * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3658
+	 *                                  page_routes haven't been defined yet.
3659
+	 * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3660
+	 *                                  still save a transient for the notice.
3661
+	 * @return void
3662
+	 * @throws EE_Error
3663
+	 */
3664
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3665
+	{
3666
+		//first let's set individual error properties if doing_ajax and the properties aren't already set.
3667
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3668
+			$notices = EE_Error::get_notices(false);
3669
+			if (empty($this->_template_args['success'])) {
3670
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3671
+			}
3672
+			if (empty($this->_template_args['errors'])) {
3673
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3674
+			}
3675
+			if (empty($this->_template_args['attention'])) {
3676
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3677
+			}
3678
+		}
3679
+		$this->_template_args['notices'] = EE_Error::get_notices();
3680
+		//IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3681
+		if (! defined('DOING_AJAX') || $sticky_notices) {
3682
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3683
+			$this->_add_transient(
3684
+				$route,
3685
+				$this->_template_args['notices'],
3686
+				true,
3687
+				$skip_route_verify
3688
+			);
3689
+		}
3690
+	}
3691
+
3692
+
3693
+
3694
+	/**
3695
+	 * get_action_link_or_button
3696
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3697
+	 *
3698
+	 * @param string $action        use this to indicate which action the url is generated with.
3699
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3700
+	 *                              property.
3701
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3702
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3703
+	 * @param string $base_url      If this is not provided
3704
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3705
+	 *                              Otherwise this value will be used.
3706
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3707
+	 * @return string
3708
+	 * @throws InvalidArgumentException
3709
+	 * @throws InvalidInterfaceException
3710
+	 * @throws InvalidDataTypeException
3711
+	 * @throws EE_Error
3712
+	 */
3713
+	public function get_action_link_or_button(
3714
+		$action,
3715
+		$type = 'add',
3716
+		$extra_request = array(),
3717
+		$class = 'button-primary',
3718
+		$base_url = '',
3719
+		$exclude_nonce = false
3720
+	) {
3721
+		//first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3722
+		if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3723
+			throw new EE_Error(
3724
+				sprintf(
3725
+					esc_html__(
3726
+						'There is no page route for given action for the button.  This action was given: %s',
3727
+						'event_espresso'
3728
+					),
3729
+					$action
3730
+				)
3731
+			);
3732
+		}
3733
+		if (! isset($this->_labels['buttons'][$type])) {
3734
+			throw new EE_Error(
3735
+				sprintf(
3736
+					__(
3737
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3738
+						'event_espresso'
3739
+					),
3740
+					$type
3741
+				)
3742
+			);
3743
+		}
3744
+		//finally check user access for this button.
3745
+		$has_access = $this->check_user_access($action, true);
3746
+		if (! $has_access) {
3747
+			return '';
3748
+		}
3749
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3750
+		$query_args = array(
3751
+			'action' => $action,
3752
+		);
3753
+		//merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3754
+		if (! empty($extra_request)) {
3755
+			$query_args = array_merge($extra_request, $query_args);
3756
+		}
3757
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3758
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3759
+	}
3760
+
3761
+
3762
+
3763
+	/**
3764
+	 * _per_page_screen_option
3765
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3766
+	 *
3767
+	 * @return void
3768
+	 * @throws InvalidArgumentException
3769
+	 * @throws InvalidInterfaceException
3770
+	 * @throws InvalidDataTypeException
3771
+	 */
3772
+	protected function _per_page_screen_option()
3773
+	{
3774
+		$option = 'per_page';
3775
+		$args   = array(
3776
+			'label'   => esc_html__(
3777
+					apply_filters(
3778
+						'FHEE__EE_Admin_Page___per_page_screen_options___label',
3779
+						$this->_admin_page_title,
3780
+						$this
3781
+					)
3782
+			),
3783
+			'default' => (int) apply_filters(
3784
+					'FHEE__EE_Admin_Page___per_page_screen_options__default',
3785
+					10
3786
+			),
3787
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3788
+		);
3789
+		//ONLY add the screen option if the user has access to it.
3790
+		if ($this->check_user_access($this->_current_view, true)) {
3791
+			add_screen_option($option, $args);
3792
+		}
3793
+	}
3794
+
3795
+
3796
+
3797
+	/**
3798
+	 * set_per_page_screen_option
3799
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3800
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3801
+	 * admin_menu.
3802
+	 *
3803
+	 * @return void
3804
+	 */
3805
+	private function _set_per_page_screen_options()
3806
+	{
3807
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3808
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3809
+			if (! $user = wp_get_current_user()) {
3810
+				return;
3811
+			}
3812
+			$option = $_POST['wp_screen_options']['option'];
3813
+			$value  = $_POST['wp_screen_options']['value'];
3814
+			if ($option != sanitize_key($option)) {
3815
+				return;
3816
+			}
3817
+			$map_option = $option;
3818
+			$option     = str_replace('-', '_', $option);
3819
+			switch ($map_option) {
3820
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3821
+					$value = (int)$value;
3822
+					$max_value = apply_filters(
3823
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3824
+						999,
3825
+						$this->_current_page,
3826
+						$this->_current_view
3827
+					);
3828
+					if ($value < 1 || $value > $max_value) {
3829
+						return;
3830
+					}
3831
+					break;
3832
+				default:
3833
+					$value = apply_filters(
3834
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3835
+						false,
3836
+						$option,
3837
+						$value
3838
+					);
3839
+					if (false === $value) {
3840
+						return;
3841
+					}
3842
+					break;
3843
+			}
3844
+			update_user_meta($user->ID, $option, $value);
3845
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3846
+			exit;
3847
+		}
3848
+	}
3849
+
3850
+
3851
+
3852
+	/**
3853
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3854
+	 *
3855
+	 * @param array $data array that will be assigned to template args.
3856
+	 */
3857
+	public function set_template_args($data)
3858
+	{
3859
+		$this->_template_args = array_merge($this->_template_args, (array)$data);
3860
+	}
3861
+
3862
+
3863
+
3864
+	/**
3865
+	 * This makes available the WP transient system for temporarily moving data between routes
3866
+	 *
3867
+	 * @param string $route             the route that should receive the transient
3868
+	 * @param array  $data              the data that gets sent
3869
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3870
+	 *                                  normal route transient.
3871
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3872
+	 *                                  when we are adding a transient before page_routes have been defined.
3873
+	 * @return void
3874
+	 * @throws EE_Error
3875
+	 */
3876
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3877
+	{
3878
+		$user_id = get_current_user_id();
3879
+		if (! $skip_route_verify) {
3880
+			$this->_verify_route($route);
3881
+		}
3882
+		//now let's set the string for what kind of transient we're setting
3883
+		$transient = $notices
3884
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3885
+			: 'rte_tx_' . $route . '_' . $user_id;
3886
+		$data      = $notices ? array('notices' => $data) : $data;
3887
+		//is there already a transient for this route?  If there is then let's ADD to that transient
3888
+		$existing = is_multisite() && is_network_admin()
3889
+			? get_site_transient($transient)
3890
+			: get_transient($transient);
3891
+		if ($existing) {
3892
+			$data = array_merge((array)$data, (array)$existing);
3893
+		}
3894
+		if (is_multisite() && is_network_admin()) {
3895
+			set_site_transient($transient, $data, 8);
3896
+		} else {
3897
+			set_transient($transient, $data, 8);
3898
+		}
3899
+	}
3900
+
3901
+
3902
+
3903
+	/**
3904
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3905
+	 *
3906
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3907
+	 * @param string $route
3908
+	 * @return mixed data
3909
+	 */
3910
+	protected function _get_transient($notices = false, $route = '')
3911
+	{
3912
+		$user_id   = get_current_user_id();
3913
+		$route     = ! $route ? $this->_req_action : $route;
3914
+		$transient = $notices
3915
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3916
+			: 'rte_tx_' . $route . '_' . $user_id;
3917
+		$data      = is_multisite() && is_network_admin()
3918
+			? get_site_transient($transient)
3919
+			: get_transient($transient);
3920
+		//delete transient after retrieval (just in case it hasn't expired);
3921
+		if (is_multisite() && is_network_admin()) {
3922
+			delete_site_transient($transient);
3923
+		} else {
3924
+			delete_transient($transient);
3925
+		}
3926
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3927
+	}
3928
+
3929
+
3930
+
3931
+	/**
3932
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3933
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3934
+	 * default route callback on the EE_Admin page you want it run.)
3935
+	 *
3936
+	 * @return void
3937
+	 */
3938
+	protected function _transient_garbage_collection()
3939
+	{
3940
+		global $wpdb;
3941
+		//retrieve all existing transients
3942
+		$query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3943
+		if ($results = $wpdb->get_results($query)) {
3944
+			foreach ($results as $result) {
3945
+				$transient = str_replace('_transient_', '', $result->option_name);
3946
+				get_transient($transient);
3947
+				if (is_multisite() && is_network_admin()) {
3948
+					get_site_transient($transient);
3949
+				}
3950
+			}
3951
+		}
3952
+	}
3953
+
3954
+
3955
+
3956
+	/**
3957
+	 * get_view
3958
+	 *
3959
+	 * @return string content of _view property
3960
+	 */
3961
+	public function get_view()
3962
+	{
3963
+		return $this->_view;
3964
+	}
3965
+
3966
+
3967
+
3968
+	/**
3969
+	 * getter for the protected $_views property
3970
+	 *
3971
+	 * @return array
3972
+	 */
3973
+	public function get_views()
3974
+	{
3975
+		return $this->_views;
3976
+	}
3977
+
3978
+
3979
+
3980
+	/**
3981
+	 * get_current_page
3982
+	 *
3983
+	 * @return string _current_page property value
3984
+	 */
3985
+	public function get_current_page()
3986
+	{
3987
+		return $this->_current_page;
3988
+	}
3989
+
3990
+
3991
+
3992
+	/**
3993
+	 * get_current_view
3994
+	 *
3995
+	 * @return string _current_view property value
3996
+	 */
3997
+	public function get_current_view()
3998
+	{
3999
+		return $this->_current_view;
4000
+	}
4001
+
4002
+
4003
+
4004
+	/**
4005
+	 * get_current_screen
4006
+	 *
4007
+	 * @return object The current WP_Screen object
4008
+	 */
4009
+	public function get_current_screen()
4010
+	{
4011
+		return $this->_current_screen;
4012
+	}
4013
+
4014
+
4015
+
4016
+	/**
4017
+	 * get_current_page_view_url
4018
+	 *
4019
+	 * @return string This returns the url for the current_page_view.
4020
+	 */
4021
+	public function get_current_page_view_url()
4022
+	{
4023
+		return $this->_current_page_view_url;
4024
+	}
4025
+
4026
+
4027
+
4028
+	/**
4029
+	 * just returns the _req_data property
4030
+	 *
4031
+	 * @return array
4032
+	 */
4033
+	public function get_request_data()
4034
+	{
4035
+		return $this->_req_data;
4036
+	}
4037
+
4038
+
4039
+
4040
+	/**
4041
+	 * returns the _req_data protected property
4042
+	 *
4043
+	 * @return string
4044
+	 */
4045
+	public function get_req_action()
4046
+	{
4047
+		return $this->_req_action;
4048
+	}
4049
+
4050
+
4051
+
4052
+	/**
4053
+	 * @return bool  value of $_is_caf property
4054
+	 */
4055
+	public function is_caf()
4056
+	{
4057
+		return $this->_is_caf;
4058
+	}
4059
+
4060
+
4061
+
4062
+	/**
4063
+	 * @return mixed
4064
+	 */
4065
+	public function default_espresso_metaboxes()
4066
+	{
4067
+		return $this->_default_espresso_metaboxes;
4068
+	}
4069
+
4070
+
4071
+
4072
+	/**
4073
+	 * @return mixed
4074
+	 */
4075
+	public function admin_base_url()
4076
+	{
4077
+		return $this->_admin_base_url;
4078
+	}
4079 4079
 
4080 4080
 
4081 4081
 
4082
-    /**
4083
-     * @return mixed
4084
-     */
4085
-    public function wp_page_slug()
4086
-    {
4087
-        return $this->_wp_page_slug;
4088
-    }
4082
+	/**
4083
+	 * @return mixed
4084
+	 */
4085
+	public function wp_page_slug()
4086
+	{
4087
+		return $this->_wp_page_slug;
4088
+	}
4089 4089
 
4090 4090
 
4091
-
4092
-    /**
4093
-     * updates  espresso configuration settings
4094
-     *
4095
-     * @param string                   $tab
4096
-     * @param EE_Config_Base|EE_Config $config
4097
-     * @param string                   $file file where error occurred
4098
-     * @param string                   $func function  where error occurred
4099
-     * @param string                   $line line no where error occurred
4100
-     * @return boolean
4101
-     */
4102
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4103
-    {
4104
-        //remove any options that are NOT going to be saved with the config settings.
4105
-        if (isset($config->core->ee_ueip_optin)) {
4106
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4107
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4108
-            update_option('ee_ueip_has_notified', true);
4109
-        }
4110
-        // and save it (note we're also doing the network save here)
4111
-        $net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4112
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4113
-        if ($config_saved && $net_saved) {
4114
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4115
-            return true;
4116
-        }
4117
-        EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4118
-        return false;
4119
-    }
4120
-
4121
-
4122
-
4123
-    /**
4124
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4125
-     *
4126
-     * @return array
4127
-     */
4128
-    public function get_yes_no_values()
4129
-    {
4130
-        return $this->_yes_no_values;
4131
-    }
4132
-
4133
-
4134
-
4135
-    protected function _get_dir()
4136
-    {
4137
-        $reflector = new ReflectionClass(get_class($this));
4138
-        return dirname($reflector->getFileName());
4139
-    }
4140
-
4141
-
4142
-
4143
-    /**
4144
-     * A helper for getting a "next link".
4145
-     *
4146
-     * @param string $url   The url to link to
4147
-     * @param string $class The class to use.
4148
-     * @return string
4149
-     */
4150
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4151
-    {
4152
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4153
-    }
4154
-
4155
-
4156
-
4157
-    /**
4158
-     * A helper for getting a "previous link".
4159
-     *
4160
-     * @param string $url   The url to link to
4161
-     * @param string $class The class to use.
4162
-     * @return string
4163
-     */
4164
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4165
-    {
4166
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4167
-    }
4168
-
4169
-
4170
-
4171
-
4172
-
4173
-
4174
-
4175
-    //below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4176
-
4177
-
4178
-    /**
4179
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4180
-     * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4181
-     * _req_data array.
4182
-     *
4183
-     * @return bool success/fail
4184
-     * @throws EE_Error
4185
-     * @throws InvalidArgumentException
4186
-     * @throws ReflectionException
4187
-     * @throws InvalidDataTypeException
4188
-     * @throws InvalidInterfaceException
4189
-     */
4190
-    protected function _process_resend_registration()
4191
-    {
4192
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4193
-        do_action(
4194
-            'AHEE__EE_Admin_Page___process_resend_registration',
4195
-            $this->_template_args['success'],
4196
-            $this->_req_data
4197
-        );
4198
-        return $this->_template_args['success'];
4199
-    }
4200
-
4201
-
4202
-
4203
-    /**
4204
-     * This automatically processes any payment message notifications when manual payment has been applied.
4205
-     *
4206
-     * @param \EE_Payment $payment
4207
-     * @return bool success/fail
4208
-     */
4209
-    protected function _process_payment_notification(EE_Payment $payment)
4210
-    {
4211
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4212
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4213
-        $this->_template_args['success'] = apply_filters(
4214
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4215
-            false,
4216
-            $payment
4217
-        );
4218
-        return $this->_template_args['success'];
4219
-    }
4091
+
4092
+	/**
4093
+	 * updates  espresso configuration settings
4094
+	 *
4095
+	 * @param string                   $tab
4096
+	 * @param EE_Config_Base|EE_Config $config
4097
+	 * @param string                   $file file where error occurred
4098
+	 * @param string                   $func function  where error occurred
4099
+	 * @param string                   $line line no where error occurred
4100
+	 * @return boolean
4101
+	 */
4102
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4103
+	{
4104
+		//remove any options that are NOT going to be saved with the config settings.
4105
+		if (isset($config->core->ee_ueip_optin)) {
4106
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4107
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4108
+			update_option('ee_ueip_has_notified', true);
4109
+		}
4110
+		// and save it (note we're also doing the network save here)
4111
+		$net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4112
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4113
+		if ($config_saved && $net_saved) {
4114
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4115
+			return true;
4116
+		}
4117
+		EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4118
+		return false;
4119
+	}
4120
+
4121
+
4122
+
4123
+	/**
4124
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4125
+	 *
4126
+	 * @return array
4127
+	 */
4128
+	public function get_yes_no_values()
4129
+	{
4130
+		return $this->_yes_no_values;
4131
+	}
4132
+
4133
+
4134
+
4135
+	protected function _get_dir()
4136
+	{
4137
+		$reflector = new ReflectionClass(get_class($this));
4138
+		return dirname($reflector->getFileName());
4139
+	}
4140
+
4141
+
4142
+
4143
+	/**
4144
+	 * A helper for getting a "next link".
4145
+	 *
4146
+	 * @param string $url   The url to link to
4147
+	 * @param string $class The class to use.
4148
+	 * @return string
4149
+	 */
4150
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4151
+	{
4152
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4153
+	}
4154
+
4155
+
4156
+
4157
+	/**
4158
+	 * A helper for getting a "previous link".
4159
+	 *
4160
+	 * @param string $url   The url to link to
4161
+	 * @param string $class The class to use.
4162
+	 * @return string
4163
+	 */
4164
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4165
+	{
4166
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4167
+	}
4168
+
4169
+
4170
+
4171
+
4172
+
4173
+
4174
+
4175
+	//below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4176
+
4177
+
4178
+	/**
4179
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4180
+	 * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4181
+	 * _req_data array.
4182
+	 *
4183
+	 * @return bool success/fail
4184
+	 * @throws EE_Error
4185
+	 * @throws InvalidArgumentException
4186
+	 * @throws ReflectionException
4187
+	 * @throws InvalidDataTypeException
4188
+	 * @throws InvalidInterfaceException
4189
+	 */
4190
+	protected function _process_resend_registration()
4191
+	{
4192
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4193
+		do_action(
4194
+			'AHEE__EE_Admin_Page___process_resend_registration',
4195
+			$this->_template_args['success'],
4196
+			$this->_req_data
4197
+		);
4198
+		return $this->_template_args['success'];
4199
+	}
4200
+
4201
+
4202
+
4203
+	/**
4204
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4205
+	 *
4206
+	 * @param \EE_Payment $payment
4207
+	 * @return bool success/fail
4208
+	 */
4209
+	protected function _process_payment_notification(EE_Payment $payment)
4210
+	{
4211
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4212
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4213
+		$this->_template_args['success'] = apply_filters(
4214
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4215
+			false,
4216
+			$payment
4217
+		);
4218
+		return $this->_template_args['success'];
4219
+	}
4220 4220
 
4221 4221
 
4222 4222
 }
Please login to merge, or discard this patch.
core/EE_System.core.php 1 patch
Indentation   +1236 added lines, -1236 removed lines patch added patch discarded remove patch
@@ -21,1242 +21,1242 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
26
-     * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
27
-     */
28
-    const req_type_normal = 0;
29
-
30
-    /**
31
-     * Indicates this is a brand new installation of EE so we should install
32
-     * tables and default data etc
33
-     */
34
-    const req_type_new_activation = 1;
35
-
36
-    /**
37
-     * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
38
-     * and we just exited maintenance mode). We MUST check the database is setup properly
39
-     * and that default data is setup too
40
-     */
41
-    const req_type_reactivation = 2;
42
-
43
-    /**
44
-     * indicates that EE has been upgraded since its previous request.
45
-     * We may have data migration scripts to call and will want to trigger maintenance mode
46
-     */
47
-    const req_type_upgrade = 3;
48
-
49
-    /**
50
-     * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
51
-     */
52
-    const req_type_downgrade = 4;
53
-
54
-    /**
55
-     * @deprecated since version 4.6.0.dev.006
56
-     * Now whenever a new_activation is detected the request type is still just
57
-     * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
58
-     * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
59
-     * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
60
-     * (Specifically, when the migration manager indicates migrations are finished
61
-     * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
62
-     */
63
-    const req_type_activation_but_not_installed = 5;
64
-
65
-    /**
66
-     * option prefix for recording the activation history (like core's "espresso_db_update") of addons
67
-     */
68
-    const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
69
-
70
-
71
-    /**
72
-     * @var EE_System $_instance
73
-     */
74
-    private static $_instance;
75
-
76
-    /**
77
-     * @var EE_Registry $registry
78
-     */
79
-    private $registry;
80
-
81
-    /**
82
-     * @var LoaderInterface $loader
83
-     */
84
-    private $loader;
85
-
86
-    /**
87
-     * @var EE_Capabilities $capabilities
88
-     */
89
-    private $capabilities;
90
-
91
-    /**
92
-     * @var EE_Request $request
93
-     */
94
-    private $request;
95
-
96
-    /**
97
-     * @var EE_Maintenance_Mode $maintenance_mode
98
-     */
99
-    private $maintenance_mode;
100
-
101
-    /**
102
-     * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
103
-     * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
104
-     *
105
-     * @var int $_req_type
106
-     */
107
-    private $_req_type;
108
-
109
-    /**
110
-     * Whether or not there was a non-micro version change in EE core version during this request
111
-     *
112
-     * @var boolean $_major_version_change
113
-     */
114
-    private $_major_version_change = false;
115
-
116
-
117
-
118
-    /**
119
-     * @singleton method used to instantiate class object
120
-     * @param EE_Registry|null         $registry
121
-     * @param LoaderInterface|null     $loader
122
-     * @param EE_Capabilities|null     $capabilities
123
-     * @param EE_Request|null          $request
124
-     * @param EE_Maintenance_Mode|null $maintenance_mode
125
-     * @return EE_System
126
-     */
127
-    public static function instance(
128
-        EE_Registry $registry = null,
129
-        LoaderInterface $loader = null,
130
-        EE_Capabilities $capabilities = null,
131
-        EE_Request $request = null,
132
-        EE_Maintenance_Mode $maintenance_mode = null
133
-    ) {
134
-        // check if class object is instantiated
135
-        if (! self::$_instance instanceof EE_System) {
136
-            self::$_instance = new self($registry, $loader, $capabilities, $request, $maintenance_mode);
137
-        }
138
-        return self::$_instance;
139
-    }
140
-
141
-
142
-
143
-    /**
144
-     * resets the instance and returns it
145
-     *
146
-     * @return EE_System
147
-     */
148
-    public static function reset()
149
-    {
150
-        self::$_instance->_req_type = null;
151
-        //make sure none of the old hooks are left hanging around
152
-        remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
153
-        //we need to reset the migration manager in order for it to detect DMSs properly
154
-        EE_Data_Migration_Manager::reset();
155
-        self::instance()->detect_activations_or_upgrades();
156
-        self::instance()->perform_activations_upgrades_and_migrations();
157
-        return self::instance();
158
-    }
159
-
160
-
161
-
162
-    /**
163
-     * sets hooks for running rest of system
164
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
165
-     * starting EE Addons from any other point may lead to problems
166
-     *
167
-     * @param EE_Registry         $registry
168
-     * @param LoaderInterface     $loader
169
-     * @param EE_Capabilities     $capabilities
170
-     * @param EE_Request          $request
171
-     * @param EE_Maintenance_Mode $maintenance_mode
172
-     */
173
-    private function __construct(
174
-        EE_Registry $registry,
175
-        LoaderInterface $loader,
176
-        EE_Capabilities $capabilities,
177
-        EE_Request $request,
178
-        EE_Maintenance_Mode $maintenance_mode
179
-    ) {
180
-        $this->registry = $registry;
181
-        $this->loader = $loader;
182
-        $this->capabilities = $capabilities;
183
-        $this->request = $request;
184
-        $this->maintenance_mode = $maintenance_mode;
185
-        do_action('AHEE__EE_System__construct__begin', $this);
186
-        add_action(
187
-            'AHEE__EE_Bootstrap__load_espresso_addons',
188
-            array($this, 'loadCapabilities'),
189
-            5
190
-        );
191
-        add_action(
192
-            'AHEE__EE_Bootstrap__load_espresso_addons',
193
-            array($this, 'loadCommandBus'),
194
-            7
195
-        );
196
-        add_action(
197
-            'AHEE__EE_Bootstrap__load_espresso_addons',
198
-            array($this, 'loadPluginApi'),
199
-            9
200
-        );
201
-        // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
202
-        add_action(
203
-            'AHEE__EE_Bootstrap__load_espresso_addons',
204
-            array($this, 'load_espresso_addons')
205
-        );
206
-        // when an ee addon is activated, we want to call the core hook(s) again
207
-        // because the newly-activated addon didn't get a chance to run at all
208
-        add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
209
-        // detect whether install or upgrade
210
-        add_action(
211
-            'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
212
-            array($this, 'detect_activations_or_upgrades'),
213
-            3
214
-        );
215
-        // load EE_Config, EE_Textdomain, etc
216
-        add_action(
217
-            'AHEE__EE_Bootstrap__load_core_configuration',
218
-            array($this, 'load_core_configuration'),
219
-            5
220
-        );
221
-        // load EE_Config, EE_Textdomain, etc
222
-        add_action(
223
-            'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
224
-            array($this, 'register_shortcodes_modules_and_widgets'),
225
-            7
226
-        );
227
-        // you wanna get going? I wanna get going... let's get going!
228
-        add_action(
229
-            'AHEE__EE_Bootstrap__brew_espresso',
230
-            array($this, 'brew_espresso'),
231
-            9
232
-        );
233
-        //other housekeeping
234
-        //exclude EE critical pages from wp_list_pages
235
-        add_filter(
236
-            'wp_list_pages_excludes',
237
-            array($this, 'remove_pages_from_wp_list_pages'),
238
-            10
239
-        );
240
-        // ALL EE Addons should use the following hook point to attach their initial setup too
241
-        // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
242
-        do_action('AHEE__EE_System__construct__complete', $this);
243
-    }
244
-
245
-
246
-
247
-    /**
248
-     * load and setup EE_Capabilities
249
-     *
250
-     * @return void
251
-     * @throws EE_Error
252
-     */
253
-    public function loadCapabilities()
254
-    {
255
-        $this->loader->getShared('EE_Capabilities');
256
-        add_action(
257
-            'AHEE__EE_Capabilities__init_caps__before_initialization',
258
-            function() {
259
-                LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
260
-            }
261
-        );
262
-    }
263
-
264
-
265
-
266
-    /**
267
-     * create and cache the CommandBus, and also add middleware
268
-     * The CapChecker middleware requires the use of EE_Capabilities
269
-     * which is why we need to load the CommandBus after Caps are set up
270
-     *
271
-     * @return void
272
-     * @throws EE_Error
273
-     */
274
-    public function loadCommandBus()
275
-    {
276
-        $this->loader->getShared(
277
-            'CommandBusInterface',
278
-            array(
279
-                null,
280
-                apply_filters(
281
-                    'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
282
-                    array(
283
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
284
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
285
-                    )
286
-                ),
287
-            )
288
-        );
289
-    }
290
-
291
-
292
-
293
-    /**
294
-     * @return void
295
-     * @throws EE_Error
296
-     */
297
-    public function loadPluginApi()
298
-    {
299
-        // set autoloaders for all of the classes implementing EEI_Plugin_API
300
-        // which provide helpers for EE plugin authors to more easily register certain components with EE.
301
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
302
-    }
303
-
304
-
305
-    /**
306
-     * @param string $addon_name
307
-     * @param string $version_constant
308
-     * @param string $min_version_required
309
-     * @param string $load_callback
310
-     * @param string $plugin_file_constant
311
-     * @return void
312
-     */
313
-    private function deactivateIncompatibleAddon(
314
-        $addon_name,
315
-        $version_constant,
316
-        $min_version_required,
317
-        $load_callback,
318
-        $plugin_file_constant
319
-    ) {
320
-        if (! defined($version_constant)) {
321
-            return;
322
-        }
323
-        $addon_version = constant($version_constant);
324
-        if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
325
-            remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
326
-            if (! function_exists('deactivate_plugins')) {
327
-                require_once ABSPATH . 'wp-admin/includes/plugin.php';
328
-            }
329
-            deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
330
-            unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
331
-            EE_Error::add_error(
332
-                sprintf(
333
-                    esc_html__(
334
-                        'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.',
335
-                        'event_espresso'
336
-                    ),
337
-                    $addon_name,
338
-                    $min_version_required
339
-                ),
340
-                __FILE__, __FUNCTION__ . "({$addon_name})", __LINE__
341
-            );
342
-            EE_Error::get_notices(false, true);
343
-        }
344
-    }
345
-
346
-
347
-    /**
348
-     * load_espresso_addons
349
-     * allow addons to load first so that they can set hooks for running DMS's, etc
350
-     * this is hooked into both:
351
-     *    'AHEE__EE_Bootstrap__load_core_configuration'
352
-     *        which runs during the WP 'plugins_loaded' action at priority 5
353
-     *    and the WP 'activate_plugin' hook point
354
-     *
355
-     * @access public
356
-     * @return void
357
-     */
358
-    public function load_espresso_addons()
359
-    {
360
-        $this->deactivateIncompatibleAddon(
361
-            'Wait Lists',
362
-            'EE_WAIT_LISTS_VERSION',
363
-            '1.0.0.beta.074',
364
-            'load_espresso_wait_lists',
365
-            'EE_WAIT_LISTS_PLUGIN_FILE'
366
-        );
367
-        $this->deactivateIncompatibleAddon(
368
-            'Automated Upcoming Event Notifications',
369
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
370
-            '1.0.0.beta.091',
371
-            'load_espresso_automated_upcoming_event_notification',
372
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
373
-        );
374
-        do_action('AHEE__EE_System__load_espresso_addons');
375
-        //if the WP API basic auth plugin isn't already loaded, load it now.
376
-        //We want it for mobile apps. Just include the entire plugin
377
-        //also, don't load the basic auth when a plugin is getting activated, because
378
-        //it could be the basic auth plugin, and it doesn't check if its methods are already defined
379
-        //and causes a fatal error
380
-        if (
381
-            ! (
382
-                isset($_GET['activate'])
383
-                && $_GET['activate'] === 'true'
384
-            )
385
-            && ! function_exists('json_basic_auth_handler')
386
-            && ! function_exists('json_basic_auth_error')
387
-            && ! (
388
-                isset($_GET['action'])
389
-                && in_array($_GET['action'], array('activate', 'activate-selected'), true)
390
-            )
391
-        ) {
392
-            include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
393
-        }
394
-        do_action('AHEE__EE_System__load_espresso_addons__complete');
395
-    }
396
-
397
-
398
-
399
-    /**
400
-     * detect_activations_or_upgrades
401
-     * Checks for activation or upgrade of core first;
402
-     * then also checks if any registered addons have been activated or upgraded
403
-     * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
404
-     * which runs during the WP 'plugins_loaded' action at priority 3
405
-     *
406
-     * @access public
407
-     * @return void
408
-     */
409
-    public function detect_activations_or_upgrades()
410
-    {
411
-        //first off: let's make sure to handle core
412
-        $this->detect_if_activation_or_upgrade();
413
-        foreach ($this->registry->addons as $addon) {
414
-            if ($addon instanceof EE_Addon) {
415
-                //detect teh request type for that addon
416
-                $addon->detect_activation_or_upgrade();
417
-            }
418
-        }
419
-    }
420
-
421
-
422
-
423
-    /**
424
-     * detect_if_activation_or_upgrade
425
-     * Takes care of detecting whether this is a brand new install or code upgrade,
426
-     * and either setting up the DB or setting up maintenance mode etc.
427
-     *
428
-     * @access public
429
-     * @return void
430
-     */
431
-    public function detect_if_activation_or_upgrade()
432
-    {
433
-        do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
434
-        // check if db has been updated, or if its a brand-new installation
435
-        $espresso_db_update = $this->fix_espresso_db_upgrade_option();
436
-        $request_type = $this->detect_req_type($espresso_db_update);
437
-        //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
438
-        switch ($request_type) {
439
-            case EE_System::req_type_new_activation:
440
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
441
-                $this->_handle_core_version_change($espresso_db_update);
442
-                break;
443
-            case EE_System::req_type_reactivation:
444
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
445
-                $this->_handle_core_version_change($espresso_db_update);
446
-                break;
447
-            case EE_System::req_type_upgrade:
448
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
449
-                //migrations may be required now that we've upgraded
450
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
451
-                $this->_handle_core_version_change($espresso_db_update);
452
-                //				echo "done upgrade";die;
453
-                break;
454
-            case EE_System::req_type_downgrade:
455
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
456
-                //its possible migrations are no longer required
457
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
458
-                $this->_handle_core_version_change($espresso_db_update);
459
-                break;
460
-            case EE_System::req_type_normal:
461
-            default:
462
-                //				$this->_maybe_redirect_to_ee_about();
463
-                break;
464
-        }
465
-        do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
466
-    }
467
-
468
-
469
-
470
-    /**
471
-     * Updates the list of installed versions and sets hooks for
472
-     * initializing the database later during the request
473
-     *
474
-     * @param array $espresso_db_update
475
-     */
476
-    private function _handle_core_version_change($espresso_db_update)
477
-    {
478
-        $this->update_list_of_installed_versions($espresso_db_update);
479
-        //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
480
-        add_action(
481
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
482
-            array($this, 'initialize_db_if_no_migrations_required')
483
-        );
484
-    }
485
-
486
-
487
-
488
-    /**
489
-     * standardizes the wp option 'espresso_db_upgrade' which actually stores
490
-     * information about what versions of EE have been installed and activated,
491
-     * NOT necessarily the state of the database
492
-     *
493
-     * @param mixed $espresso_db_update the value of the WordPress option.
494
-     *                                            If not supplied, fetches it from the options table
495
-     * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
496
-     */
497
-    private function fix_espresso_db_upgrade_option($espresso_db_update = null)
498
-    {
499
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
500
-        if (! $espresso_db_update) {
501
-            $espresso_db_update = get_option('espresso_db_update');
502
-        }
503
-        // check that option is an array
504
-        if (! is_array($espresso_db_update)) {
505
-            // if option is FALSE, then it never existed
506
-            if ($espresso_db_update === false) {
507
-                // make $espresso_db_update an array and save option with autoload OFF
508
-                $espresso_db_update = array();
509
-                add_option('espresso_db_update', $espresso_db_update, '', 'no');
510
-            } else {
511
-                // option is NOT FALSE but also is NOT an array, so make it an array and save it
512
-                $espresso_db_update = array($espresso_db_update => array());
513
-                update_option('espresso_db_update', $espresso_db_update);
514
-            }
515
-        } else {
516
-            $corrected_db_update = array();
517
-            //if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
518
-            foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
519
-                if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
520
-                    //the key is an int, and the value IS NOT an array
521
-                    //so it must be numerically-indexed, where values are versions installed...
522
-                    //fix it!
523
-                    $version_string = $should_be_array;
524
-                    $corrected_db_update[$version_string] = array('unknown-date');
525
-                } else {
526
-                    //ok it checks out
527
-                    $corrected_db_update[$should_be_version_string] = $should_be_array;
528
-                }
529
-            }
530
-            $espresso_db_update = $corrected_db_update;
531
-            update_option('espresso_db_update', $espresso_db_update);
532
-        }
533
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
534
-        return $espresso_db_update;
535
-    }
536
-
537
-
538
-
539
-    /**
540
-     * Does the traditional work of setting up the plugin's database and adding default data.
541
-     * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
542
-     * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
543
-     * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
544
-     * so that it will be done when migrations are finished
545
-     *
546
-     * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
547
-     * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
548
-     *                                       This is a resource-intensive job
549
-     *                                       so we prefer to only do it when necessary
550
-     * @return void
551
-     * @throws EE_Error
552
-     */
553
-    public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
554
-    {
555
-        $request_type = $this->detect_req_type();
556
-        //only initialize system if we're not in maintenance mode.
557
-        if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
558
-            update_option('ee_flush_rewrite_rules', true);
559
-            if ($verify_schema) {
560
-                EEH_Activation::initialize_db_and_folders();
561
-            }
562
-            EEH_Activation::initialize_db_content();
563
-            EEH_Activation::system_initialization();
564
-            if ($initialize_addons_too) {
565
-                $this->initialize_addons();
566
-            }
567
-        } else {
568
-            EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
569
-        }
570
-        if ($request_type === EE_System::req_type_new_activation
571
-            || $request_type === EE_System::req_type_reactivation
572
-            || (
573
-                $request_type === EE_System::req_type_upgrade
574
-                && $this->is_major_version_change()
575
-            )
576
-        ) {
577
-            add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
578
-        }
579
-    }
580
-
581
-
582
-
583
-    /**
584
-     * Initializes the db for all registered addons
585
-     *
586
-     * @throws EE_Error
587
-     */
588
-    public function initialize_addons()
589
-    {
590
-        //foreach registered addon, make sure its db is up-to-date too
591
-        foreach ($this->registry->addons as $addon) {
592
-            if ($addon instanceof EE_Addon) {
593
-                $addon->initialize_db_if_no_migrations_required();
594
-            }
595
-        }
596
-    }
597
-
598
-
599
-
600
-    /**
601
-     * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
602
-     *
603
-     * @param    array  $version_history
604
-     * @param    string $current_version_to_add version to be added to the version history
605
-     * @return    boolean success as to whether or not this option was changed
606
-     */
607
-    public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
608
-    {
609
-        if (! $version_history) {
610
-            $version_history = $this->fix_espresso_db_upgrade_option($version_history);
611
-        }
612
-        if ($current_version_to_add === null) {
613
-            $current_version_to_add = espresso_version();
614
-        }
615
-        $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time());
616
-        // re-save
617
-        return update_option('espresso_db_update', $version_history);
618
-    }
619
-
620
-
621
-
622
-    /**
623
-     * Detects if the current version indicated in the has existed in the list of
624
-     * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
625
-     *
626
-     * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
627
-     *                                  If not supplied, fetches it from the options table.
628
-     *                                  Also, caches its result so later parts of the code can also know whether
629
-     *                                  there's been an update or not. This way we can add the current version to
630
-     *                                  espresso_db_update, but still know if this is a new install or not
631
-     * @return int one of the constants on EE_System::req_type_
632
-     */
633
-    public function detect_req_type($espresso_db_update = null)
634
-    {
635
-        if ($this->_req_type === null) {
636
-            $espresso_db_update = ! empty($espresso_db_update)
637
-                ? $espresso_db_update
638
-                : $this->fix_espresso_db_upgrade_option();
639
-            $this->_req_type = EE_System::detect_req_type_given_activation_history(
640
-                $espresso_db_update,
641
-                'ee_espresso_activation', espresso_version()
642
-            );
643
-            $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
644
-        }
645
-        return $this->_req_type;
646
-    }
647
-
648
-
649
-
650
-    /**
651
-     * Returns whether or not there was a non-micro version change (ie, change in either
652
-     * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
653
-     * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
654
-     *
655
-     * @param $activation_history
656
-     * @return bool
657
-     */
658
-    private function _detect_major_version_change($activation_history)
659
-    {
660
-        $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
661
-        $previous_version_parts = explode('.', $previous_version);
662
-        $current_version_parts = explode('.', espresso_version());
663
-        return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
664
-               && ($previous_version_parts[0] !== $current_version_parts[0]
665
-                   || $previous_version_parts[1] !== $current_version_parts[1]
666
-               );
667
-    }
668
-
669
-
670
-
671
-    /**
672
-     * Returns true if either the major or minor version of EE changed during this request.
673
-     * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001
674
-     *
675
-     * @return bool
676
-     */
677
-    public function is_major_version_change()
678
-    {
679
-        return $this->_major_version_change;
680
-    }
681
-
682
-
683
-
684
-    /**
685
-     * Determines the request type for any ee addon, given three piece of info: the current array of activation
686
-     * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
687
-     * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
688
-     * just activated to (for core that will always be espresso_version())
689
-     *
690
-     * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
691
-     *                                                 ee plugin. for core that's 'espresso_db_update'
692
-     * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
693
-     *                                                 indicate that this plugin was just activated
694
-     * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
695
-     *                                                 espresso_version())
696
-     * @return int one of the constants on EE_System::req_type_*
697
-     */
698
-    public static function detect_req_type_given_activation_history(
699
-        $activation_history_for_addon,
700
-        $activation_indicator_option_name,
701
-        $version_to_upgrade_to
702
-    ) {
703
-        $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
704
-        if ($activation_history_for_addon) {
705
-            //it exists, so this isn't a completely new install
706
-            //check if this version already in that list of previously installed versions
707
-            if (! isset($activation_history_for_addon[$version_to_upgrade_to])) {
708
-                //it a version we haven't seen before
709
-                if ($version_is_higher === 1) {
710
-                    $req_type = EE_System::req_type_upgrade;
711
-                } else {
712
-                    $req_type = EE_System::req_type_downgrade;
713
-                }
714
-                delete_option($activation_indicator_option_name);
715
-            } else {
716
-                // its not an update. maybe a reactivation?
717
-                if (get_option($activation_indicator_option_name, false)) {
718
-                    if ($version_is_higher === -1) {
719
-                        $req_type = EE_System::req_type_downgrade;
720
-                    } else if ($version_is_higher === 0) {
721
-                        //we've seen this version before, but it's an activation. must be a reactivation
722
-                        $req_type = EE_System::req_type_reactivation;
723
-                    } else {//$version_is_higher === 1
724
-                        $req_type = EE_System::req_type_upgrade;
725
-                    }
726
-                    delete_option($activation_indicator_option_name);
727
-                } else {
728
-                    //we've seen this version before and the activation indicate doesn't show it was just activated
729
-                    if ($version_is_higher === -1) {
730
-                        $req_type = EE_System::req_type_downgrade;
731
-                    } else if ($version_is_higher === 0) {
732
-                        //we've seen this version before and it's not an activation. its normal request
733
-                        $req_type = EE_System::req_type_normal;
734
-                    } else {//$version_is_higher === 1
735
-                        $req_type = EE_System::req_type_upgrade;
736
-                    }
737
-                }
738
-            }
739
-        } else {
740
-            //brand new install
741
-            $req_type = EE_System::req_type_new_activation;
742
-            delete_option($activation_indicator_option_name);
743
-        }
744
-        return $req_type;
745
-    }
746
-
747
-
748
-
749
-    /**
750
-     * Detects if the $version_to_upgrade_to is higher than the most recent version in
751
-     * the $activation_history_for_addon
752
-     *
753
-     * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
754
-     *                                             sometimes containing 'unknown-date'
755
-     * @param string $version_to_upgrade_to        (current version)
756
-     * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
757
-     *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
758
-     *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
759
-     *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
760
-     */
761
-    private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
762
-    {
763
-        //find the most recently-activated version
764
-        $most_recently_active_version =
765
-            EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
766
-        return version_compare($version_to_upgrade_to, $most_recently_active_version);
767
-    }
768
-
769
-
770
-
771
-    /**
772
-     * Gets the most recently active version listed in the activation history,
773
-     * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
774
-     *
775
-     * @param array $activation_history  (keys are versions, values are arrays of times activated,
776
-     *                                   sometimes containing 'unknown-date'
777
-     * @return string
778
-     */
779
-    private static function _get_most_recently_active_version_from_activation_history($activation_history)
780
-    {
781
-        $most_recently_active_version_activation = '1970-01-01 00:00:00';
782
-        $most_recently_active_version = '0.0.0.dev.000';
783
-        if (is_array($activation_history)) {
784
-            foreach ($activation_history as $version => $times_activated) {
785
-                //check there is a record of when this version was activated. Otherwise,
786
-                //mark it as unknown
787
-                if (! $times_activated) {
788
-                    $times_activated = array('unknown-date');
789
-                }
790
-                if (is_string($times_activated)) {
791
-                    $times_activated = array($times_activated);
792
-                }
793
-                foreach ($times_activated as $an_activation) {
794
-                    if ($an_activation !== 'unknown-date' && $an_activation > $most_recently_active_version_activation) {
795
-                        $most_recently_active_version = $version;
796
-                        $most_recently_active_version_activation = $an_activation === 'unknown-date'
797
-                            ? '1970-01-01 00:00:00'
798
-                            : $an_activation;
799
-                    }
800
-                }
801
-            }
802
-        }
803
-        return $most_recently_active_version;
804
-    }
805
-
806
-
807
-
808
-    /**
809
-     * This redirects to the about EE page after activation
810
-     *
811
-     * @return void
812
-     */
813
-    public function redirect_to_about_ee()
814
-    {
815
-        $notices = EE_Error::get_notices(false);
816
-        //if current user is an admin and it's not an ajax or rest request
817
-        if (
818
-            ! (defined('DOING_AJAX') && DOING_AJAX)
819
-            && ! (defined('REST_REQUEST') && REST_REQUEST)
820
-            && ! isset($notices['errors'])
821
-            && apply_filters(
822
-                'FHEE__EE_System__redirect_to_about_ee__do_redirect',
823
-                $this->capabilities->current_user_can('manage_options', 'espresso_about_default')
824
-            )
825
-        ) {
826
-            $query_params = array('page' => 'espresso_about');
827
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
828
-                $query_params['new_activation'] = true;
829
-            }
830
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
831
-                $query_params['reactivation'] = true;
832
-            }
833
-            $url = add_query_arg($query_params, admin_url('admin.php'));
834
-            wp_safe_redirect($url);
835
-            exit();
836
-        }
837
-    }
838
-
839
-
840
-
841
-    /**
842
-     * load_core_configuration
843
-     * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
844
-     * which runs during the WP 'plugins_loaded' action at priority 5
845
-     *
846
-     * @return void
847
-     * @throws ReflectionException
848
-     */
849
-    public function load_core_configuration()
850
-    {
851
-        do_action('AHEE__EE_System__load_core_configuration__begin', $this);
852
-        $this->loader->getShared('EE_Load_Textdomain');
853
-        //load textdomain
854
-        EE_Load_Textdomain::load_textdomain();
855
-        // load and setup EE_Config and EE_Network_Config
856
-        $config = $this->loader->getShared('EE_Config');
857
-        $this->loader->getShared('EE_Network_Config');
858
-        // setup autoloaders
859
-        // enable logging?
860
-        if ($config->admin->use_full_logging) {
861
-            $this->loader->getShared('EE_Log');
862
-        }
863
-        // check for activation errors
864
-        $activation_errors = get_option('ee_plugin_activation_errors', false);
865
-        if ($activation_errors) {
866
-            EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
867
-            update_option('ee_plugin_activation_errors', false);
868
-        }
869
-        // get model names
870
-        $this->_parse_model_names();
871
-        //load caf stuff a chance to play during the activation process too.
872
-        $this->_maybe_brew_regular();
873
-        do_action('AHEE__EE_System__load_core_configuration__complete', $this);
874
-    }
875
-
876
-
877
-
878
-    /**
879
-     * cycles through all of the models/*.model.php files, and assembles an array of model names
880
-     *
881
-     * @return void
882
-     * @throws ReflectionException
883
-     */
884
-    private function _parse_model_names()
885
-    {
886
-        //get all the files in the EE_MODELS folder that end in .model.php
887
-        $models = glob(EE_MODELS . '*.model.php');
888
-        $model_names = array();
889
-        $non_abstract_db_models = array();
890
-        foreach ($models as $model) {
891
-            // get model classname
892
-            $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
893
-            $short_name = str_replace('EEM_', '', $classname);
894
-            $reflectionClass = new ReflectionClass($classname);
895
-            if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
896
-                $non_abstract_db_models[$short_name] = $classname;
897
-            }
898
-            $model_names[$short_name] = $classname;
899
-        }
900
-        $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
901
-        $this->registry->non_abstract_db_models = apply_filters(
902
-            'FHEE__EE_System__parse_implemented_model_names',
903
-            $non_abstract_db_models
904
-        );
905
-    }
906
-
907
-
908
-
909
-    /**
910
-     * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
911
-     * that need to be setup before our EE_System launches.
912
-     *
913
-     * @return void
914
-     */
915
-    private function _maybe_brew_regular()
916
-    {
917
-        if ((! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) {
918
-            require_once EE_CAFF_PATH . 'brewing_regular.php';
919
-        }
920
-    }
921
-
922
-
923
-
924
-    /**
925
-     * register_shortcodes_modules_and_widgets
926
-     * generate lists of shortcodes and modules, then verify paths and classes
927
-     * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
928
-     * which runs during the WP 'plugins_loaded' action at priority 7
929
-     *
930
-     * @access public
931
-     * @return void
932
-     * @throws Exception
933
-     */
934
-    public function register_shortcodes_modules_and_widgets()
935
-    {
936
-        try {
937
-            // load, register, and add shortcodes the new way
938
-            $this->loader->getShared(
939
-                'EventEspresso\core\services\shortcodes\ShortcodesManager',
940
-                array(
941
-                    // and the old way, but we'll put it under control of the new system
942
-                    EE_Config::getLegacyShortcodesManager()
943
-                )
944
-            );
945
-        } catch (Exception $exception) {
946
-            new ExceptionStackTraceDisplay($exception);
947
-        }
948
-        do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
949
-        // check for addons using old hook point
950
-        if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
951
-            $this->_incompatible_addon_error();
952
-        }
953
-    }
954
-
955
-
956
-
957
-    /**
958
-     * _incompatible_addon_error
959
-     *
960
-     * @access public
961
-     * @return void
962
-     */
963
-    private function _incompatible_addon_error()
964
-    {
965
-        // get array of classes hooking into here
966
-        $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
967
-            'AHEE__EE_System__register_shortcodes_modules_and_addons'
968
-        );
969
-        if (! empty($class_names)) {
970
-            $msg = __(
971
-                'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
972
-                'event_espresso'
973
-            );
974
-            $msg .= '<ul>';
975
-            foreach ($class_names as $class_name) {
976
-                $msg .= '<li><b>Event Espresso - ' . str_replace(
977
-                        array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
978
-                        $class_name
979
-                    ) . '</b></li>';
980
-            }
981
-            $msg .= '</ul>';
982
-            $msg .= __(
983
-                'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
984
-                'event_espresso'
985
-            );
986
-            // save list of incompatible addons to wp-options for later use
987
-            add_option('ee_incompatible_addons', $class_names, '', 'no');
988
-            if (is_admin()) {
989
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
990
-            }
991
-        }
992
-    }
993
-
994
-
995
-
996
-    /**
997
-     * brew_espresso
998
-     * begins the process of setting hooks for initializing EE in the correct order
999
-     * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1000
-     * which runs during the WP 'plugins_loaded' action at priority 9
1001
-     *
1002
-     * @return void
1003
-     */
1004
-    public function brew_espresso()
1005
-    {
1006
-        do_action('AHEE__EE_System__brew_espresso__begin', $this);
1007
-        // load some final core systems
1008
-        add_action('init', array($this, 'set_hooks_for_core'), 1);
1009
-        add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1010
-        add_action('init', array($this, 'load_CPTs_and_session'), 5);
1011
-        add_action('init', array($this, 'load_controllers'), 7);
1012
-        add_action('init', array($this, 'core_loaded_and_ready'), 9);
1013
-        add_action('init', array($this, 'initialize'), 10);
1014
-        add_action('init', array($this, 'initialize_last'), 100);
1015
-        if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
1016
-            // pew pew pew
1017
-            $this->loader->getShared('EventEspresso\core\services\licensing\LicenseService');
1018
-            do_action('AHEE__EE_System__brew_espresso__after_pue_init');
1019
-        }
1020
-        do_action('AHEE__EE_System__brew_espresso__complete', $this);
1021
-    }
1022
-
1023
-
1024
-
1025
-    /**
1026
-     *    set_hooks_for_core
1027
-     *
1028
-     * @access public
1029
-     * @return    void
1030
-     * @throws EE_Error
1031
-     */
1032
-    public function set_hooks_for_core()
1033
-    {
1034
-        $this->_deactivate_incompatible_addons();
1035
-        do_action('AHEE__EE_System__set_hooks_for_core');
1036
-        //caps need to be initialized on every request so that capability maps are set.
1037
-        //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1038
-        $this->registry->CAP->init_caps();
1039
-    }
1040
-
1041
-
1042
-
1043
-    /**
1044
-     * Using the information gathered in EE_System::_incompatible_addon_error,
1045
-     * deactivates any addons considered incompatible with the current version of EE
1046
-     */
1047
-    private function _deactivate_incompatible_addons()
1048
-    {
1049
-        $incompatible_addons = get_option('ee_incompatible_addons', array());
1050
-        if (! empty($incompatible_addons)) {
1051
-            $active_plugins = get_option('active_plugins', array());
1052
-            foreach ($active_plugins as $active_plugin) {
1053
-                foreach ($incompatible_addons as $incompatible_addon) {
1054
-                    if (strpos($active_plugin, $incompatible_addon) !== false) {
1055
-                        unset($_GET['activate']);
1056
-                        espresso_deactivate_plugin($active_plugin);
1057
-                    }
1058
-                }
1059
-            }
1060
-        }
1061
-    }
1062
-
1063
-
1064
-
1065
-    /**
1066
-     *    perform_activations_upgrades_and_migrations
1067
-     *
1068
-     * @access public
1069
-     * @return    void
1070
-     */
1071
-    public function perform_activations_upgrades_and_migrations()
1072
-    {
1073
-        //first check if we had previously attempted to setup EE's directories but failed
1074
-        if (EEH_Activation::upload_directories_incomplete()) {
1075
-            EEH_Activation::create_upload_directories();
1076
-        }
1077
-        do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1078
-    }
1079
-
1080
-
1081
-
1082
-    /**
1083
-     *    load_CPTs_and_session
1084
-     *
1085
-     * @access public
1086
-     * @return    void
1087
-     */
1088
-    public function load_CPTs_and_session()
1089
-    {
1090
-        do_action('AHEE__EE_System__load_CPTs_and_session__start');
1091
-        // register Custom Post Types
1092
-        $this->loader->getShared('EE_Register_CPTs');
1093
-        do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1094
-    }
1095
-
1096
-
1097
-
1098
-    /**
1099
-     * load_controllers
1100
-     * this is the best place to load any additional controllers that needs access to EE core.
1101
-     * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1102
-     * time
1103
-     *
1104
-     * @access public
1105
-     * @return void
1106
-     */
1107
-    public function load_controllers()
1108
-    {
1109
-        do_action('AHEE__EE_System__load_controllers__start');
1110
-        // let's get it started
1111
-        if (! is_admin() && ! $this->maintenance_mode->level()) {
1112
-            do_action('AHEE__EE_System__load_controllers__load_front_controllers');
1113
-            $this->loader->getShared('EE_Front_Controller');
1114
-        } else if (! EE_FRONT_AJAX) {
1115
-            do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1116
-            $this->loader->getShared('EE_Admin');
1117
-        }
1118
-        do_action('AHEE__EE_System__load_controllers__complete');
1119
-    }
1120
-
1121
-
1122
-
1123
-    /**
1124
-     * core_loaded_and_ready
1125
-     * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1126
-     *
1127
-     * @access public
1128
-     * @return void
1129
-     */
1130
-    public function core_loaded_and_ready()
1131
-    {
1132
-        $this->loader->getShared('EE_Session');
1133
-        do_action('AHEE__EE_System__core_loaded_and_ready');
1134
-        // load_espresso_template_tags
1135
-        if (is_readable(EE_PUBLIC . 'template_tags.php')) {
1136
-            require_once(EE_PUBLIC . 'template_tags.php');
1137
-        }
1138
-        do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1139
-        $this->loader->getShared('EventEspresso\core\services\assets\Registry');
1140
-    }
1141
-
1142
-
1143
-
1144
-    /**
1145
-     * initialize
1146
-     * this is the best place to begin initializing client code
1147
-     *
1148
-     * @access public
1149
-     * @return void
1150
-     */
1151
-    public function initialize()
1152
-    {
1153
-        do_action('AHEE__EE_System__initialize');
1154
-    }
1155
-
1156
-
1157
-
1158
-    /**
1159
-     * initialize_last
1160
-     * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1161
-     * initialize has done so
1162
-     *
1163
-     * @access public
1164
-     * @return void
1165
-     */
1166
-    public function initialize_last()
1167
-    {
1168
-        do_action('AHEE__EE_System__initialize_last');
1169
-        add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1170
-    }
1171
-
1172
-
1173
-
1174
-    /**
1175
-     * @return void
1176
-     * @throws EE_Error
1177
-     */
1178
-    public function addEspressoToolbar()
1179
-    {
1180
-        $this->loader->getShared(
1181
-            'EventEspresso\core\domain\services\admin\AdminToolBar',
1182
-            array($this->registry->CAP)
1183
-        );
1184
-    }
1185
-
1186
-
1187
-
1188
-    /**
1189
-     * do_not_cache
1190
-     * sets no cache headers and defines no cache constants for WP plugins
1191
-     *
1192
-     * @access public
1193
-     * @return void
1194
-     */
1195
-    public static function do_not_cache()
1196
-    {
1197
-        // set no cache constants
1198
-        if (! defined('DONOTCACHEPAGE')) {
1199
-            define('DONOTCACHEPAGE', true);
1200
-        }
1201
-        if (! defined('DONOTCACHCEOBJECT')) {
1202
-            define('DONOTCACHCEOBJECT', true);
1203
-        }
1204
-        if (! defined('DONOTCACHEDB')) {
1205
-            define('DONOTCACHEDB', true);
1206
-        }
1207
-        // add no cache headers
1208
-        add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1209
-        // plus a little extra for nginx and Google Chrome
1210
-        add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1211
-        // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1212
-        remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1213
-    }
1214
-
1215
-
1216
-
1217
-    /**
1218
-     *    extra_nocache_headers
1219
-     *
1220
-     * @access    public
1221
-     * @param $headers
1222
-     * @return    array
1223
-     */
1224
-    public static function extra_nocache_headers($headers)
1225
-    {
1226
-        // for NGINX
1227
-        $headers['X-Accel-Expires'] = 0;
1228
-        // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1229
-        $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1230
-        return $headers;
1231
-    }
1232
-
1233
-
1234
-
1235
-    /**
1236
-     *    nocache_headers
1237
-     *
1238
-     * @access    public
1239
-     * @return    void
1240
-     */
1241
-    public static function nocache_headers()
1242
-    {
1243
-        nocache_headers();
1244
-    }
1245
-
1246
-
1247
-
1248
-
1249
-    /**
1250
-     * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1251
-     * never returned with the function.
1252
-     *
1253
-     * @param  array $exclude_array any existing pages being excluded are in this array.
1254
-     * @return array
1255
-     */
1256
-    public function remove_pages_from_wp_list_pages($exclude_array)
1257
-    {
1258
-        return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1259
-    }
24
+	/**
25
+	 * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
26
+	 * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
27
+	 */
28
+	const req_type_normal = 0;
29
+
30
+	/**
31
+	 * Indicates this is a brand new installation of EE so we should install
32
+	 * tables and default data etc
33
+	 */
34
+	const req_type_new_activation = 1;
35
+
36
+	/**
37
+	 * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
38
+	 * and we just exited maintenance mode). We MUST check the database is setup properly
39
+	 * and that default data is setup too
40
+	 */
41
+	const req_type_reactivation = 2;
42
+
43
+	/**
44
+	 * indicates that EE has been upgraded since its previous request.
45
+	 * We may have data migration scripts to call and will want to trigger maintenance mode
46
+	 */
47
+	const req_type_upgrade = 3;
48
+
49
+	/**
50
+	 * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
51
+	 */
52
+	const req_type_downgrade = 4;
53
+
54
+	/**
55
+	 * @deprecated since version 4.6.0.dev.006
56
+	 * Now whenever a new_activation is detected the request type is still just
57
+	 * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
58
+	 * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
59
+	 * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
60
+	 * (Specifically, when the migration manager indicates migrations are finished
61
+	 * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
62
+	 */
63
+	const req_type_activation_but_not_installed = 5;
64
+
65
+	/**
66
+	 * option prefix for recording the activation history (like core's "espresso_db_update") of addons
67
+	 */
68
+	const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
69
+
70
+
71
+	/**
72
+	 * @var EE_System $_instance
73
+	 */
74
+	private static $_instance;
75
+
76
+	/**
77
+	 * @var EE_Registry $registry
78
+	 */
79
+	private $registry;
80
+
81
+	/**
82
+	 * @var LoaderInterface $loader
83
+	 */
84
+	private $loader;
85
+
86
+	/**
87
+	 * @var EE_Capabilities $capabilities
88
+	 */
89
+	private $capabilities;
90
+
91
+	/**
92
+	 * @var EE_Request $request
93
+	 */
94
+	private $request;
95
+
96
+	/**
97
+	 * @var EE_Maintenance_Mode $maintenance_mode
98
+	 */
99
+	private $maintenance_mode;
100
+
101
+	/**
102
+	 * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
103
+	 * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
104
+	 *
105
+	 * @var int $_req_type
106
+	 */
107
+	private $_req_type;
108
+
109
+	/**
110
+	 * Whether or not there was a non-micro version change in EE core version during this request
111
+	 *
112
+	 * @var boolean $_major_version_change
113
+	 */
114
+	private $_major_version_change = false;
115
+
116
+
117
+
118
+	/**
119
+	 * @singleton method used to instantiate class object
120
+	 * @param EE_Registry|null         $registry
121
+	 * @param LoaderInterface|null     $loader
122
+	 * @param EE_Capabilities|null     $capabilities
123
+	 * @param EE_Request|null          $request
124
+	 * @param EE_Maintenance_Mode|null $maintenance_mode
125
+	 * @return EE_System
126
+	 */
127
+	public static function instance(
128
+		EE_Registry $registry = null,
129
+		LoaderInterface $loader = null,
130
+		EE_Capabilities $capabilities = null,
131
+		EE_Request $request = null,
132
+		EE_Maintenance_Mode $maintenance_mode = null
133
+	) {
134
+		// check if class object is instantiated
135
+		if (! self::$_instance instanceof EE_System) {
136
+			self::$_instance = new self($registry, $loader, $capabilities, $request, $maintenance_mode);
137
+		}
138
+		return self::$_instance;
139
+	}
140
+
141
+
142
+
143
+	/**
144
+	 * resets the instance and returns it
145
+	 *
146
+	 * @return EE_System
147
+	 */
148
+	public static function reset()
149
+	{
150
+		self::$_instance->_req_type = null;
151
+		//make sure none of the old hooks are left hanging around
152
+		remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
153
+		//we need to reset the migration manager in order for it to detect DMSs properly
154
+		EE_Data_Migration_Manager::reset();
155
+		self::instance()->detect_activations_or_upgrades();
156
+		self::instance()->perform_activations_upgrades_and_migrations();
157
+		return self::instance();
158
+	}
159
+
160
+
161
+
162
+	/**
163
+	 * sets hooks for running rest of system
164
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
165
+	 * starting EE Addons from any other point may lead to problems
166
+	 *
167
+	 * @param EE_Registry         $registry
168
+	 * @param LoaderInterface     $loader
169
+	 * @param EE_Capabilities     $capabilities
170
+	 * @param EE_Request          $request
171
+	 * @param EE_Maintenance_Mode $maintenance_mode
172
+	 */
173
+	private function __construct(
174
+		EE_Registry $registry,
175
+		LoaderInterface $loader,
176
+		EE_Capabilities $capabilities,
177
+		EE_Request $request,
178
+		EE_Maintenance_Mode $maintenance_mode
179
+	) {
180
+		$this->registry = $registry;
181
+		$this->loader = $loader;
182
+		$this->capabilities = $capabilities;
183
+		$this->request = $request;
184
+		$this->maintenance_mode = $maintenance_mode;
185
+		do_action('AHEE__EE_System__construct__begin', $this);
186
+		add_action(
187
+			'AHEE__EE_Bootstrap__load_espresso_addons',
188
+			array($this, 'loadCapabilities'),
189
+			5
190
+		);
191
+		add_action(
192
+			'AHEE__EE_Bootstrap__load_espresso_addons',
193
+			array($this, 'loadCommandBus'),
194
+			7
195
+		);
196
+		add_action(
197
+			'AHEE__EE_Bootstrap__load_espresso_addons',
198
+			array($this, 'loadPluginApi'),
199
+			9
200
+		);
201
+		// allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
202
+		add_action(
203
+			'AHEE__EE_Bootstrap__load_espresso_addons',
204
+			array($this, 'load_espresso_addons')
205
+		);
206
+		// when an ee addon is activated, we want to call the core hook(s) again
207
+		// because the newly-activated addon didn't get a chance to run at all
208
+		add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
209
+		// detect whether install or upgrade
210
+		add_action(
211
+			'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
212
+			array($this, 'detect_activations_or_upgrades'),
213
+			3
214
+		);
215
+		// load EE_Config, EE_Textdomain, etc
216
+		add_action(
217
+			'AHEE__EE_Bootstrap__load_core_configuration',
218
+			array($this, 'load_core_configuration'),
219
+			5
220
+		);
221
+		// load EE_Config, EE_Textdomain, etc
222
+		add_action(
223
+			'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
224
+			array($this, 'register_shortcodes_modules_and_widgets'),
225
+			7
226
+		);
227
+		// you wanna get going? I wanna get going... let's get going!
228
+		add_action(
229
+			'AHEE__EE_Bootstrap__brew_espresso',
230
+			array($this, 'brew_espresso'),
231
+			9
232
+		);
233
+		//other housekeeping
234
+		//exclude EE critical pages from wp_list_pages
235
+		add_filter(
236
+			'wp_list_pages_excludes',
237
+			array($this, 'remove_pages_from_wp_list_pages'),
238
+			10
239
+		);
240
+		// ALL EE Addons should use the following hook point to attach their initial setup too
241
+		// it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
242
+		do_action('AHEE__EE_System__construct__complete', $this);
243
+	}
244
+
245
+
246
+
247
+	/**
248
+	 * load and setup EE_Capabilities
249
+	 *
250
+	 * @return void
251
+	 * @throws EE_Error
252
+	 */
253
+	public function loadCapabilities()
254
+	{
255
+		$this->loader->getShared('EE_Capabilities');
256
+		add_action(
257
+			'AHEE__EE_Capabilities__init_caps__before_initialization',
258
+			function() {
259
+				LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
260
+			}
261
+		);
262
+	}
263
+
264
+
265
+
266
+	/**
267
+	 * create and cache the CommandBus, and also add middleware
268
+	 * The CapChecker middleware requires the use of EE_Capabilities
269
+	 * which is why we need to load the CommandBus after Caps are set up
270
+	 *
271
+	 * @return void
272
+	 * @throws EE_Error
273
+	 */
274
+	public function loadCommandBus()
275
+	{
276
+		$this->loader->getShared(
277
+			'CommandBusInterface',
278
+			array(
279
+				null,
280
+				apply_filters(
281
+					'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
282
+					array(
283
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
284
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
285
+					)
286
+				),
287
+			)
288
+		);
289
+	}
290
+
291
+
292
+
293
+	/**
294
+	 * @return void
295
+	 * @throws EE_Error
296
+	 */
297
+	public function loadPluginApi()
298
+	{
299
+		// set autoloaders for all of the classes implementing EEI_Plugin_API
300
+		// which provide helpers for EE plugin authors to more easily register certain components with EE.
301
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
302
+	}
303
+
304
+
305
+	/**
306
+	 * @param string $addon_name
307
+	 * @param string $version_constant
308
+	 * @param string $min_version_required
309
+	 * @param string $load_callback
310
+	 * @param string $plugin_file_constant
311
+	 * @return void
312
+	 */
313
+	private function deactivateIncompatibleAddon(
314
+		$addon_name,
315
+		$version_constant,
316
+		$min_version_required,
317
+		$load_callback,
318
+		$plugin_file_constant
319
+	) {
320
+		if (! defined($version_constant)) {
321
+			return;
322
+		}
323
+		$addon_version = constant($version_constant);
324
+		if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
325
+			remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
326
+			if (! function_exists('deactivate_plugins')) {
327
+				require_once ABSPATH . 'wp-admin/includes/plugin.php';
328
+			}
329
+			deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
330
+			unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
331
+			EE_Error::add_error(
332
+				sprintf(
333
+					esc_html__(
334
+						'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.',
335
+						'event_espresso'
336
+					),
337
+					$addon_name,
338
+					$min_version_required
339
+				),
340
+				__FILE__, __FUNCTION__ . "({$addon_name})", __LINE__
341
+			);
342
+			EE_Error::get_notices(false, true);
343
+		}
344
+	}
345
+
346
+
347
+	/**
348
+	 * load_espresso_addons
349
+	 * allow addons to load first so that they can set hooks for running DMS's, etc
350
+	 * this is hooked into both:
351
+	 *    'AHEE__EE_Bootstrap__load_core_configuration'
352
+	 *        which runs during the WP 'plugins_loaded' action at priority 5
353
+	 *    and the WP 'activate_plugin' hook point
354
+	 *
355
+	 * @access public
356
+	 * @return void
357
+	 */
358
+	public function load_espresso_addons()
359
+	{
360
+		$this->deactivateIncompatibleAddon(
361
+			'Wait Lists',
362
+			'EE_WAIT_LISTS_VERSION',
363
+			'1.0.0.beta.074',
364
+			'load_espresso_wait_lists',
365
+			'EE_WAIT_LISTS_PLUGIN_FILE'
366
+		);
367
+		$this->deactivateIncompatibleAddon(
368
+			'Automated Upcoming Event Notifications',
369
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
370
+			'1.0.0.beta.091',
371
+			'load_espresso_automated_upcoming_event_notification',
372
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
373
+		);
374
+		do_action('AHEE__EE_System__load_espresso_addons');
375
+		//if the WP API basic auth plugin isn't already loaded, load it now.
376
+		//We want it for mobile apps. Just include the entire plugin
377
+		//also, don't load the basic auth when a plugin is getting activated, because
378
+		//it could be the basic auth plugin, and it doesn't check if its methods are already defined
379
+		//and causes a fatal error
380
+		if (
381
+			! (
382
+				isset($_GET['activate'])
383
+				&& $_GET['activate'] === 'true'
384
+			)
385
+			&& ! function_exists('json_basic_auth_handler')
386
+			&& ! function_exists('json_basic_auth_error')
387
+			&& ! (
388
+				isset($_GET['action'])
389
+				&& in_array($_GET['action'], array('activate', 'activate-selected'), true)
390
+			)
391
+		) {
392
+			include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
393
+		}
394
+		do_action('AHEE__EE_System__load_espresso_addons__complete');
395
+	}
396
+
397
+
398
+
399
+	/**
400
+	 * detect_activations_or_upgrades
401
+	 * Checks for activation or upgrade of core first;
402
+	 * then also checks if any registered addons have been activated or upgraded
403
+	 * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
404
+	 * which runs during the WP 'plugins_loaded' action at priority 3
405
+	 *
406
+	 * @access public
407
+	 * @return void
408
+	 */
409
+	public function detect_activations_or_upgrades()
410
+	{
411
+		//first off: let's make sure to handle core
412
+		$this->detect_if_activation_or_upgrade();
413
+		foreach ($this->registry->addons as $addon) {
414
+			if ($addon instanceof EE_Addon) {
415
+				//detect teh request type for that addon
416
+				$addon->detect_activation_or_upgrade();
417
+			}
418
+		}
419
+	}
420
+
421
+
422
+
423
+	/**
424
+	 * detect_if_activation_or_upgrade
425
+	 * Takes care of detecting whether this is a brand new install or code upgrade,
426
+	 * and either setting up the DB or setting up maintenance mode etc.
427
+	 *
428
+	 * @access public
429
+	 * @return void
430
+	 */
431
+	public function detect_if_activation_or_upgrade()
432
+	{
433
+		do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
434
+		// check if db has been updated, or if its a brand-new installation
435
+		$espresso_db_update = $this->fix_espresso_db_upgrade_option();
436
+		$request_type = $this->detect_req_type($espresso_db_update);
437
+		//EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
438
+		switch ($request_type) {
439
+			case EE_System::req_type_new_activation:
440
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
441
+				$this->_handle_core_version_change($espresso_db_update);
442
+				break;
443
+			case EE_System::req_type_reactivation:
444
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
445
+				$this->_handle_core_version_change($espresso_db_update);
446
+				break;
447
+			case EE_System::req_type_upgrade:
448
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
449
+				//migrations may be required now that we've upgraded
450
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
451
+				$this->_handle_core_version_change($espresso_db_update);
452
+				//				echo "done upgrade";die;
453
+				break;
454
+			case EE_System::req_type_downgrade:
455
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
456
+				//its possible migrations are no longer required
457
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
458
+				$this->_handle_core_version_change($espresso_db_update);
459
+				break;
460
+			case EE_System::req_type_normal:
461
+			default:
462
+				//				$this->_maybe_redirect_to_ee_about();
463
+				break;
464
+		}
465
+		do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
466
+	}
467
+
468
+
469
+
470
+	/**
471
+	 * Updates the list of installed versions and sets hooks for
472
+	 * initializing the database later during the request
473
+	 *
474
+	 * @param array $espresso_db_update
475
+	 */
476
+	private function _handle_core_version_change($espresso_db_update)
477
+	{
478
+		$this->update_list_of_installed_versions($espresso_db_update);
479
+		//get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
480
+		add_action(
481
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
482
+			array($this, 'initialize_db_if_no_migrations_required')
483
+		);
484
+	}
485
+
486
+
487
+
488
+	/**
489
+	 * standardizes the wp option 'espresso_db_upgrade' which actually stores
490
+	 * information about what versions of EE have been installed and activated,
491
+	 * NOT necessarily the state of the database
492
+	 *
493
+	 * @param mixed $espresso_db_update the value of the WordPress option.
494
+	 *                                            If not supplied, fetches it from the options table
495
+	 * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
496
+	 */
497
+	private function fix_espresso_db_upgrade_option($espresso_db_update = null)
498
+	{
499
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
500
+		if (! $espresso_db_update) {
501
+			$espresso_db_update = get_option('espresso_db_update');
502
+		}
503
+		// check that option is an array
504
+		if (! is_array($espresso_db_update)) {
505
+			// if option is FALSE, then it never existed
506
+			if ($espresso_db_update === false) {
507
+				// make $espresso_db_update an array and save option with autoload OFF
508
+				$espresso_db_update = array();
509
+				add_option('espresso_db_update', $espresso_db_update, '', 'no');
510
+			} else {
511
+				// option is NOT FALSE but also is NOT an array, so make it an array and save it
512
+				$espresso_db_update = array($espresso_db_update => array());
513
+				update_option('espresso_db_update', $espresso_db_update);
514
+			}
515
+		} else {
516
+			$corrected_db_update = array();
517
+			//if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
518
+			foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
519
+				if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
520
+					//the key is an int, and the value IS NOT an array
521
+					//so it must be numerically-indexed, where values are versions installed...
522
+					//fix it!
523
+					$version_string = $should_be_array;
524
+					$corrected_db_update[$version_string] = array('unknown-date');
525
+				} else {
526
+					//ok it checks out
527
+					$corrected_db_update[$should_be_version_string] = $should_be_array;
528
+				}
529
+			}
530
+			$espresso_db_update = $corrected_db_update;
531
+			update_option('espresso_db_update', $espresso_db_update);
532
+		}
533
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
534
+		return $espresso_db_update;
535
+	}
536
+
537
+
538
+
539
+	/**
540
+	 * Does the traditional work of setting up the plugin's database and adding default data.
541
+	 * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
542
+	 * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
543
+	 * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
544
+	 * so that it will be done when migrations are finished
545
+	 *
546
+	 * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
547
+	 * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
548
+	 *                                       This is a resource-intensive job
549
+	 *                                       so we prefer to only do it when necessary
550
+	 * @return void
551
+	 * @throws EE_Error
552
+	 */
553
+	public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
554
+	{
555
+		$request_type = $this->detect_req_type();
556
+		//only initialize system if we're not in maintenance mode.
557
+		if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
558
+			update_option('ee_flush_rewrite_rules', true);
559
+			if ($verify_schema) {
560
+				EEH_Activation::initialize_db_and_folders();
561
+			}
562
+			EEH_Activation::initialize_db_content();
563
+			EEH_Activation::system_initialization();
564
+			if ($initialize_addons_too) {
565
+				$this->initialize_addons();
566
+			}
567
+		} else {
568
+			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
569
+		}
570
+		if ($request_type === EE_System::req_type_new_activation
571
+			|| $request_type === EE_System::req_type_reactivation
572
+			|| (
573
+				$request_type === EE_System::req_type_upgrade
574
+				&& $this->is_major_version_change()
575
+			)
576
+		) {
577
+			add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
578
+		}
579
+	}
580
+
581
+
582
+
583
+	/**
584
+	 * Initializes the db for all registered addons
585
+	 *
586
+	 * @throws EE_Error
587
+	 */
588
+	public function initialize_addons()
589
+	{
590
+		//foreach registered addon, make sure its db is up-to-date too
591
+		foreach ($this->registry->addons as $addon) {
592
+			if ($addon instanceof EE_Addon) {
593
+				$addon->initialize_db_if_no_migrations_required();
594
+			}
595
+		}
596
+	}
597
+
598
+
599
+
600
+	/**
601
+	 * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
602
+	 *
603
+	 * @param    array  $version_history
604
+	 * @param    string $current_version_to_add version to be added to the version history
605
+	 * @return    boolean success as to whether or not this option was changed
606
+	 */
607
+	public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
608
+	{
609
+		if (! $version_history) {
610
+			$version_history = $this->fix_espresso_db_upgrade_option($version_history);
611
+		}
612
+		if ($current_version_to_add === null) {
613
+			$current_version_to_add = espresso_version();
614
+		}
615
+		$version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time());
616
+		// re-save
617
+		return update_option('espresso_db_update', $version_history);
618
+	}
619
+
620
+
621
+
622
+	/**
623
+	 * Detects if the current version indicated in the has existed in the list of
624
+	 * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
625
+	 *
626
+	 * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
627
+	 *                                  If not supplied, fetches it from the options table.
628
+	 *                                  Also, caches its result so later parts of the code can also know whether
629
+	 *                                  there's been an update or not. This way we can add the current version to
630
+	 *                                  espresso_db_update, but still know if this is a new install or not
631
+	 * @return int one of the constants on EE_System::req_type_
632
+	 */
633
+	public function detect_req_type($espresso_db_update = null)
634
+	{
635
+		if ($this->_req_type === null) {
636
+			$espresso_db_update = ! empty($espresso_db_update)
637
+				? $espresso_db_update
638
+				: $this->fix_espresso_db_upgrade_option();
639
+			$this->_req_type = EE_System::detect_req_type_given_activation_history(
640
+				$espresso_db_update,
641
+				'ee_espresso_activation', espresso_version()
642
+			);
643
+			$this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
644
+		}
645
+		return $this->_req_type;
646
+	}
647
+
648
+
649
+
650
+	/**
651
+	 * Returns whether or not there was a non-micro version change (ie, change in either
652
+	 * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
653
+	 * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
654
+	 *
655
+	 * @param $activation_history
656
+	 * @return bool
657
+	 */
658
+	private function _detect_major_version_change($activation_history)
659
+	{
660
+		$previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
661
+		$previous_version_parts = explode('.', $previous_version);
662
+		$current_version_parts = explode('.', espresso_version());
663
+		return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
664
+			   && ($previous_version_parts[0] !== $current_version_parts[0]
665
+				   || $previous_version_parts[1] !== $current_version_parts[1]
666
+			   );
667
+	}
668
+
669
+
670
+
671
+	/**
672
+	 * Returns true if either the major or minor version of EE changed during this request.
673
+	 * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001
674
+	 *
675
+	 * @return bool
676
+	 */
677
+	public function is_major_version_change()
678
+	{
679
+		return $this->_major_version_change;
680
+	}
681
+
682
+
683
+
684
+	/**
685
+	 * Determines the request type for any ee addon, given three piece of info: the current array of activation
686
+	 * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
687
+	 * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
688
+	 * just activated to (for core that will always be espresso_version())
689
+	 *
690
+	 * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
691
+	 *                                                 ee plugin. for core that's 'espresso_db_update'
692
+	 * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
693
+	 *                                                 indicate that this plugin was just activated
694
+	 * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
695
+	 *                                                 espresso_version())
696
+	 * @return int one of the constants on EE_System::req_type_*
697
+	 */
698
+	public static function detect_req_type_given_activation_history(
699
+		$activation_history_for_addon,
700
+		$activation_indicator_option_name,
701
+		$version_to_upgrade_to
702
+	) {
703
+		$version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
704
+		if ($activation_history_for_addon) {
705
+			//it exists, so this isn't a completely new install
706
+			//check if this version already in that list of previously installed versions
707
+			if (! isset($activation_history_for_addon[$version_to_upgrade_to])) {
708
+				//it a version we haven't seen before
709
+				if ($version_is_higher === 1) {
710
+					$req_type = EE_System::req_type_upgrade;
711
+				} else {
712
+					$req_type = EE_System::req_type_downgrade;
713
+				}
714
+				delete_option($activation_indicator_option_name);
715
+			} else {
716
+				// its not an update. maybe a reactivation?
717
+				if (get_option($activation_indicator_option_name, false)) {
718
+					if ($version_is_higher === -1) {
719
+						$req_type = EE_System::req_type_downgrade;
720
+					} else if ($version_is_higher === 0) {
721
+						//we've seen this version before, but it's an activation. must be a reactivation
722
+						$req_type = EE_System::req_type_reactivation;
723
+					} else {//$version_is_higher === 1
724
+						$req_type = EE_System::req_type_upgrade;
725
+					}
726
+					delete_option($activation_indicator_option_name);
727
+				} else {
728
+					//we've seen this version before and the activation indicate doesn't show it was just activated
729
+					if ($version_is_higher === -1) {
730
+						$req_type = EE_System::req_type_downgrade;
731
+					} else if ($version_is_higher === 0) {
732
+						//we've seen this version before and it's not an activation. its normal request
733
+						$req_type = EE_System::req_type_normal;
734
+					} else {//$version_is_higher === 1
735
+						$req_type = EE_System::req_type_upgrade;
736
+					}
737
+				}
738
+			}
739
+		} else {
740
+			//brand new install
741
+			$req_type = EE_System::req_type_new_activation;
742
+			delete_option($activation_indicator_option_name);
743
+		}
744
+		return $req_type;
745
+	}
746
+
747
+
748
+
749
+	/**
750
+	 * Detects if the $version_to_upgrade_to is higher than the most recent version in
751
+	 * the $activation_history_for_addon
752
+	 *
753
+	 * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
754
+	 *                                             sometimes containing 'unknown-date'
755
+	 * @param string $version_to_upgrade_to        (current version)
756
+	 * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
757
+	 *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
758
+	 *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
759
+	 *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
760
+	 */
761
+	private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
762
+	{
763
+		//find the most recently-activated version
764
+		$most_recently_active_version =
765
+			EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
766
+		return version_compare($version_to_upgrade_to, $most_recently_active_version);
767
+	}
768
+
769
+
770
+
771
+	/**
772
+	 * Gets the most recently active version listed in the activation history,
773
+	 * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
774
+	 *
775
+	 * @param array $activation_history  (keys are versions, values are arrays of times activated,
776
+	 *                                   sometimes containing 'unknown-date'
777
+	 * @return string
778
+	 */
779
+	private static function _get_most_recently_active_version_from_activation_history($activation_history)
780
+	{
781
+		$most_recently_active_version_activation = '1970-01-01 00:00:00';
782
+		$most_recently_active_version = '0.0.0.dev.000';
783
+		if (is_array($activation_history)) {
784
+			foreach ($activation_history as $version => $times_activated) {
785
+				//check there is a record of when this version was activated. Otherwise,
786
+				//mark it as unknown
787
+				if (! $times_activated) {
788
+					$times_activated = array('unknown-date');
789
+				}
790
+				if (is_string($times_activated)) {
791
+					$times_activated = array($times_activated);
792
+				}
793
+				foreach ($times_activated as $an_activation) {
794
+					if ($an_activation !== 'unknown-date' && $an_activation > $most_recently_active_version_activation) {
795
+						$most_recently_active_version = $version;
796
+						$most_recently_active_version_activation = $an_activation === 'unknown-date'
797
+							? '1970-01-01 00:00:00'
798
+							: $an_activation;
799
+					}
800
+				}
801
+			}
802
+		}
803
+		return $most_recently_active_version;
804
+	}
805
+
806
+
807
+
808
+	/**
809
+	 * This redirects to the about EE page after activation
810
+	 *
811
+	 * @return void
812
+	 */
813
+	public function redirect_to_about_ee()
814
+	{
815
+		$notices = EE_Error::get_notices(false);
816
+		//if current user is an admin and it's not an ajax or rest request
817
+		if (
818
+			! (defined('DOING_AJAX') && DOING_AJAX)
819
+			&& ! (defined('REST_REQUEST') && REST_REQUEST)
820
+			&& ! isset($notices['errors'])
821
+			&& apply_filters(
822
+				'FHEE__EE_System__redirect_to_about_ee__do_redirect',
823
+				$this->capabilities->current_user_can('manage_options', 'espresso_about_default')
824
+			)
825
+		) {
826
+			$query_params = array('page' => 'espresso_about');
827
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
828
+				$query_params['new_activation'] = true;
829
+			}
830
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
831
+				$query_params['reactivation'] = true;
832
+			}
833
+			$url = add_query_arg($query_params, admin_url('admin.php'));
834
+			wp_safe_redirect($url);
835
+			exit();
836
+		}
837
+	}
838
+
839
+
840
+
841
+	/**
842
+	 * load_core_configuration
843
+	 * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
844
+	 * which runs during the WP 'plugins_loaded' action at priority 5
845
+	 *
846
+	 * @return void
847
+	 * @throws ReflectionException
848
+	 */
849
+	public function load_core_configuration()
850
+	{
851
+		do_action('AHEE__EE_System__load_core_configuration__begin', $this);
852
+		$this->loader->getShared('EE_Load_Textdomain');
853
+		//load textdomain
854
+		EE_Load_Textdomain::load_textdomain();
855
+		// load and setup EE_Config and EE_Network_Config
856
+		$config = $this->loader->getShared('EE_Config');
857
+		$this->loader->getShared('EE_Network_Config');
858
+		// setup autoloaders
859
+		// enable logging?
860
+		if ($config->admin->use_full_logging) {
861
+			$this->loader->getShared('EE_Log');
862
+		}
863
+		// check for activation errors
864
+		$activation_errors = get_option('ee_plugin_activation_errors', false);
865
+		if ($activation_errors) {
866
+			EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
867
+			update_option('ee_plugin_activation_errors', false);
868
+		}
869
+		// get model names
870
+		$this->_parse_model_names();
871
+		//load caf stuff a chance to play during the activation process too.
872
+		$this->_maybe_brew_regular();
873
+		do_action('AHEE__EE_System__load_core_configuration__complete', $this);
874
+	}
875
+
876
+
877
+
878
+	/**
879
+	 * cycles through all of the models/*.model.php files, and assembles an array of model names
880
+	 *
881
+	 * @return void
882
+	 * @throws ReflectionException
883
+	 */
884
+	private function _parse_model_names()
885
+	{
886
+		//get all the files in the EE_MODELS folder that end in .model.php
887
+		$models = glob(EE_MODELS . '*.model.php');
888
+		$model_names = array();
889
+		$non_abstract_db_models = array();
890
+		foreach ($models as $model) {
891
+			// get model classname
892
+			$classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
893
+			$short_name = str_replace('EEM_', '', $classname);
894
+			$reflectionClass = new ReflectionClass($classname);
895
+			if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
896
+				$non_abstract_db_models[$short_name] = $classname;
897
+			}
898
+			$model_names[$short_name] = $classname;
899
+		}
900
+		$this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
901
+		$this->registry->non_abstract_db_models = apply_filters(
902
+			'FHEE__EE_System__parse_implemented_model_names',
903
+			$non_abstract_db_models
904
+		);
905
+	}
906
+
907
+
908
+
909
+	/**
910
+	 * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
911
+	 * that need to be setup before our EE_System launches.
912
+	 *
913
+	 * @return void
914
+	 */
915
+	private function _maybe_brew_regular()
916
+	{
917
+		if ((! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) {
918
+			require_once EE_CAFF_PATH . 'brewing_regular.php';
919
+		}
920
+	}
921
+
922
+
923
+
924
+	/**
925
+	 * register_shortcodes_modules_and_widgets
926
+	 * generate lists of shortcodes and modules, then verify paths and classes
927
+	 * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
928
+	 * which runs during the WP 'plugins_loaded' action at priority 7
929
+	 *
930
+	 * @access public
931
+	 * @return void
932
+	 * @throws Exception
933
+	 */
934
+	public function register_shortcodes_modules_and_widgets()
935
+	{
936
+		try {
937
+			// load, register, and add shortcodes the new way
938
+			$this->loader->getShared(
939
+				'EventEspresso\core\services\shortcodes\ShortcodesManager',
940
+				array(
941
+					// and the old way, but we'll put it under control of the new system
942
+					EE_Config::getLegacyShortcodesManager()
943
+				)
944
+			);
945
+		} catch (Exception $exception) {
946
+			new ExceptionStackTraceDisplay($exception);
947
+		}
948
+		do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
949
+		// check for addons using old hook point
950
+		if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
951
+			$this->_incompatible_addon_error();
952
+		}
953
+	}
954
+
955
+
956
+
957
+	/**
958
+	 * _incompatible_addon_error
959
+	 *
960
+	 * @access public
961
+	 * @return void
962
+	 */
963
+	private function _incompatible_addon_error()
964
+	{
965
+		// get array of classes hooking into here
966
+		$class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
967
+			'AHEE__EE_System__register_shortcodes_modules_and_addons'
968
+		);
969
+		if (! empty($class_names)) {
970
+			$msg = __(
971
+				'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
972
+				'event_espresso'
973
+			);
974
+			$msg .= '<ul>';
975
+			foreach ($class_names as $class_name) {
976
+				$msg .= '<li><b>Event Espresso - ' . str_replace(
977
+						array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
978
+						$class_name
979
+					) . '</b></li>';
980
+			}
981
+			$msg .= '</ul>';
982
+			$msg .= __(
983
+				'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
984
+				'event_espresso'
985
+			);
986
+			// save list of incompatible addons to wp-options for later use
987
+			add_option('ee_incompatible_addons', $class_names, '', 'no');
988
+			if (is_admin()) {
989
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
990
+			}
991
+		}
992
+	}
993
+
994
+
995
+
996
+	/**
997
+	 * brew_espresso
998
+	 * begins the process of setting hooks for initializing EE in the correct order
999
+	 * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1000
+	 * which runs during the WP 'plugins_loaded' action at priority 9
1001
+	 *
1002
+	 * @return void
1003
+	 */
1004
+	public function brew_espresso()
1005
+	{
1006
+		do_action('AHEE__EE_System__brew_espresso__begin', $this);
1007
+		// load some final core systems
1008
+		add_action('init', array($this, 'set_hooks_for_core'), 1);
1009
+		add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1010
+		add_action('init', array($this, 'load_CPTs_and_session'), 5);
1011
+		add_action('init', array($this, 'load_controllers'), 7);
1012
+		add_action('init', array($this, 'core_loaded_and_ready'), 9);
1013
+		add_action('init', array($this, 'initialize'), 10);
1014
+		add_action('init', array($this, 'initialize_last'), 100);
1015
+		if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
1016
+			// pew pew pew
1017
+			$this->loader->getShared('EventEspresso\core\services\licensing\LicenseService');
1018
+			do_action('AHEE__EE_System__brew_espresso__after_pue_init');
1019
+		}
1020
+		do_action('AHEE__EE_System__brew_espresso__complete', $this);
1021
+	}
1022
+
1023
+
1024
+
1025
+	/**
1026
+	 *    set_hooks_for_core
1027
+	 *
1028
+	 * @access public
1029
+	 * @return    void
1030
+	 * @throws EE_Error
1031
+	 */
1032
+	public function set_hooks_for_core()
1033
+	{
1034
+		$this->_deactivate_incompatible_addons();
1035
+		do_action('AHEE__EE_System__set_hooks_for_core');
1036
+		//caps need to be initialized on every request so that capability maps are set.
1037
+		//@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1038
+		$this->registry->CAP->init_caps();
1039
+	}
1040
+
1041
+
1042
+
1043
+	/**
1044
+	 * Using the information gathered in EE_System::_incompatible_addon_error,
1045
+	 * deactivates any addons considered incompatible with the current version of EE
1046
+	 */
1047
+	private function _deactivate_incompatible_addons()
1048
+	{
1049
+		$incompatible_addons = get_option('ee_incompatible_addons', array());
1050
+		if (! empty($incompatible_addons)) {
1051
+			$active_plugins = get_option('active_plugins', array());
1052
+			foreach ($active_plugins as $active_plugin) {
1053
+				foreach ($incompatible_addons as $incompatible_addon) {
1054
+					if (strpos($active_plugin, $incompatible_addon) !== false) {
1055
+						unset($_GET['activate']);
1056
+						espresso_deactivate_plugin($active_plugin);
1057
+					}
1058
+				}
1059
+			}
1060
+		}
1061
+	}
1062
+
1063
+
1064
+
1065
+	/**
1066
+	 *    perform_activations_upgrades_and_migrations
1067
+	 *
1068
+	 * @access public
1069
+	 * @return    void
1070
+	 */
1071
+	public function perform_activations_upgrades_and_migrations()
1072
+	{
1073
+		//first check if we had previously attempted to setup EE's directories but failed
1074
+		if (EEH_Activation::upload_directories_incomplete()) {
1075
+			EEH_Activation::create_upload_directories();
1076
+		}
1077
+		do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1078
+	}
1079
+
1080
+
1081
+
1082
+	/**
1083
+	 *    load_CPTs_and_session
1084
+	 *
1085
+	 * @access public
1086
+	 * @return    void
1087
+	 */
1088
+	public function load_CPTs_and_session()
1089
+	{
1090
+		do_action('AHEE__EE_System__load_CPTs_and_session__start');
1091
+		// register Custom Post Types
1092
+		$this->loader->getShared('EE_Register_CPTs');
1093
+		do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1094
+	}
1095
+
1096
+
1097
+
1098
+	/**
1099
+	 * load_controllers
1100
+	 * this is the best place to load any additional controllers that needs access to EE core.
1101
+	 * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1102
+	 * time
1103
+	 *
1104
+	 * @access public
1105
+	 * @return void
1106
+	 */
1107
+	public function load_controllers()
1108
+	{
1109
+		do_action('AHEE__EE_System__load_controllers__start');
1110
+		// let's get it started
1111
+		if (! is_admin() && ! $this->maintenance_mode->level()) {
1112
+			do_action('AHEE__EE_System__load_controllers__load_front_controllers');
1113
+			$this->loader->getShared('EE_Front_Controller');
1114
+		} else if (! EE_FRONT_AJAX) {
1115
+			do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1116
+			$this->loader->getShared('EE_Admin');
1117
+		}
1118
+		do_action('AHEE__EE_System__load_controllers__complete');
1119
+	}
1120
+
1121
+
1122
+
1123
+	/**
1124
+	 * core_loaded_and_ready
1125
+	 * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1126
+	 *
1127
+	 * @access public
1128
+	 * @return void
1129
+	 */
1130
+	public function core_loaded_and_ready()
1131
+	{
1132
+		$this->loader->getShared('EE_Session');
1133
+		do_action('AHEE__EE_System__core_loaded_and_ready');
1134
+		// load_espresso_template_tags
1135
+		if (is_readable(EE_PUBLIC . 'template_tags.php')) {
1136
+			require_once(EE_PUBLIC . 'template_tags.php');
1137
+		}
1138
+		do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1139
+		$this->loader->getShared('EventEspresso\core\services\assets\Registry');
1140
+	}
1141
+
1142
+
1143
+
1144
+	/**
1145
+	 * initialize
1146
+	 * this is the best place to begin initializing client code
1147
+	 *
1148
+	 * @access public
1149
+	 * @return void
1150
+	 */
1151
+	public function initialize()
1152
+	{
1153
+		do_action('AHEE__EE_System__initialize');
1154
+	}
1155
+
1156
+
1157
+
1158
+	/**
1159
+	 * initialize_last
1160
+	 * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1161
+	 * initialize has done so
1162
+	 *
1163
+	 * @access public
1164
+	 * @return void
1165
+	 */
1166
+	public function initialize_last()
1167
+	{
1168
+		do_action('AHEE__EE_System__initialize_last');
1169
+		add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1170
+	}
1171
+
1172
+
1173
+
1174
+	/**
1175
+	 * @return void
1176
+	 * @throws EE_Error
1177
+	 */
1178
+	public function addEspressoToolbar()
1179
+	{
1180
+		$this->loader->getShared(
1181
+			'EventEspresso\core\domain\services\admin\AdminToolBar',
1182
+			array($this->registry->CAP)
1183
+		);
1184
+	}
1185
+
1186
+
1187
+
1188
+	/**
1189
+	 * do_not_cache
1190
+	 * sets no cache headers and defines no cache constants for WP plugins
1191
+	 *
1192
+	 * @access public
1193
+	 * @return void
1194
+	 */
1195
+	public static function do_not_cache()
1196
+	{
1197
+		// set no cache constants
1198
+		if (! defined('DONOTCACHEPAGE')) {
1199
+			define('DONOTCACHEPAGE', true);
1200
+		}
1201
+		if (! defined('DONOTCACHCEOBJECT')) {
1202
+			define('DONOTCACHCEOBJECT', true);
1203
+		}
1204
+		if (! defined('DONOTCACHEDB')) {
1205
+			define('DONOTCACHEDB', true);
1206
+		}
1207
+		// add no cache headers
1208
+		add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1209
+		// plus a little extra for nginx and Google Chrome
1210
+		add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1211
+		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1212
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1213
+	}
1214
+
1215
+
1216
+
1217
+	/**
1218
+	 *    extra_nocache_headers
1219
+	 *
1220
+	 * @access    public
1221
+	 * @param $headers
1222
+	 * @return    array
1223
+	 */
1224
+	public static function extra_nocache_headers($headers)
1225
+	{
1226
+		// for NGINX
1227
+		$headers['X-Accel-Expires'] = 0;
1228
+		// plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1229
+		$headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1230
+		return $headers;
1231
+	}
1232
+
1233
+
1234
+
1235
+	/**
1236
+	 *    nocache_headers
1237
+	 *
1238
+	 * @access    public
1239
+	 * @return    void
1240
+	 */
1241
+	public static function nocache_headers()
1242
+	{
1243
+		nocache_headers();
1244
+	}
1245
+
1246
+
1247
+
1248
+
1249
+	/**
1250
+	 * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1251
+	 * never returned with the function.
1252
+	 *
1253
+	 * @param  array $exclude_array any existing pages being excluded are in this array.
1254
+	 * @return array
1255
+	 */
1256
+	public function remove_pages_from_wp_list_pages($exclude_array)
1257
+	{
1258
+		return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1259
+	}
1260 1260
 
1261 1261
 
1262 1262
 
Please login to merge, or discard this patch.
core/EE_Deprecated.core.php 2 patches
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 		);
1053 1053
 		do_action(
1054 1054
 			'AHEE__EE_Capabilities__init_role_caps__complete',
1055
-            $capabilities_map
1055
+			$capabilities_map
1056 1056
 		);
1057 1057
 	}
1058 1058
 );
@@ -1072,9 +1072,9 @@  discard block
 block discarded – undo
1072 1072
 			'filter'
1073 1073
 		);
1074 1074
 		return apply_filters(
1075
-            'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1076
-            $existing_attendee, $registration, $attendee_data
1077
-        );
1075
+			'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1076
+			$existing_attendee, $registration, $attendee_data
1077
+		);
1078 1078
 	},
1079 1079
 	10,3
1080 1080
 );
@@ -1087,89 +1087,89 @@  discard block
 block discarded – undo
1087 1087
 class EE_Event_List_Query extends WP_Query
1088 1088
 {
1089 1089
 
1090
-    private $title;
1091
-
1092
-    private $css_class;
1093
-
1094
-    private $category_slug;
1095
-
1096
-    /**
1097
-     * EE_Event_List_Query constructor.
1098
-     *
1099
-     * @param array $args
1100
-     */
1101
-    public function __construct($args = array())
1102
-    {
1103
-        \EE_Error::doing_it_wrong(
1104
-            __METHOD__,
1105
-            __(
1106
-                'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1107
-                'event_espresso'
1108
-            ),
1109
-            '4.9.27',
1110
-            '5.0.0'
1111
-        );
1112
-        $this->title = isset($args['title']) ? $args['title'] : '';
1113
-        $this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1114
-        $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1115
-        $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1116
-        // the current "page" we are viewing
1117
-        $paged = max(1, get_query_var('paged'));
1118
-        // Force these args
1119
-        $args = array_merge(
1120
-            $args, array(
1121
-            'post_type'              => 'espresso_events',
1122
-            'posts_per_page'         => $limit,
1123
-            'update_post_term_cache' => false,
1124
-            'update_post_meta_cache' => false,
1125
-            'paged'                  => $paged,
1126
-            'offset'                 => ($paged - 1) * $limit
1127
-        )
1128
-        );
1129
-        // run the query
1130
-        parent::__construct($args);
1131
-    }
1132
-
1133
-
1134
-
1135
-    /**
1136
-     * event_list_title
1137
-     *
1138
-     * @param string $event_list_title
1139
-     * @return string
1140
-     */
1141
-    public function event_list_title($event_list_title = '')
1142
-    {
1143
-        if (! empty($this->title)) {
1144
-            return $this->title;
1145
-        }
1146
-        return $event_list_title;
1147
-    }
1148
-
1149
-
1150
-
1151
-    /**
1152
-     * event_list_css
1153
-     *
1154
-     * @param string $event_list_css
1155
-     * @return string
1156
-     */
1157
-    public function event_list_css($event_list_css = '')
1158
-    {
1159
-        $event_list_css .= ! empty($event_list_css)
1160
-            ? ' '
1161
-            : '';
1162
-        $event_list_css .= ! empty($this->css_class)
1163
-            ? $this->css_class
1164
-            : '';
1165
-        $event_list_css .= ! empty($event_list_css)
1166
-            ? ' '
1167
-            : '';
1168
-        $event_list_css .= ! empty($this->category_slug)
1169
-            ? $this->category_slug
1170
-            : '';
1171
-        return $event_list_css;
1172
-    }
1090
+	private $title;
1091
+
1092
+	private $css_class;
1093
+
1094
+	private $category_slug;
1095
+
1096
+	/**
1097
+	 * EE_Event_List_Query constructor.
1098
+	 *
1099
+	 * @param array $args
1100
+	 */
1101
+	public function __construct($args = array())
1102
+	{
1103
+		\EE_Error::doing_it_wrong(
1104
+			__METHOD__,
1105
+			__(
1106
+				'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1107
+				'event_espresso'
1108
+			),
1109
+			'4.9.27',
1110
+			'5.0.0'
1111
+		);
1112
+		$this->title = isset($args['title']) ? $args['title'] : '';
1113
+		$this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1114
+		$this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1115
+		$limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1116
+		// the current "page" we are viewing
1117
+		$paged = max(1, get_query_var('paged'));
1118
+		// Force these args
1119
+		$args = array_merge(
1120
+			$args, array(
1121
+			'post_type'              => 'espresso_events',
1122
+			'posts_per_page'         => $limit,
1123
+			'update_post_term_cache' => false,
1124
+			'update_post_meta_cache' => false,
1125
+			'paged'                  => $paged,
1126
+			'offset'                 => ($paged - 1) * $limit
1127
+		)
1128
+		);
1129
+		// run the query
1130
+		parent::__construct($args);
1131
+	}
1132
+
1133
+
1134
+
1135
+	/**
1136
+	 * event_list_title
1137
+	 *
1138
+	 * @param string $event_list_title
1139
+	 * @return string
1140
+	 */
1141
+	public function event_list_title($event_list_title = '')
1142
+	{
1143
+		if (! empty($this->title)) {
1144
+			return $this->title;
1145
+		}
1146
+		return $event_list_title;
1147
+	}
1148
+
1149
+
1150
+
1151
+	/**
1152
+	 * event_list_css
1153
+	 *
1154
+	 * @param string $event_list_css
1155
+	 * @return string
1156
+	 */
1157
+	public function event_list_css($event_list_css = '')
1158
+	{
1159
+		$event_list_css .= ! empty($event_list_css)
1160
+			? ' '
1161
+			: '';
1162
+		$event_list_css .= ! empty($this->css_class)
1163
+			? $this->css_class
1164
+			: '';
1165
+		$event_list_css .= ! empty($event_list_css)
1166
+			? ' '
1167
+			: '';
1168
+		$event_list_css .= ! empty($this->category_slug)
1169
+			? $this->category_slug
1170
+			: '';
1171
+		return $event_list_css;
1172
+	}
1173 1173
 
1174 1174
 }
1175 1175
 
@@ -1186,66 +1186,66 @@  discard block
 block discarded – undo
1186 1186
 {
1187 1187
 
1188 1188
 
1189
-    /**
1190
-     *    class constructor
1191
-     *
1192
-     * @deprecated $VID:$
1193
-     */
1194
-    public function __construct()
1195
-    {
1196
-        EE_Error::doing_it_wrong(
1197
-            __METHOD__,
1198
-            sprintf(
1199
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1200
-                __CLASS__,
1201
-                'EventEspresso\core\services\licensing\LicenseServices'
1202
-            ),
1203
-            '$VID:$'
1204
-        );
1205
-    }
1206
-
1207
-
1208
-    /**
1209
-     * The purpose of this function is to display information about Event Espresso data collection
1210
-     * and a optin selection for extra data collecting by users.
1211
-     *
1212
-     * @param bool $extra
1213
-     * @return string html.
1214
-     * @deprecated $VID:$
1215
-     */
1216
-    public static function espresso_data_collection_optin_text($extra = true)
1217
-    {
1218
-        EE_Error::doing_it_wrong(
1219
-            __METHOD__,
1220
-            sprintf(
1221
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1222
-                __METHOD__,
1223
-                'EventEspresso\core\domain\services\Stats::optinText'
1224
-            ),
1225
-            '$VID:$'
1226
-        );
1227
-        Stats::optinText($extra);
1228
-    }
1229
-
1230
-    /**
1231
-     * This is a handy helper method for retrieving whether there is an update available for the given plugin.
1232
-     *
1233
-     * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
1234
-     *                          identify plugins. Defaults to core update
1235
-     * @return boolean           True if update available, false if not.
1236
-     * @deprecated $VID:$
1237
-     */
1238
-    public static function is_update_available($basename = '')
1239
-    {
1240
-        EE_Error::doing_it_wrong(
1241
-            __METHOD__,
1242
-            sprintf(
1243
-                esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1244
-                __METHOD__,
1245
-                'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable'
1246
-            ),
1247
-            '$VID:$'
1248
-        );
1249
-        return LicenseService::isUpdateAvailable($basename);
1250
-    }
1189
+	/**
1190
+	 *    class constructor
1191
+	 *
1192
+	 * @deprecated $VID:$
1193
+	 */
1194
+	public function __construct()
1195
+	{
1196
+		EE_Error::doing_it_wrong(
1197
+			__METHOD__,
1198
+			sprintf(
1199
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1200
+				__CLASS__,
1201
+				'EventEspresso\core\services\licensing\LicenseServices'
1202
+			),
1203
+			'$VID:$'
1204
+		);
1205
+	}
1206
+
1207
+
1208
+	/**
1209
+	 * The purpose of this function is to display information about Event Espresso data collection
1210
+	 * and a optin selection for extra data collecting by users.
1211
+	 *
1212
+	 * @param bool $extra
1213
+	 * @return string html.
1214
+	 * @deprecated $VID:$
1215
+	 */
1216
+	public static function espresso_data_collection_optin_text($extra = true)
1217
+	{
1218
+		EE_Error::doing_it_wrong(
1219
+			__METHOD__,
1220
+			sprintf(
1221
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1222
+				__METHOD__,
1223
+				'EventEspresso\core\domain\services\Stats::optinText'
1224
+			),
1225
+			'$VID:$'
1226
+		);
1227
+		Stats::optinText($extra);
1228
+	}
1229
+
1230
+	/**
1231
+	 * This is a handy helper method for retrieving whether there is an update available for the given plugin.
1232
+	 *
1233
+	 * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
1234
+	 *                          identify plugins. Defaults to core update
1235
+	 * @return boolean           True if update available, false if not.
1236
+	 * @deprecated $VID:$
1237
+	 */
1238
+	public static function is_update_available($basename = '')
1239
+	{
1240
+		EE_Error::doing_it_wrong(
1241
+			__METHOD__,
1242
+			sprintf(
1243
+				esc_html__('%1$s has been replaced by %2$s.', 'event_espresso'),
1244
+				__METHOD__,
1245
+				'EventEspresso\core\services\licensing\LicenseService::isUpdateAvailable'
1246
+			),
1247
+			'$VID:$'
1248
+		);
1249
+		return LicenseService::isUpdateAvailable($basename);
1250
+	}
1251 1251
 }
1252 1252
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -4,8 +4,8 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\interfaces\InterminableInterface;
5 5
 use EventEspresso\core\services\licensing\LicenseService;
6 6
 
7
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
8
-	exit( 'No direct script access allowed' );
7
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
8
+	exit('No direct script access allowed');
9 9
 }
10 10
 /**
11 11
  * ************************************************************************
@@ -48,8 +48,8 @@  discard block
 block discarded – undo
48 48
 	$action_or_filter = 'action'
49 49
 ) {
50 50
 	$action_or_filter = $action_or_filter === 'action'
51
-		? esc_html__( 'action', 'event_espresso' )
52
-		: esc_html__( 'filter', 'event_espresso' );
51
+		? esc_html__('action', 'event_espresso')
52
+		: esc_html__('filter', 'event_espresso');
53 53
 	EE_Error::doing_it_wrong(
54 54
 		$deprecated_filter,
55 55
 		sprintf(
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
  * @param \EE_Checkout $checkout
74 74
  * @return string
75 75
  */
76
-function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) {
76
+function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) {
77 77
 	// list of old filters
78 78
 	$deprecated_filters = array(
79 79
 		'update_registration_details' => true,
@@ -83,16 +83,16 @@  discard block
 block discarded – undo
83 83
 		'proceed_to' => true,
84 84
 	);
85 85
 	// loop thru and call doing_it_wrong() or remove any that aren't being used
86
-	foreach ( $deprecated_filters as $deprecated_filter => $on ) {
86
+	foreach ($deprecated_filters as $deprecated_filter => $on) {
87 87
 		// was this filter called ?
88
-		if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) {
88
+		if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) {
89 89
 			// only display doing_it_wrong() notice to Event Admins during non-AJAX requests
90
-			if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) {
90
+			if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) {
91 91
 				EE_Error::doing_it_wrong(
92
-					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
92
+					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter,
93 93
 					sprintf(
94
-						__( 'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ),
95
-						'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
94
+						__('The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'),
95
+						'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter,
96 96
 						'<br />',
97 97
 						'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
98 98
 						'/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
@@ -101,24 +101,24 @@  discard block
 block discarded – undo
101 101
 				);
102 102
 			}
103 103
 		} else {
104
-			unset( $deprecated_filters[ $deprecated_filter ] );
104
+			unset($deprecated_filters[$deprecated_filter]);
105 105
 		}
106 106
 	}
107
-	if ( ! empty( $deprecated_filters )) {
108
-
109
-		if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) {
110
-			$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text );
111
-		} else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) {
112
-			$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text );
113
-		} else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) {
114
-			$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text );
107
+	if ( ! empty($deprecated_filters)) {
108
+
109
+		if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
110
+			$submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text);
111
+		} else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) {
112
+			$submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text);
113
+		} else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) {
114
+			$submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text);
115 115
 		}
116
-		if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) {
117
-			if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) {
118
-				$submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text );
116
+		if ($checkout->next_step instanceof EE_SPCO_Reg_Step) {
117
+			if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) {
118
+				$submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text);
119 119
 			}
120
-			if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) {
121
-				$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name();
120
+			if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) {
121
+				$submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name();
122 122
 			}
123 123
 		}
124 124
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	return $submit_button_text;
127 127
 
128 128
 }
129
-add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 );
129
+add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2);
130 130
 
131 131
 
132 132
 
@@ -137,16 +137,16 @@  discard block
 block discarded – undo
137 137
  * @param \EE_Checkout $checkout
138 138
  * @param boolean $status_updates
139 139
  */
140
-function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) {
140
+function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) {
141 141
 	$action_ref = NULL;
142
-	$action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
143
-	$action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
144
-	if ( $action_ref ) {
142
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
143
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
144
+	if ($action_ref) {
145 145
 
146 146
 		EE_Error::doing_it_wrong(
147 147
 			$action_ref,
148 148
 			sprintf(
149
-				__( 'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ),
149
+				__('This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'),
150 150
 				'<br />',
151 151
 				'/core/business/EE_Transaction_Processor.class.php',
152 152
 				'AHEE__EE_Transaction_Processor__finalize',
@@ -156,39 +156,39 @@  discard block
 block discarded – undo
156 156
 			),
157 157
 			'4.6.0'
158 158
 		);
159
-		switch ( $action_ref ) {
159
+		switch ($action_ref) {
160 160
 			case 'AHEE__EE_Transaction__finalize__new_transaction' :
161
-				do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request );
161
+				do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request);
162 162
 				break;
163 163
 			case 'AHEE__EE_Transaction__finalize__all_transaction' :
164
-				do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request );
164
+				do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request);
165 165
 				break;
166 166
 		}
167 167
 	}
168 168
 }
169
-add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 );
169
+add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2);
170 170
 /**
171 171
  * ee_deprecated_finalize_registration
172 172
  *
173 173
  * @param EE_Registration $registration
174 174
  */
175
-function ee_deprecated_finalize_registration( EE_Registration $registration ) {
176
-	$action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL;
177
-	if ( $action_ref ) {
175
+function ee_deprecated_finalize_registration(EE_Registration $registration) {
176
+	$action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL;
177
+	if ($action_ref) {
178 178
 		EE_Error::doing_it_wrong(
179 179
 			$action_ref,
180 180
 			sprintf(
181
-				__( 'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ),
181
+				__('This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'),
182 182
 				'<br />',
183 183
 				'/core/business/EE_Registration_Processor.class.php',
184 184
 				'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook'
185 185
 			),
186 186
 			'4.6.0'
187 187
 		);
188
-		do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )));
188
+		do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX)));
189 189
 	}
190 190
 }
191
-add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 );
191
+add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1);
192 192
 
193 193
 
194 194
 
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
  * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called.
197 197
  * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately.
198 198
  */
199
-function ee_deprecated_hooks(){
199
+function ee_deprecated_hooks() {
200 200
 	/**
201 201
 	 * @var $hooks array where keys are hook names, and their values are array{
202 202
 	 *			@type string $version  when deprecated
@@ -207,25 +207,25 @@  discard block
 block discarded – undo
207 207
 	$hooks = array(
208 208
 		'AHEE__EE_System___do_setup_validations' => array(
209 209
 			'version' => '4.6.0',
210
-			'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ),
210
+			'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'),
211 211
 			'still_works' => FALSE
212 212
 		)
213 213
 	);
214
-	foreach( $hooks as $name => $deprecation_info ){
215
-		if( has_action( $name ) ){
214
+	foreach ($hooks as $name => $deprecation_info) {
215
+		if (has_action($name)) {
216 216
 			EE_Error::doing_it_wrong(
217 217
 				$name,
218 218
 				sprintf(
219
-					__('This filter is deprecated. %1$s%2$s','event_espresso'),
220
-					$deprecation_info[ 'still_works' ] ?  __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ),
221
-					isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' )
219
+					__('This filter is deprecated. %1$s%2$s', 'event_espresso'),
220
+					$deprecation_info['still_works'] ?  __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'),
221
+					isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso')
222 222
 				),
223
-				isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' )
223
+				isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso')
224 224
 			);
225 225
 		}
226 226
 	}
227 227
 }
228
-add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' );
228
+add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks');
229 229
 
230 230
 
231 231
 
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
  * @return boolean
237 237
  */
238 238
 function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() {
239
-	$in_use =  has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' )
240
-			|| has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' );
241
-	if( $in_use ) {
239
+	$in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns')
240
+			|| has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save');
241
+	if ($in_use) {
242 242
 		$msg = __(
243 243
 			'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
244 244
 			. 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
@@ -247,18 +247,18 @@  discard block
 block discarded – undo
247 247
 			'event_espresso' )
248 248
 		;
249 249
 		EE_Error::doing_it_wrong(
250
-			__CLASS__ . '::' . __FUNCTION__,
250
+			__CLASS__.'::'.__FUNCTION__,
251 251
 			$msg,
252 252
 			'4.8.32.rc.000'
253 253
 		);
254 254
 		//it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
255
-		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
256
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
255
+		if (is_admin() && ! defined('DOING_AJAX')) {
256
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
257 257
 		}
258 258
 	}
259 259
 	return $in_use;
260 260
 }
261
-add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' );
261
+add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks');
262 262
 
263 263
 /**
264 264
  * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165
@@ -267,34 +267,34 @@  discard block
 block discarded – undo
267 267
  * @param EE_Admin_Page $admin_page
268 268
  * @return void
269 269
  */
270
-function ee_deprecated_update_attendee_registration_form_old( $admin_page ) {
270
+function ee_deprecated_update_attendee_registration_form_old($admin_page) {
271 271
 	//check if the old hooks are in use. If not, do the default
272
-	if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
273
-		|| ! $admin_page instanceof EE_Admin_Page ) {
272
+	if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
273
+		|| ! $admin_page instanceof EE_Admin_Page) {
274 274
 		return;
275 275
 	}
276 276
 	$req_data = $admin_page->get_request_data();
277
-	$qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE;
278
-	$REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE;
279
-	$qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns );
280
-	if ( ! $REG_ID || ! $qstns ) {
281
-		EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
277
+	$qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE;
278
+	$REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE;
279
+	$qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
280
+	if ( ! $REG_ID || ! $qstns) {
281
+		EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
282 282
 	}
283 283
 	$success = TRUE;
284 284
 
285 285
 	// allow others to get in on this awesome fun   :D
286
-	do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns );
286
+	do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns);
287 287
 	// loop thru questions... FINALLY!!!
288 288
 
289
-	foreach ( $qstns as $QST_ID => $qstn ) {
289
+	foreach ($qstns as $QST_ID => $qstn) {
290 290
 		//if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
291
-		if ( !is_array($qstn) ) {
292
-			$success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn);
291
+		if ( ! is_array($qstn)) {
292
+			$success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
293 293
 			continue;
294 294
 		}
295 295
 
296 296
 
297
-		foreach ( $qstn as $ANS_ID => $ANS_value ) {
297
+		foreach ($qstn as $ANS_ID => $ANS_value) {
298 298
 			//get answer
299 299
 			$query_params = array(
300 300
 				0 => array(
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 				);
306 306
 			$answer = EEM_Answer::instance()->get_one($query_params);
307 307
 			//this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
308
-			if ( ! $answer instanceof EE_Answer ) {
308
+			if ( ! $answer instanceof EE_Answer) {
309 309
 				$set_values = array(
310 310
 					'QST_ID' => $QST_ID,
311 311
 					'REG_ID' => $REG_ID,
@@ -320,11 +320,11 @@  discard block
 block discarded – undo
320 320
 		}
321 321
 	}
322 322
 	$what = __('Registration Form', 'event_espresso');
323
-	$route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' );
324
-	$admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route );
323
+	$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
324
+	$admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
325 325
 	exit;
326 326
 }
327
-add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 );
327
+add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1);
328 328
 /**
329 329
  * Render the registration admin page's custom questions area in the old fashion
330 330
  * and firing the old hooks. When this method is removed, we can probably also
@@ -337,31 +337,31 @@  discard block
 block discarded – undo
337 337
  * @return bool
338 338
  * @throws \EE_Error
339 339
  */
340
-function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) {
340
+function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) {
341 341
 	//check if the old hooks are in use. If not, do the default
342
-	if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
343
-		|| ! $admin_page instanceof EE_Admin_Page ) {
342
+	if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
343
+		|| ! $admin_page instanceof EE_Admin_Page) {
344 344
 		return $do_default_action;
345 345
 	}
346
-	add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 );
347
-	add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 );
348
-	add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 );
349
-	add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 );
346
+	add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1);
347
+	add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1);
348
+	add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1);
349
+	add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1);
350 350
 
351
-	$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') );
351
+	$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID'));
352 352
 
353
-	EE_Registry::instance()->load_helper( 'Form_Fields' );
353
+	EE_Registry::instance()->load_helper('Form_Fields');
354 354
 	$template_args = array(
355
-		'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ),
355
+		'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups),
356 356
 		'reg_questions_form_action' => 'edit_registration',
357 357
 		'REG_ID' => $registration->ID()
358 358
 	);
359
-	$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
360
-	echo EEH_Template::display_template( $template_path, $template_args, TRUE );
359
+	$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
360
+	echo EEH_Template::display_template($template_path, $template_args, TRUE);
361 361
 	//indicate that we should not do the default admin page code
362 362
 	return false;
363 363
 }
364
-add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 );
364
+add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3);
365 365
 
366 366
 
367 367
 
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
 			'4.9.0'
403 403
 		);
404 404
 		/** @var EE_Message_Resource_Manager $message_resource_manager */
405
-		$message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
406
-		$messenger = $message_resource_manager->get_messenger( $messenger_name );
407
-		$message_type = $message_resource_manager->get_message_type( $message_type_name );
405
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
406
+		$messenger = $message_resource_manager->get_messenger($messenger_name);
407
+		$message_type = $message_resource_manager->get_message_type($message_type_name);
408 408
 		return EE_Registry::instance()->load_lib(
409 409
 			'Messages_Template_Defaults',
410 410
 			array(
@@ -469,15 +469,15 @@  discard block
 block discarded – undo
469 469
 	/**
470 470
 	 * @param string $method
471 471
 	 */
472
-	public function _class_is_deprecated( $method ) {
472
+	public function _class_is_deprecated($method) {
473 473
 		EE_Error::doing_it_wrong(
474
-			'EE_messages::' . $method,
475
-			__( 'EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.' ),
474
+			'EE_messages::'.$method,
475
+			__('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
476 476
 			'4.9.0',
477 477
 			'4.10.0.p'
478 478
 		);
479 479
 		// Please use EE_Message_Resource_Manager instead
480
-		$this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
480
+		$this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
481 481
 	}
482 482
 
483 483
 
@@ -487,10 +487,10 @@  discard block
 block discarded – undo
487 487
 	 * @param string $messenger_name
488 488
 	 * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
489 489
 	 */
490
-	public function ensure_messenger_is_active( $messenger_name ) {
490
+	public function ensure_messenger_is_active($messenger_name) {
491 491
 		// EE_messages has been deprecated
492
-		$this->_class_is_deprecated( __FUNCTION__ );
493
-		return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name );
492
+		$this->_class_is_deprecated(__FUNCTION__);
493
+		return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name);
494 494
 	}
495 495
 
496 496
 
@@ -502,10 +502,10 @@  discard block
 block discarded – undo
502 502
 	 * @return bool true if it got activated (or was active) and false if not.
503 503
 	 * @throws \EE_Error
504 504
 	 */
505
-	public function ensure_message_type_is_active( $message_type, $messenger ) {
505
+	public function ensure_message_type_is_active($message_type, $messenger) {
506 506
 		// EE_messages has been deprecated
507
-		$this->_class_is_deprecated( __FUNCTION__ );
508
-		return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger );
507
+		$this->_class_is_deprecated(__FUNCTION__);
508
+		return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger);
509 509
 	}
510 510
 
511 511
 
@@ -518,10 +518,10 @@  discard block
 block discarded – undo
518 518
 	 *                                            they are already setup.)
519 519
 	 * @return boolean an array of generated templates or false if nothing generated/activated.
520 520
 	 */
521
-	public function activate_messenger( $messenger_name, $mts_to_activate = array() ) {
521
+	public function activate_messenger($messenger_name, $mts_to_activate = array()) {
522 522
 		// EE_messages has been deprecated
523
-		$this->_class_is_deprecated( __FUNCTION__ );
524
-		return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate );
523
+		$this->_class_is_deprecated(__FUNCTION__);
524
+		return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate);
525 525
 	}
526 526
 
527 527
 
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 *
534 534
 	 * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
535 535
 	 */
536
-	public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) {
536
+	public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) {
537 537
 		// EE_messages has been deprecated
538
-		$this->_class_is_deprecated( __FUNCTION__ );
539
-		return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type );
538
+		$this->_class_is_deprecated(__FUNCTION__);
539
+		return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type);
540 540
 	}
541 541
 
542 542
 
@@ -546,10 +546,10 @@  discard block
 block discarded – undo
546 546
 	 * @param string $messenger
547 547
 	 * @return EE_messenger | null
548 548
 	 */
549
-	public function get_messenger_if_active( $messenger ) {
549
+	public function get_messenger_if_active($messenger) {
550 550
 		// EE_messages has been deprecated
551
-		$this->_class_is_deprecated( __FUNCTION__ );
552
-		return $this->_message_resource_manager->get_active_messenger( $messenger );
551
+		$this->_class_is_deprecated(__FUNCTION__);
552
+		return $this->_message_resource_manager->get_active_messenger($messenger);
553 553
 	}
554 554
 
555 555
 
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
 	 *                  'message_type' => null
571 571
 	 *                  )
572 572
 	 */
573
-	public function validate_for_use( EE_Message $message ) {
573
+	public function validate_for_use(EE_Message $message) {
574 574
 		// EE_messages has been deprecated
575
-		$this->_class_is_deprecated( __FUNCTION__ );
575
+		$this->_class_is_deprecated(__FUNCTION__);
576 576
 		return array(
577 577
 			'messenger'    => $message->messenger_object(),
578 578
 			'message_type' => $message->message_type_object(),
@@ -600,41 +600,41 @@  discard block
 block discarded – undo
600 600
 		$send = true
601 601
 	) {
602 602
 		// EE_messages has been deprecated
603
-		$this->_class_is_deprecated( __FUNCTION__ );
603
+		$this->_class_is_deprecated(__FUNCTION__);
604 604
 		/** @type EE_Messages_Processor $processor */
605
-		$processor = EE_Registry::instance()->load_lib( 'Messages_Processor' );
605
+		$processor = EE_Registry::instance()->load_lib('Messages_Processor');
606 606
 		$error = false;
607 607
 		//try to intelligently determine what method we'll call based on the incoming data.
608 608
 		//if generating and sending are different then generate and send immediately.
609
-		if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) {
609
+		if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
610 610
 			//in the legacy system, when generating and sending were different, that means all the
611 611
 			//vars are already in the request object.  So let's just use that.
612 612
 			try {
613 613
 				/** @type EE_Message_To_Generate_From_Request $mtg */
614
-				$mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' );
615
-				$processor->generate_and_send_now( $mtg );
616
-			} catch ( EE_Error $e ) {
614
+				$mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
615
+				$processor->generate_and_send_now($mtg);
616
+			} catch (EE_Error $e) {
617 617
 				$error_msg = __(
618 618
 					'Please note that a system message failed to send due to a technical issue.',
619 619
 					'event_espresso'
620 620
 				);
621 621
 				// add specific message for developers if WP_DEBUG in on
622
-				$error_msg .= '||' . $e->getMessage();
623
-				EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
622
+				$error_msg .= '||'.$e->getMessage();
623
+				EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
624 624
 				$error = true;
625 625
 			}
626 626
 		} else {
627
-			$processor->generate_for_all_active_messengers( $type, $vars, $send );
627
+			$processor->generate_for_all_active_messengers($type, $vars, $send);
628 628
 			//let's find out if there were any errors and how many successfully were queued.
629 629
 			$count_errors = $processor->get_queue()->count_STS_in_queue(
630
-				array( EEM_Message::status_failed, EEM_Message::status_debug_only )
630
+				array(EEM_Message::status_failed, EEM_Message::status_debug_only)
631 631
 			);
632
-			$count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete );
633
-			$count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry );
632
+			$count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
633
+			$count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry);
634 634
 			$count_errors = $count_errors + $count_retry;
635
-			if ( $count_errors > 0 ) {
635
+			if ($count_errors > 0) {
636 636
 				$error = true;
637
-				if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) {
637
+				if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) {
638 638
 					$message = sprintf(
639 639
 						__(
640 640
 							'There were %d errors and %d messages successfully queued for generation and sending',
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 						$count_errors,
644 644
 						$count_queued
645 645
 					);
646
-				} elseif ( $count_errors > 1 && $count_queued === 1 ) {
646
+				} elseif ($count_errors > 1 && $count_queued === 1) {
647 647
 					$message = sprintf(
648 648
 						__(
649 649
 							'There were %d errors and %d message successfully queued for generation.',
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 						$count_errors,
653 653
 						$count_queued
654 654
 					);
655
-				} elseif ( $count_errors === 1 && $count_queued > 1 ) {
655
+				} elseif ($count_errors === 1 && $count_queued > 1) {
656 656
 					$message = sprintf(
657 657
 						__(
658 658
 							'There was %d error and %d messages successfully queued for generation.',
@@ -670,9 +670,9 @@  discard block
 block discarded – undo
670 670
 						$count_errors
671 671
 					);
672 672
 				}
673
-				EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ );
673
+				EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__);
674 674
 			} else {
675
-				if ( $count_queued === 1 ) {
675
+				if ($count_queued === 1) {
676 676
 					$message = sprintf(
677 677
 						__(
678 678
 							'%d message successfully queued for generation.',
@@ -689,18 +689,18 @@  discard block
 block discarded – undo
689 689
 						$count_queued
690 690
 					);
691 691
 				}
692
-				EE_Error::add_success( $message );
692
+				EE_Error::add_success($message);
693 693
 			}
694 694
 		}
695 695
 		//if no error then return the generated message(s).
696
-		if ( ! $error && ! $send ) {
697
-			$generated_queue = $processor->generate_queue( false );
696
+		if ( ! $error && ! $send) {
697
+			$generated_queue = $processor->generate_queue(false);
698 698
 			//get message and return.
699 699
 			$generated_queue->get_message_repository()->rewind();
700 700
 			$messages = array();
701
-			while ( $generated_queue->get_message_repository()->valid() ) {
701
+			while ($generated_queue->get_message_repository()->valid()) {
702 702
 				$message = $generated_queue->get_message_repository()->current();
703
-				if ( $message instanceof EE_Message ) {
703
+				if ($message instanceof EE_Message) {
704 704
 					//set properties that might be expected by add-ons (backward compat)
705 705
 					$message->content = $message->content();
706 706
 					$message->template_pack = $message->get_template_pack();
@@ -725,10 +725,10 @@  discard block
 block discarded – undo
725 725
 	 * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular preview
726 726
 	 * @return string          The body of the message.
727 727
 	 */
728
-	public function preview_message( $type, $context, $messenger, $send = false ) {
728
+	public function preview_message($type, $context, $messenger, $send = false) {
729 729
 		// EE_messages has been deprecated
730
-		$this->_class_is_deprecated( __FUNCTION__ );
731
-		return EED_Messages::preview_message( $type, $context, $messenger, $send );
730
+		$this->_class_is_deprecated(__FUNCTION__);
731
+		return EED_Messages::preview_message($type, $context, $messenger, $send);
732 732
 	}
733 733
 
734 734
 
@@ -742,14 +742,14 @@  discard block
 block discarded – undo
742 742
 	 *
743 743
 	 * @return bool          success or fail.
744 744
 	 */
745
-	public function send_message_with_messenger_only( $messenger, $message_type, $message ) {
745
+	public function send_message_with_messenger_only($messenger, $message_type, $message) {
746 746
 		// EE_messages has been deprecated
747
-		$this->_class_is_deprecated( __FUNCTION__ );
747
+		$this->_class_is_deprecated(__FUNCTION__);
748 748
 		//setup for sending to new method.
749 749
 		/** @type EE_Messages_Queue $queue */
750
-		$queue = EE_Registry::instance()->load_lib( 'Messages_Queue' );
750
+		$queue = EE_Registry::instance()->load_lib('Messages_Queue');
751 751
 		//make sure we have a proper message object
752
-		if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) {
752
+		if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
753 753
 			$msg = EE_Message_Factory::create(
754 754
 				array(
755 755
 					'MSG_messenger'    => $messenger,
@@ -761,15 +761,15 @@  discard block
 block discarded – undo
761 761
 		} else {
762 762
 			$msg = $message;
763 763
 		}
764
-		if ( ! $msg instanceof EE_Message ) {
764
+		if ( ! $msg instanceof EE_Message) {
765 765
 			return false;
766 766
 		}
767 767
 		//make sure any content in a content property (if not empty) is set on the MSG_content.
768
-		if ( ! empty( $msg->content ) ) {
769
-			$msg->set( 'MSG_content', $msg->content );
768
+		if ( ! empty($msg->content)) {
769
+			$msg->set('MSG_content', $msg->content);
770 770
 		}
771
-		$queue->add( $msg );
772
-		return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue );
771
+		$queue->add($msg);
772
+		return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue);
773 773
 	}
774 774
 
775 775
 
@@ -783,11 +783,11 @@  discard block
 block discarded – undo
783 783
 	 * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned.
784 784
 	 * @throws \EE_Error
785 785
 	 */
786
-	public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) {
786
+	public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) {
787 787
 		// EE_messages has been deprecated
788
-		$this->_class_is_deprecated( __FUNCTION__ );
789
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
790
-		return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global );
788
+		$this->_class_is_deprecated(__FUNCTION__);
789
+		EE_Registry::instance()->load_helper('MSG_Template');
790
+		return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global);
791 791
 	}
792 792
 
793 793
 
@@ -798,11 +798,11 @@  discard block
 block discarded – undo
798 798
 	 * @param  string $message_type_name name of EE_message_type
799 799
 	 * @return array
800 800
 	 */
801
-	public function get_fields( $messenger_name, $message_type_name ) {
801
+	public function get_fields($messenger_name, $message_type_name) {
802 802
 		// EE_messages has been deprecated
803
-		$this->_class_is_deprecated( __FUNCTION__ );
804
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
805
-		return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name );
803
+		$this->_class_is_deprecated(__FUNCTION__);
804
+		EE_Registry::instance()->load_helper('MSG_Template');
805
+		return EEH_MSG_Template::get_fields($messenger_name, $message_type_name);
806 806
 	}
807 807
 
808 808
 
@@ -816,13 +816,13 @@  discard block
 block discarded – undo
816 816
 	 * @return array                    multidimensional array of messenger and message_type objects
817 817
 	 *                                    (messengers index, and message_type index);
818 818
 	 */
819
-	public function get_installed( $type = 'all', $skip_cache = false ) {
819
+	public function get_installed($type = 'all', $skip_cache = false) {
820 820
 		// EE_messages has been deprecated
821
-		$this->_class_is_deprecated( __FUNCTION__ );
822
-		if ( $skip_cache ) {
821
+		$this->_class_is_deprecated(__FUNCTION__);
822
+		if ($skip_cache) {
823 823
 			$this->_message_resource_manager->reset_active_messengers_and_message_types();
824 824
 		}
825
-		switch ( $type ) {
825
+		switch ($type) {
826 826
 			case 'messengers' :
827 827
 				return array(
828 828
 					'messenger' => $this->_message_resource_manager->installed_messengers(),
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 	 */
852 852
 	public function get_active_messengers() {
853 853
 		// EE_messages has been deprecated
854
-		$this->_class_is_deprecated( __FUNCTION__ );
854
+		$this->_class_is_deprecated(__FUNCTION__);
855 855
 		return $this->_message_resource_manager->active_messengers();
856 856
 	}
857 857
 
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 	 */
864 864
 	public function get_active_message_types() {
865 865
 		// EE_messages has been deprecated
866
-		$this->_class_is_deprecated( __FUNCTION__ );
866
+		$this->_class_is_deprecated(__FUNCTION__);
867 867
 		return $this->_message_resource_manager->list_of_active_message_types();
868 868
 	}
869 869
 
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 	 */
876 876
 	public function get_active_message_type_objects() {
877 877
 		// EE_messages has been deprecated
878
-		$this->_class_is_deprecated( __FUNCTION__ );
878
+		$this->_class_is_deprecated(__FUNCTION__);
879 879
 		return $this->_message_resource_manager->get_active_message_type_objects();
880 880
 	}
881 881
 
@@ -887,10 +887,10 @@  discard block
 block discarded – undo
887 887
 	 * @param string $messenger The messenger being checked
888 888
 	 * @return EE_message_type[]    (or empty array if none present)
889 889
 	 */
890
-	public function get_active_message_types_per_messenger( $messenger ) {
890
+	public function get_active_message_types_per_messenger($messenger) {
891 891
 		// EE_messages has been deprecated
892
-		$this->_class_is_deprecated( __FUNCTION__ );
893
-		return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger );
892
+		$this->_class_is_deprecated(__FUNCTION__);
893
+		return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger);
894 894
 	}
895 895
 
896 896
 
@@ -901,10 +901,10 @@  discard block
 block discarded – undo
901 901
 	 * @param string $message_type The string should correspond to a message type.
902 902
 	 * @return EE_message_type|null
903 903
 	 */
904
-	public function get_active_message_type( $messenger, $message_type ) {
904
+	public function get_active_message_type($messenger, $message_type) {
905 905
 		// EE_messages has been deprecated
906
-		$this->_class_is_deprecated( __FUNCTION__ );
907
-		return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type );
906
+		$this->_class_is_deprecated(__FUNCTION__);
907
+		return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type);
908 908
 	}
909 909
 
910 910
 
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 	 */
916 916
 	public function get_installed_message_types() {
917 917
 		// EE_messages has been deprecated
918
-		$this->_class_is_deprecated( __FUNCTION__ );
918
+		$this->_class_is_deprecated(__FUNCTION__);
919 919
 		return $this->_message_resource_manager->installed_message_types();
920 920
 	}
921 921
 
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 	 */
928 928
 	public function get_installed_messengers() {
929 929
 		// EE_messages has been deprecated
930
-		$this->_class_is_deprecated( __FUNCTION__ );
930
+		$this->_class_is_deprecated(__FUNCTION__);
931 931
 		return $this->_message_resource_manager->installed_messengers();
932 932
 	}
933 933
 
@@ -938,10 +938,10 @@  discard block
 block discarded – undo
938 938
 	 * @param   bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type.
939 939
 	 * @return array
940 940
 	 */
941
-	public function get_all_contexts( $slugs_only = true ) {
941
+	public function get_all_contexts($slugs_only = true) {
942 942
 		// EE_messages has been deprecated
943
-		$this->_class_is_deprecated( __FUNCTION__ );
944
-		return $this->_message_resource_manager->get_all_contexts( $slugs_only );
943
+		$this->_class_is_deprecated(__FUNCTION__);
944
+		return $this->_message_resource_manager->get_all_contexts($slugs_only);
945 945
 	}
946 946
 
947 947
 
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
 add_filter(
1001 1001
 	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
1002 1002
 	function($event_list_iframe_css) {
1003
-		if ( ! has_filter( 'FHEE__EventsArchiveIframe__event_list_iframe__css' )) {
1003
+		if ( ! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
1004 1004
 			return $event_list_iframe_css;
1005 1005
 		}
1006 1006
 		deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
 add_filter(
1021 1021
 	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1022 1022
 	function($event_list_iframe_js) {
1023
-		if ( ! has_filter( 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js' )) {
1023
+		if ( ! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1024 1024
 			return $event_list_iframe_js;
1025 1025
 		}
1026 1026
 		deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 add_action(
1041 1041
 	'AHEE__EE_Capabilities__addCaps__complete',
1042 1042
 	function($capabilities_map) {
1043
-		if ( ! has_action( 'AHEE__EE_Capabilities__init_role_caps__complete' )) {
1043
+		if ( ! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1044 1044
 			return;
1045 1045
 		}
1046 1046
 		deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 add_filter(
1061 1061
 	'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1062 1062
 	function($existing_attendee, $registration, $attendee_data) {
1063
-		if ( ! has_filter( 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee' )) {
1063
+		if ( ! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1064 1064
 			return $existing_attendee;
1065 1065
 		}
1066 1066
 		deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
             $existing_attendee, $registration, $attendee_data
1077 1077
         );
1078 1078
 	},
1079
-	10,3
1079
+	10, 3
1080 1080
 );
1081 1081
 
1082 1082
 /**
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
      */
1141 1141
     public function event_list_title($event_list_title = '')
1142 1142
     {
1143
-        if (! empty($this->title)) {
1143
+        if ( ! empty($this->title)) {
1144 1144
             return $this->title;
1145 1145
         }
1146 1146
         return $event_list_title;
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Indentation   +3075 added lines, -3075 removed lines patch added patch discarded remove patch
@@ -17,2457 +17,2457 @@  discard block
 block discarded – undo
17 17
 final class EE_Config implements ResettableInterface
18 18
 {
19 19
 
20
-    const OPTION_NAME        = 'ee_config';
20
+	const OPTION_NAME        = 'ee_config';
21
+
22
+	const LOG_NAME           = 'ee_config_log';
23
+
24
+	const LOG_LENGTH         = 100;
25
+
26
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
27
+
28
+
29
+	/**
30
+	 *    instance of the EE_Config object
31
+	 *
32
+	 * @var    EE_Config $_instance
33
+	 * @access    private
34
+	 */
35
+	private static $_instance;
36
+
37
+	/**
38
+	 * @var boolean $_logging_enabled
39
+	 */
40
+	private static $_logging_enabled = false;
41
+
42
+	/**
43
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
+	 */
45
+	private $legacy_shortcodes_manager;
46
+
47
+	/**
48
+	 * An StdClass whose property names are addon slugs,
49
+	 * and values are their config classes
50
+	 *
51
+	 * @var StdClass
52
+	 */
53
+	public $addons;
54
+
55
+	/**
56
+	 * @var EE_Admin_Config
57
+	 */
58
+	public $admin;
59
+
60
+	/**
61
+	 * @var EE_Core_Config
62
+	 */
63
+	public $core;
64
+
65
+	/**
66
+	 * @var EE_Currency_Config
67
+	 */
68
+	public $currency;
69
+
70
+	/**
71
+	 * @var EE_Organization_Config
72
+	 */
73
+	public $organization;
74
+
75
+	/**
76
+	 * @var EE_Registration_Config
77
+	 */
78
+	public $registration;
79
+
80
+	/**
81
+	 * @var EE_Template_Config
82
+	 */
83
+	public $template_settings;
84
+
85
+	/**
86
+	 * Holds EE environment values.
87
+	 *
88
+	 * @var EE_Environment_Config
89
+	 */
90
+	public $environment;
91
+
92
+	/**
93
+	 * settings pertaining to Google maps
94
+	 *
95
+	 * @var EE_Map_Config
96
+	 */
97
+	public $map_settings;
98
+
99
+	/**
100
+	 * settings pertaining to Taxes
101
+	 *
102
+	 * @var EE_Tax_Config
103
+	 */
104
+	public $tax_settings;
105
+
106
+
107
+	/**
108
+	 * Settings pertaining to global messages settings.
109
+	 *
110
+	 * @var EE_Messages_Config
111
+	 */
112
+	public $messages;
113
+
114
+	/**
115
+	 * @deprecated
116
+	 * @var EE_Gateway_Config
117
+	 */
118
+	public $gateway;
119
+
120
+	/**
121
+	 * @var    array $_addon_option_names
122
+	 * @access    private
123
+	 */
124
+	private $_addon_option_names = array();
125
+
126
+	/**
127
+	 * @var    array $_module_route_map
128
+	 * @access    private
129
+	 */
130
+	private static $_module_route_map = array();
131
+
132
+	/**
133
+	 * @var    array $_module_forward_map
134
+	 * @access    private
135
+	 */
136
+	private static $_module_forward_map = array();
137
+
138
+	/**
139
+	 * @var    array $_module_view_map
140
+	 * @access    private
141
+	 */
142
+	private static $_module_view_map = array();
143
+
144
+
145
+
146
+	/**
147
+	 * @singleton method used to instantiate class object
148
+	 * @access    public
149
+	 * @return EE_Config instance
150
+	 */
151
+	public static function instance()
152
+	{
153
+		// check if class object is instantiated, and instantiated properly
154
+		if (! self::$_instance instanceof EE_Config) {
155
+			self::$_instance = new self();
156
+		}
157
+		return self::$_instance;
158
+	}
159
+
160
+
161
+
162
+	/**
163
+	 * Resets the config
164
+	 *
165
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
166
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
167
+	 *                               reflect its state in the database
168
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
169
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
170
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
171
+	 *                               site was put into maintenance mode)
172
+	 * @return EE_Config
173
+	 */
174
+	public static function reset($hard_reset = false, $reinstantiate = true)
175
+	{
176
+		if (self::$_instance instanceof EE_Config) {
177
+			if ($hard_reset) {
178
+				self::$_instance->legacy_shortcodes_manager = null;
179
+				self::$_instance->_addon_option_names = array();
180
+				self::$_instance->_initialize_config();
181
+				self::$_instance->update_espresso_config();
182
+			}
183
+			self::$_instance->update_addon_option_names();
184
+		}
185
+		self::$_instance = null;
186
+		//we don't need to reset the static properties imo because those should
187
+		//only change when a module is added or removed. Currently we don't
188
+		//support removing a module during a request when it previously existed
189
+		if ($reinstantiate) {
190
+			return self::instance();
191
+		} else {
192
+			return null;
193
+		}
194
+	}
195
+
196
+
197
+
198
+	/**
199
+	 *    class constructor
200
+	 *
201
+	 * @access    private
202
+	 */
203
+	private function __construct()
204
+	{
205
+		do_action('AHEE__EE_Config__construct__begin', $this);
206
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
207
+		// setup empty config classes
208
+		$this->_initialize_config();
209
+		// load existing EE site settings
210
+		$this->_load_core_config();
211
+		// confirm everything loaded correctly and set filtered defaults if not
212
+		$this->_verify_config();
213
+		//  register shortcodes and modules
214
+		add_action(
215
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
216
+			array($this, 'register_shortcodes_and_modules'),
217
+			999
218
+		);
219
+		//  initialize shortcodes and modules
220
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
221
+		// register widgets
222
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
223
+		// shutdown
224
+		add_action('shutdown', array($this, 'shutdown'), 10);
225
+		// construct__end hook
226
+		do_action('AHEE__EE_Config__construct__end', $this);
227
+		// hardcoded hack
228
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
229
+	}
230
+
231
+
232
+
233
+	/**
234
+	 * @return boolean
235
+	 */
236
+	public static function logging_enabled()
237
+	{
238
+		return self::$_logging_enabled;
239
+	}
240
+
241
+
242
+
243
+	/**
244
+	 * use to get the current theme if needed from static context
245
+	 *
246
+	 * @return string current theme set.
247
+	 */
248
+	public static function get_current_theme()
249
+	{
250
+		return isset(self::$_instance->template_settings->current_espresso_theme)
251
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
252
+	}
253
+
254
+
255
+
256
+	/**
257
+	 *        _initialize_config
258
+	 *
259
+	 * @access private
260
+	 * @return void
261
+	 */
262
+	private function _initialize_config()
263
+	{
264
+		EE_Config::trim_log();
265
+		//set defaults
266
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
267
+		$this->addons = new stdClass();
268
+		// set _module_route_map
269
+		EE_Config::$_module_route_map = array();
270
+		// set _module_forward_map
271
+		EE_Config::$_module_forward_map = array();
272
+		// set _module_view_map
273
+		EE_Config::$_module_view_map = array();
274
+	}
275
+
276
+
277
+
278
+	/**
279
+	 *        load core plugin configuration
280
+	 *
281
+	 * @access private
282
+	 * @return void
283
+	 */
284
+	private function _load_core_config()
285
+	{
286
+		// load_core_config__start hook
287
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
288
+		$espresso_config = $this->get_espresso_config();
289
+		foreach ($espresso_config as $config => $settings) {
290
+			// load_core_config__start hook
291
+			$settings = apply_filters(
292
+				'FHEE__EE_Config___load_core_config__config_settings',
293
+				$settings,
294
+				$config,
295
+				$this
296
+			);
297
+			if (is_object($settings) && property_exists($this, $config)) {
298
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
299
+				//call configs populate method to ensure any defaults are set for empty values.
300
+				if (method_exists($settings, 'populate')) {
301
+					$this->{$config}->populate();
302
+				}
303
+				if (method_exists($settings, 'do_hooks')) {
304
+					$this->{$config}->do_hooks();
305
+				}
306
+			}
307
+		}
308
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
309
+			$this->update_espresso_config();
310
+		}
311
+		// load_core_config__end hook
312
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
313
+	}
314
+
315
+
316
+
317
+	/**
318
+	 *    _verify_config
319
+	 *
320
+	 * @access    protected
321
+	 * @return    void
322
+	 */
323
+	protected function _verify_config()
324
+	{
325
+		$this->core = $this->core instanceof EE_Core_Config
326
+			? $this->core
327
+			: new EE_Core_Config();
328
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
329
+		$this->organization = $this->organization instanceof EE_Organization_Config
330
+			? $this->organization
331
+			: new EE_Organization_Config();
332
+		$this->organization = apply_filters(
333
+			'FHEE__EE_Config___initialize_config__organization',
334
+			$this->organization
335
+		);
336
+		$this->currency = $this->currency instanceof EE_Currency_Config
337
+			? $this->currency
338
+			: new EE_Currency_Config();
339
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
340
+		$this->registration = $this->registration instanceof EE_Registration_Config
341
+			? $this->registration
342
+			: new EE_Registration_Config();
343
+		$this->registration = apply_filters(
344
+			'FHEE__EE_Config___initialize_config__registration',
345
+			$this->registration
346
+		);
347
+		$this->admin = $this->admin instanceof EE_Admin_Config
348
+			? $this->admin
349
+			: new EE_Admin_Config();
350
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
351
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
352
+			? $this->template_settings
353
+			: new EE_Template_Config();
354
+		$this->template_settings = apply_filters(
355
+			'FHEE__EE_Config___initialize_config__template_settings',
356
+			$this->template_settings
357
+		);
358
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
359
+			? $this->map_settings
360
+			: new EE_Map_Config();
361
+		$this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
362
+			$this->map_settings);
363
+		$this->environment = $this->environment instanceof EE_Environment_Config
364
+			? $this->environment
365
+			: new EE_Environment_Config();
366
+		$this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
367
+			$this->environment);
368
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
+			? $this->tax_settings
370
+			: new EE_Tax_Config();
371
+		$this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
372
+			$this->tax_settings);
373
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
374
+		$this->messages = $this->messages instanceof EE_Messages_Config
375
+			? $this->messages
376
+			: new EE_Messages_Config();
377
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
378
+			? $this->gateway
379
+			: new EE_Gateway_Config();
380
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
381
+		$this->legacy_shortcodes_manager = null;
382
+	}
383
+
384
+
385
+	/**
386
+	 *    get_espresso_config
387
+	 *
388
+	 * @access    public
389
+	 * @return    array of espresso config stuff
390
+	 */
391
+	public function get_espresso_config()
392
+	{
393
+		// grab espresso configuration
394
+		return apply_filters(
395
+			'FHEE__EE_Config__get_espresso_config__CFG',
396
+			get_option(EE_Config::OPTION_NAME, array())
397
+		);
398
+	}
399
+
400
+
401
+
402
+	/**
403
+	 *    double_check_config_comparison
404
+	 *
405
+	 * @access    public
406
+	 * @param string $option
407
+	 * @param        $old_value
408
+	 * @param        $value
409
+	 */
410
+	public function double_check_config_comparison($option = '', $old_value, $value)
411
+	{
412
+		// make sure we're checking the ee config
413
+		if ($option === EE_Config::OPTION_NAME) {
414
+			// run a loose comparison of the old value against the new value for type and properties,
415
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
416
+			if ($value != $old_value) {
417
+				// if they are NOT the same, then remove the hook,
418
+				// which means the subsequent update results will be based solely on the update query results
419
+				// the reason we do this is because, as stated above,
420
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
421
+				// this happens PRIOR to serialization and any subsequent update.
422
+				// If values are found to match their previous old value,
423
+				// then WP bails before performing any update.
424
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
425
+				// it just pulled from the db, with the one being passed to it (which will not match).
426
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
427
+				// MySQL MAY ALSO NOT perform the update because
428
+				// the string it sees in the db looks the same as the new one it has been passed!!!
429
+				// This results in the query returning an "affected rows" value of ZERO,
430
+				// which gets returned immediately by WP update_option and looks like an error.
431
+				remove_action('update_option', array($this, 'check_config_updated'));
432
+			}
433
+		}
434
+	}
435
+
436
+
437
+
438
+	/**
439
+	 *    update_espresso_config
440
+	 *
441
+	 * @access   public
442
+	 */
443
+	protected function _reset_espresso_addon_config()
444
+	{
445
+		$this->_addon_option_names = array();
446
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
447
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
448
+			if ($addon_config_obj instanceof EE_Config_Base) {
449
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
450
+			}
451
+			$this->addons->{$addon_name} = null;
452
+		}
453
+	}
454
+
455
+
456
+
457
+	/**
458
+	 *    update_espresso_config
459
+	 *
460
+	 * @access   public
461
+	 * @param   bool $add_success
462
+	 * @param   bool $add_error
463
+	 * @return   bool
464
+	 */
465
+	public function update_espresso_config($add_success = false, $add_error = true)
466
+	{
467
+		// don't allow config updates during WP heartbeats
468
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
+			return false;
470
+		}
471
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
+		//$clone = clone( self::$_instance );
473
+		//self::$_instance = NULL;
474
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
+		$this->_reset_espresso_addon_config();
476
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
+		// but BEFORE the actual update occurs
478
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
+		$this->legacy_shortcodes_manager = null;
482
+		// now update "ee_config"
483
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
484
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
+		EE_Config::log(EE_Config::OPTION_NAME);
486
+		// if not saved... check if the hook we just added still exists;
487
+		// if it does, it means one of two things:
488
+		// 		that update_option bailed at the ( $value === $old_value ) conditional,
489
+		//		 or...
490
+		// 		the db update query returned 0 rows affected
491
+		// 		(probably because the data  value was the same from it's perspective)
492
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
493
+		// but just means no update occurred, so don't display an error to the user.
494
+		// BUT... if update_option returns FALSE, AND the hook is missing,
495
+		// then it means that something truly went wrong
496
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
+		// remove our action since we don't want it in the system anymore
498
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
+		//self::$_instance = $clone;
501
+		//unset( $clone );
502
+		// if config remains the same or was updated successfully
503
+		if ($saved) {
504
+			if ($add_success) {
505
+				EE_Error::add_success(
506
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
+					__FILE__,
508
+					__FUNCTION__,
509
+					__LINE__
510
+				);
511
+			}
512
+			return true;
513
+		} else {
514
+			if ($add_error) {
515
+				EE_Error::add_error(
516
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
+					__FILE__,
518
+					__FUNCTION__,
519
+					__LINE__
520
+				);
521
+			}
522
+			return false;
523
+		}
524
+	}
525
+
526
+
527
+
528
+	/**
529
+	 *    _verify_config_params
530
+	 *
531
+	 * @access    private
532
+	 * @param    string         $section
533
+	 * @param    string         $name
534
+	 * @param    string         $config_class
535
+	 * @param    EE_Config_Base $config_obj
536
+	 * @param    array          $tests_to_run
537
+	 * @param    bool           $display_errors
538
+	 * @return    bool    TRUE on success, FALSE on fail
539
+	 */
540
+	private function _verify_config_params(
541
+		$section = '',
542
+		$name = '',
543
+		$config_class = '',
544
+		$config_obj = null,
545
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
+		$display_errors = true
547
+	) {
548
+		try {
549
+			foreach ($tests_to_run as $test) {
550
+				switch ($test) {
551
+					// TEST #1 : check that section was set
552
+					case 1 :
553
+						if (empty($section)) {
554
+							if ($display_errors) {
555
+								throw new EE_Error(
556
+									sprintf(
557
+										__(
558
+											'No configuration section has been provided while attempting to save "%s".',
559
+											'event_espresso'
560
+										),
561
+										$config_class
562
+									)
563
+								);
564
+							}
565
+							return false;
566
+						}
567
+						break;
568
+					// TEST #2 : check that settings section exists
569
+					case 2 :
570
+						if (! isset($this->{$section})) {
571
+							if ($display_errors) {
572
+								throw new EE_Error(
573
+									sprintf(
574
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
575
+										$section
576
+									)
577
+								);
578
+							}
579
+							return false;
580
+						}
581
+						break;
582
+					// TEST #3 : check that section is the proper format
583
+					case 3 :
584
+						if (
585
+						! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
+						) {
587
+							if ($display_errors) {
588
+								throw new EE_Error(
589
+									sprintf(
590
+										__(
591
+											'The "%s" configuration settings have not been formatted correctly.',
592
+											'event_espresso'
593
+										),
594
+										$section
595
+									)
596
+								);
597
+							}
598
+							return false;
599
+						}
600
+						break;
601
+					// TEST #4 : check that config section name has been set
602
+					case 4 :
603
+						if (empty($name)) {
604
+							if ($display_errors) {
605
+								throw new EE_Error(
606
+									__(
607
+										'No name has been provided for the specific configuration section.',
608
+										'event_espresso'
609
+									)
610
+								);
611
+							}
612
+							return false;
613
+						}
614
+						break;
615
+					// TEST #5 : check that a config class name has been set
616
+					case 5 :
617
+						if (empty($config_class)) {
618
+							if ($display_errors) {
619
+								throw new EE_Error(
620
+									__(
621
+										'No class name has been provided for the specific configuration section.',
622
+										'event_espresso'
623
+									)
624
+								);
625
+							}
626
+							return false;
627
+						}
628
+						break;
629
+					// TEST #6 : verify config class is accessible
630
+					case 6 :
631
+						if (! class_exists($config_class)) {
632
+							if ($display_errors) {
633
+								throw new EE_Error(
634
+									sprintf(
635
+										__(
636
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
+											'event_espresso'
638
+										),
639
+										$config_class
640
+									)
641
+								);
642
+							}
643
+							return false;
644
+						}
645
+						break;
646
+					// TEST #7 : check that config has even been set
647
+					case 7 :
648
+						if (! isset($this->{$section}->{$name})) {
649
+							if ($display_errors) {
650
+								throw new EE_Error(
651
+									sprintf(
652
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
+										$section,
654
+										$name
655
+									)
656
+								);
657
+							}
658
+							return false;
659
+						} else {
660
+							// and make sure it's not serialized
661
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
+						}
663
+						break;
664
+					// TEST #8 : check that config is the requested type
665
+					case 8 :
666
+						if (! $this->{$section}->{$name} instanceof $config_class) {
667
+							if ($display_errors) {
668
+								throw new EE_Error(
669
+									sprintf(
670
+										__(
671
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
+											'event_espresso'
673
+										),
674
+										$section,
675
+										$name,
676
+										$config_class
677
+									)
678
+								);
679
+							}
680
+							return false;
681
+						}
682
+						break;
683
+					// TEST #9 : verify config object
684
+					case 9 :
685
+						if (! $config_obj instanceof EE_Config_Base) {
686
+							if ($display_errors) {
687
+								throw new EE_Error(
688
+									sprintf(
689
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
+										print_r($config_obj, true)
691
+									)
692
+								);
693
+							}
694
+							return false;
695
+						}
696
+						break;
697
+				}
698
+			}
699
+		} catch (EE_Error $e) {
700
+			$e->get_error();
701
+		}
702
+		// you have successfully run the gauntlet
703
+		return true;
704
+	}
705
+
706
+
707
+
708
+	/**
709
+	 *    _generate_config_option_name
710
+	 *
711
+	 * @access        protected
712
+	 * @param        string $section
713
+	 * @param        string $name
714
+	 * @return        string
715
+	 */
716
+	private function _generate_config_option_name($section = '', $name = '')
717
+	{
718
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
+	}
720
+
721
+
722
+
723
+	/**
724
+	 *    _set_config_class
725
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
726
+	 *
727
+	 * @access    private
728
+	 * @param    string $config_class
729
+	 * @param    string $name
730
+	 * @return    string
731
+	 */
732
+	private function _set_config_class($config_class = '', $name = '')
733
+	{
734
+		return ! empty($config_class)
735
+			? $config_class
736
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
+	}
738
+
739
+
740
+
741
+	/**
742
+	 *    set_config
743
+	 *
744
+	 * @access    protected
745
+	 * @param    string         $section
746
+	 * @param    string         $name
747
+	 * @param    string         $config_class
748
+	 * @param    EE_Config_Base $config_obj
749
+	 * @return    EE_Config_Base
750
+	 */
751
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
+	{
753
+		// ensure config class is set to something
754
+		$config_class = $this->_set_config_class($config_class, $name);
755
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
756
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
+			return null;
758
+		}
759
+		$config_option_name = $this->_generate_config_option_name($section, $name);
760
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
+		if (! isset($this->_addon_option_names[$config_option_name])) {
762
+			$this->_addon_option_names[$config_option_name] = $config_class;
763
+			$this->update_addon_option_names();
764
+		}
765
+		// verify the incoming config object but suppress errors
766
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
+			$config_obj = new $config_class();
768
+		}
769
+		if (get_option($config_option_name)) {
770
+			EE_Config::log($config_option_name);
771
+			update_option($config_option_name, $config_obj);
772
+			$this->{$section}->{$name} = $config_obj;
773
+			return $this->{$section}->{$name};
774
+		} else {
775
+			// create a wp-option for this config
776
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
777
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
778
+				return $this->{$section}->{$name};
779
+			} else {
780
+				EE_Error::add_error(
781
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
+					__FILE__,
783
+					__FUNCTION__,
784
+					__LINE__
785
+				);
786
+				return null;
787
+			}
788
+		}
789
+	}
790
+
791
+
792
+
793
+	/**
794
+	 *    update_config
795
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
+	 *
797
+	 * @access    public
798
+	 * @param    string                $section
799
+	 * @param    string                $name
800
+	 * @param    EE_Config_Base|string $config_obj
801
+	 * @param    bool                  $throw_errors
802
+	 * @return    bool
803
+	 */
804
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
+	{
806
+		// don't allow config updates during WP heartbeats
807
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
+			return false;
809
+		}
810
+		$config_obj = maybe_unserialize($config_obj);
811
+		// get class name of the incoming object
812
+		$config_class = get_class($config_obj);
813
+		// run tests 1-5 and 9 to verify config
814
+		if (! $this->_verify_config_params(
815
+			$section,
816
+			$name,
817
+			$config_class,
818
+			$config_obj,
819
+			array(1, 2, 3, 4, 7, 9)
820
+		)
821
+		) {
822
+			return false;
823
+		}
824
+		$config_option_name = $this->_generate_config_option_name($section, $name);
825
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
+		if (! isset($this->_addon_option_names[$config_option_name])) {
827
+			// save new config to db
828
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
+				return true;
830
+			}
831
+		} else {
832
+			// first check if the record already exists
833
+			$existing_config = get_option($config_option_name);
834
+			$config_obj = serialize($config_obj);
835
+			// just return if db record is already up to date (NOT type safe comparison)
836
+			if ($existing_config == $config_obj) {
837
+				$this->{$section}->{$name} = $config_obj;
838
+				return true;
839
+			} else if (update_option($config_option_name, $config_obj)) {
840
+				EE_Config::log($config_option_name);
841
+				// update wp-option for this config class
842
+				$this->{$section}->{$name} = $config_obj;
843
+				return true;
844
+			} elseif ($throw_errors) {
845
+				EE_Error::add_error(
846
+					sprintf(
847
+						__(
848
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
+							'event_espresso'
850
+						),
851
+						$config_class,
852
+						'EE_Config->' . $section . '->' . $name
853
+					),
854
+					__FILE__,
855
+					__FUNCTION__,
856
+					__LINE__
857
+				);
858
+			}
859
+		}
860
+		return false;
861
+	}
862
+
863
+
864
+
865
+	/**
866
+	 *    get_config
867
+	 *
868
+	 * @access    public
869
+	 * @param    string $section
870
+	 * @param    string $name
871
+	 * @param    string $config_class
872
+	 * @return    mixed EE_Config_Base | NULL
873
+	 */
874
+	public function get_config($section = '', $name = '', $config_class = '')
875
+	{
876
+		// ensure config class is set to something
877
+		$config_class = $this->_set_config_class($config_class, $name);
878
+		// run tests 1-4, 6 and 7 to verify that all params have been set
879
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
+			return null;
881
+		}
882
+		// now test if the requested config object exists, but suppress errors
883
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
+			// config already exists, so pass it back
885
+			return $this->{$section}->{$name};
886
+		}
887
+		// load config option from db if it exists
888
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
+		// verify the newly retrieved config object, but suppress errors
890
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
+			// config is good, so set it and pass it back
892
+			$this->{$section}->{$name} = $config_obj;
893
+			return $this->{$section}->{$name};
894
+		}
895
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
896
+		$config_obj = $this->set_config($section, $name, $config_class);
897
+		// verify the newly created config object
898
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
+			return $this->{$section}->{$name};
900
+		} else {
901
+			EE_Error::add_error(
902
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
+				__FILE__,
904
+				__FUNCTION__,
905
+				__LINE__
906
+			);
907
+		}
908
+		return null;
909
+	}
910
+
911
+
912
+
913
+	/**
914
+	 *    get_config_option
915
+	 *
916
+	 * @access    public
917
+	 * @param    string $config_option_name
918
+	 * @return    mixed EE_Config_Base | FALSE
919
+	 */
920
+	public function get_config_option($config_option_name = '')
921
+	{
922
+		// retrieve the wp-option for this config class.
923
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
924
+		if (empty($config_option)) {
925
+			EE_Config::log($config_option_name . '-NOT-FOUND');
926
+		}
927
+		return $config_option;
928
+	}
929
+
930
+
931
+
932
+	/**
933
+	 * log
934
+	 *
935
+	 * @param string $config_option_name
936
+	 */
937
+	public static function log($config_option_name = '')
938
+	{
939
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
+			$config_log = get_option(EE_Config::LOG_NAME, array());
941
+			//copy incoming $_REQUEST and sanitize it so we can save it
942
+			$_request = $_REQUEST;
943
+			array_walk_recursive($_request, 'sanitize_text_field');
944
+			$config_log[(string)microtime(true)] = array(
945
+				'config_name' => $config_option_name,
946
+				'request'     => $_request,
947
+			);
948
+			update_option(EE_Config::LOG_NAME, $config_log);
949
+		}
950
+	}
951
+
952
+
953
+
954
+	/**
955
+	 * trim_log
956
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
+	 */
958
+	public static function trim_log()
959
+	{
960
+		if (! EE_Config::logging_enabled()) {
961
+			return;
962
+		}
963
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
+		$log_length = count($config_log);
965
+		if ($log_length > EE_Config::LOG_LENGTH) {
966
+			ksort($config_log);
967
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
+			update_option(EE_Config::LOG_NAME, $config_log);
969
+		}
970
+	}
971
+
972
+
973
+
974
+	/**
975
+	 *    get_page_for_posts
976
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
978
+	 *
979
+	 * @access    public
980
+	 * @return    string
981
+	 */
982
+	public static function get_page_for_posts()
983
+	{
984
+		$page_for_posts = get_option('page_for_posts');
985
+		if (! $page_for_posts) {
986
+			return 'posts';
987
+		}
988
+		/** @type WPDB $wpdb */
989
+		global $wpdb;
990
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
+	}
993
+
994
+
995
+
996
+	/**
997
+	 *    register_shortcodes_and_modules.
998
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
999
+	 *    In fact, this is where we give modules a chance to let core know they exist
1000
+	 *    so they can help trigger maintenance mode if it's needed
1001
+	 *
1002
+	 * @access    public
1003
+	 * @return    void
1004
+	 */
1005
+	public function register_shortcodes_and_modules()
1006
+	{
1007
+		// allow modules to set hooks for the rest of the system
1008
+		EE_Registry::instance()->modules = $this->_register_modules();
1009
+	}
1010
+
1011
+
1012
+
1013
+	/**
1014
+	 *    initialize_shortcodes_and_modules
1015
+	 *    meaning they can start adding their hooks to get stuff done
1016
+	 *
1017
+	 * @access    public
1018
+	 * @return    void
1019
+	 */
1020
+	public function initialize_shortcodes_and_modules()
1021
+	{
1022
+		// allow modules to set hooks for the rest of the system
1023
+		$this->_initialize_modules();
1024
+	}
1025
+
1026
+
1027
+
1028
+	/**
1029
+	 *    widgets_init
1030
+	 *
1031
+	 * @access private
1032
+	 * @return void
1033
+	 */
1034
+	public function widgets_init()
1035
+	{
1036
+		//only init widgets on admin pages when not in complete maintenance, and
1037
+		//on frontend when not in any maintenance mode
1038
+		if (
1039
+			! EE_Maintenance_Mode::instance()->level()
1040
+			|| (
1041
+				is_admin()
1042
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
+			)
1044
+		) {
1045
+			// grab list of installed widgets
1046
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
+			// filter list of modules to register
1048
+			$widgets_to_register = apply_filters(
1049
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
+				$widgets_to_register
1051
+			);
1052
+			if (! empty($widgets_to_register)) {
1053
+				// cycle thru widget folders
1054
+				foreach ($widgets_to_register as $widget_path) {
1055
+					// add to list of installed widget modules
1056
+					EE_Config::register_ee_widget($widget_path);
1057
+				}
1058
+			}
1059
+			// filter list of installed modules
1060
+			EE_Registry::instance()->widgets = apply_filters(
1061
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1062
+				EE_Registry::instance()->widgets
1063
+			);
1064
+		}
1065
+	}
1066
+
1067
+
1068
+
1069
+	/**
1070
+	 *    register_ee_widget - makes core aware of this widget
1071
+	 *
1072
+	 * @access    public
1073
+	 * @param    string $widget_path - full path up to and including widget folder
1074
+	 * @return    void
1075
+	 */
1076
+	public static function register_ee_widget($widget_path = null)
1077
+	{
1078
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
+		$widget_ext = '.widget.php';
1080
+		// make all separators match
1081
+		$widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
+		// does the file path INCLUDE the actual file name as part of the path ?
1083
+		if (strpos($widget_path, $widget_ext) !== false) {
1084
+			// grab and shortcode file name from directory name and break apart at dots
1085
+			$file_name = explode('.', basename($widget_path));
1086
+			// take first segment from file name pieces and remove class prefix if it exists
1087
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
+			// sanitize shortcode directory name
1089
+			$widget = sanitize_key($widget);
1090
+			// now we need to rebuild the shortcode path
1091
+			$widget_path = explode(DS, $widget_path);
1092
+			// remove last segment
1093
+			array_pop($widget_path);
1094
+			// glue it back together
1095
+			$widget_path = implode(DS, $widget_path);
1096
+		} else {
1097
+			// grab and sanitize widget directory name
1098
+			$widget = sanitize_key(basename($widget_path));
1099
+		}
1100
+		// create classname from widget directory name
1101
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
+		// add class prefix
1103
+		$widget_class = 'EEW_' . $widget;
1104
+		// does the widget exist ?
1105
+		if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
+			$msg = sprintf(
1107
+				__(
1108
+					'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1109
+					'event_espresso'
1110
+				),
1111
+				$widget_class,
1112
+				$widget_path . DS . $widget_class . $widget_ext
1113
+			);
1114
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
+			return;
1116
+		}
1117
+		// load the widget class file
1118
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1119
+		// verify that class exists
1120
+		if (! class_exists($widget_class)) {
1121
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
+			return;
1124
+		}
1125
+		register_widget($widget_class);
1126
+		// add to array of registered widgets
1127
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
+	}
1129
+
1130
+
1131
+
1132
+	/**
1133
+	 *        _register_modules
1134
+	 *
1135
+	 * @access private
1136
+	 * @return array
1137
+	 */
1138
+	private function _register_modules()
1139
+	{
1140
+		// grab list of installed modules
1141
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
+		// filter list of modules to register
1143
+		$modules_to_register = apply_filters(
1144
+			'FHEE__EE_Config__register_modules__modules_to_register',
1145
+			$modules_to_register
1146
+		);
1147
+		if (! empty($modules_to_register)) {
1148
+			// loop through folders
1149
+			foreach ($modules_to_register as $module_path) {
1150
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
+				if (
1152
+					$module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
+					&& $module_path !== EE_MODULES . 'gateways'
1154
+				) {
1155
+					// add to list of installed modules
1156
+					EE_Config::register_module($module_path);
1157
+				}
1158
+			}
1159
+		}
1160
+		// filter list of installed modules
1161
+		return apply_filters(
1162
+			'FHEE__EE_Config___register_modules__installed_modules',
1163
+			EE_Registry::instance()->modules
1164
+		);
1165
+	}
1166
+
1167
+
1168
+
1169
+	/**
1170
+	 *    register_module - makes core aware of this module
1171
+	 *
1172
+	 * @access    public
1173
+	 * @param    string $module_path - full path up to and including module folder
1174
+	 * @return    bool
1175
+	 */
1176
+	public static function register_module($module_path = null)
1177
+	{
1178
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
+		$module_ext = '.module.php';
1180
+		// make all separators match
1181
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
+		// does the file path INCLUDE the actual file name as part of the path ?
1183
+		if (strpos($module_path, $module_ext) !== false) {
1184
+			// grab and shortcode file name from directory name and break apart at dots
1185
+			$module_file = explode('.', basename($module_path));
1186
+			// now we need to rebuild the shortcode path
1187
+			$module_path = explode(DS, $module_path);
1188
+			// remove last segment
1189
+			array_pop($module_path);
1190
+			// glue it back together
1191
+			$module_path = implode(DS, $module_path) . DS;
1192
+			// take first segment from file name pieces and sanitize it
1193
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
+			// ensure class prefix is added
1195
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
+		} else {
1197
+			// we need to generate the filename based off of the folder name
1198
+			// grab and sanitize module name
1199
+			$module = strtolower(basename($module_path));
1200
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
+			// like trailingslashit()
1202
+			$module_path = rtrim($module_path, DS) . DS;
1203
+			// create classname from module directory name
1204
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
+			// add class prefix
1206
+			$module_class = 'EED_' . $module;
1207
+		}
1208
+		// does the module exist ?
1209
+		if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
+			$msg = sprintf(
1211
+				__(
1212
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1213
+					'event_espresso'
1214
+				),
1215
+				$module
1216
+			);
1217
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
+			return false;
1219
+		}
1220
+		// load the module class file
1221
+		require_once($module_path . $module_class . $module_ext);
1222
+		// verify that class exists
1223
+		if (! class_exists($module_class)) {
1224
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
+			return false;
1227
+		}
1228
+		// add to array of registered modules
1229
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
+		do_action(
1231
+			'AHEE__EE_Config__register_module__complete',
1232
+			$module_class,
1233
+			EE_Registry::instance()->modules->{$module_class}
1234
+		);
1235
+		return true;
1236
+	}
1237
+
1238
+
1239
+
1240
+	/**
1241
+	 *    _initialize_modules
1242
+	 *    allow modules to set hooks for the rest of the system
1243
+	 *
1244
+	 * @access private
1245
+	 * @return void
1246
+	 */
1247
+	private function _initialize_modules()
1248
+	{
1249
+		// cycle thru shortcode folders
1250
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
+			// which set hooks ?
1253
+			if (is_admin()) {
1254
+				// fire immediately
1255
+				call_user_func(array($module_class, 'set_hooks_admin'));
1256
+			} else {
1257
+				// delay until other systems are online
1258
+				add_action(
1259
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
+					array($module_class, 'set_hooks')
1261
+				);
1262
+			}
1263
+		}
1264
+	}
1265
+
1266
+
1267
+
1268
+	/**
1269
+	 *    register_route - adds module method routes to route_map
1270
+	 *
1271
+	 * @access    public
1272
+	 * @param    string $route       - "pretty" public alias for module method
1273
+	 * @param    string $module      - module name (classname without EED_ prefix)
1274
+	 * @param    string $method_name - the actual module method to be routed to
1275
+	 * @param    string $key         - url param key indicating a route is being called
1276
+	 * @return    bool
1277
+	 */
1278
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
+	{
1280
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
+		$module = str_replace('EED_', '', $module);
1282
+		$module_class = 'EED_' . $module;
1283
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
+			return false;
1287
+		}
1288
+		if (empty($route)) {
1289
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
+			return false;
1292
+		}
1293
+		if (! method_exists('EED_' . $module, $method_name)) {
1294
+			$msg = sprintf(
1295
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
+				$route
1297
+			);
1298
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
+			return false;
1300
+		}
1301
+		EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
+		return true;
1303
+	}
1304
+
1305
+
1306
+
1307
+	/**
1308
+	 *    get_route - get module method route
1309
+	 *
1310
+	 * @access    public
1311
+	 * @param    string $route - "pretty" public alias for module method
1312
+	 * @param    string $key   - url param key indicating a route is being called
1313
+	 * @return    string
1314
+	 */
1315
+	public static function get_route($route = null, $key = 'ee')
1316
+	{
1317
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1318
+		$route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
+		if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
+			return EE_Config::$_module_route_map[$key][$route];
1321
+		}
1322
+		return null;
1323
+	}
1324
+
1325
+
1326
+
1327
+	/**
1328
+	 *    get_routes - get ALL module method routes
1329
+	 *
1330
+	 * @access    public
1331
+	 * @return    array
1332
+	 */
1333
+	public static function get_routes()
1334
+	{
1335
+		return EE_Config::$_module_route_map;
1336
+	}
1337
+
1338
+
1339
+
1340
+	/**
1341
+	 *    register_forward - allows modules to forward request to another module for further processing
1342
+	 *
1343
+	 * @access    public
1344
+	 * @param    string       $route   - "pretty" public alias for module method
1345
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
+	 *                                 class, allows different forwards to be served based on status
1347
+	 * @param    array|string $forward - function name or array( class, method )
1348
+	 * @param    string       $key     - url param key indicating a route is being called
1349
+	 * @return    bool
1350
+	 */
1351
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
+	{
1353
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
+			$msg = sprintf(
1356
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
+				$route
1358
+			);
1359
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
+			return false;
1361
+		}
1362
+		if (empty($forward)) {
1363
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
+			return false;
1366
+		}
1367
+		if (is_array($forward)) {
1368
+			if (! isset($forward[1])) {
1369
+				$msg = sprintf(
1370
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
+					$route
1372
+				);
1373
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
+				return false;
1375
+			}
1376
+			if (! method_exists($forward[0], $forward[1])) {
1377
+				$msg = sprintf(
1378
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
+					$forward[1],
1380
+					$route
1381
+				);
1382
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
+				return false;
1384
+			}
1385
+		} else if (! function_exists($forward)) {
1386
+			$msg = sprintf(
1387
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
+				$forward,
1389
+				$route
1390
+			);
1391
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
+			return false;
1393
+		}
1394
+		EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
+		return true;
1396
+	}
1397
+
1398
+
1399
+
1400
+	/**
1401
+	 *    get_forward - get forwarding route
1402
+	 *
1403
+	 * @access    public
1404
+	 * @param    string  $route  - "pretty" public alias for module method
1405
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
+	 *                           allows different forwards to be served based on status
1407
+	 * @param    string  $key    - url param key indicating a route is being called
1408
+	 * @return    string
1409
+	 */
1410
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
+	{
1412
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
+		if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
+			return apply_filters(
1415
+				'FHEE__EE_Config__get_forward',
1416
+				EE_Config::$_module_forward_map[$key][$route][$status],
1417
+				$route,
1418
+				$status
1419
+			);
1420
+		}
1421
+		return null;
1422
+	}
1423
+
1424
+
1425
+
1426
+	/**
1427
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1428
+	 *    results
1429
+	 *
1430
+	 * @access    public
1431
+	 * @param    string  $route  - "pretty" public alias for module method
1432
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
+	 *                           allows different views to be served based on status
1434
+	 * @param    string  $view
1435
+	 * @param    string  $key    - url param key indicating a route is being called
1436
+	 * @return    bool
1437
+	 */
1438
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
+	{
1440
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
+		if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
+			$msg = sprintf(
1443
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1444
+				$route
1445
+			);
1446
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
+			return false;
1448
+		}
1449
+		if (! is_readable($view)) {
1450
+			$msg = sprintf(
1451
+				__(
1452
+					'The %s view file could not be found or is not readable due to file permissions.',
1453
+					'event_espresso'
1454
+				),
1455
+				$view
1456
+			);
1457
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
+			return false;
1459
+		}
1460
+		EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
+		return true;
1462
+	}
1463
+
1464
+
1465
+
1466
+	/**
1467
+	 *    get_view - get view for route and status
1468
+	 *
1469
+	 * @access    public
1470
+	 * @param    string  $route  - "pretty" public alias for module method
1471
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
+	 *                           allows different views to be served based on status
1473
+	 * @param    string  $key    - url param key indicating a route is being called
1474
+	 * @return    string
1475
+	 */
1476
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1477
+	{
1478
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
+		if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
+			return apply_filters(
1481
+				'FHEE__EE_Config__get_view',
1482
+				EE_Config::$_module_view_map[$key][$route][$status],
1483
+				$route,
1484
+				$status
1485
+			);
1486
+		}
1487
+		return null;
1488
+	}
1489
+
1490
+
1491
+
1492
+	public function update_addon_option_names()
1493
+	{
1494
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
+	}
1496
+
1497
+
1498
+
1499
+	public function shutdown()
1500
+	{
1501
+		$this->update_addon_option_names();
1502
+	}
1503
+
1504
+
1505
+
1506
+	/**
1507
+	 * @return LegacyShortcodesManager
1508
+	 */
1509
+	public static function getLegacyShortcodesManager()
1510
+	{
1511
+
1512
+		if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
+				EE_Registry::instance()
1515
+			);
1516
+		}
1517
+		return EE_Config::instance()->legacy_shortcodes_manager;
1518
+	}
1519
+
1520
+
1521
+
1522
+	/**
1523
+	 * register_shortcode - makes core aware of this shortcode
1524
+	 *
1525
+	 * @deprecated 4.9.26
1526
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1527
+	 * @return    bool
1528
+	 */
1529
+	public static function register_shortcode($shortcode_path = null)
1530
+	{
1531
+		EE_Error::doing_it_wrong(
1532
+			__METHOD__,
1533
+			__(
1534
+				'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1535
+				'event_espresso'
1536
+			),
1537
+			'4.9.26'
1538
+		);
1539
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
+	}
21 1541
 
22
-    const LOG_NAME           = 'ee_config_log';
23 1542
 
24
-    const LOG_LENGTH         = 100;
25 1543
 
26
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
27
-
28
-
29
-    /**
30
-     *    instance of the EE_Config object
31
-     *
32
-     * @var    EE_Config $_instance
33
-     * @access    private
34
-     */
35
-    private static $_instance;
36
-
37
-    /**
38
-     * @var boolean $_logging_enabled
39
-     */
40
-    private static $_logging_enabled = false;
41
-
42
-    /**
43
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
44
-     */
45
-    private $legacy_shortcodes_manager;
46
-
47
-    /**
48
-     * An StdClass whose property names are addon slugs,
49
-     * and values are their config classes
50
-     *
51
-     * @var StdClass
52
-     */
53
-    public $addons;
54
-
55
-    /**
56
-     * @var EE_Admin_Config
57
-     */
58
-    public $admin;
59
-
60
-    /**
61
-     * @var EE_Core_Config
62
-     */
63
-    public $core;
64
-
65
-    /**
66
-     * @var EE_Currency_Config
67
-     */
68
-    public $currency;
69
-
70
-    /**
71
-     * @var EE_Organization_Config
72
-     */
73
-    public $organization;
74
-
75
-    /**
76
-     * @var EE_Registration_Config
77
-     */
78
-    public $registration;
79
-
80
-    /**
81
-     * @var EE_Template_Config
82
-     */
83
-    public $template_settings;
84
-
85
-    /**
86
-     * Holds EE environment values.
87
-     *
88
-     * @var EE_Environment_Config
89
-     */
90
-    public $environment;
91
-
92
-    /**
93
-     * settings pertaining to Google maps
94
-     *
95
-     * @var EE_Map_Config
96
-     */
97
-    public $map_settings;
98
-
99
-    /**
100
-     * settings pertaining to Taxes
101
-     *
102
-     * @var EE_Tax_Config
103
-     */
104
-    public $tax_settings;
105
-
106
-
107
-    /**
108
-     * Settings pertaining to global messages settings.
109
-     *
110
-     * @var EE_Messages_Config
111
-     */
112
-    public $messages;
113
-
114
-    /**
115
-     * @deprecated
116
-     * @var EE_Gateway_Config
117
-     */
118
-    public $gateway;
119
-
120
-    /**
121
-     * @var    array $_addon_option_names
122
-     * @access    private
123
-     */
124
-    private $_addon_option_names = array();
125
-
126
-    /**
127
-     * @var    array $_module_route_map
128
-     * @access    private
129
-     */
130
-    private static $_module_route_map = array();
131
-
132
-    /**
133
-     * @var    array $_module_forward_map
134
-     * @access    private
135
-     */
136
-    private static $_module_forward_map = array();
137
-
138
-    /**
139
-     * @var    array $_module_view_map
140
-     * @access    private
141
-     */
142
-    private static $_module_view_map = array();
143
-
144
-
145
-
146
-    /**
147
-     * @singleton method used to instantiate class object
148
-     * @access    public
149
-     * @return EE_Config instance
150
-     */
151
-    public static function instance()
152
-    {
153
-        // check if class object is instantiated, and instantiated properly
154
-        if (! self::$_instance instanceof EE_Config) {
155
-            self::$_instance = new self();
156
-        }
157
-        return self::$_instance;
158
-    }
159
-
160
-
161
-
162
-    /**
163
-     * Resets the config
164
-     *
165
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
166
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
167
-     *                               reflect its state in the database
168
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
169
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
170
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
171
-     *                               site was put into maintenance mode)
172
-     * @return EE_Config
173
-     */
174
-    public static function reset($hard_reset = false, $reinstantiate = true)
175
-    {
176
-        if (self::$_instance instanceof EE_Config) {
177
-            if ($hard_reset) {
178
-                self::$_instance->legacy_shortcodes_manager = null;
179
-                self::$_instance->_addon_option_names = array();
180
-                self::$_instance->_initialize_config();
181
-                self::$_instance->update_espresso_config();
182
-            }
183
-            self::$_instance->update_addon_option_names();
184
-        }
185
-        self::$_instance = null;
186
-        //we don't need to reset the static properties imo because those should
187
-        //only change when a module is added or removed. Currently we don't
188
-        //support removing a module during a request when it previously existed
189
-        if ($reinstantiate) {
190
-            return self::instance();
191
-        } else {
192
-            return null;
193
-        }
194
-    }
195
-
196
-
197
-
198
-    /**
199
-     *    class constructor
200
-     *
201
-     * @access    private
202
-     */
203
-    private function __construct()
204
-    {
205
-        do_action('AHEE__EE_Config__construct__begin', $this);
206
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
207
-        // setup empty config classes
208
-        $this->_initialize_config();
209
-        // load existing EE site settings
210
-        $this->_load_core_config();
211
-        // confirm everything loaded correctly and set filtered defaults if not
212
-        $this->_verify_config();
213
-        //  register shortcodes and modules
214
-        add_action(
215
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
216
-            array($this, 'register_shortcodes_and_modules'),
217
-            999
218
-        );
219
-        //  initialize shortcodes and modules
220
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
221
-        // register widgets
222
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
223
-        // shutdown
224
-        add_action('shutdown', array($this, 'shutdown'), 10);
225
-        // construct__end hook
226
-        do_action('AHEE__EE_Config__construct__end', $this);
227
-        // hardcoded hack
228
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
229
-    }
230
-
231
-
232
-
233
-    /**
234
-     * @return boolean
235
-     */
236
-    public static function logging_enabled()
237
-    {
238
-        return self::$_logging_enabled;
239
-    }
240
-
241
-
242
-
243
-    /**
244
-     * use to get the current theme if needed from static context
245
-     *
246
-     * @return string current theme set.
247
-     */
248
-    public static function get_current_theme()
249
-    {
250
-        return isset(self::$_instance->template_settings->current_espresso_theme)
251
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
252
-    }
253
-
254
-
255
-
256
-    /**
257
-     *        _initialize_config
258
-     *
259
-     * @access private
260
-     * @return void
261
-     */
262
-    private function _initialize_config()
263
-    {
264
-        EE_Config::trim_log();
265
-        //set defaults
266
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
267
-        $this->addons = new stdClass();
268
-        // set _module_route_map
269
-        EE_Config::$_module_route_map = array();
270
-        // set _module_forward_map
271
-        EE_Config::$_module_forward_map = array();
272
-        // set _module_view_map
273
-        EE_Config::$_module_view_map = array();
274
-    }
275
-
276
-
277
-
278
-    /**
279
-     *        load core plugin configuration
280
-     *
281
-     * @access private
282
-     * @return void
283
-     */
284
-    private function _load_core_config()
285
-    {
286
-        // load_core_config__start hook
287
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
288
-        $espresso_config = $this->get_espresso_config();
289
-        foreach ($espresso_config as $config => $settings) {
290
-            // load_core_config__start hook
291
-            $settings = apply_filters(
292
-                'FHEE__EE_Config___load_core_config__config_settings',
293
-                $settings,
294
-                $config,
295
-                $this
296
-            );
297
-            if (is_object($settings) && property_exists($this, $config)) {
298
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
299
-                //call configs populate method to ensure any defaults are set for empty values.
300
-                if (method_exists($settings, 'populate')) {
301
-                    $this->{$config}->populate();
302
-                }
303
-                if (method_exists($settings, 'do_hooks')) {
304
-                    $this->{$config}->do_hooks();
305
-                }
306
-            }
307
-        }
308
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
309
-            $this->update_espresso_config();
310
-        }
311
-        // load_core_config__end hook
312
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
313
-    }
314
-
315
-
316
-
317
-    /**
318
-     *    _verify_config
319
-     *
320
-     * @access    protected
321
-     * @return    void
322
-     */
323
-    protected function _verify_config()
324
-    {
325
-        $this->core = $this->core instanceof EE_Core_Config
326
-            ? $this->core
327
-            : new EE_Core_Config();
328
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
329
-        $this->organization = $this->organization instanceof EE_Organization_Config
330
-            ? $this->organization
331
-            : new EE_Organization_Config();
332
-        $this->organization = apply_filters(
333
-            'FHEE__EE_Config___initialize_config__organization',
334
-            $this->organization
335
-        );
336
-        $this->currency = $this->currency instanceof EE_Currency_Config
337
-            ? $this->currency
338
-            : new EE_Currency_Config();
339
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
340
-        $this->registration = $this->registration instanceof EE_Registration_Config
341
-            ? $this->registration
342
-            : new EE_Registration_Config();
343
-        $this->registration = apply_filters(
344
-            'FHEE__EE_Config___initialize_config__registration',
345
-            $this->registration
346
-        );
347
-        $this->admin = $this->admin instanceof EE_Admin_Config
348
-            ? $this->admin
349
-            : new EE_Admin_Config();
350
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
351
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
352
-            ? $this->template_settings
353
-            : new EE_Template_Config();
354
-        $this->template_settings = apply_filters(
355
-            'FHEE__EE_Config___initialize_config__template_settings',
356
-            $this->template_settings
357
-        );
358
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
359
-            ? $this->map_settings
360
-            : new EE_Map_Config();
361
-        $this->map_settings = apply_filters('FHEE__EE_Config___initialize_config__map_settings',
362
-            $this->map_settings);
363
-        $this->environment = $this->environment instanceof EE_Environment_Config
364
-            ? $this->environment
365
-            : new EE_Environment_Config();
366
-        $this->environment = apply_filters('FHEE__EE_Config___initialize_config__environment',
367
-            $this->environment);
368
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
369
-            ? $this->tax_settings
370
-            : new EE_Tax_Config();
371
-        $this->tax_settings = apply_filters('FHEE__EE_Config___initialize_config__tax_settings',
372
-            $this->tax_settings);
373
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
374
-        $this->messages = $this->messages instanceof EE_Messages_Config
375
-            ? $this->messages
376
-            : new EE_Messages_Config();
377
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
378
-            ? $this->gateway
379
-            : new EE_Gateway_Config();
380
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
381
-        $this->legacy_shortcodes_manager = null;
382
-    }
383
-
384
-
385
-    /**
386
-     *    get_espresso_config
387
-     *
388
-     * @access    public
389
-     * @return    array of espresso config stuff
390
-     */
391
-    public function get_espresso_config()
392
-    {
393
-        // grab espresso configuration
394
-        return apply_filters(
395
-            'FHEE__EE_Config__get_espresso_config__CFG',
396
-            get_option(EE_Config::OPTION_NAME, array())
397
-        );
398
-    }
399
-
400
-
401
-
402
-    /**
403
-     *    double_check_config_comparison
404
-     *
405
-     * @access    public
406
-     * @param string $option
407
-     * @param        $old_value
408
-     * @param        $value
409
-     */
410
-    public function double_check_config_comparison($option = '', $old_value, $value)
411
-    {
412
-        // make sure we're checking the ee config
413
-        if ($option === EE_Config::OPTION_NAME) {
414
-            // run a loose comparison of the old value against the new value for type and properties,
415
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
416
-            if ($value != $old_value) {
417
-                // if they are NOT the same, then remove the hook,
418
-                // which means the subsequent update results will be based solely on the update query results
419
-                // the reason we do this is because, as stated above,
420
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
421
-                // this happens PRIOR to serialization and any subsequent update.
422
-                // If values are found to match their previous old value,
423
-                // then WP bails before performing any update.
424
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
425
-                // it just pulled from the db, with the one being passed to it (which will not match).
426
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
427
-                // MySQL MAY ALSO NOT perform the update because
428
-                // the string it sees in the db looks the same as the new one it has been passed!!!
429
-                // This results in the query returning an "affected rows" value of ZERO,
430
-                // which gets returned immediately by WP update_option and looks like an error.
431
-                remove_action('update_option', array($this, 'check_config_updated'));
432
-            }
433
-        }
434
-    }
435
-
436
-
437
-
438
-    /**
439
-     *    update_espresso_config
440
-     *
441
-     * @access   public
442
-     */
443
-    protected function _reset_espresso_addon_config()
444
-    {
445
-        $this->_addon_option_names = array();
446
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
447
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
448
-            if ($addon_config_obj instanceof EE_Config_Base) {
449
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
450
-            }
451
-            $this->addons->{$addon_name} = null;
452
-        }
453
-    }
454
-
455
-
456
-
457
-    /**
458
-     *    update_espresso_config
459
-     *
460
-     * @access   public
461
-     * @param   bool $add_success
462
-     * @param   bool $add_error
463
-     * @return   bool
464
-     */
465
-    public function update_espresso_config($add_success = false, $add_error = true)
466
-    {
467
-        // don't allow config updates during WP heartbeats
468
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
469
-            return false;
470
-        }
471
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
472
-        //$clone = clone( self::$_instance );
473
-        //self::$_instance = NULL;
474
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
475
-        $this->_reset_espresso_addon_config();
476
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
477
-        // but BEFORE the actual update occurs
478
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
479
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
480
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
481
-        $this->legacy_shortcodes_manager = null;
482
-        // now update "ee_config"
483
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
484
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
485
-        EE_Config::log(EE_Config::OPTION_NAME);
486
-        // if not saved... check if the hook we just added still exists;
487
-        // if it does, it means one of two things:
488
-        // 		that update_option bailed at the ( $value === $old_value ) conditional,
489
-        //		 or...
490
-        // 		the db update query returned 0 rows affected
491
-        // 		(probably because the data  value was the same from it's perspective)
492
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
493
-        // but just means no update occurred, so don't display an error to the user.
494
-        // BUT... if update_option returns FALSE, AND the hook is missing,
495
-        // then it means that something truly went wrong
496
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
497
-        // remove our action since we don't want it in the system anymore
498
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
499
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
500
-        //self::$_instance = $clone;
501
-        //unset( $clone );
502
-        // if config remains the same or was updated successfully
503
-        if ($saved) {
504
-            if ($add_success) {
505
-                EE_Error::add_success(
506
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
507
-                    __FILE__,
508
-                    __FUNCTION__,
509
-                    __LINE__
510
-                );
511
-            }
512
-            return true;
513
-        } else {
514
-            if ($add_error) {
515
-                EE_Error::add_error(
516
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
517
-                    __FILE__,
518
-                    __FUNCTION__,
519
-                    __LINE__
520
-                );
521
-            }
522
-            return false;
523
-        }
524
-    }
525
-
526
-
527
-
528
-    /**
529
-     *    _verify_config_params
530
-     *
531
-     * @access    private
532
-     * @param    string         $section
533
-     * @param    string         $name
534
-     * @param    string         $config_class
535
-     * @param    EE_Config_Base $config_obj
536
-     * @param    array          $tests_to_run
537
-     * @param    bool           $display_errors
538
-     * @return    bool    TRUE on success, FALSE on fail
539
-     */
540
-    private function _verify_config_params(
541
-        $section = '',
542
-        $name = '',
543
-        $config_class = '',
544
-        $config_obj = null,
545
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
546
-        $display_errors = true
547
-    ) {
548
-        try {
549
-            foreach ($tests_to_run as $test) {
550
-                switch ($test) {
551
-                    // TEST #1 : check that section was set
552
-                    case 1 :
553
-                        if (empty($section)) {
554
-                            if ($display_errors) {
555
-                                throw new EE_Error(
556
-                                    sprintf(
557
-                                        __(
558
-                                            'No configuration section has been provided while attempting to save "%s".',
559
-                                            'event_espresso'
560
-                                        ),
561
-                                        $config_class
562
-                                    )
563
-                                );
564
-                            }
565
-                            return false;
566
-                        }
567
-                        break;
568
-                    // TEST #2 : check that settings section exists
569
-                    case 2 :
570
-                        if (! isset($this->{$section})) {
571
-                            if ($display_errors) {
572
-                                throw new EE_Error(
573
-                                    sprintf(
574
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
575
-                                        $section
576
-                                    )
577
-                                );
578
-                            }
579
-                            return false;
580
-                        }
581
-                        break;
582
-                    // TEST #3 : check that section is the proper format
583
-                    case 3 :
584
-                        if (
585
-                        ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
586
-                        ) {
587
-                            if ($display_errors) {
588
-                                throw new EE_Error(
589
-                                    sprintf(
590
-                                        __(
591
-                                            'The "%s" configuration settings have not been formatted correctly.',
592
-                                            'event_espresso'
593
-                                        ),
594
-                                        $section
595
-                                    )
596
-                                );
597
-                            }
598
-                            return false;
599
-                        }
600
-                        break;
601
-                    // TEST #4 : check that config section name has been set
602
-                    case 4 :
603
-                        if (empty($name)) {
604
-                            if ($display_errors) {
605
-                                throw new EE_Error(
606
-                                    __(
607
-                                        'No name has been provided for the specific configuration section.',
608
-                                        'event_espresso'
609
-                                    )
610
-                                );
611
-                            }
612
-                            return false;
613
-                        }
614
-                        break;
615
-                    // TEST #5 : check that a config class name has been set
616
-                    case 5 :
617
-                        if (empty($config_class)) {
618
-                            if ($display_errors) {
619
-                                throw new EE_Error(
620
-                                    __(
621
-                                        'No class name has been provided for the specific configuration section.',
622
-                                        'event_espresso'
623
-                                    )
624
-                                );
625
-                            }
626
-                            return false;
627
-                        }
628
-                        break;
629
-                    // TEST #6 : verify config class is accessible
630
-                    case 6 :
631
-                        if (! class_exists($config_class)) {
632
-                            if ($display_errors) {
633
-                                throw new EE_Error(
634
-                                    sprintf(
635
-                                        __(
636
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
637
-                                            'event_espresso'
638
-                                        ),
639
-                                        $config_class
640
-                                    )
641
-                                );
642
-                            }
643
-                            return false;
644
-                        }
645
-                        break;
646
-                    // TEST #7 : check that config has even been set
647
-                    case 7 :
648
-                        if (! isset($this->{$section}->{$name})) {
649
-                            if ($display_errors) {
650
-                                throw new EE_Error(
651
-                                    sprintf(
652
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
653
-                                        $section,
654
-                                        $name
655
-                                    )
656
-                                );
657
-                            }
658
-                            return false;
659
-                        } else {
660
-                            // and make sure it's not serialized
661
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
662
-                        }
663
-                        break;
664
-                    // TEST #8 : check that config is the requested type
665
-                    case 8 :
666
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
667
-                            if ($display_errors) {
668
-                                throw new EE_Error(
669
-                                    sprintf(
670
-                                        __(
671
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
672
-                                            'event_espresso'
673
-                                        ),
674
-                                        $section,
675
-                                        $name,
676
-                                        $config_class
677
-                                    )
678
-                                );
679
-                            }
680
-                            return false;
681
-                        }
682
-                        break;
683
-                    // TEST #9 : verify config object
684
-                    case 9 :
685
-                        if (! $config_obj instanceof EE_Config_Base) {
686
-                            if ($display_errors) {
687
-                                throw new EE_Error(
688
-                                    sprintf(
689
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
690
-                                        print_r($config_obj, true)
691
-                                    )
692
-                                );
693
-                            }
694
-                            return false;
695
-                        }
696
-                        break;
697
-                }
698
-            }
699
-        } catch (EE_Error $e) {
700
-            $e->get_error();
701
-        }
702
-        // you have successfully run the gauntlet
703
-        return true;
704
-    }
705
-
706
-
707
-
708
-    /**
709
-     *    _generate_config_option_name
710
-     *
711
-     * @access        protected
712
-     * @param        string $section
713
-     * @param        string $name
714
-     * @return        string
715
-     */
716
-    private function _generate_config_option_name($section = '', $name = '')
717
-    {
718
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
719
-    }
720
-
721
-
722
-
723
-    /**
724
-     *    _set_config_class
725
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
726
-     *
727
-     * @access    private
728
-     * @param    string $config_class
729
-     * @param    string $name
730
-     * @return    string
731
-     */
732
-    private function _set_config_class($config_class = '', $name = '')
733
-    {
734
-        return ! empty($config_class)
735
-            ? $config_class
736
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
737
-    }
738
-
739
-
740
-
741
-    /**
742
-     *    set_config
743
-     *
744
-     * @access    protected
745
-     * @param    string         $section
746
-     * @param    string         $name
747
-     * @param    string         $config_class
748
-     * @param    EE_Config_Base $config_obj
749
-     * @return    EE_Config_Base
750
-     */
751
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
752
-    {
753
-        // ensure config class is set to something
754
-        $config_class = $this->_set_config_class($config_class, $name);
755
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
756
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
757
-            return null;
758
-        }
759
-        $config_option_name = $this->_generate_config_option_name($section, $name);
760
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
761
-        if (! isset($this->_addon_option_names[$config_option_name])) {
762
-            $this->_addon_option_names[$config_option_name] = $config_class;
763
-            $this->update_addon_option_names();
764
-        }
765
-        // verify the incoming config object but suppress errors
766
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
767
-            $config_obj = new $config_class();
768
-        }
769
-        if (get_option($config_option_name)) {
770
-            EE_Config::log($config_option_name);
771
-            update_option($config_option_name, $config_obj);
772
-            $this->{$section}->{$name} = $config_obj;
773
-            return $this->{$section}->{$name};
774
-        } else {
775
-            // create a wp-option for this config
776
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
777
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
778
-                return $this->{$section}->{$name};
779
-            } else {
780
-                EE_Error::add_error(
781
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
782
-                    __FILE__,
783
-                    __FUNCTION__,
784
-                    __LINE__
785
-                );
786
-                return null;
787
-            }
788
-        }
789
-    }
790
-
791
-
792
-
793
-    /**
794
-     *    update_config
795
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
796
-     *
797
-     * @access    public
798
-     * @param    string                $section
799
-     * @param    string                $name
800
-     * @param    EE_Config_Base|string $config_obj
801
-     * @param    bool                  $throw_errors
802
-     * @return    bool
803
-     */
804
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
805
-    {
806
-        // don't allow config updates during WP heartbeats
807
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
808
-            return false;
809
-        }
810
-        $config_obj = maybe_unserialize($config_obj);
811
-        // get class name of the incoming object
812
-        $config_class = get_class($config_obj);
813
-        // run tests 1-5 and 9 to verify config
814
-        if (! $this->_verify_config_params(
815
-            $section,
816
-            $name,
817
-            $config_class,
818
-            $config_obj,
819
-            array(1, 2, 3, 4, 7, 9)
820
-        )
821
-        ) {
822
-            return false;
823
-        }
824
-        $config_option_name = $this->_generate_config_option_name($section, $name);
825
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
826
-        if (! isset($this->_addon_option_names[$config_option_name])) {
827
-            // save new config to db
828
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
829
-                return true;
830
-            }
831
-        } else {
832
-            // first check if the record already exists
833
-            $existing_config = get_option($config_option_name);
834
-            $config_obj = serialize($config_obj);
835
-            // just return if db record is already up to date (NOT type safe comparison)
836
-            if ($existing_config == $config_obj) {
837
-                $this->{$section}->{$name} = $config_obj;
838
-                return true;
839
-            } else if (update_option($config_option_name, $config_obj)) {
840
-                EE_Config::log($config_option_name);
841
-                // update wp-option for this config class
842
-                $this->{$section}->{$name} = $config_obj;
843
-                return true;
844
-            } elseif ($throw_errors) {
845
-                EE_Error::add_error(
846
-                    sprintf(
847
-                        __(
848
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
849
-                            'event_espresso'
850
-                        ),
851
-                        $config_class,
852
-                        'EE_Config->' . $section . '->' . $name
853
-                    ),
854
-                    __FILE__,
855
-                    __FUNCTION__,
856
-                    __LINE__
857
-                );
858
-            }
859
-        }
860
-        return false;
861
-    }
862
-
863
-
864
-
865
-    /**
866
-     *    get_config
867
-     *
868
-     * @access    public
869
-     * @param    string $section
870
-     * @param    string $name
871
-     * @param    string $config_class
872
-     * @return    mixed EE_Config_Base | NULL
873
-     */
874
-    public function get_config($section = '', $name = '', $config_class = '')
875
-    {
876
-        // ensure config class is set to something
877
-        $config_class = $this->_set_config_class($config_class, $name);
878
-        // run tests 1-4, 6 and 7 to verify that all params have been set
879
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
880
-            return null;
881
-        }
882
-        // now test if the requested config object exists, but suppress errors
883
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
884
-            // config already exists, so pass it back
885
-            return $this->{$section}->{$name};
886
-        }
887
-        // load config option from db if it exists
888
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
889
-        // verify the newly retrieved config object, but suppress errors
890
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
891
-            // config is good, so set it and pass it back
892
-            $this->{$section}->{$name} = $config_obj;
893
-            return $this->{$section}->{$name};
894
-        }
895
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
896
-        $config_obj = $this->set_config($section, $name, $config_class);
897
-        // verify the newly created config object
898
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
899
-            return $this->{$section}->{$name};
900
-        } else {
901
-            EE_Error::add_error(
902
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
903
-                __FILE__,
904
-                __FUNCTION__,
905
-                __LINE__
906
-            );
907
-        }
908
-        return null;
909
-    }
910
-
911
-
912
-
913
-    /**
914
-     *    get_config_option
915
-     *
916
-     * @access    public
917
-     * @param    string $config_option_name
918
-     * @return    mixed EE_Config_Base | FALSE
919
-     */
920
-    public function get_config_option($config_option_name = '')
921
-    {
922
-        // retrieve the wp-option for this config class.
923
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
924
-        if (empty($config_option)) {
925
-            EE_Config::log($config_option_name . '-NOT-FOUND');
926
-        }
927
-        return $config_option;
928
-    }
929
-
930
-
931
-
932
-    /**
933
-     * log
934
-     *
935
-     * @param string $config_option_name
936
-     */
937
-    public static function log($config_option_name = '')
938
-    {
939
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
940
-            $config_log = get_option(EE_Config::LOG_NAME, array());
941
-            //copy incoming $_REQUEST and sanitize it so we can save it
942
-            $_request = $_REQUEST;
943
-            array_walk_recursive($_request, 'sanitize_text_field');
944
-            $config_log[(string)microtime(true)] = array(
945
-                'config_name' => $config_option_name,
946
-                'request'     => $_request,
947
-            );
948
-            update_option(EE_Config::LOG_NAME, $config_log);
949
-        }
950
-    }
951
-
952
-
953
-
954
-    /**
955
-     * trim_log
956
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
957
-     */
958
-    public static function trim_log()
959
-    {
960
-        if (! EE_Config::logging_enabled()) {
961
-            return;
962
-        }
963
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
964
-        $log_length = count($config_log);
965
-        if ($log_length > EE_Config::LOG_LENGTH) {
966
-            ksort($config_log);
967
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
968
-            update_option(EE_Config::LOG_NAME, $config_log);
969
-        }
970
-    }
971
-
972
-
973
-
974
-    /**
975
-     *    get_page_for_posts
976
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
977
-     *    wp-option "page_for_posts", or "posts" if no page is selected
978
-     *
979
-     * @access    public
980
-     * @return    string
981
-     */
982
-    public static function get_page_for_posts()
983
-    {
984
-        $page_for_posts = get_option('page_for_posts');
985
-        if (! $page_for_posts) {
986
-            return 'posts';
987
-        }
988
-        /** @type WPDB $wpdb */
989
-        global $wpdb;
990
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
991
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
992
-    }
993
-
994
-
995
-
996
-    /**
997
-     *    register_shortcodes_and_modules.
998
-     *    At this point, it's too early to tell if we're maintenance mode or not.
999
-     *    In fact, this is where we give modules a chance to let core know they exist
1000
-     *    so they can help trigger maintenance mode if it's needed
1001
-     *
1002
-     * @access    public
1003
-     * @return    void
1004
-     */
1005
-    public function register_shortcodes_and_modules()
1006
-    {
1007
-        // allow modules to set hooks for the rest of the system
1008
-        EE_Registry::instance()->modules = $this->_register_modules();
1009
-    }
1010
-
1011
-
1012
-
1013
-    /**
1014
-     *    initialize_shortcodes_and_modules
1015
-     *    meaning they can start adding their hooks to get stuff done
1016
-     *
1017
-     * @access    public
1018
-     * @return    void
1019
-     */
1020
-    public function initialize_shortcodes_and_modules()
1021
-    {
1022
-        // allow modules to set hooks for the rest of the system
1023
-        $this->_initialize_modules();
1024
-    }
1025
-
1026
-
1027
-
1028
-    /**
1029
-     *    widgets_init
1030
-     *
1031
-     * @access private
1032
-     * @return void
1033
-     */
1034
-    public function widgets_init()
1035
-    {
1036
-        //only init widgets on admin pages when not in complete maintenance, and
1037
-        //on frontend when not in any maintenance mode
1038
-        if (
1039
-            ! EE_Maintenance_Mode::instance()->level()
1040
-            || (
1041
-                is_admin()
1042
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1043
-            )
1044
-        ) {
1045
-            // grab list of installed widgets
1046
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1047
-            // filter list of modules to register
1048
-            $widgets_to_register = apply_filters(
1049
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1050
-                $widgets_to_register
1051
-            );
1052
-            if (! empty($widgets_to_register)) {
1053
-                // cycle thru widget folders
1054
-                foreach ($widgets_to_register as $widget_path) {
1055
-                    // add to list of installed widget modules
1056
-                    EE_Config::register_ee_widget($widget_path);
1057
-                }
1058
-            }
1059
-            // filter list of installed modules
1060
-            EE_Registry::instance()->widgets = apply_filters(
1061
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1062
-                EE_Registry::instance()->widgets
1063
-            );
1064
-        }
1065
-    }
1066
-
1067
-
1068
-
1069
-    /**
1070
-     *    register_ee_widget - makes core aware of this widget
1071
-     *
1072
-     * @access    public
1073
-     * @param    string $widget_path - full path up to and including widget folder
1074
-     * @return    void
1075
-     */
1076
-    public static function register_ee_widget($widget_path = null)
1077
-    {
1078
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1079
-        $widget_ext = '.widget.php';
1080
-        // make all separators match
1081
-        $widget_path = rtrim(str_replace('/\\', DS, $widget_path), DS);
1082
-        // does the file path INCLUDE the actual file name as part of the path ?
1083
-        if (strpos($widget_path, $widget_ext) !== false) {
1084
-            // grab and shortcode file name from directory name and break apart at dots
1085
-            $file_name = explode('.', basename($widget_path));
1086
-            // take first segment from file name pieces and remove class prefix if it exists
1087
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1088
-            // sanitize shortcode directory name
1089
-            $widget = sanitize_key($widget);
1090
-            // now we need to rebuild the shortcode path
1091
-            $widget_path = explode(DS, $widget_path);
1092
-            // remove last segment
1093
-            array_pop($widget_path);
1094
-            // glue it back together
1095
-            $widget_path = implode(DS, $widget_path);
1096
-        } else {
1097
-            // grab and sanitize widget directory name
1098
-            $widget = sanitize_key(basename($widget_path));
1099
-        }
1100
-        // create classname from widget directory name
1101
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1102
-        // add class prefix
1103
-        $widget_class = 'EEW_' . $widget;
1104
-        // does the widget exist ?
1105
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1106
-            $msg = sprintf(
1107
-                __(
1108
-                    'The requested %s widget file could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s',
1109
-                    'event_espresso'
1110
-                ),
1111
-                $widget_class,
1112
-                $widget_path . DS . $widget_class . $widget_ext
1113
-            );
1114
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1115
-            return;
1116
-        }
1117
-        // load the widget class file
1118
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1119
-        // verify that class exists
1120
-        if (! class_exists($widget_class)) {
1121
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1122
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1123
-            return;
1124
-        }
1125
-        register_widget($widget_class);
1126
-        // add to array of registered widgets
1127
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1128
-    }
1129
-
1130
-
1131
-
1132
-    /**
1133
-     *        _register_modules
1134
-     *
1135
-     * @access private
1136
-     * @return array
1137
-     */
1138
-    private function _register_modules()
1139
-    {
1140
-        // grab list of installed modules
1141
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1142
-        // filter list of modules to register
1143
-        $modules_to_register = apply_filters(
1144
-            'FHEE__EE_Config__register_modules__modules_to_register',
1145
-            $modules_to_register
1146
-        );
1147
-        if (! empty($modules_to_register)) {
1148
-            // loop through folders
1149
-            foreach ($modules_to_register as $module_path) {
1150
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1151
-                if (
1152
-                    $module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1153
-                    && $module_path !== EE_MODULES . 'gateways'
1154
-                ) {
1155
-                    // add to list of installed modules
1156
-                    EE_Config::register_module($module_path);
1157
-                }
1158
-            }
1159
-        }
1160
-        // filter list of installed modules
1161
-        return apply_filters(
1162
-            'FHEE__EE_Config___register_modules__installed_modules',
1163
-            EE_Registry::instance()->modules
1164
-        );
1165
-    }
1166
-
1167
-
1168
-
1169
-    /**
1170
-     *    register_module - makes core aware of this module
1171
-     *
1172
-     * @access    public
1173
-     * @param    string $module_path - full path up to and including module folder
1174
-     * @return    bool
1175
-     */
1176
-    public static function register_module($module_path = null)
1177
-    {
1178
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1179
-        $module_ext = '.module.php';
1180
-        // make all separators match
1181
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1182
-        // does the file path INCLUDE the actual file name as part of the path ?
1183
-        if (strpos($module_path, $module_ext) !== false) {
1184
-            // grab and shortcode file name from directory name and break apart at dots
1185
-            $module_file = explode('.', basename($module_path));
1186
-            // now we need to rebuild the shortcode path
1187
-            $module_path = explode(DS, $module_path);
1188
-            // remove last segment
1189
-            array_pop($module_path);
1190
-            // glue it back together
1191
-            $module_path = implode(DS, $module_path) . DS;
1192
-            // take first segment from file name pieces and sanitize it
1193
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1194
-            // ensure class prefix is added
1195
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1196
-        } else {
1197
-            // we need to generate the filename based off of the folder name
1198
-            // grab and sanitize module name
1199
-            $module = strtolower(basename($module_path));
1200
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1201
-            // like trailingslashit()
1202
-            $module_path = rtrim($module_path, DS) . DS;
1203
-            // create classname from module directory name
1204
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1205
-            // add class prefix
1206
-            $module_class = 'EED_' . $module;
1207
-        }
1208
-        // does the module exist ?
1209
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1210
-            $msg = sprintf(
1211
-                __(
1212
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1213
-                    'event_espresso'
1214
-                ),
1215
-                $module
1216
-            );
1217
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1218
-            return false;
1219
-        }
1220
-        // load the module class file
1221
-        require_once($module_path . $module_class . $module_ext);
1222
-        // verify that class exists
1223
-        if (! class_exists($module_class)) {
1224
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1225
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1226
-            return false;
1227
-        }
1228
-        // add to array of registered modules
1229
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1230
-        do_action(
1231
-            'AHEE__EE_Config__register_module__complete',
1232
-            $module_class,
1233
-            EE_Registry::instance()->modules->{$module_class}
1234
-        );
1235
-        return true;
1236
-    }
1237
-
1238
-
1239
-
1240
-    /**
1241
-     *    _initialize_modules
1242
-     *    allow modules to set hooks for the rest of the system
1243
-     *
1244
-     * @access private
1245
-     * @return void
1246
-     */
1247
-    private function _initialize_modules()
1248
-    {
1249
-        // cycle thru shortcode folders
1250
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1251
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1252
-            // which set hooks ?
1253
-            if (is_admin()) {
1254
-                // fire immediately
1255
-                call_user_func(array($module_class, 'set_hooks_admin'));
1256
-            } else {
1257
-                // delay until other systems are online
1258
-                add_action(
1259
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1260
-                    array($module_class, 'set_hooks')
1261
-                );
1262
-            }
1263
-        }
1264
-    }
1265
-
1266
-
1267
-
1268
-    /**
1269
-     *    register_route - adds module method routes to route_map
1270
-     *
1271
-     * @access    public
1272
-     * @param    string $route       - "pretty" public alias for module method
1273
-     * @param    string $module      - module name (classname without EED_ prefix)
1274
-     * @param    string $method_name - the actual module method to be routed to
1275
-     * @param    string $key         - url param key indicating a route is being called
1276
-     * @return    bool
1277
-     */
1278
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1279
-    {
1280
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1281
-        $module = str_replace('EED_', '', $module);
1282
-        $module_class = 'EED_' . $module;
1283
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1284
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1285
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1286
-            return false;
1287
-        }
1288
-        if (empty($route)) {
1289
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1290
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1291
-            return false;
1292
-        }
1293
-        if (! method_exists('EED_' . $module, $method_name)) {
1294
-            $msg = sprintf(
1295
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1296
-                $route
1297
-            );
1298
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1299
-            return false;
1300
-        }
1301
-        EE_Config::$_module_route_map[$key][$route] = array('EED_' . $module, $method_name);
1302
-        return true;
1303
-    }
1304
-
1305
-
1306
-
1307
-    /**
1308
-     *    get_route - get module method route
1309
-     *
1310
-     * @access    public
1311
-     * @param    string $route - "pretty" public alias for module method
1312
-     * @param    string $key   - url param key indicating a route is being called
1313
-     * @return    string
1314
-     */
1315
-    public static function get_route($route = null, $key = 'ee')
1316
-    {
1317
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1318
-        $route = (string)apply_filters('FHEE__EE_Config__get_route', $route);
1319
-        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1320
-            return EE_Config::$_module_route_map[$key][$route];
1321
-        }
1322
-        return null;
1323
-    }
1324
-
1325
-
1326
-
1327
-    /**
1328
-     *    get_routes - get ALL module method routes
1329
-     *
1330
-     * @access    public
1331
-     * @return    array
1332
-     */
1333
-    public static function get_routes()
1334
-    {
1335
-        return EE_Config::$_module_route_map;
1336
-    }
1337
-
1338
-
1339
-
1340
-    /**
1341
-     *    register_forward - allows modules to forward request to another module for further processing
1342
-     *
1343
-     * @access    public
1344
-     * @param    string       $route   - "pretty" public alias for module method
1345
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1346
-     *                                 class, allows different forwards to be served based on status
1347
-     * @param    array|string $forward - function name or array( class, method )
1348
-     * @param    string       $key     - url param key indicating a route is being called
1349
-     * @return    bool
1350
-     */
1351
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1352
-    {
1353
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1354
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1355
-            $msg = sprintf(
1356
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1357
-                $route
1358
-            );
1359
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1360
-            return false;
1361
-        }
1362
-        if (empty($forward)) {
1363
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1364
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1365
-            return false;
1366
-        }
1367
-        if (is_array($forward)) {
1368
-            if (! isset($forward[1])) {
1369
-                $msg = sprintf(
1370
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1371
-                    $route
1372
-                );
1373
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1374
-                return false;
1375
-            }
1376
-            if (! method_exists($forward[0], $forward[1])) {
1377
-                $msg = sprintf(
1378
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1379
-                    $forward[1],
1380
-                    $route
1381
-                );
1382
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1383
-                return false;
1384
-            }
1385
-        } else if (! function_exists($forward)) {
1386
-            $msg = sprintf(
1387
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1388
-                $forward,
1389
-                $route
1390
-            );
1391
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1392
-            return false;
1393
-        }
1394
-        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1395
-        return true;
1396
-    }
1397
-
1398
-
1399
-
1400
-    /**
1401
-     *    get_forward - get forwarding route
1402
-     *
1403
-     * @access    public
1404
-     * @param    string  $route  - "pretty" public alias for module method
1405
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1406
-     *                           allows different forwards to be served based on status
1407
-     * @param    string  $key    - url param key indicating a route is being called
1408
-     * @return    string
1409
-     */
1410
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1411
-    {
1412
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1413
-        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1414
-            return apply_filters(
1415
-                'FHEE__EE_Config__get_forward',
1416
-                EE_Config::$_module_forward_map[$key][$route][$status],
1417
-                $route,
1418
-                $status
1419
-            );
1420
-        }
1421
-        return null;
1422
-    }
1423
-
1424
-
1425
-
1426
-    /**
1427
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1428
-     *    results
1429
-     *
1430
-     * @access    public
1431
-     * @param    string  $route  - "pretty" public alias for module method
1432
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1433
-     *                           allows different views to be served based on status
1434
-     * @param    string  $view
1435
-     * @param    string  $key    - url param key indicating a route is being called
1436
-     * @return    bool
1437
-     */
1438
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1439
-    {
1440
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1441
-        if (! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1442
-            $msg = sprintf(
1443
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1444
-                $route
1445
-            );
1446
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1447
-            return false;
1448
-        }
1449
-        if (! is_readable($view)) {
1450
-            $msg = sprintf(
1451
-                __(
1452
-                    'The %s view file could not be found or is not readable due to file permissions.',
1453
-                    'event_espresso'
1454
-                ),
1455
-                $view
1456
-            );
1457
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1458
-            return false;
1459
-        }
1460
-        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1461
-        return true;
1462
-    }
1463
-
1464
-
1465
-
1466
-    /**
1467
-     *    get_view - get view for route and status
1468
-     *
1469
-     * @access    public
1470
-     * @param    string  $route  - "pretty" public alias for module method
1471
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1472
-     *                           allows different views to be served based on status
1473
-     * @param    string  $key    - url param key indicating a route is being called
1474
-     * @return    string
1475
-     */
1476
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1477
-    {
1478
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1479
-        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1480
-            return apply_filters(
1481
-                'FHEE__EE_Config__get_view',
1482
-                EE_Config::$_module_view_map[$key][$route][$status],
1483
-                $route,
1484
-                $status
1485
-            );
1486
-        }
1487
-        return null;
1488
-    }
1489
-
1490
-
1491
-
1492
-    public function update_addon_option_names()
1493
-    {
1494
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1495
-    }
1496
-
1497
-
1498
-
1499
-    public function shutdown()
1500
-    {
1501
-        $this->update_addon_option_names();
1502
-    }
1503
-
1504
-
1505
-
1506
-    /**
1507
-     * @return LegacyShortcodesManager
1508
-     */
1509
-    public static function getLegacyShortcodesManager()
1510
-    {
1511
-
1512
-        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1513
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1514
-                EE_Registry::instance()
1515
-            );
1516
-        }
1517
-        return EE_Config::instance()->legacy_shortcodes_manager;
1518
-    }
1519
-
1520
-
1521
-
1522
-    /**
1523
-     * register_shortcode - makes core aware of this shortcode
1524
-     *
1525
-     * @deprecated 4.9.26
1526
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1527
-     * @return    bool
1528
-     */
1529
-    public static function register_shortcode($shortcode_path = null)
1530
-    {
1531
-        EE_Error::doing_it_wrong(
1532
-            __METHOD__,
1533
-            __(
1534
-                'Usage is deprecated. Use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::registerShortcode() as direct replacement, or better yet, please see the new \EventEspresso\core\services\shortcodes\ShortcodesManager class.',
1535
-                'event_espresso'
1536
-            ),
1537
-            '4.9.26'
1538
-        );
1539
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1540
-    }
1541
-
1542
-
1543
-
1544
-}
1545
-
1546
-
1547
-
1548
-/**
1549
- * Base class used for config classes. These classes should generally not have
1550
- * magic functions in use, except we'll allow them to magically set and get stuff...
1551
- * basically, they should just be well-defined stdClasses
1552
- */
1553
-class EE_Config_Base
1554
-{
1555
-
1556
-    /**
1557
-     * Utility function for escaping the value of a property and returning.
1558
-     *
1559
-     * @param string $property property name (checks to see if exists).
1560
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
-     * @throws \EE_Error
1562
-     */
1563
-    public function get_pretty($property)
1564
-    {
1565
-        if (! property_exists($this, $property)) {
1566
-            throw new EE_Error(
1567
-                sprintf(
1568
-                    __(
1569
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
-                        'event_espresso'
1571
-                    ),
1572
-                    get_class($this),
1573
-                    $property
1574
-                )
1575
-            );
1576
-        }
1577
-        //just handling escaping of strings for now.
1578
-        if (is_string($this->{$property})) {
1579
-            return stripslashes($this->{$property});
1580
-        }
1581
-        return $this->{$property};
1582
-    }
1583
-
1584
-
1585
-
1586
-    public function populate()
1587
-    {
1588
-        //grab defaults via a new instance of this class.
1589
-        $class_name = get_class($this);
1590
-        $defaults = new $class_name;
1591
-        //loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
-        //default from our $defaults object.
1593
-        foreach (get_object_vars($defaults) as $property => $value) {
1594
-            if ($this->{$property} === null) {
1595
-                $this->{$property} = $value;
1596
-            }
1597
-        }
1598
-        //cleanup
1599
-        unset($defaults);
1600
-    }
1601
-
1602
-
1603
-
1604
-    /**
1605
-     *        __isset
1606
-     *
1607
-     * @param $a
1608
-     * @return bool
1609
-     */
1610
-    public function __isset($a)
1611
-    {
1612
-        return false;
1613
-    }
1614
-
1615
-
1616
-
1617
-    /**
1618
-     *        __unset
1619
-     *
1620
-     * @param $a
1621
-     * @return bool
1622
-     */
1623
-    public function __unset($a)
1624
-    {
1625
-        return false;
1626
-    }
1627
-
1628
-
1629
-
1630
-    /**
1631
-     *        __clone
1632
-     */
1633
-    public function __clone()
1634
-    {
1635
-    }
1636
-
1637
-
1638
-
1639
-    /**
1640
-     *        __wakeup
1641
-     */
1642
-    public function __wakeup()
1643
-    {
1644
-    }
1645
-
1646
-
1647
-
1648
-    /**
1649
-     *        __destruct
1650
-     */
1651
-    public function __destruct()
1652
-    {
1653
-    }
1654
-}
1655
-
1656
-
1657
-
1658
-/**
1659
- * Class for defining what's in the EE_Config relating to registration settings
1660
- */
1661
-class EE_Core_Config extends EE_Config_Base
1662
-{
1663
-
1664
-    public $current_blog_id;
1665
-
1666
-    public $ee_ueip_optin;
1667
-
1668
-    public $ee_ueip_has_notified;
1669
-
1670
-    /**
1671
-     * Not to be confused with the 4 critical page variables (See
1672
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
-     *
1676
-     * @var array
1677
-     */
1678
-    public $post_shortcodes;
1679
-
1680
-    public $module_route_map;
1681
-
1682
-    public $module_forward_map;
1683
-
1684
-    public $module_view_map;
1685
-
1686
-    /**
1687
-     * The next 4 vars are the IDs of critical EE pages.
1688
-     *
1689
-     * @var int
1690
-     */
1691
-    public $reg_page_id;
1692
-
1693
-    public $txn_page_id;
1694
-
1695
-    public $thank_you_page_id;
1696
-
1697
-    public $cancel_page_id;
1698
-
1699
-    /**
1700
-     * The next 4 vars are the URLs of critical EE pages.
1701
-     *
1702
-     * @var int
1703
-     */
1704
-    public $reg_page_url;
1705
-
1706
-    public $txn_page_url;
1707
-
1708
-    public $thank_you_page_url;
1709
-
1710
-    public $cancel_page_url;
1711
-
1712
-    /**
1713
-     * The next vars relate to the custom slugs for EE CPT routes
1714
-     */
1715
-    public $event_cpt_slug;
1716
-
1717
-
1718
-    /**
1719
-     * This caches the _ee_ueip_option in case this config is reset in the same
1720
-     * request across blog switches in a multisite context.
1721
-     * Avoids extra queries to the db for this option.
1722
-     *
1723
-     * @var bool
1724
-     */
1725
-    public static $ee_ueip_option;
1726
-
1727
-
1728
-
1729
-    /**
1730
-     *    class constructor
1731
-     *
1732
-     * @access    public
1733
-     */
1734
-    public function __construct()
1735
-    {
1736
-        // set default organization settings
1737
-        $this->current_blog_id = get_current_blog_id();
1738
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
-        $this->post_shortcodes = array();
1742
-        $this->module_route_map = array();
1743
-        $this->module_forward_map = array();
1744
-        $this->module_view_map = array();
1745
-        // critical EE page IDs
1746
-        $this->reg_page_id = 0;
1747
-        $this->txn_page_id = 0;
1748
-        $this->thank_you_page_id = 0;
1749
-        $this->cancel_page_id = 0;
1750
-        // critical EE page URLs
1751
-        $this->reg_page_url = '';
1752
-        $this->txn_page_url = '';
1753
-        $this->thank_you_page_url = '';
1754
-        $this->cancel_page_url = '';
1755
-        //cpt slugs
1756
-        $this->event_cpt_slug = __('events', 'event_espresso');
1757
-        //ueip constant check
1758
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
-            $this->ee_ueip_optin = false;
1760
-            $this->ee_ueip_has_notified = true;
1761
-        }
1762
-    }
1763
-
1764
-
1765
-
1766
-    /**
1767
-     * @return array
1768
-     */
1769
-    public function get_critical_pages_array()
1770
-    {
1771
-        return array(
1772
-            $this->reg_page_id,
1773
-            $this->txn_page_id,
1774
-            $this->thank_you_page_id,
1775
-            $this->cancel_page_id,
1776
-        );
1777
-    }
1778
-
1779
-
1780
-
1781
-    /**
1782
-     * @return array
1783
-     */
1784
-    public function get_critical_pages_shortcodes_array()
1785
-    {
1786
-        return array(
1787
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
-        );
1792
-    }
1793
-
1794
-
1795
-
1796
-    /**
1797
-     *  gets/returns URL for EE reg_page
1798
-     *
1799
-     * @access    public
1800
-     * @return    string
1801
-     */
1802
-    public function reg_page_url()
1803
-    {
1804
-        if (! $this->reg_page_url) {
1805
-            $this->reg_page_url = add_query_arg(
1806
-                                      array('uts' => time()),
1807
-                                      get_permalink($this->reg_page_id)
1808
-                                  ) . '#checkout';
1809
-        }
1810
-        return $this->reg_page_url;
1811
-    }
1812
-
1813
-
1814
-
1815
-    /**
1816
-     *  gets/returns URL for EE txn_page
1817
-     *
1818
-     * @param array $query_args like what gets passed to
1819
-     *                          add_query_arg() as the first argument
1820
-     * @access    public
1821
-     * @return    string
1822
-     */
1823
-    public function txn_page_url($query_args = array())
1824
-    {
1825
-        if (! $this->txn_page_url) {
1826
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1827
-        }
1828
-        if ($query_args) {
1829
-            return add_query_arg($query_args, $this->txn_page_url);
1830
-        } else {
1831
-            return $this->txn_page_url;
1832
-        }
1833
-    }
1834
-
1835
-
1836
-
1837
-    /**
1838
-     *  gets/returns URL for EE thank_you_page
1839
-     *
1840
-     * @param array $query_args like what gets passed to
1841
-     *                          add_query_arg() as the first argument
1842
-     * @access    public
1843
-     * @return    string
1844
-     */
1845
-    public function thank_you_page_url($query_args = array())
1846
-    {
1847
-        if (! $this->thank_you_page_url) {
1848
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
-        }
1850
-        if ($query_args) {
1851
-            return add_query_arg($query_args, $this->thank_you_page_url);
1852
-        } else {
1853
-            return $this->thank_you_page_url;
1854
-        }
1855
-    }
1856
-
1857
-
1858
-
1859
-    /**
1860
-     *  gets/returns URL for EE cancel_page
1861
-     *
1862
-     * @access    public
1863
-     * @return    string
1864
-     */
1865
-    public function cancel_page_url()
1866
-    {
1867
-        if (! $this->cancel_page_url) {
1868
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
-        }
1870
-        return $this->cancel_page_url;
1871
-    }
1872
-
1873
-
1874
-
1875
-    /**
1876
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
-     *
1878
-     * @since 4.7.5
1879
-     */
1880
-    protected function _reset_urls()
1881
-    {
1882
-        $this->reg_page_url = '';
1883
-        $this->txn_page_url = '';
1884
-        $this->cancel_page_url = '';
1885
-        $this->thank_you_page_url = '';
1886
-    }
1887
-
1888
-
1889
-
1890
-    /**
1891
-     * Used to return what the optin value is set for the EE User Experience Program.
1892
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
-     * on the main site only.
1894
-     *
1895
-     * @return mixed|void
1896
-     */
1897
-    protected function _get_main_ee_ueip_optin()
1898
-    {
1899
-        //if this is the main site then we can just bypass our direct query.
1900
-        if (is_main_site()) {
1901
-            return get_option('ee_ueip_optin', false);
1902
-        }
1903
-        //is this already cached for this request?  If so use it.
1904
-        if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
-            return EE_Core_Config::$ee_ueip_option;
1906
-        }
1907
-        global $wpdb;
1908
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1909
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
-        $option = 'ee_ueip_optin';
1911
-        //set correct table for query
1912
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
-        //rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
-        //get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
-        //re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
-        //this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
-        //for the purpose of caching.
1918
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1919
-        if (false !== $pre) {
1920
-            EE_Core_Config::$ee_ueip_option = $pre;
1921
-            return EE_Core_Config::$ee_ueip_option;
1922
-        }
1923
-        $row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
-            $option));
1925
-        if (is_object($row)) {
1926
-            $value = $row->option_value;
1927
-        } else { //option does not exist so use default.
1928
-            return apply_filters('default_option_' . $option, false, $option);
1929
-        }
1930
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
-        return EE_Core_Config::$ee_ueip_option;
1932
-    }
1933
-
1934
-    /**
1935
-     * Utility function for escaping the value of a property and returning.
1936
-     *
1937
-     * @param string $property property name (checks to see if exists).
1938
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1939
-     * @throws \EE_Error
1940
-     */
1941
-    public function get_pretty($property)
1942
-    {
1943
-        if ($property === 'ee_ueip_optin') {
1944
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1945
-        }
1946
-        return parent::get_pretty($property);
1947
-    }
1948
-
1949
-
1950
-    /**
1951
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1952
-     * on the object.
1953
-     *
1954
-     * @return array
1955
-     */
1956
-    public function __sleep()
1957
-    {
1958
-        //reset all url properties
1959
-        $this->_reset_urls();
1960
-        //return what to save to db
1961
-        return array_keys(get_object_vars($this));
1962
-    }
1963
-
1964
-}
1965
-
1966
-
1967
-
1968
-/**
1969
- * Config class for storing info on the Organization
1970
- */
1971
-class EE_Organization_Config extends EE_Config_Base
1972
-{
1973
-
1974
-    /**
1975
-     * @var string $name
1976
-     * eg EE4.1
1977
-     */
1978
-    public $name;
1979
-
1980
-    /**
1981
-     * @var string $address_1
1982
-     * eg 123 Onna Road
1983
-     */
1984
-    public $address_1;
1985
-
1986
-    /**
1987
-     * @var string $address_2
1988
-     * eg PO Box 123
1989
-     */
1990
-    public $address_2;
1991
-
1992
-    /**
1993
-     * @var string $city
1994
-     * eg Inna City
1995
-     */
1996
-    public $city;
1997
-
1998
-    /**
1999
-     * @var int $STA_ID
2000
-     * eg 4
2001
-     */
2002
-    public $STA_ID;
2003
-
2004
-    /**
2005
-     * @var string $CNT_ISO
2006
-     * eg US
2007
-     */
2008
-    public $CNT_ISO;
2009
-
2010
-    /**
2011
-     * @var string $zip
2012
-     * eg 12345  or V1A 2B3
2013
-     */
2014
-    public $zip;
2015
-
2016
-    /**
2017
-     * @var string $email
2018
-     * eg [email protected]
2019
-     */
2020
-    public $email;
2021
-
2022
-
2023
-    /**
2024
-     * @var string $phone
2025
-     * eg. 111-111-1111
2026
-     */
2027
-    public $phone;
2028
-
2029
-
2030
-    /**
2031
-     * @var string $vat
2032
-     * VAT/Tax Number
2033
-     */
2034
-    public $vat;
2035
-
2036
-    /**
2037
-     * @var string $logo_url
2038
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2039
-     */
2040
-    public $logo_url;
2041
-
2042
-
2043
-    /**
2044
-     * The below are all various properties for holding links to organization social network profiles
2045
-     *
2046
-     * @var string
2047
-     */
2048
-    /**
2049
-     * facebook (facebook.com/profile.name)
2050
-     *
2051
-     * @var string
2052
-     */
2053
-    public $facebook;
2054
-
2055
-
2056
-    /**
2057
-     * twitter (twitter.com/twitter_handle)
2058
-     *
2059
-     * @var string
2060
-     */
2061
-    public $twitter;
2062
-
2063
-
2064
-    /**
2065
-     * linkedin (linkedin.com/in/profile_name)
2066
-     *
2067
-     * @var string
2068
-     */
2069
-    public $linkedin;
2070
-
2071
-
2072
-    /**
2073
-     * pinterest (www.pinterest.com/profile_name)
2074
-     *
2075
-     * @var string
2076
-     */
2077
-    public $pinterest;
2078
-
2079
-
2080
-    /**
2081
-     * google+ (google.com/+profileName)
2082
-     *
2083
-     * @var string
2084
-     */
2085
-    public $google;
2086
-
2087
-
2088
-    /**
2089
-     * instagram (instagram.com/handle)
2090
-     *
2091
-     * @var string
2092
-     */
2093
-    public $instagram;
2094
-
2095
-
2096
-
2097
-    /**
2098
-     *    class constructor
2099
-     *
2100
-     * @access    public
2101
-     */
2102
-    public function __construct()
2103
-    {
2104
-        // set default organization settings
2105
-        //decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2106
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2107
-        $this->address_1 = '123 Onna Road';
2108
-        $this->address_2 = 'PO Box 123';
2109
-        $this->city = 'Inna City';
2110
-        $this->STA_ID = 4;
2111
-        $this->CNT_ISO = 'US';
2112
-        $this->zip = '12345';
2113
-        $this->email = get_bloginfo('admin_email');
2114
-        $this->phone = '';
2115
-        $this->vat = '123456789';
2116
-        $this->logo_url = '';
2117
-        $this->facebook = '';
2118
-        $this->twitter = '';
2119
-        $this->linkedin = '';
2120
-        $this->pinterest = '';
2121
-        $this->google = '';
2122
-        $this->instagram = '';
2123
-    }
2124
-
2125
-}
2126
-
2127
-
2128
-
2129
-/**
2130
- * Class for defining what's in the EE_Config relating to currency
2131
- */
2132
-class EE_Currency_Config extends EE_Config_Base
2133
-{
2134
-
2135
-    /**
2136
-     * @var string $code
2137
-     * eg 'US'
2138
-     */
2139
-    public $code;
2140
-
2141
-    /**
2142
-     * @var string $name
2143
-     * eg 'Dollar'
2144
-     */
2145
-    public $name;
2146
-
2147
-    /**
2148
-     * plural name
2149
-     *
2150
-     * @var string $plural
2151
-     * eg 'Dollars'
2152
-     */
2153
-    public $plural;
2154
-
2155
-    /**
2156
-     * currency sign
2157
-     *
2158
-     * @var string $sign
2159
-     * eg '$'
2160
-     */
2161
-    public $sign;
2162
-
2163
-    /**
2164
-     * Whether the currency sign should come before the number or not
2165
-     *
2166
-     * @var boolean $sign_b4
2167
-     */
2168
-    public $sign_b4;
2169
-
2170
-    /**
2171
-     * How many digits should come after the decimal place
2172
-     *
2173
-     * @var int $dec_plc
2174
-     */
2175
-    public $dec_plc;
2176
-
2177
-    /**
2178
-     * Symbol to use for decimal mark
2179
-     *
2180
-     * @var string $dec_mrk
2181
-     * eg '.'
2182
-     */
2183
-    public $dec_mrk;
2184
-
2185
-    /**
2186
-     * Symbol to use for thousands
2187
-     *
2188
-     * @var string $thsnds
2189
-     * eg ','
2190
-     */
2191
-    public $thsnds;
2192
-
2193
-
2194
-
2195
-    /**
2196
-     *    class constructor
2197
-     *
2198
-     * @access    public
2199
-     * @param string $CNT_ISO
2200
-     * @throws \EE_Error
2201
-     */
2202
-    public function __construct($CNT_ISO = '')
2203
-    {
2204
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2205
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2206
-        // get country code from organization settings or use default
2207
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2208
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2209
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2210
-            : '';
2211
-        // but override if requested
2212
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2213
-        // so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2214
-        if (
2215
-            ! empty($CNT_ISO)
2216
-            && EE_Maintenance_Mode::instance()->models_can_query()
2217
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2218
-        ) {
2219
-            // retrieve the country settings from the db, just in case they have been customized
2220
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2221
-            if ($country instanceof EE_Country) {
2222
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2223
-                $this->name = $country->currency_name_single();    // Dollar
2224
-                $this->plural = $country->currency_name_plural();    // Dollars
2225
-                $this->sign = $country->currency_sign();            // currency sign: $
2226
-                $this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2227
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2228
-                $this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2229
-                $this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2230
-            }
2231
-        }
2232
-        // fallback to hardcoded defaults, in case the above failed
2233
-        if (empty($this->code)) {
2234
-            // set default currency settings
2235
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2236
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2237
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2238
-            $this->sign = '$';    // currency sign: $
2239
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2240
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2241
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2242
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2243
-        }
2244
-    }
2245
-}
2246
-
2247
-
2248
-
2249
-/**
2250
- * Class for defining what's in the EE_Config relating to registration settings
2251
- */
2252
-class EE_Registration_Config extends EE_Config_Base
2253
-{
2254
-
2255
-    /**
2256
-     * Default registration status
2257
-     *
2258
-     * @var string $default_STS_ID
2259
-     * eg 'RPP'
2260
-     */
2261
-    public $default_STS_ID;
2262
-
2263
-
2264
-    /**
2265
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2266
-     * registrations)
2267
-     * @var int
2268
-     */
2269
-    public $default_maximum_number_of_tickets;
2270
-
2271
-
2272
-    /**
2273
-     * level of validation to apply to email addresses
2274
-     *
2275
-     * @var string $email_validation_level
2276
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2277
-     */
2278
-    public $email_validation_level;
2279
-
2280
-    /**
2281
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2282
-     *
2283
-     * @var boolean $show_pending_payment_options
2284
-     */
2285
-    public $show_pending_payment_options;
2286
-
2287
-    /**
2288
-     * Whether to skip the registration confirmation page
2289
-     *
2290
-     * @var boolean $skip_reg_confirmation
2291
-     */
2292
-    public $skip_reg_confirmation;
2293
-
2294
-    /**
2295
-     * an array of SPCO reg steps where:
2296
-     *        the keys denotes the reg step order
2297
-     *        each element consists of an array with the following elements:
2298
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2299
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2300
-     *            "slug" => the URL param used to trigger the reg step
2301
-     *
2302
-     * @var array $reg_steps
2303
-     */
2304
-    public $reg_steps;
2305
-
2306
-    /**
2307
-     * Whether registration confirmation should be the last page of SPCO
2308
-     *
2309
-     * @var boolean $reg_confirmation_last
2310
-     */
2311
-    public $reg_confirmation_last;
2312
-
2313
-    /**
2314
-     * Whether or not to enable the EE Bot Trap
2315
-     *
2316
-     * @var boolean $use_bot_trap
2317
-     */
2318
-    public $use_bot_trap;
2319
-
2320
-    /**
2321
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2322
-     *
2323
-     * @var boolean $use_encryption
2324
-     */
2325
-    public $use_encryption;
1544
+}
2326 1545
 
2327
-    /**
2328
-     * Whether or not to use ReCaptcha
2329
-     *
2330
-     * @var boolean $use_captcha
2331
-     */
2332
-    public $use_captcha;
2333 1546
 
2334
-    /**
2335
-     * ReCaptcha Theme
2336
-     *
2337
-     * @var string $recaptcha_theme
2338
-     *    options: 'dark    ', 'light'
2339
-     */
2340
-    public $recaptcha_theme;
2341 1547
 
2342
-    /**
2343
-     * ReCaptcha Type
2344
-     *
2345
-     * @var string $recaptcha_type
2346
-     *    options: 'audio', 'image'
2347
-     */
2348
-    public $recaptcha_type;
1548
+/**
1549
+ * Base class used for config classes. These classes should generally not have
1550
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1551
+ * basically, they should just be well-defined stdClasses
1552
+ */
1553
+class EE_Config_Base
1554
+{
2349 1555
 
2350
-    /**
2351
-     * ReCaptcha language
2352
-     *
2353
-     * @var string $recaptcha_language
2354
-     * eg 'en'
2355
-     */
2356
-    public $recaptcha_language;
1556
+	/**
1557
+	 * Utility function for escaping the value of a property and returning.
1558
+	 *
1559
+	 * @param string $property property name (checks to see if exists).
1560
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1561
+	 * @throws \EE_Error
1562
+	 */
1563
+	public function get_pretty($property)
1564
+	{
1565
+		if (! property_exists($this, $property)) {
1566
+			throw new EE_Error(
1567
+				sprintf(
1568
+					__(
1569
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1570
+						'event_espresso'
1571
+					),
1572
+					get_class($this),
1573
+					$property
1574
+				)
1575
+			);
1576
+		}
1577
+		//just handling escaping of strings for now.
1578
+		if (is_string($this->{$property})) {
1579
+			return stripslashes($this->{$property});
1580
+		}
1581
+		return $this->{$property};
1582
+	}
1583
+
1584
+
1585
+
1586
+	public function populate()
1587
+	{
1588
+		//grab defaults via a new instance of this class.
1589
+		$class_name = get_class($this);
1590
+		$defaults = new $class_name;
1591
+		//loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1592
+		//default from our $defaults object.
1593
+		foreach (get_object_vars($defaults) as $property => $value) {
1594
+			if ($this->{$property} === null) {
1595
+				$this->{$property} = $value;
1596
+			}
1597
+		}
1598
+		//cleanup
1599
+		unset($defaults);
1600
+	}
1601
+
1602
+
1603
+
1604
+	/**
1605
+	 *        __isset
1606
+	 *
1607
+	 * @param $a
1608
+	 * @return bool
1609
+	 */
1610
+	public function __isset($a)
1611
+	{
1612
+		return false;
1613
+	}
1614
+
1615
+
1616
+
1617
+	/**
1618
+	 *        __unset
1619
+	 *
1620
+	 * @param $a
1621
+	 * @return bool
1622
+	 */
1623
+	public function __unset($a)
1624
+	{
1625
+		return false;
1626
+	}
1627
+
1628
+
1629
+
1630
+	/**
1631
+	 *        __clone
1632
+	 */
1633
+	public function __clone()
1634
+	{
1635
+	}
1636
+
1637
+
1638
+
1639
+	/**
1640
+	 *        __wakeup
1641
+	 */
1642
+	public function __wakeup()
1643
+	{
1644
+	}
1645
+
1646
+
1647
+
1648
+	/**
1649
+	 *        __destruct
1650
+	 */
1651
+	public function __destruct()
1652
+	{
1653
+	}
1654
+}
2357 1655
 
2358
-    /**
2359
-     * ReCaptcha public key
2360
-     *
2361
-     * @var string $recaptcha_publickey
2362
-     */
2363
-    public $recaptcha_publickey;
2364 1656
 
2365
-    /**
2366
-     * ReCaptcha private key
2367
-     *
2368
-     * @var string $recaptcha_privatekey
2369
-     */
2370
-    public $recaptcha_privatekey;
2371 1657
 
2372
-    /**
2373
-     * ReCaptcha width
2374
-     *
2375
-     * @var int $recaptcha_width
2376
-     * @deprecated
2377
-     */
2378
-    public $recaptcha_width;
1658
+/**
1659
+ * Class for defining what's in the EE_Config relating to registration settings
1660
+ */
1661
+class EE_Core_Config extends EE_Config_Base
1662
+{
2379 1663
 
2380
-    /**
2381
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2382
-     *
2383
-     * @var boolean $track_invalid_checkout_access
2384
-     */
2385
-    protected $track_invalid_checkout_access = true;
1664
+	public $current_blog_id;
1665
+
1666
+	public $ee_ueip_optin;
1667
+
1668
+	public $ee_ueip_has_notified;
1669
+
1670
+	/**
1671
+	 * Not to be confused with the 4 critical page variables (See
1672
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1673
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1674
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1675
+	 *
1676
+	 * @var array
1677
+	 */
1678
+	public $post_shortcodes;
1679
+
1680
+	public $module_route_map;
1681
+
1682
+	public $module_forward_map;
1683
+
1684
+	public $module_view_map;
1685
+
1686
+	/**
1687
+	 * The next 4 vars are the IDs of critical EE pages.
1688
+	 *
1689
+	 * @var int
1690
+	 */
1691
+	public $reg_page_id;
1692
+
1693
+	public $txn_page_id;
1694
+
1695
+	public $thank_you_page_id;
1696
+
1697
+	public $cancel_page_id;
1698
+
1699
+	/**
1700
+	 * The next 4 vars are the URLs of critical EE pages.
1701
+	 *
1702
+	 * @var int
1703
+	 */
1704
+	public $reg_page_url;
1705
+
1706
+	public $txn_page_url;
1707
+
1708
+	public $thank_you_page_url;
1709
+
1710
+	public $cancel_page_url;
1711
+
1712
+	/**
1713
+	 * The next vars relate to the custom slugs for EE CPT routes
1714
+	 */
1715
+	public $event_cpt_slug;
1716
+
1717
+
1718
+	/**
1719
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1720
+	 * request across blog switches in a multisite context.
1721
+	 * Avoids extra queries to the db for this option.
1722
+	 *
1723
+	 * @var bool
1724
+	 */
1725
+	public static $ee_ueip_option;
1726
+
1727
+
1728
+
1729
+	/**
1730
+	 *    class constructor
1731
+	 *
1732
+	 * @access    public
1733
+	 */
1734
+	public function __construct()
1735
+	{
1736
+		// set default organization settings
1737
+		$this->current_blog_id = get_current_blog_id();
1738
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1739
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1740
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1741
+		$this->post_shortcodes = array();
1742
+		$this->module_route_map = array();
1743
+		$this->module_forward_map = array();
1744
+		$this->module_view_map = array();
1745
+		// critical EE page IDs
1746
+		$this->reg_page_id = 0;
1747
+		$this->txn_page_id = 0;
1748
+		$this->thank_you_page_id = 0;
1749
+		$this->cancel_page_id = 0;
1750
+		// critical EE page URLs
1751
+		$this->reg_page_url = '';
1752
+		$this->txn_page_url = '';
1753
+		$this->thank_you_page_url = '';
1754
+		$this->cancel_page_url = '';
1755
+		//cpt slugs
1756
+		$this->event_cpt_slug = __('events', 'event_espresso');
1757
+		//ueip constant check
1758
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1759
+			$this->ee_ueip_optin = false;
1760
+			$this->ee_ueip_has_notified = true;
1761
+		}
1762
+	}
1763
+
1764
+
1765
+
1766
+	/**
1767
+	 * @return array
1768
+	 */
1769
+	public function get_critical_pages_array()
1770
+	{
1771
+		return array(
1772
+			$this->reg_page_id,
1773
+			$this->txn_page_id,
1774
+			$this->thank_you_page_id,
1775
+			$this->cancel_page_id,
1776
+		);
1777
+	}
1778
+
1779
+
1780
+
1781
+	/**
1782
+	 * @return array
1783
+	 */
1784
+	public function get_critical_pages_shortcodes_array()
1785
+	{
1786
+		return array(
1787
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1788
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1789
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1790
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1791
+		);
1792
+	}
1793
+
1794
+
1795
+
1796
+	/**
1797
+	 *  gets/returns URL for EE reg_page
1798
+	 *
1799
+	 * @access    public
1800
+	 * @return    string
1801
+	 */
1802
+	public function reg_page_url()
1803
+	{
1804
+		if (! $this->reg_page_url) {
1805
+			$this->reg_page_url = add_query_arg(
1806
+									  array('uts' => time()),
1807
+									  get_permalink($this->reg_page_id)
1808
+								  ) . '#checkout';
1809
+		}
1810
+		return $this->reg_page_url;
1811
+	}
1812
+
1813
+
1814
+
1815
+	/**
1816
+	 *  gets/returns URL for EE txn_page
1817
+	 *
1818
+	 * @param array $query_args like what gets passed to
1819
+	 *                          add_query_arg() as the first argument
1820
+	 * @access    public
1821
+	 * @return    string
1822
+	 */
1823
+	public function txn_page_url($query_args = array())
1824
+	{
1825
+		if (! $this->txn_page_url) {
1826
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1827
+		}
1828
+		if ($query_args) {
1829
+			return add_query_arg($query_args, $this->txn_page_url);
1830
+		} else {
1831
+			return $this->txn_page_url;
1832
+		}
1833
+	}
1834
+
1835
+
1836
+
1837
+	/**
1838
+	 *  gets/returns URL for EE thank_you_page
1839
+	 *
1840
+	 * @param array $query_args like what gets passed to
1841
+	 *                          add_query_arg() as the first argument
1842
+	 * @access    public
1843
+	 * @return    string
1844
+	 */
1845
+	public function thank_you_page_url($query_args = array())
1846
+	{
1847
+		if (! $this->thank_you_page_url) {
1848
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1849
+		}
1850
+		if ($query_args) {
1851
+			return add_query_arg($query_args, $this->thank_you_page_url);
1852
+		} else {
1853
+			return $this->thank_you_page_url;
1854
+		}
1855
+	}
1856
+
1857
+
1858
+
1859
+	/**
1860
+	 *  gets/returns URL for EE cancel_page
1861
+	 *
1862
+	 * @access    public
1863
+	 * @return    string
1864
+	 */
1865
+	public function cancel_page_url()
1866
+	{
1867
+		if (! $this->cancel_page_url) {
1868
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1869
+		}
1870
+		return $this->cancel_page_url;
1871
+	}
1872
+
1873
+
1874
+
1875
+	/**
1876
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1877
+	 *
1878
+	 * @since 4.7.5
1879
+	 */
1880
+	protected function _reset_urls()
1881
+	{
1882
+		$this->reg_page_url = '';
1883
+		$this->txn_page_url = '';
1884
+		$this->cancel_page_url = '';
1885
+		$this->thank_you_page_url = '';
1886
+	}
1887
+
1888
+
1889
+
1890
+	/**
1891
+	 * Used to return what the optin value is set for the EE User Experience Program.
1892
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1893
+	 * on the main site only.
1894
+	 *
1895
+	 * @return mixed|void
1896
+	 */
1897
+	protected function _get_main_ee_ueip_optin()
1898
+	{
1899
+		//if this is the main site then we can just bypass our direct query.
1900
+		if (is_main_site()) {
1901
+			return get_option('ee_ueip_optin', false);
1902
+		}
1903
+		//is this already cached for this request?  If so use it.
1904
+		if ( ! empty(EE_Core_Config::$ee_ueip_option)) {
1905
+			return EE_Core_Config::$ee_ueip_option;
1906
+		}
1907
+		global $wpdb;
1908
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1909
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1910
+		$option = 'ee_ueip_optin';
1911
+		//set correct table for query
1912
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1913
+		//rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1914
+		//get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1915
+		//re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1916
+		//this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1917
+		//for the purpose of caching.
1918
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1919
+		if (false !== $pre) {
1920
+			EE_Core_Config::$ee_ueip_option = $pre;
1921
+			return EE_Core_Config::$ee_ueip_option;
1922
+		}
1923
+		$row = $wpdb->get_row($wpdb->prepare("SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1924
+			$option));
1925
+		if (is_object($row)) {
1926
+			$value = $row->option_value;
1927
+		} else { //option does not exist so use default.
1928
+			return apply_filters('default_option_' . $option, false, $option);
1929
+		}
1930
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1931
+		return EE_Core_Config::$ee_ueip_option;
1932
+	}
1933
+
1934
+	/**
1935
+	 * Utility function for escaping the value of a property and returning.
1936
+	 *
1937
+	 * @param string $property property name (checks to see if exists).
1938
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1939
+	 * @throws \EE_Error
1940
+	 */
1941
+	public function get_pretty($property)
1942
+	{
1943
+		if ($property === 'ee_ueip_optin') {
1944
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1945
+		}
1946
+		return parent::get_pretty($property);
1947
+	}
1948
+
1949
+
1950
+	/**
1951
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1952
+	 * on the object.
1953
+	 *
1954
+	 * @return array
1955
+	 */
1956
+	public function __sleep()
1957
+	{
1958
+		//reset all url properties
1959
+		$this->_reset_urls();
1960
+		//return what to save to db
1961
+		return array_keys(get_object_vars($this));
1962
+	}
2386 1963
 
1964
+}
2387 1965
 
2388 1966
 
2389
-    /**
2390
-     *    class constructor
2391
-     *
2392
-     * @access    public
2393
-     */
2394
-    public function __construct()
2395
-    {
2396
-        // set default registration settings
2397
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2398
-        $this->email_validation_level = 'wp_default';
2399
-        $this->show_pending_payment_options = true;
2400
-        $this->skip_reg_confirmation = false;
2401
-        $this->reg_steps = array();
2402
-        $this->reg_confirmation_last = false;
2403
-        $this->use_bot_trap = true;
2404
-        $this->use_encryption = true;
2405
-        $this->use_captcha = false;
2406
-        $this->recaptcha_theme = 'light';
2407
-        $this->recaptcha_type = 'image';
2408
-        $this->recaptcha_language = 'en';
2409
-        $this->recaptcha_publickey = null;
2410
-        $this->recaptcha_privatekey = null;
2411
-        $this->recaptcha_width = 500;
2412
-        $this->default_maximum_number_of_tickets = 10;
2413
-    }
2414
-
2415
-
2416
-
2417
-    /**
2418
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2419
-     *
2420
-     * @since 4.8.8.rc.019
2421
-     */
2422
-    public function do_hooks()
2423
-    {
2424
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2425
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2426
-    }
2427 1967
 
1968
+/**
1969
+ * Config class for storing info on the Organization
1970
+ */
1971
+class EE_Organization_Config extends EE_Config_Base
1972
+{
2428 1973
 
1974
+	/**
1975
+	 * @var string $name
1976
+	 * eg EE4.1
1977
+	 */
1978
+	public $name;
1979
+
1980
+	/**
1981
+	 * @var string $address_1
1982
+	 * eg 123 Onna Road
1983
+	 */
1984
+	public $address_1;
1985
+
1986
+	/**
1987
+	 * @var string $address_2
1988
+	 * eg PO Box 123
1989
+	 */
1990
+	public $address_2;
1991
+
1992
+	/**
1993
+	 * @var string $city
1994
+	 * eg Inna City
1995
+	 */
1996
+	public $city;
1997
+
1998
+	/**
1999
+	 * @var int $STA_ID
2000
+	 * eg 4
2001
+	 */
2002
+	public $STA_ID;
2003
+
2004
+	/**
2005
+	 * @var string $CNT_ISO
2006
+	 * eg US
2007
+	 */
2008
+	public $CNT_ISO;
2009
+
2010
+	/**
2011
+	 * @var string $zip
2012
+	 * eg 12345  or V1A 2B3
2013
+	 */
2014
+	public $zip;
2015
+
2016
+	/**
2017
+	 * @var string $email
2018
+	 * eg [email protected]
2019
+	 */
2020
+	public $email;
2021
+
2022
+
2023
+	/**
2024
+	 * @var string $phone
2025
+	 * eg. 111-111-1111
2026
+	 */
2027
+	public $phone;
2028
+
2029
+
2030
+	/**
2031
+	 * @var string $vat
2032
+	 * VAT/Tax Number
2033
+	 */
2034
+	public $vat;
2035
+
2036
+	/**
2037
+	 * @var string $logo_url
2038
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
2039
+	 */
2040
+	public $logo_url;
2041
+
2042
+
2043
+	/**
2044
+	 * The below are all various properties for holding links to organization social network profiles
2045
+	 *
2046
+	 * @var string
2047
+	 */
2048
+	/**
2049
+	 * facebook (facebook.com/profile.name)
2050
+	 *
2051
+	 * @var string
2052
+	 */
2053
+	public $facebook;
2054
+
2055
+
2056
+	/**
2057
+	 * twitter (twitter.com/twitter_handle)
2058
+	 *
2059
+	 * @var string
2060
+	 */
2061
+	public $twitter;
2062
+
2063
+
2064
+	/**
2065
+	 * linkedin (linkedin.com/in/profile_name)
2066
+	 *
2067
+	 * @var string
2068
+	 */
2069
+	public $linkedin;
2070
+
2071
+
2072
+	/**
2073
+	 * pinterest (www.pinterest.com/profile_name)
2074
+	 *
2075
+	 * @var string
2076
+	 */
2077
+	public $pinterest;
2078
+
2079
+
2080
+	/**
2081
+	 * google+ (google.com/+profileName)
2082
+	 *
2083
+	 * @var string
2084
+	 */
2085
+	public $google;
2086
+
2087
+
2088
+	/**
2089
+	 * instagram (instagram.com/handle)
2090
+	 *
2091
+	 * @var string
2092
+	 */
2093
+	public $instagram;
2094
+
2095
+
2096
+
2097
+	/**
2098
+	 *    class constructor
2099
+	 *
2100
+	 * @access    public
2101
+	 */
2102
+	public function __construct()
2103
+	{
2104
+		// set default organization settings
2105
+		//decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2106
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2107
+		$this->address_1 = '123 Onna Road';
2108
+		$this->address_2 = 'PO Box 123';
2109
+		$this->city = 'Inna City';
2110
+		$this->STA_ID = 4;
2111
+		$this->CNT_ISO = 'US';
2112
+		$this->zip = '12345';
2113
+		$this->email = get_bloginfo('admin_email');
2114
+		$this->phone = '';
2115
+		$this->vat = '123456789';
2116
+		$this->logo_url = '';
2117
+		$this->facebook = '';
2118
+		$this->twitter = '';
2119
+		$this->linkedin = '';
2120
+		$this->pinterest = '';
2121
+		$this->google = '';
2122
+		$this->instagram = '';
2123
+	}
2429 2124
 
2430
-    /**
2431
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2432
-     * field matches the config setting for default_STS_ID.
2433
-     */
2434
-    public function set_default_reg_status_on_EEM_Event()
2435
-    {
2436
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2437
-    }
2125
+}
2438 2126
 
2439 2127
 
2440
-    /**
2441
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2442
-     * for Events matches the config setting for default_maximum_number_of_tickets
2443
-     */
2444
-    public function set_default_max_ticket_on_EEM_Event()
2445
-    {
2446
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2447
-    }
2448 2128
 
2129
+/**
2130
+ * Class for defining what's in the EE_Config relating to currency
2131
+ */
2132
+class EE_Currency_Config extends EE_Config_Base
2133
+{
2449 2134
 
2135
+	/**
2136
+	 * @var string $code
2137
+	 * eg 'US'
2138
+	 */
2139
+	public $code;
2140
+
2141
+	/**
2142
+	 * @var string $name
2143
+	 * eg 'Dollar'
2144
+	 */
2145
+	public $name;
2146
+
2147
+	/**
2148
+	 * plural name
2149
+	 *
2150
+	 * @var string $plural
2151
+	 * eg 'Dollars'
2152
+	 */
2153
+	public $plural;
2154
+
2155
+	/**
2156
+	 * currency sign
2157
+	 *
2158
+	 * @var string $sign
2159
+	 * eg '$'
2160
+	 */
2161
+	public $sign;
2162
+
2163
+	/**
2164
+	 * Whether the currency sign should come before the number or not
2165
+	 *
2166
+	 * @var boolean $sign_b4
2167
+	 */
2168
+	public $sign_b4;
2169
+
2170
+	/**
2171
+	 * How many digits should come after the decimal place
2172
+	 *
2173
+	 * @var int $dec_plc
2174
+	 */
2175
+	public $dec_plc;
2176
+
2177
+	/**
2178
+	 * Symbol to use for decimal mark
2179
+	 *
2180
+	 * @var string $dec_mrk
2181
+	 * eg '.'
2182
+	 */
2183
+	public $dec_mrk;
2184
+
2185
+	/**
2186
+	 * Symbol to use for thousands
2187
+	 *
2188
+	 * @var string $thsnds
2189
+	 * eg ','
2190
+	 */
2191
+	public $thsnds;
2192
+
2193
+
2194
+
2195
+	/**
2196
+	 *    class constructor
2197
+	 *
2198
+	 * @access    public
2199
+	 * @param string $CNT_ISO
2200
+	 * @throws \EE_Error
2201
+	 */
2202
+	public function __construct($CNT_ISO = '')
2203
+	{
2204
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2205
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2206
+		// get country code from organization settings or use default
2207
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2208
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2209
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2210
+			: '';
2211
+		// but override if requested
2212
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2213
+		// so if that all went well, and we are not in M-Mode (cuz you can't query the db in M-Mode) and double-check the countries table exists
2214
+		if (
2215
+			! empty($CNT_ISO)
2216
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2217
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2218
+		) {
2219
+			// retrieve the country settings from the db, just in case they have been customized
2220
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2221
+			if ($country instanceof EE_Country) {
2222
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2223
+				$this->name = $country->currency_name_single();    // Dollar
2224
+				$this->plural = $country->currency_name_plural();    // Dollars
2225
+				$this->sign = $country->currency_sign();            // currency sign: $
2226
+				$this->sign_b4 = $country->currency_sign_before();        // currency sign before or after: $TRUE  or  FALSE$
2227
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2228
+				$this->dec_mrk = $country->currency_decimal_mark();    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2229
+				$this->thsnds = $country->currency_thousands_separator();    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2230
+			}
2231
+		}
2232
+		// fallback to hardcoded defaults, in case the above failed
2233
+		if (empty($this->code)) {
2234
+			// set default currency settings
2235
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2236
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2237
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2238
+			$this->sign = '$';    // currency sign: $
2239
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2240
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2241
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2242
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2243
+		}
2244
+	}
2245
+}
2450 2246
 
2451
-    /**
2452
-     * @return boolean
2453
-     */
2454
-    public function track_invalid_checkout_access()
2455
-    {
2456
-        return $this->track_invalid_checkout_access;
2457
-    }
2458 2247
 
2459 2248
 
2249
+/**
2250
+ * Class for defining what's in the EE_Config relating to registration settings
2251
+ */
2252
+class EE_Registration_Config extends EE_Config_Base
2253
+{
2460 2254
 
2461
-    /**
2462
-     * @param boolean $track_invalid_checkout_access
2463
-     */
2464
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2465
-    {
2466
-        $this->track_invalid_checkout_access = filter_var(
2467
-            $track_invalid_checkout_access,
2468
-            FILTER_VALIDATE_BOOLEAN
2469
-        );
2470
-    }
2255
+	/**
2256
+	 * Default registration status
2257
+	 *
2258
+	 * @var string $default_STS_ID
2259
+	 * eg 'RPP'
2260
+	 */
2261
+	public $default_STS_ID;
2262
+
2263
+
2264
+	/**
2265
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2266
+	 * registrations)
2267
+	 * @var int
2268
+	 */
2269
+	public $default_maximum_number_of_tickets;
2270
+
2271
+
2272
+	/**
2273
+	 * level of validation to apply to email addresses
2274
+	 *
2275
+	 * @var string $email_validation_level
2276
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2277
+	 */
2278
+	public $email_validation_level;
2279
+
2280
+	/**
2281
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2282
+	 *
2283
+	 * @var boolean $show_pending_payment_options
2284
+	 */
2285
+	public $show_pending_payment_options;
2286
+
2287
+	/**
2288
+	 * Whether to skip the registration confirmation page
2289
+	 *
2290
+	 * @var boolean $skip_reg_confirmation
2291
+	 */
2292
+	public $skip_reg_confirmation;
2293
+
2294
+	/**
2295
+	 * an array of SPCO reg steps where:
2296
+	 *        the keys denotes the reg step order
2297
+	 *        each element consists of an array with the following elements:
2298
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2299
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2300
+	 *            "slug" => the URL param used to trigger the reg step
2301
+	 *
2302
+	 * @var array $reg_steps
2303
+	 */
2304
+	public $reg_steps;
2305
+
2306
+	/**
2307
+	 * Whether registration confirmation should be the last page of SPCO
2308
+	 *
2309
+	 * @var boolean $reg_confirmation_last
2310
+	 */
2311
+	public $reg_confirmation_last;
2312
+
2313
+	/**
2314
+	 * Whether or not to enable the EE Bot Trap
2315
+	 *
2316
+	 * @var boolean $use_bot_trap
2317
+	 */
2318
+	public $use_bot_trap;
2319
+
2320
+	/**
2321
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2322
+	 *
2323
+	 * @var boolean $use_encryption
2324
+	 */
2325
+	public $use_encryption;
2326
+
2327
+	/**
2328
+	 * Whether or not to use ReCaptcha
2329
+	 *
2330
+	 * @var boolean $use_captcha
2331
+	 */
2332
+	public $use_captcha;
2333
+
2334
+	/**
2335
+	 * ReCaptcha Theme
2336
+	 *
2337
+	 * @var string $recaptcha_theme
2338
+	 *    options: 'dark    ', 'light'
2339
+	 */
2340
+	public $recaptcha_theme;
2341
+
2342
+	/**
2343
+	 * ReCaptcha Type
2344
+	 *
2345
+	 * @var string $recaptcha_type
2346
+	 *    options: 'audio', 'image'
2347
+	 */
2348
+	public $recaptcha_type;
2349
+
2350
+	/**
2351
+	 * ReCaptcha language
2352
+	 *
2353
+	 * @var string $recaptcha_language
2354
+	 * eg 'en'
2355
+	 */
2356
+	public $recaptcha_language;
2357
+
2358
+	/**
2359
+	 * ReCaptcha public key
2360
+	 *
2361
+	 * @var string $recaptcha_publickey
2362
+	 */
2363
+	public $recaptcha_publickey;
2364
+
2365
+	/**
2366
+	 * ReCaptcha private key
2367
+	 *
2368
+	 * @var string $recaptcha_privatekey
2369
+	 */
2370
+	public $recaptcha_privatekey;
2371
+
2372
+	/**
2373
+	 * ReCaptcha width
2374
+	 *
2375
+	 * @var int $recaptcha_width
2376
+	 * @deprecated
2377
+	 */
2378
+	public $recaptcha_width;
2379
+
2380
+	/**
2381
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2382
+	 *
2383
+	 * @var boolean $track_invalid_checkout_access
2384
+	 */
2385
+	protected $track_invalid_checkout_access = true;
2386
+
2387
+
2388
+
2389
+	/**
2390
+	 *    class constructor
2391
+	 *
2392
+	 * @access    public
2393
+	 */
2394
+	public function __construct()
2395
+	{
2396
+		// set default registration settings
2397
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2398
+		$this->email_validation_level = 'wp_default';
2399
+		$this->show_pending_payment_options = true;
2400
+		$this->skip_reg_confirmation = false;
2401
+		$this->reg_steps = array();
2402
+		$this->reg_confirmation_last = false;
2403
+		$this->use_bot_trap = true;
2404
+		$this->use_encryption = true;
2405
+		$this->use_captcha = false;
2406
+		$this->recaptcha_theme = 'light';
2407
+		$this->recaptcha_type = 'image';
2408
+		$this->recaptcha_language = 'en';
2409
+		$this->recaptcha_publickey = null;
2410
+		$this->recaptcha_privatekey = null;
2411
+		$this->recaptcha_width = 500;
2412
+		$this->default_maximum_number_of_tickets = 10;
2413
+	}
2414
+
2415
+
2416
+
2417
+	/**
2418
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2419
+	 *
2420
+	 * @since 4.8.8.rc.019
2421
+	 */
2422
+	public function do_hooks()
2423
+	{
2424
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2425
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2426
+	}
2427
+
2428
+
2429
+
2430
+	/**
2431
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_default_registration_status
2432
+	 * field matches the config setting for default_STS_ID.
2433
+	 */
2434
+	public function set_default_reg_status_on_EEM_Event()
2435
+	{
2436
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2437
+	}
2438
+
2439
+
2440
+	/**
2441
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2442
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2443
+	 */
2444
+	public function set_default_max_ticket_on_EEM_Event()
2445
+	{
2446
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2447
+	}
2448
+
2449
+
2450
+
2451
+	/**
2452
+	 * @return boolean
2453
+	 */
2454
+	public function track_invalid_checkout_access()
2455
+	{
2456
+		return $this->track_invalid_checkout_access;
2457
+	}
2458
+
2459
+
2460
+
2461
+	/**
2462
+	 * @param boolean $track_invalid_checkout_access
2463
+	 */
2464
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2465
+	{
2466
+		$this->track_invalid_checkout_access = filter_var(
2467
+			$track_invalid_checkout_access,
2468
+			FILTER_VALIDATE_BOOLEAN
2469
+		);
2470
+	}
2471 2471
 
2472 2472
 
2473 2473
 
@@ -2481,160 +2481,160 @@  discard block
 block discarded – undo
2481 2481
 class EE_Admin_Config extends EE_Config_Base
2482 2482
 {
2483 2483
 
2484
-    /**
2485
-     * @var boolean $use_personnel_manager
2486
-     */
2487
-    public $use_personnel_manager;
2488
-
2489
-    /**
2490
-     * @var boolean $use_dashboard_widget
2491
-     */
2492
-    public $use_dashboard_widget;
2493
-
2494
-    /**
2495
-     * @var int $events_in_dashboard
2496
-     */
2497
-    public $events_in_dashboard;
2498
-
2499
-    /**
2500
-     * @var boolean $use_event_timezones
2501
-     */
2502
-    public $use_event_timezones;
2503
-
2504
-    /**
2505
-     * @var boolean $use_full_logging
2506
-     */
2507
-    public $use_full_logging;
2508
-
2509
-    /**
2510
-     * @var string $log_file_name
2511
-     */
2512
-    public $log_file_name;
2513
-
2514
-    /**
2515
-     * @var string $debug_file_name
2516
-     */
2517
-    public $debug_file_name;
2518
-
2519
-    /**
2520
-     * @var boolean $use_remote_logging
2521
-     */
2522
-    public $use_remote_logging;
2523
-
2524
-    /**
2525
-     * @var string $remote_logging_url
2526
-     */
2527
-    public $remote_logging_url;
2528
-
2529
-    /**
2530
-     * @var boolean $show_reg_footer
2531
-     */
2532
-    public $show_reg_footer;
2533
-
2534
-    /**
2535
-     * @var string $affiliate_id
2536
-     */
2537
-    public $affiliate_id;
2538
-
2539
-    /**
2540
-     * help tours on or off (global setting)
2541
-     *
2542
-     * @var boolean
2543
-     */
2544
-    public $help_tour_activation;
2545
-
2546
-    /**
2547
-     * adds extra layer of encoding to session data to prevent serialization errors
2548
-     * but is incompatible with some server configuration errors
2549
-     * if you get "500 internal server errors" during registration, try turning this on
2550
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2551
-     *
2552
-     * @var boolean $encode_session_data
2553
-     */
2554
-    private $encode_session_data = false;
2555
-
2556
-
2557
-
2558
-    /**
2559
-     *    class constructor
2560
-     *
2561
-     * @access    public
2562
-     */
2563
-    public function __construct()
2564
-    {
2565
-        // set default general admin settings
2566
-        $this->use_personnel_manager = true;
2567
-        $this->use_dashboard_widget = true;
2568
-        $this->events_in_dashboard = 30;
2569
-        $this->use_event_timezones = false;
2570
-        $this->use_full_logging = false;
2571
-        $this->use_remote_logging = false;
2572
-        $this->remote_logging_url = null;
2573
-        $this->show_reg_footer = true;
2574
-        $this->affiliate_id = 'default';
2575
-        $this->help_tour_activation = true;
2576
-        $this->encode_session_data = false;
2577
-    }
2578
-
2579
-
2580
-
2581
-    /**
2582
-     * @param bool $reset
2583
-     * @return string
2584
-     */
2585
-    public function log_file_name($reset = false)
2586
-    {
2587
-        if (empty($this->log_file_name) || $reset) {
2588
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2589
-            EE_Config::instance()->update_espresso_config(false, false);
2590
-        }
2591
-        return $this->log_file_name;
2592
-    }
2593
-
2594
-
2595
-
2596
-    /**
2597
-     * @param bool $reset
2598
-     * @return string
2599
-     */
2600
-    public function debug_file_name($reset = false)
2601
-    {
2602
-        if (empty($this->debug_file_name) || $reset) {
2603
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2604
-            EE_Config::instance()->update_espresso_config(false, false);
2605
-        }
2606
-        return $this->debug_file_name;
2607
-    }
2608
-
2609
-
2610
-
2611
-    /**
2612
-     * @return string
2613
-     */
2614
-    public function affiliate_id()
2615
-    {
2616
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2617
-    }
2618
-
2619
-
2620
-
2621
-    /**
2622
-     * @return boolean
2623
-     */
2624
-    public function encode_session_data()
2625
-    {
2626
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2627
-    }
2628
-
2629
-
2630
-
2631
-    /**
2632
-     * @param boolean $encode_session_data
2633
-     */
2634
-    public function set_encode_session_data($encode_session_data)
2635
-    {
2636
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2637
-    }
2484
+	/**
2485
+	 * @var boolean $use_personnel_manager
2486
+	 */
2487
+	public $use_personnel_manager;
2488
+
2489
+	/**
2490
+	 * @var boolean $use_dashboard_widget
2491
+	 */
2492
+	public $use_dashboard_widget;
2493
+
2494
+	/**
2495
+	 * @var int $events_in_dashboard
2496
+	 */
2497
+	public $events_in_dashboard;
2498
+
2499
+	/**
2500
+	 * @var boolean $use_event_timezones
2501
+	 */
2502
+	public $use_event_timezones;
2503
+
2504
+	/**
2505
+	 * @var boolean $use_full_logging
2506
+	 */
2507
+	public $use_full_logging;
2508
+
2509
+	/**
2510
+	 * @var string $log_file_name
2511
+	 */
2512
+	public $log_file_name;
2513
+
2514
+	/**
2515
+	 * @var string $debug_file_name
2516
+	 */
2517
+	public $debug_file_name;
2518
+
2519
+	/**
2520
+	 * @var boolean $use_remote_logging
2521
+	 */
2522
+	public $use_remote_logging;
2523
+
2524
+	/**
2525
+	 * @var string $remote_logging_url
2526
+	 */
2527
+	public $remote_logging_url;
2528
+
2529
+	/**
2530
+	 * @var boolean $show_reg_footer
2531
+	 */
2532
+	public $show_reg_footer;
2533
+
2534
+	/**
2535
+	 * @var string $affiliate_id
2536
+	 */
2537
+	public $affiliate_id;
2538
+
2539
+	/**
2540
+	 * help tours on or off (global setting)
2541
+	 *
2542
+	 * @var boolean
2543
+	 */
2544
+	public $help_tour_activation;
2545
+
2546
+	/**
2547
+	 * adds extra layer of encoding to session data to prevent serialization errors
2548
+	 * but is incompatible with some server configuration errors
2549
+	 * if you get "500 internal server errors" during registration, try turning this on
2550
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2551
+	 *
2552
+	 * @var boolean $encode_session_data
2553
+	 */
2554
+	private $encode_session_data = false;
2555
+
2556
+
2557
+
2558
+	/**
2559
+	 *    class constructor
2560
+	 *
2561
+	 * @access    public
2562
+	 */
2563
+	public function __construct()
2564
+	{
2565
+		// set default general admin settings
2566
+		$this->use_personnel_manager = true;
2567
+		$this->use_dashboard_widget = true;
2568
+		$this->events_in_dashboard = 30;
2569
+		$this->use_event_timezones = false;
2570
+		$this->use_full_logging = false;
2571
+		$this->use_remote_logging = false;
2572
+		$this->remote_logging_url = null;
2573
+		$this->show_reg_footer = true;
2574
+		$this->affiliate_id = 'default';
2575
+		$this->help_tour_activation = true;
2576
+		$this->encode_session_data = false;
2577
+	}
2578
+
2579
+
2580
+
2581
+	/**
2582
+	 * @param bool $reset
2583
+	 * @return string
2584
+	 */
2585
+	public function log_file_name($reset = false)
2586
+	{
2587
+		if (empty($this->log_file_name) || $reset) {
2588
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2589
+			EE_Config::instance()->update_espresso_config(false, false);
2590
+		}
2591
+		return $this->log_file_name;
2592
+	}
2593
+
2594
+
2595
+
2596
+	/**
2597
+	 * @param bool $reset
2598
+	 * @return string
2599
+	 */
2600
+	public function debug_file_name($reset = false)
2601
+	{
2602
+		if (empty($this->debug_file_name) || $reset) {
2603
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2604
+			EE_Config::instance()->update_espresso_config(false, false);
2605
+		}
2606
+		return $this->debug_file_name;
2607
+	}
2608
+
2609
+
2610
+
2611
+	/**
2612
+	 * @return string
2613
+	 */
2614
+	public function affiliate_id()
2615
+	{
2616
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2617
+	}
2618
+
2619
+
2620
+
2621
+	/**
2622
+	 * @return boolean
2623
+	 */
2624
+	public function encode_session_data()
2625
+	{
2626
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2627
+	}
2628
+
2629
+
2630
+
2631
+	/**
2632
+	 * @param boolean $encode_session_data
2633
+	 */
2634
+	public function set_encode_session_data($encode_session_data)
2635
+	{
2636
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2637
+	}
2638 2638
 
2639 2639
 
2640 2640
 
@@ -2648,71 +2648,71 @@  discard block
 block discarded – undo
2648 2648
 class EE_Template_Config extends EE_Config_Base
2649 2649
 {
2650 2650
 
2651
-    /**
2652
-     * @var boolean $enable_default_style
2653
-     */
2654
-    public $enable_default_style;
2655
-
2656
-    /**
2657
-     * @var string $custom_style_sheet
2658
-     */
2659
-    public $custom_style_sheet;
2660
-
2661
-    /**
2662
-     * @var boolean $display_address_in_regform
2663
-     */
2664
-    public $display_address_in_regform;
2665
-
2666
-    /**
2667
-     * @var int $display_description_on_multi_reg_page
2668
-     */
2669
-    public $display_description_on_multi_reg_page;
2670
-
2671
-    /**
2672
-     * @var boolean $use_custom_templates
2673
-     */
2674
-    public $use_custom_templates;
2675
-
2676
-    /**
2677
-     * @var string $current_espresso_theme
2678
-     */
2679
-    public $current_espresso_theme;
2680
-
2681
-    /**
2682
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2683
-     */
2684
-    public $EED_Ticket_Selector;
2685
-
2686
-    /**
2687
-     * @var EE_Event_Single_Config $EED_Event_Single
2688
-     */
2689
-    public $EED_Event_Single;
2690
-
2691
-    /**
2692
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2693
-     */
2694
-    public $EED_Events_Archive;
2695
-
2696
-
2697
-
2698
-    /**
2699
-     *    class constructor
2700
-     *
2701
-     * @access    public
2702
-     */
2703
-    public function __construct()
2704
-    {
2705
-        // set default template settings
2706
-        $this->enable_default_style = true;
2707
-        $this->custom_style_sheet = null;
2708
-        $this->display_address_in_regform = true;
2709
-        $this->display_description_on_multi_reg_page = false;
2710
-        $this->use_custom_templates = false;
2711
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2712
-        $this->EED_Event_Single = null;
2713
-        $this->EED_Events_Archive = null;
2714
-        $this->EED_Ticket_Selector = null;
2715
-    }
2651
+	/**
2652
+	 * @var boolean $enable_default_style
2653
+	 */
2654
+	public $enable_default_style;
2655
+
2656
+	/**
2657
+	 * @var string $custom_style_sheet
2658
+	 */
2659
+	public $custom_style_sheet;
2660
+
2661
+	/**
2662
+	 * @var boolean $display_address_in_regform
2663
+	 */
2664
+	public $display_address_in_regform;
2665
+
2666
+	/**
2667
+	 * @var int $display_description_on_multi_reg_page
2668
+	 */
2669
+	public $display_description_on_multi_reg_page;
2670
+
2671
+	/**
2672
+	 * @var boolean $use_custom_templates
2673
+	 */
2674
+	public $use_custom_templates;
2675
+
2676
+	/**
2677
+	 * @var string $current_espresso_theme
2678
+	 */
2679
+	public $current_espresso_theme;
2680
+
2681
+	/**
2682
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2683
+	 */
2684
+	public $EED_Ticket_Selector;
2685
+
2686
+	/**
2687
+	 * @var EE_Event_Single_Config $EED_Event_Single
2688
+	 */
2689
+	public $EED_Event_Single;
2690
+
2691
+	/**
2692
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2693
+	 */
2694
+	public $EED_Events_Archive;
2695
+
2696
+
2697
+
2698
+	/**
2699
+	 *    class constructor
2700
+	 *
2701
+	 * @access    public
2702
+	 */
2703
+	public function __construct()
2704
+	{
2705
+		// set default template settings
2706
+		$this->enable_default_style = true;
2707
+		$this->custom_style_sheet = null;
2708
+		$this->display_address_in_regform = true;
2709
+		$this->display_description_on_multi_reg_page = false;
2710
+		$this->use_custom_templates = false;
2711
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2712
+		$this->EED_Event_Single = null;
2713
+		$this->EED_Events_Archive = null;
2714
+		$this->EED_Ticket_Selector = null;
2715
+	}
2716 2716
 
2717 2717
 }
2718 2718
 
@@ -2724,115 +2724,115 @@  discard block
 block discarded – undo
2724 2724
 class EE_Map_Config extends EE_Config_Base
2725 2725
 {
2726 2726
 
2727
-    /**
2728
-     * @var boolean $use_google_maps
2729
-     */
2730
-    public $use_google_maps;
2731
-
2732
-    /**
2733
-     * @var string $api_key
2734
-     */
2735
-    public $google_map_api_key;
2736
-
2737
-    /**
2738
-     * @var int $event_details_map_width
2739
-     */
2740
-    public $event_details_map_width;
2741
-
2742
-    /**
2743
-     * @var int $event_details_map_height
2744
-     */
2745
-    public $event_details_map_height;
2746
-
2747
-    /**
2748
-     * @var int $event_details_map_zoom
2749
-     */
2750
-    public $event_details_map_zoom;
2751
-
2752
-    /**
2753
-     * @var boolean $event_details_display_nav
2754
-     */
2755
-    public $event_details_display_nav;
2756
-
2757
-    /**
2758
-     * @var boolean $event_details_nav_size
2759
-     */
2760
-    public $event_details_nav_size;
2761
-
2762
-    /**
2763
-     * @var string $event_details_control_type
2764
-     */
2765
-    public $event_details_control_type;
2766
-
2767
-    /**
2768
-     * @var string $event_details_map_align
2769
-     */
2770
-    public $event_details_map_align;
2771
-
2772
-    /**
2773
-     * @var int $event_list_map_width
2774
-     */
2775
-    public $event_list_map_width;
2776
-
2777
-    /**
2778
-     * @var int $event_list_map_height
2779
-     */
2780
-    public $event_list_map_height;
2781
-
2782
-    /**
2783
-     * @var int $event_list_map_zoom
2784
-     */
2785
-    public $event_list_map_zoom;
2786
-
2787
-    /**
2788
-     * @var boolean $event_list_display_nav
2789
-     */
2790
-    public $event_list_display_nav;
2791
-
2792
-    /**
2793
-     * @var boolean $event_list_nav_size
2794
-     */
2795
-    public $event_list_nav_size;
2796
-
2797
-    /**
2798
-     * @var string $event_list_control_type
2799
-     */
2800
-    public $event_list_control_type;
2801
-
2802
-    /**
2803
-     * @var string $event_list_map_align
2804
-     */
2805
-    public $event_list_map_align;
2806
-
2807
-
2808
-
2809
-    /**
2810
-     *    class constructor
2811
-     *
2812
-     * @access    public
2813
-     */
2814
-    public function __construct()
2815
-    {
2816
-        // set default map settings
2817
-        $this->use_google_maps = true;
2818
-        $this->google_map_api_key = '';
2819
-        // for event details pages (reg page)
2820
-        $this->event_details_map_width = 585;            // ee_map_width_single
2821
-        $this->event_details_map_height = 362;            // ee_map_height_single
2822
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2823
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2824
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2825
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2826
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2827
-        // for event list pages
2828
-        $this->event_list_map_width = 300;            // ee_map_width
2829
-        $this->event_list_map_height = 185;        // ee_map_height
2830
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2831
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2832
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2833
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2834
-        $this->event_list_map_align = 'center';            // ee_map_align
2835
-    }
2727
+	/**
2728
+	 * @var boolean $use_google_maps
2729
+	 */
2730
+	public $use_google_maps;
2731
+
2732
+	/**
2733
+	 * @var string $api_key
2734
+	 */
2735
+	public $google_map_api_key;
2736
+
2737
+	/**
2738
+	 * @var int $event_details_map_width
2739
+	 */
2740
+	public $event_details_map_width;
2741
+
2742
+	/**
2743
+	 * @var int $event_details_map_height
2744
+	 */
2745
+	public $event_details_map_height;
2746
+
2747
+	/**
2748
+	 * @var int $event_details_map_zoom
2749
+	 */
2750
+	public $event_details_map_zoom;
2751
+
2752
+	/**
2753
+	 * @var boolean $event_details_display_nav
2754
+	 */
2755
+	public $event_details_display_nav;
2756
+
2757
+	/**
2758
+	 * @var boolean $event_details_nav_size
2759
+	 */
2760
+	public $event_details_nav_size;
2761
+
2762
+	/**
2763
+	 * @var string $event_details_control_type
2764
+	 */
2765
+	public $event_details_control_type;
2766
+
2767
+	/**
2768
+	 * @var string $event_details_map_align
2769
+	 */
2770
+	public $event_details_map_align;
2771
+
2772
+	/**
2773
+	 * @var int $event_list_map_width
2774
+	 */
2775
+	public $event_list_map_width;
2776
+
2777
+	/**
2778
+	 * @var int $event_list_map_height
2779
+	 */
2780
+	public $event_list_map_height;
2781
+
2782
+	/**
2783
+	 * @var int $event_list_map_zoom
2784
+	 */
2785
+	public $event_list_map_zoom;
2786
+
2787
+	/**
2788
+	 * @var boolean $event_list_display_nav
2789
+	 */
2790
+	public $event_list_display_nav;
2791
+
2792
+	/**
2793
+	 * @var boolean $event_list_nav_size
2794
+	 */
2795
+	public $event_list_nav_size;
2796
+
2797
+	/**
2798
+	 * @var string $event_list_control_type
2799
+	 */
2800
+	public $event_list_control_type;
2801
+
2802
+	/**
2803
+	 * @var string $event_list_map_align
2804
+	 */
2805
+	public $event_list_map_align;
2806
+
2807
+
2808
+
2809
+	/**
2810
+	 *    class constructor
2811
+	 *
2812
+	 * @access    public
2813
+	 */
2814
+	public function __construct()
2815
+	{
2816
+		// set default map settings
2817
+		$this->use_google_maps = true;
2818
+		$this->google_map_api_key = '';
2819
+		// for event details pages (reg page)
2820
+		$this->event_details_map_width = 585;            // ee_map_width_single
2821
+		$this->event_details_map_height = 362;            // ee_map_height_single
2822
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2823
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2824
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2825
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2826
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2827
+		// for event list pages
2828
+		$this->event_list_map_width = 300;            // ee_map_width
2829
+		$this->event_list_map_height = 185;        // ee_map_height
2830
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2831
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2832
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2833
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2834
+		$this->event_list_map_align = 'center';            // ee_map_align
2835
+	}
2836 2836
 
2837 2837
 }
2838 2838
 
@@ -2844,47 +2844,47 @@  discard block
 block discarded – undo
2844 2844
 class EE_Events_Archive_Config extends EE_Config_Base
2845 2845
 {
2846 2846
 
2847
-    public $display_status_banner;
2847
+	public $display_status_banner;
2848 2848
 
2849
-    public $display_description;
2849
+	public $display_description;
2850 2850
 
2851
-    public $display_ticket_selector;
2851
+	public $display_ticket_selector;
2852 2852
 
2853
-    public $display_datetimes;
2853
+	public $display_datetimes;
2854 2854
 
2855
-    public $display_venue;
2855
+	public $display_venue;
2856 2856
 
2857
-    public $display_expired_events;
2857
+	public $display_expired_events;
2858 2858
 
2859
-    public $use_sortable_display_order;
2859
+	public $use_sortable_display_order;
2860 2860
 
2861
-    public $display_order_tickets;
2861
+	public $display_order_tickets;
2862 2862
 
2863
-    public $display_order_datetimes;
2863
+	public $display_order_datetimes;
2864 2864
 
2865
-    public $display_order_event;
2865
+	public $display_order_event;
2866 2866
 
2867
-    public $display_order_venue;
2867
+	public $display_order_venue;
2868 2868
 
2869 2869
 
2870 2870
 
2871
-    /**
2872
-     *    class constructor
2873
-     */
2874
-    public function __construct()
2875
-    {
2876
-        $this->display_status_banner = 0;
2877
-        $this->display_description = 1;
2878
-        $this->display_ticket_selector = 0;
2879
-        $this->display_datetimes = 1;
2880
-        $this->display_venue = 0;
2881
-        $this->display_expired_events = 0;
2882
-        $this->use_sortable_display_order = false;
2883
-        $this->display_order_tickets = 100;
2884
-        $this->display_order_datetimes = 110;
2885
-        $this->display_order_event = 120;
2886
-        $this->display_order_venue = 130;
2887
-    }
2871
+	/**
2872
+	 *    class constructor
2873
+	 */
2874
+	public function __construct()
2875
+	{
2876
+		$this->display_status_banner = 0;
2877
+		$this->display_description = 1;
2878
+		$this->display_ticket_selector = 0;
2879
+		$this->display_datetimes = 1;
2880
+		$this->display_venue = 0;
2881
+		$this->display_expired_events = 0;
2882
+		$this->use_sortable_display_order = false;
2883
+		$this->display_order_tickets = 100;
2884
+		$this->display_order_datetimes = 110;
2885
+		$this->display_order_event = 120;
2886
+		$this->display_order_venue = 130;
2887
+	}
2888 2888
 }
2889 2889
 
2890 2890
 
@@ -2895,35 +2895,35 @@  discard block
 block discarded – undo
2895 2895
 class EE_Event_Single_Config extends EE_Config_Base
2896 2896
 {
2897 2897
 
2898
-    public $display_status_banner_single;
2898
+	public $display_status_banner_single;
2899 2899
 
2900
-    public $display_venue;
2900
+	public $display_venue;
2901 2901
 
2902
-    public $use_sortable_display_order;
2902
+	public $use_sortable_display_order;
2903 2903
 
2904
-    public $display_order_tickets;
2904
+	public $display_order_tickets;
2905 2905
 
2906
-    public $display_order_datetimes;
2906
+	public $display_order_datetimes;
2907 2907
 
2908
-    public $display_order_event;
2908
+	public $display_order_event;
2909 2909
 
2910
-    public $display_order_venue;
2910
+	public $display_order_venue;
2911 2911
 
2912 2912
 
2913 2913
 
2914
-    /**
2915
-     *    class constructor
2916
-     */
2917
-    public function __construct()
2918
-    {
2919
-        $this->display_status_banner_single = 0;
2920
-        $this->display_venue = 1;
2921
-        $this->use_sortable_display_order = false;
2922
-        $this->display_order_tickets = 100;
2923
-        $this->display_order_datetimes = 110;
2924
-        $this->display_order_event = 120;
2925
-        $this->display_order_venue = 130;
2926
-    }
2914
+	/**
2915
+	 *    class constructor
2916
+	 */
2917
+	public function __construct()
2918
+	{
2919
+		$this->display_status_banner_single = 0;
2920
+		$this->display_venue = 1;
2921
+		$this->use_sortable_display_order = false;
2922
+		$this->display_order_tickets = 100;
2923
+		$this->display_order_datetimes = 110;
2924
+		$this->display_order_event = 120;
2925
+		$this->display_order_venue = 130;
2926
+	}
2927 2927
 }
2928 2928
 
2929 2929
 
@@ -2934,152 +2934,152 @@  discard block
 block discarded – undo
2934 2934
 class EE_Ticket_Selector_Config extends EE_Config_Base
2935 2935
 {
2936 2936
 
2937
-    /**
2938
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2939
-     */
2940
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2941
-
2942
-    /**
2943
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2944
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2945
-     */
2946
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2947
-
2948
-    /**
2949
-     * @var boolean $show_ticket_sale_columns
2950
-     */
2951
-    public $show_ticket_sale_columns;
2952
-
2953
-    /**
2954
-     * @var boolean $show_ticket_details
2955
-     */
2956
-    public $show_ticket_details;
2957
-
2958
-    /**
2959
-     * @var boolean $show_expired_tickets
2960
-     */
2961
-    public $show_expired_tickets;
2962
-
2963
-    /**
2964
-     * whether or not to display a dropdown box populated with event datetimes
2965
-     * that toggles which tickets are displayed for a ticket selector.
2966
-     * uses one of the *_DATETIME_SELECTOR constants defined above
2967
-     *
2968
-     * @var string $show_datetime_selector
2969
-     */
2970
-    private $show_datetime_selector = 'no_datetime_selector';
2971
-
2972
-    /**
2973
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
2974
-     *
2975
-     * @var int $datetime_selector_threshold
2976
-     */
2977
-    private $datetime_selector_threshold = 3;
2978
-
2979
-
2980
-
2981
-    /**
2982
-     *    class constructor
2983
-     */
2984
-    public function __construct()
2985
-    {
2986
-        $this->show_ticket_sale_columns = true;
2987
-        $this->show_ticket_details = true;
2988
-        $this->show_expired_tickets = true;
2989
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2990
-        $this->datetime_selector_threshold = 3;
2991
-    }
2992
-
2993
-
2994
-
2995
-    /**
2996
-     * returns true if a datetime selector should be displayed
2997
-     *
2998
-     * @param array $datetimes
2999
-     * @return bool
3000
-     */
3001
-    public function showDatetimeSelector(array $datetimes)
3002
-    {
3003
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3004
-        return ! (
3005
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3006
-            || (
3007
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3008
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3009
-            )
3010
-        );
3011
-    }
3012
-
3013
-
3014
-
3015
-    /**
3016
-     * @return string
3017
-     */
3018
-    public function getShowDatetimeSelector()
3019
-    {
3020
-        return $this->show_datetime_selector;
3021
-    }
3022
-
3023
-
3024
-
3025
-    /**
3026
-     * @param bool $keys_only
3027
-     * @return array
3028
-     */
3029
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3030
-    {
3031
-        return $keys_only
3032
-            ? array(
3033
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3034
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3035
-            )
3036
-            : array(
3037
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3038
-                    'Do not show date & time filter', 'event_espresso'
3039
-                ),
3040
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3041
-                    'Maybe show date & time filter', 'event_espresso'
3042
-                ),
3043
-            );
3044
-    }
3045
-
3046
-
3047
-
3048
-    /**
3049
-     * @param string $show_datetime_selector
3050
-     */
3051
-    public function setShowDatetimeSelector($show_datetime_selector)
3052
-    {
3053
-        $this->show_datetime_selector = in_array(
3054
-            $show_datetime_selector,
3055
-            $this->getShowDatetimeSelectorOptions(),
3056
-            true
3057
-        )
3058
-            ? $show_datetime_selector
3059
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3060
-    }
3061
-
3062
-
3063
-
3064
-    /**
3065
-     * @return int
3066
-     */
3067
-    public function getDatetimeSelectorThreshold()
3068
-    {
3069
-        return $this->datetime_selector_threshold;
3070
-    }
3071
-
3072
-
3073
-
3074
-
3075
-    /**
3076
-     * @param int $datetime_selector_threshold
3077
-     */
3078
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3079
-    {
3080
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3081
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3082
-    }
2937
+	/**
2938
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2939
+	 */
2940
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2941
+
2942
+	/**
2943
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2944
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2945
+	 */
2946
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2947
+
2948
+	/**
2949
+	 * @var boolean $show_ticket_sale_columns
2950
+	 */
2951
+	public $show_ticket_sale_columns;
2952
+
2953
+	/**
2954
+	 * @var boolean $show_ticket_details
2955
+	 */
2956
+	public $show_ticket_details;
2957
+
2958
+	/**
2959
+	 * @var boolean $show_expired_tickets
2960
+	 */
2961
+	public $show_expired_tickets;
2962
+
2963
+	/**
2964
+	 * whether or not to display a dropdown box populated with event datetimes
2965
+	 * that toggles which tickets are displayed for a ticket selector.
2966
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
2967
+	 *
2968
+	 * @var string $show_datetime_selector
2969
+	 */
2970
+	private $show_datetime_selector = 'no_datetime_selector';
2971
+
2972
+	/**
2973
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
2974
+	 *
2975
+	 * @var int $datetime_selector_threshold
2976
+	 */
2977
+	private $datetime_selector_threshold = 3;
2978
+
2979
+
2980
+
2981
+	/**
2982
+	 *    class constructor
2983
+	 */
2984
+	public function __construct()
2985
+	{
2986
+		$this->show_ticket_sale_columns = true;
2987
+		$this->show_ticket_details = true;
2988
+		$this->show_expired_tickets = true;
2989
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
2990
+		$this->datetime_selector_threshold = 3;
2991
+	}
2992
+
2993
+
2994
+
2995
+	/**
2996
+	 * returns true if a datetime selector should be displayed
2997
+	 *
2998
+	 * @param array $datetimes
2999
+	 * @return bool
3000
+	 */
3001
+	public function showDatetimeSelector(array $datetimes)
3002
+	{
3003
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3004
+		return ! (
3005
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3006
+			|| (
3007
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3008
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3009
+			)
3010
+		);
3011
+	}
3012
+
3013
+
3014
+
3015
+	/**
3016
+	 * @return string
3017
+	 */
3018
+	public function getShowDatetimeSelector()
3019
+	{
3020
+		return $this->show_datetime_selector;
3021
+	}
3022
+
3023
+
3024
+
3025
+	/**
3026
+	 * @param bool $keys_only
3027
+	 * @return array
3028
+	 */
3029
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3030
+	{
3031
+		return $keys_only
3032
+			? array(
3033
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3034
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3035
+			)
3036
+			: array(
3037
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3038
+					'Do not show date & time filter', 'event_espresso'
3039
+				),
3040
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3041
+					'Maybe show date & time filter', 'event_espresso'
3042
+				),
3043
+			);
3044
+	}
3045
+
3046
+
3047
+
3048
+	/**
3049
+	 * @param string $show_datetime_selector
3050
+	 */
3051
+	public function setShowDatetimeSelector($show_datetime_selector)
3052
+	{
3053
+		$this->show_datetime_selector = in_array(
3054
+			$show_datetime_selector,
3055
+			$this->getShowDatetimeSelectorOptions(),
3056
+			true
3057
+		)
3058
+			? $show_datetime_selector
3059
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3060
+	}
3061
+
3062
+
3063
+
3064
+	/**
3065
+	 * @return int
3066
+	 */
3067
+	public function getDatetimeSelectorThreshold()
3068
+	{
3069
+		return $this->datetime_selector_threshold;
3070
+	}
3071
+
3072
+
3073
+
3074
+
3075
+	/**
3076
+	 * @param int $datetime_selector_threshold
3077
+	 */
3078
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3079
+	{
3080
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3081
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3082
+	}
3083 3083
 
3084 3084
 
3085 3085
 
@@ -3097,85 +3097,85 @@  discard block
 block discarded – undo
3097 3097
 class EE_Environment_Config extends EE_Config_Base
3098 3098
 {
3099 3099
 
3100
-    /**
3101
-     * Hold any php environment variables that we want to track.
3102
-     *
3103
-     * @var stdClass;
3104
-     */
3105
-    public $php;
3106
-
3107
-
3108
-
3109
-    /**
3110
-     *    constructor
3111
-     */
3112
-    public function __construct()
3113
-    {
3114
-        $this->php = new stdClass();
3115
-        $this->_set_php_values();
3116
-    }
3117
-
3118
-
3119
-
3120
-    /**
3121
-     * This sets the php environment variables.
3122
-     *
3123
-     * @since 4.4.0
3124
-     * @return void
3125
-     */
3126
-    protected function _set_php_values()
3127
-    {
3128
-        $this->php->max_input_vars = ini_get('max_input_vars');
3129
-        $this->php->version = phpversion();
3130
-    }
3131
-
3132
-
3133
-
3134
-    /**
3135
-     * helper method for determining whether input_count is
3136
-     * reaching the potential maximum the server can handle
3137
-     * according to max_input_vars
3138
-     *
3139
-     * @param int   $input_count the count of input vars.
3140
-     * @return array {
3141
-     *                           An array that represents whether available space and if no available space the error
3142
-     *                           message.
3143
-     * @type bool   $has_space   whether more inputs can be added.
3144
-     * @type string $msg         Any message to be displayed.
3145
-     *                           }
3146
-     */
3147
-    public function max_input_vars_limit_check($input_count = 0)
3148
-    {
3149
-        if (! empty($this->php->max_input_vars)
3150
-            && ($input_count >= $this->php->max_input_vars)
3151
-            && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3152
-        ) {
3153
-            return sprintf(
3154
-                __(
3155
-                    'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3156
-                    'event_espresso'
3157
-                ),
3158
-                '<br>',
3159
-                $input_count,
3160
-                $this->php->max_input_vars
3161
-            );
3162
-        } else {
3163
-            return '';
3164
-        }
3165
-    }
3166
-
3167
-
3168
-
3169
-    /**
3170
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3171
-     *
3172
-     * @since 4.4.1
3173
-     * @return void
3174
-     */
3175
-    public function recheck_values()
3176
-    {
3177
-        $this->_set_php_values();
3178
-    }
3100
+	/**
3101
+	 * Hold any php environment variables that we want to track.
3102
+	 *
3103
+	 * @var stdClass;
3104
+	 */
3105
+	public $php;
3106
+
3107
+
3108
+
3109
+	/**
3110
+	 *    constructor
3111
+	 */
3112
+	public function __construct()
3113
+	{
3114
+		$this->php = new stdClass();
3115
+		$this->_set_php_values();
3116
+	}
3117
+
3118
+
3119
+
3120
+	/**
3121
+	 * This sets the php environment variables.
3122
+	 *
3123
+	 * @since 4.4.0
3124
+	 * @return void
3125
+	 */
3126
+	protected function _set_php_values()
3127
+	{
3128
+		$this->php->max_input_vars = ini_get('max_input_vars');
3129
+		$this->php->version = phpversion();
3130
+	}
3131
+
3132
+
3133
+
3134
+	/**
3135
+	 * helper method for determining whether input_count is
3136
+	 * reaching the potential maximum the server can handle
3137
+	 * according to max_input_vars
3138
+	 *
3139
+	 * @param int   $input_count the count of input vars.
3140
+	 * @return array {
3141
+	 *                           An array that represents whether available space and if no available space the error
3142
+	 *                           message.
3143
+	 * @type bool   $has_space   whether more inputs can be added.
3144
+	 * @type string $msg         Any message to be displayed.
3145
+	 *                           }
3146
+	 */
3147
+	public function max_input_vars_limit_check($input_count = 0)
3148
+	{
3149
+		if (! empty($this->php->max_input_vars)
3150
+			&& ($input_count >= $this->php->max_input_vars)
3151
+			&& (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3152
+		) {
3153
+			return sprintf(
3154
+				__(
3155
+					'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3156
+					'event_espresso'
3157
+				),
3158
+				'<br>',
3159
+				$input_count,
3160
+				$this->php->max_input_vars
3161
+			);
3162
+		} else {
3163
+			return '';
3164
+		}
3165
+	}
3166
+
3167
+
3168
+
3169
+	/**
3170
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3171
+	 *
3172
+	 * @since 4.4.1
3173
+	 * @return void
3174
+	 */
3175
+	public function recheck_values()
3176
+	{
3177
+		$this->_set_php_values();
3178
+	}
3179 3179
 
3180 3180
 
3181 3181
 
@@ -3193,22 +3193,22 @@  discard block
 block discarded – undo
3193 3193
 class EE_Tax_Config extends EE_Config_Base
3194 3194
 {
3195 3195
 
3196
-    /*
3196
+	/*
3197 3197
      * flag to indicate whether or not to display ticket prices with the taxes included
3198 3198
      *
3199 3199
      * @var boolean $prices_displayed_including_taxes
3200 3200
      */
3201
-    public $prices_displayed_including_taxes;
3201
+	public $prices_displayed_including_taxes;
3202 3202
 
3203 3203
 
3204 3204
 
3205
-    /**
3206
-     *    class constructor
3207
-     */
3208
-    public function __construct()
3209
-    {
3210
-        $this->prices_displayed_including_taxes = true;
3211
-    }
3205
+	/**
3206
+	 *    class constructor
3207
+	 */
3208
+	public function __construct()
3209
+	{
3210
+		$this->prices_displayed_including_taxes = true;
3211
+	}
3212 3212
 }
3213 3213
 
3214 3214
 
@@ -3223,17 +3223,17 @@  discard block
 block discarded – undo
3223 3223
 class EE_Messages_Config extends EE_Config_Base
3224 3224
 {
3225 3225
 
3226
-    /**
3227
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3228
-     * A value of 0 represents never deleting.  Default is 0.
3229
-     *
3230
-     * @var integer
3231
-     */
3232
-    public $delete_threshold;
3233
-
3234
-    public function __construct() {
3235
-        $this->delete_threshold = 0;
3236
-    }
3226
+	/**
3227
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3228
+	 * A value of 0 represents never deleting.  Default is 0.
3229
+	 *
3230
+	 * @var integer
3231
+	 */
3232
+	public $delete_threshold;
3233
+
3234
+	public function __construct() {
3235
+		$this->delete_threshold = 0;
3236
+	}
3237 3237
 }
3238 3238
 
3239 3239
 
@@ -3245,34 +3245,34 @@  discard block
 block discarded – undo
3245 3245
 class EE_Gateway_Config extends EE_Config_Base
3246 3246
 {
3247 3247
 
3248
-    /**
3249
-     * Array with keys that are payment gateways slugs, and values are arrays
3250
-     * with any config info the gateway wants to store
3251
-     *
3252
-     * @var array
3253
-     */
3254
-    public $payment_settings;
3255
-
3256
-    /**
3257
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3258
-     * the gateway is stored in the uploads directory
3259
-     *
3260
-     * @var array
3261
-     */
3262
-    public $active_gateways;
3263
-
3264
-
3265
-
3266
-    /**
3267
-     *    class constructor
3268
-     *
3269
-     * @deprecated
3270
-     */
3271
-    public function __construct()
3272
-    {
3273
-        $this->payment_settings = array();
3274
-        $this->active_gateways = array('Invoice' => false);
3275
-    }
3248
+	/**
3249
+	 * Array with keys that are payment gateways slugs, and values are arrays
3250
+	 * with any config info the gateway wants to store
3251
+	 *
3252
+	 * @var array
3253
+	 */
3254
+	public $payment_settings;
3255
+
3256
+	/**
3257
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3258
+	 * the gateway is stored in the uploads directory
3259
+	 *
3260
+	 * @var array
3261
+	 */
3262
+	public $active_gateways;
3263
+
3264
+
3265
+
3266
+	/**
3267
+	 *    class constructor
3268
+	 *
3269
+	 * @deprecated
3270
+	 */
3271
+	public function __construct()
3272
+	{
3273
+		$this->payment_settings = array();
3274
+		$this->active_gateways = array('Invoice' => false);
3275
+	}
3276 3276
 }
3277 3277
 
3278 3278
 // End of file EE_Config.core.php
Please login to merge, or discard this patch.