Completed
Branch decaf-fixes/sanitize-all-reque... (b7fe86)
by
unknown
06:39 queued 04:47
created
core/EE_Config.core.php 2 patches
Indentation   +3177 added lines, -3177 removed lines patch added patch discarded remove patch
@@ -16,2538 +16,2538 @@  discard block
 block discarded – undo
16 16
 final class EE_Config implements ResettableInterface
17 17
 {
18 18
 
19
-    const OPTION_NAME = 'ee_config';
20
-
21
-    const LOG_NAME = 'ee_config_log';
22
-
23
-    const LOG_LENGTH = 100;
24
-
25
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
26
-
27
-    /**
28
-     *    instance of the EE_Config object
29
-     *
30
-     * @var    EE_Config $_instance
31
-     * @access    private
32
-     */
33
-    private static $_instance;
34
-
35
-    /**
36
-     * @var boolean $_logging_enabled
37
-     */
38
-    private static $_logging_enabled = false;
39
-
40
-    /**
41
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
42
-     */
43
-    private $legacy_shortcodes_manager;
44
-
45
-    /**
46
-     * An StdClass whose property names are addon slugs,
47
-     * and values are their config classes
48
-     *
49
-     * @var StdClass
50
-     */
51
-    public $addons;
52
-
53
-    /**
54
-     * @var EE_Admin_Config
55
-     */
56
-    public $admin;
57
-
58
-    /**
59
-     * @var EE_Core_Config
60
-     */
61
-    public $core;
62
-
63
-    /**
64
-     * @var EE_Currency_Config
65
-     */
66
-    public $currency;
67
-
68
-    /**
69
-     * @var EE_Organization_Config
70
-     */
71
-    public $organization;
72
-
73
-    /**
74
-     * @var EE_Registration_Config
75
-     */
76
-    public $registration;
77
-
78
-    /**
79
-     * @var EE_Template_Config
80
-     */
81
-    public $template_settings;
82
-
83
-    /**
84
-     * Holds EE environment values.
85
-     *
86
-     * @var EE_Environment_Config
87
-     */
88
-    public $environment;
89
-
90
-    /**
91
-     * settings pertaining to Google maps
92
-     *
93
-     * @var EE_Map_Config
94
-     */
95
-    public $map_settings;
96
-
97
-    /**
98
-     * settings pertaining to Taxes
99
-     *
100
-     * @var EE_Tax_Config
101
-     */
102
-    public $tax_settings;
103
-
104
-    /**
105
-     * Settings pertaining to global messages settings.
106
-     *
107
-     * @var EE_Messages_Config
108
-     */
109
-    public $messages;
110
-
111
-    /**
112
-     * @deprecated
113
-     * @var EE_Gateway_Config
114
-     */
115
-    public $gateway;
116
-
117
-    /**
118
-     * @var    array $_addon_option_names
119
-     * @access    private
120
-     */
121
-    private $_addon_option_names = array();
122
-
123
-    /**
124
-     * @var    array $_module_route_map
125
-     * @access    private
126
-     */
127
-    private static $_module_route_map = array();
128
-
129
-    /**
130
-     * @var    array $_module_forward_map
131
-     * @access    private
132
-     */
133
-    private static $_module_forward_map = array();
134
-
135
-    /**
136
-     * @var    array $_module_view_map
137
-     * @access    private
138
-     */
139
-    private static $_module_view_map = array();
140
-
141
-
142
-    /**
143
-     * @singleton method used to instantiate class object
144
-     * @access    public
145
-     * @return EE_Config instance
146
-     */
147
-    public static function instance()
148
-    {
149
-        // check if class object is instantiated, and instantiated properly
150
-        if (! self::$_instance instanceof EE_Config) {
151
-            self::$_instance = new self();
152
-        }
153
-        return self::$_instance;
154
-    }
155
-
156
-
157
-    /**
158
-     * Resets the config
159
-     *
160
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
161
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
162
-     *                               reflect its state in the database
163
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
164
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
165
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
166
-     *                               site was put into maintenance mode)
167
-     * @return EE_Config
168
-     */
169
-    public static function reset($hard_reset = false, $reinstantiate = true)
170
-    {
171
-        if (self::$_instance instanceof EE_Config) {
172
-            if ($hard_reset) {
173
-                self::$_instance->legacy_shortcodes_manager = null;
174
-                self::$_instance->_addon_option_names = array();
175
-                self::$_instance->_initialize_config();
176
-                self::$_instance->update_espresso_config();
177
-            }
178
-            self::$_instance->update_addon_option_names();
179
-        }
180
-        self::$_instance = null;
181
-        // we don't need to reset the static properties imo because those should
182
-        // only change when a module is added or removed. Currently we don't
183
-        // support removing a module during a request when it previously existed
184
-        if ($reinstantiate) {
185
-            return self::instance();
186
-        } else {
187
-            return null;
188
-        }
189
-    }
190
-
191
-
192
-    /**
193
-     *    class constructor
194
-     *
195
-     * @access    private
196
-     */
197
-    private function __construct()
198
-    {
199
-        do_action('AHEE__EE_Config__construct__begin', $this);
200
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
201
-        // setup empty config classes
202
-        $this->_initialize_config();
203
-        // load existing EE site settings
204
-        $this->_load_core_config();
205
-        // confirm everything loaded correctly and set filtered defaults if not
206
-        $this->_verify_config();
207
-        //  register shortcodes and modules
208
-        add_action(
209
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
210
-            array($this, 'register_shortcodes_and_modules'),
211
-            999
212
-        );
213
-        //  initialize shortcodes and modules
214
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
215
-        // register widgets
216
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
217
-        // shutdown
218
-        add_action('shutdown', array($this, 'shutdown'), 10);
219
-        // construct__end hook
220
-        do_action('AHEE__EE_Config__construct__end', $this);
221
-        // hardcoded hack
222
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
223
-    }
224
-
225
-
226
-    /**
227
-     * @return boolean
228
-     */
229
-    public static function logging_enabled()
230
-    {
231
-        return self::$_logging_enabled;
232
-    }
233
-
234
-
235
-    /**
236
-     * use to get the current theme if needed from static context
237
-     *
238
-     * @return string current theme set.
239
-     */
240
-    public static function get_current_theme()
241
-    {
242
-        return isset(self::$_instance->template_settings->current_espresso_theme)
243
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
244
-    }
245
-
246
-
247
-    /**
248
-     *        _initialize_config
249
-     *
250
-     * @access private
251
-     * @return void
252
-     */
253
-    private function _initialize_config()
254
-    {
255
-        EE_Config::trim_log();
256
-        // set defaults
257
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
258
-        $this->addons = new stdClass();
259
-        // set _module_route_map
260
-        EE_Config::$_module_route_map = array();
261
-        // set _module_forward_map
262
-        EE_Config::$_module_forward_map = array();
263
-        // set _module_view_map
264
-        EE_Config::$_module_view_map = array();
265
-    }
266
-
267
-
268
-    /**
269
-     *        load core plugin configuration
270
-     *
271
-     * @access private
272
-     * @return void
273
-     */
274
-    private function _load_core_config()
275
-    {
276
-        // load_core_config__start hook
277
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
278
-        $espresso_config = $this->get_espresso_config();
279
-        foreach ($espresso_config as $config => $settings) {
280
-            // load_core_config__start hook
281
-            $settings = apply_filters(
282
-                'FHEE__EE_Config___load_core_config__config_settings',
283
-                $settings,
284
-                $config,
285
-                $this
286
-            );
287
-            if (is_object($settings) && property_exists($this, $config)) {
288
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
289
-                // call configs populate method to ensure any defaults are set for empty values.
290
-                if (method_exists($settings, 'populate')) {
291
-                    $this->{$config}->populate();
292
-                }
293
-                if (method_exists($settings, 'do_hooks')) {
294
-                    $this->{$config}->do_hooks();
295
-                }
296
-            }
297
-        }
298
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
299
-            $this->update_espresso_config();
300
-        }
301
-        // load_core_config__end hook
302
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
303
-    }
304
-
305
-
306
-    /**
307
-     *    _verify_config
308
-     *
309
-     * @access    protected
310
-     * @return    void
311
-     */
312
-    protected function _verify_config()
313
-    {
314
-        $this->core = $this->core instanceof EE_Core_Config
315
-            ? $this->core
316
-            : new EE_Core_Config();
317
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
318
-        $this->organization = $this->organization instanceof EE_Organization_Config
319
-            ? $this->organization
320
-            : new EE_Organization_Config();
321
-        $this->organization = apply_filters(
322
-            'FHEE__EE_Config___initialize_config__organization',
323
-            $this->organization
324
-        );
325
-        $this->currency = $this->currency instanceof EE_Currency_Config
326
-            ? $this->currency
327
-            : new EE_Currency_Config();
328
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
329
-        $this->registration = $this->registration instanceof EE_Registration_Config
330
-            ? $this->registration
331
-            : new EE_Registration_Config();
332
-        $this->registration = apply_filters(
333
-            'FHEE__EE_Config___initialize_config__registration',
334
-            $this->registration
335
-        );
336
-        $this->admin = $this->admin instanceof EE_Admin_Config
337
-            ? $this->admin
338
-            : new EE_Admin_Config();
339
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
340
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
341
-            ? $this->template_settings
342
-            : new EE_Template_Config();
343
-        $this->template_settings = apply_filters(
344
-            'FHEE__EE_Config___initialize_config__template_settings',
345
-            $this->template_settings
346
-        );
347
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
348
-            ? $this->map_settings
349
-            : new EE_Map_Config();
350
-        $this->map_settings = apply_filters(
351
-            'FHEE__EE_Config___initialize_config__map_settings',
352
-            $this->map_settings
353
-        );
354
-        $this->environment = $this->environment instanceof EE_Environment_Config
355
-            ? $this->environment
356
-            : new EE_Environment_Config();
357
-        $this->environment = apply_filters(
358
-            'FHEE__EE_Config___initialize_config__environment',
359
-            $this->environment
360
-        );
361
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
362
-            ? $this->tax_settings
363
-            : new EE_Tax_Config();
364
-        $this->tax_settings = apply_filters(
365
-            'FHEE__EE_Config___initialize_config__tax_settings',
366
-            $this->tax_settings
367
-        );
368
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
369
-        $this->messages = $this->messages instanceof EE_Messages_Config
370
-            ? $this->messages
371
-            : new EE_Messages_Config();
372
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
373
-            ? $this->gateway
374
-            : new EE_Gateway_Config();
375
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
376
-        $this->legacy_shortcodes_manager = null;
377
-    }
378
-
379
-
380
-    /**
381
-     *    get_espresso_config
382
-     *
383
-     * @access    public
384
-     * @return    array of espresso config stuff
385
-     */
386
-    public function get_espresso_config()
387
-    {
388
-        // grab espresso configuration
389
-        return apply_filters(
390
-            'FHEE__EE_Config__get_espresso_config__CFG',
391
-            get_option(EE_Config::OPTION_NAME, array())
392
-        );
393
-    }
394
-
395
-
396
-    /**
397
-     *    double_check_config_comparison
398
-     *
399
-     * @access    public
400
-     * @param string $option
401
-     * @param        $old_value
402
-     * @param        $value
403
-     */
404
-    public function double_check_config_comparison($option = '', $old_value, $value)
405
-    {
406
-        // make sure we're checking the ee config
407
-        if ($option === EE_Config::OPTION_NAME) {
408
-            // run a loose comparison of the old value against the new value for type and properties,
409
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
410
-            if ($value != $old_value) {
411
-                // if they are NOT the same, then remove the hook,
412
-                // which means the subsequent update results will be based solely on the update query results
413
-                // the reason we do this is because, as stated above,
414
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
415
-                // this happens PRIOR to serialization and any subsequent update.
416
-                // If values are found to match their previous old value,
417
-                // then WP bails before performing any update.
418
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
419
-                // it just pulled from the db, with the one being passed to it (which will not match).
420
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
421
-                // MySQL MAY ALSO NOT perform the update because
422
-                // the string it sees in the db looks the same as the new one it has been passed!!!
423
-                // This results in the query returning an "affected rows" value of ZERO,
424
-                // which gets returned immediately by WP update_option and looks like an error.
425
-                remove_action('update_option', array($this, 'check_config_updated'));
426
-            }
427
-        }
428
-    }
429
-
430
-
431
-    /**
432
-     *    update_espresso_config
433
-     *
434
-     * @access   public
435
-     */
436
-    protected function _reset_espresso_addon_config()
437
-    {
438
-        $this->_addon_option_names = array();
439
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
440
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
441
-            if ($addon_config_obj instanceof EE_Config_Base) {
442
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
443
-            }
444
-            $this->addons->{$addon_name} = null;
445
-        }
446
-    }
447
-
448
-
449
-    /**
450
-     *    update_espresso_config
451
-     *
452
-     * @access   public
453
-     * @param   bool $add_success
454
-     * @param   bool $add_error
455
-     * @return   bool
456
-     */
457
-    public function update_espresso_config($add_success = false, $add_error = true)
458
-    {
459
-        // don't allow config updates during WP heartbeats
460
-        /** @var RequestInterface $request */
461
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
462
-        if ($request->isWordPressHeartbeat()) {
463
-            return false;
464
-        }
465
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
466
-        // $clone = clone( self::$_instance );
467
-        // self::$_instance = NULL;
468
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
469
-        $this->_reset_espresso_addon_config();
470
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
471
-        // but BEFORE the actual update occurs
472
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
473
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
474
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
475
-        $this->legacy_shortcodes_manager = null;
476
-        // now update "ee_config"
477
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
478
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
479
-        EE_Config::log(EE_Config::OPTION_NAME);
480
-        // if not saved... check if the hook we just added still exists;
481
-        // if it does, it means one of two things:
482
-        // that update_option bailed at the($value === $old_value) conditional,
483
-        // or...
484
-        // the db update query returned 0 rows affected
485
-        // (probably because the data  value was the same from it's perspective)
486
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
487
-        // but just means no update occurred, so don't display an error to the user.
488
-        // BUT... if update_option returns FALSE, AND the hook is missing,
489
-        // then it means that something truly went wrong
490
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
491
-        // remove our action since we don't want it in the system anymore
492
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
493
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
494
-        // self::$_instance = $clone;
495
-        // unset( $clone );
496
-        // if config remains the same or was updated successfully
497
-        if ($saved) {
498
-            if ($add_success) {
499
-                EE_Error::add_success(
500
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
501
-                    __FILE__,
502
-                    __FUNCTION__,
503
-                    __LINE__
504
-                );
505
-            }
506
-            return true;
507
-        } else {
508
-            if ($add_error) {
509
-                EE_Error::add_error(
510
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
511
-                    __FILE__,
512
-                    __FUNCTION__,
513
-                    __LINE__
514
-                );
515
-            }
516
-            return false;
517
-        }
518
-    }
519
-
520
-
521
-    /**
522
-     *    _verify_config_params
523
-     *
524
-     * @access    private
525
-     * @param    string         $section
526
-     * @param    string         $name
527
-     * @param    string         $config_class
528
-     * @param    EE_Config_Base $config_obj
529
-     * @param    array          $tests_to_run
530
-     * @param    bool           $display_errors
531
-     * @return    bool    TRUE on success, FALSE on fail
532
-     */
533
-    private function _verify_config_params(
534
-        $section = '',
535
-        $name = '',
536
-        $config_class = '',
537
-        $config_obj = null,
538
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
539
-        $display_errors = true
540
-    ) {
541
-        try {
542
-            foreach ($tests_to_run as $test) {
543
-                switch ($test) {
544
-                    // TEST #1 : check that section was set
545
-                    case 1:
546
-                        if (empty($section)) {
547
-                            if ($display_errors) {
548
-                                throw new EE_Error(
549
-                                    sprintf(
550
-                                        __(
551
-                                            'No configuration section has been provided while attempting to save "%s".',
552
-                                            'event_espresso'
553
-                                        ),
554
-                                        $config_class
555
-                                    )
556
-                                );
557
-                            }
558
-                            return false;
559
-                        }
560
-                        break;
561
-                    // TEST #2 : check that settings section exists
562
-                    case 2:
563
-                        if (! isset($this->{$section})) {
564
-                            if ($display_errors) {
565
-                                throw new EE_Error(
566
-                                    sprintf(
567
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
568
-                                        $section
569
-                                    )
570
-                                );
571
-                            }
572
-                            return false;
573
-                        }
574
-                        break;
575
-                    // TEST #3 : check that section is the proper format
576
-                    case 3:
577
-                        if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
578
-                        ) {
579
-                            if ($display_errors) {
580
-                                throw new EE_Error(
581
-                                    sprintf(
582
-                                        __(
583
-                                            'The "%s" configuration settings have not been formatted correctly.',
584
-                                            'event_espresso'
585
-                                        ),
586
-                                        $section
587
-                                    )
588
-                                );
589
-                            }
590
-                            return false;
591
-                        }
592
-                        break;
593
-                    // TEST #4 : check that config section name has been set
594
-                    case 4:
595
-                        if (empty($name)) {
596
-                            if ($display_errors) {
597
-                                throw new EE_Error(
598
-                                    __(
599
-                                        'No name has been provided for the specific configuration section.',
600
-                                        'event_espresso'
601
-                                    )
602
-                                );
603
-                            }
604
-                            return false;
605
-                        }
606
-                        break;
607
-                    // TEST #5 : check that a config class name has been set
608
-                    case 5:
609
-                        if (empty($config_class)) {
610
-                            if ($display_errors) {
611
-                                throw new EE_Error(
612
-                                    __(
613
-                                        'No class name has been provided for the specific configuration section.',
614
-                                        'event_espresso'
615
-                                    )
616
-                                );
617
-                            }
618
-                            return false;
619
-                        }
620
-                        break;
621
-                    // TEST #6 : verify config class is accessible
622
-                    case 6:
623
-                        if (! class_exists($config_class)) {
624
-                            if ($display_errors) {
625
-                                throw new EE_Error(
626
-                                    sprintf(
627
-                                        __(
628
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
629
-                                            'event_espresso'
630
-                                        ),
631
-                                        $config_class
632
-                                    )
633
-                                );
634
-                            }
635
-                            return false;
636
-                        }
637
-                        break;
638
-                    // TEST #7 : check that config has even been set
639
-                    case 7:
640
-                        if (! isset($this->{$section}->{$name})) {
641
-                            if ($display_errors) {
642
-                                throw new EE_Error(
643
-                                    sprintf(
644
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
645
-                                        $section,
646
-                                        $name
647
-                                    )
648
-                                );
649
-                            }
650
-                            return false;
651
-                        } else {
652
-                            // and make sure it's not serialized
653
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
654
-                        }
655
-                        break;
656
-                    // TEST #8 : check that config is the requested type
657
-                    case 8:
658
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
659
-                            if ($display_errors) {
660
-                                throw new EE_Error(
661
-                                    sprintf(
662
-                                        __(
663
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
664
-                                            'event_espresso'
665
-                                        ),
666
-                                        $section,
667
-                                        $name,
668
-                                        $config_class
669
-                                    )
670
-                                );
671
-                            }
672
-                            return false;
673
-                        }
674
-                        break;
675
-                    // TEST #9 : verify config object
676
-                    case 9:
677
-                        if (! $config_obj instanceof EE_Config_Base) {
678
-                            if ($display_errors) {
679
-                                throw new EE_Error(
680
-                                    sprintf(
681
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
682
-                                        print_r($config_obj, true)
683
-                                    )
684
-                                );
685
-                            }
686
-                            return false;
687
-                        }
688
-                        break;
689
-                }
690
-            }
691
-        } catch (EE_Error $e) {
692
-            $e->get_error();
693
-        }
694
-        // you have successfully run the gauntlet
695
-        return true;
696
-    }
697
-
698
-
699
-    /**
700
-     *    _generate_config_option_name
701
-     *
702
-     * @access        protected
703
-     * @param        string $section
704
-     * @param        string $name
705
-     * @return        string
706
-     */
707
-    private function _generate_config_option_name($section = '', $name = '')
708
-    {
709
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
710
-    }
711
-
712
-
713
-    /**
714
-     *    _set_config_class
715
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
716
-     *
717
-     * @access    private
718
-     * @param    string $config_class
719
-     * @param    string $name
720
-     * @return    string
721
-     */
722
-    private function _set_config_class($config_class = '', $name = '')
723
-    {
724
-        return ! empty($config_class)
725
-            ? $config_class
726
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
727
-    }
728
-
729
-
730
-    /**
731
-     *    set_config
732
-     *
733
-     * @access    protected
734
-     * @param    string         $section
735
-     * @param    string         $name
736
-     * @param    string         $config_class
737
-     * @param    EE_Config_Base $config_obj
738
-     * @return    EE_Config_Base
739
-     */
740
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
741
-    {
742
-        // ensure config class is set to something
743
-        $config_class = $this->_set_config_class($config_class, $name);
744
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
745
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
746
-            return null;
747
-        }
748
-        $config_option_name = $this->_generate_config_option_name($section, $name);
749
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
750
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
751
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
752
-            $this->update_addon_option_names();
753
-        }
754
-        // verify the incoming config object but suppress errors
755
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
756
-            $config_obj = new $config_class();
757
-        }
758
-        if (get_option($config_option_name)) {
759
-            EE_Config::log($config_option_name);
760
-            update_option($config_option_name, $config_obj);
761
-            $this->{$section}->{$name} = $config_obj;
762
-            return $this->{$section}->{$name};
763
-        } else {
764
-            // create a wp-option for this config
765
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
766
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
767
-                return $this->{$section}->{$name};
768
-            } else {
769
-                EE_Error::add_error(
770
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
771
-                    __FILE__,
772
-                    __FUNCTION__,
773
-                    __LINE__
774
-                );
775
-                return null;
776
-            }
777
-        }
778
-    }
779
-
780
-
781
-    /**
782
-     *    update_config
783
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
784
-     *
785
-     * @access    public
786
-     * @param    string                $section
787
-     * @param    string                $name
788
-     * @param    EE_Config_Base|string $config_obj
789
-     * @param    bool                  $throw_errors
790
-     * @return    bool
791
-     */
792
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
793
-    {
794
-        // don't allow config updates during WP heartbeats
795
-        /** @var RequestInterface $request */
796
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
797
-        if ($request->isWordPressHeartbeat()) {
798
-            return false;
799
-        }
800
-        $config_obj = maybe_unserialize($config_obj);
801
-        // get class name of the incoming object
802
-        $config_class = get_class($config_obj);
803
-        // run tests 1-5 and 9 to verify config
804
-        if (! $this->_verify_config_params(
805
-            $section,
806
-            $name,
807
-            $config_class,
808
-            $config_obj,
809
-            array(1, 2, 3, 4, 7, 9)
810
-        )
811
-        ) {
812
-            return false;
813
-        }
814
-        $config_option_name = $this->_generate_config_option_name($section, $name);
815
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
816
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
817
-            // save new config to db
818
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
819
-                return true;
820
-            }
821
-        } else {
822
-            // first check if the record already exists
823
-            $existing_config = get_option($config_option_name);
824
-            $config_obj = serialize($config_obj);
825
-            // just return if db record is already up to date (NOT type safe comparison)
826
-            if ($existing_config == $config_obj) {
827
-                $this->{$section}->{$name} = $config_obj;
828
-                return true;
829
-            } elseif (update_option($config_option_name, $config_obj)) {
830
-                EE_Config::log($config_option_name);
831
-                // update wp-option for this config class
832
-                $this->{$section}->{$name} = $config_obj;
833
-                return true;
834
-            } elseif ($throw_errors) {
835
-                EE_Error::add_error(
836
-                    sprintf(
837
-                        __(
838
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
839
-                            'event_espresso'
840
-                        ),
841
-                        $config_class,
842
-                        'EE_Config->' . $section . '->' . $name
843
-                    ),
844
-                    __FILE__,
845
-                    __FUNCTION__,
846
-                    __LINE__
847
-                );
848
-            }
849
-        }
850
-        return false;
851
-    }
852
-
853
-
854
-    /**
855
-     *    get_config
856
-     *
857
-     * @access    public
858
-     * @param    string $section
859
-     * @param    string $name
860
-     * @param    string $config_class
861
-     * @return    mixed EE_Config_Base | NULL
862
-     */
863
-    public function get_config($section = '', $name = '', $config_class = '')
864
-    {
865
-        // ensure config class is set to something
866
-        $config_class = $this->_set_config_class($config_class, $name);
867
-        // run tests 1-4, 6 and 7 to verify that all params have been set
868
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
869
-            return null;
870
-        }
871
-        // now test if the requested config object exists, but suppress errors
872
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
873
-            // config already exists, so pass it back
874
-            return $this->{$section}->{$name};
875
-        }
876
-        // load config option from db if it exists
877
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
878
-        // verify the newly retrieved config object, but suppress errors
879
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
880
-            // config is good, so set it and pass it back
881
-            $this->{$section}->{$name} = $config_obj;
882
-            return $this->{$section}->{$name};
883
-        }
884
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
885
-        $config_obj = $this->set_config($section, $name, $config_class);
886
-        // verify the newly created config object
887
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
888
-            return $this->{$section}->{$name};
889
-        } else {
890
-            EE_Error::add_error(
891
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
892
-                __FILE__,
893
-                __FUNCTION__,
894
-                __LINE__
895
-            );
896
-        }
897
-        return null;
898
-    }
899
-
900
-
901
-    /**
902
-     *    get_config_option
903
-     *
904
-     * @access    public
905
-     * @param    string $config_option_name
906
-     * @return    mixed EE_Config_Base | FALSE
907
-     */
908
-    public function get_config_option($config_option_name = '')
909
-    {
910
-        // retrieve the wp-option for this config class.
911
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
912
-        if (empty($config_option)) {
913
-            EE_Config::log($config_option_name . '-NOT-FOUND');
914
-        }
915
-        return $config_option;
916
-    }
917
-
918
-
919
-    /**
920
-     * log
921
-     *
922
-     * @param string $config_option_name
923
-     */
924
-    public static function log($config_option_name = '')
925
-    {
926
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
927
-            $config_log = get_option(EE_Config::LOG_NAME, array());
928
-            /** @var RequestParams $request */
929
-            $request = LoaderFactory::getLoader()->getShared(RequestParams::class);
930
-            $config_log[ (string) microtime(true) ] = array(
931
-                'config_name' => $config_option_name,
932
-                'request'     => $request->requestParams(),
933
-            );
934
-            update_option(EE_Config::LOG_NAME, $config_log);
935
-        }
936
-    }
937
-
938
-
939
-    /**
940
-     * trim_log
941
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
942
-     */
943
-    public static function trim_log()
944
-    {
945
-        if (! EE_Config::logging_enabled()) {
946
-            return;
947
-        }
948
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
949
-        $log_length = count($config_log);
950
-        if ($log_length > EE_Config::LOG_LENGTH) {
951
-            ksort($config_log);
952
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
953
-            update_option(EE_Config::LOG_NAME, $config_log);
954
-        }
955
-    }
956
-
957
-
958
-    /**
959
-     *    get_page_for_posts
960
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
961
-     *    wp-option "page_for_posts", or "posts" if no page is selected
962
-     *
963
-     * @access    public
964
-     * @return    string
965
-     */
966
-    public static function get_page_for_posts()
967
-    {
968
-        $page_for_posts = get_option('page_for_posts');
969
-        if (! $page_for_posts) {
970
-            return 'posts';
971
-        }
972
-        global $wpdb;
973
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
974
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
975
-    }
976
-
977
-
978
-    /**
979
-     *    register_shortcodes_and_modules.
980
-     *    At this point, it's too early to tell if we're maintenance mode or not.
981
-     *    In fact, this is where we give modules a chance to let core know they exist
982
-     *    so they can help trigger maintenance mode if it's needed
983
-     *
984
-     * @access    public
985
-     * @return    void
986
-     */
987
-    public function register_shortcodes_and_modules()
988
-    {
989
-        // allow modules to set hooks for the rest of the system
990
-        EE_Registry::instance()->modules = $this->_register_modules();
991
-    }
992
-
993
-
994
-    /**
995
-     *    initialize_shortcodes_and_modules
996
-     *    meaning they can start adding their hooks to get stuff done
997
-     *
998
-     * @access    public
999
-     * @return    void
1000
-     */
1001
-    public function initialize_shortcodes_and_modules()
1002
-    {
1003
-        // allow modules to set hooks for the rest of the system
1004
-        $this->_initialize_modules();
1005
-    }
1006
-
1007
-
1008
-    /**
1009
-     *    widgets_init
1010
-     *
1011
-     * @access private
1012
-     * @return void
1013
-     */
1014
-    public function widgets_init()
1015
-    {
1016
-        // only init widgets on admin pages when not in complete maintenance, and
1017
-        // on frontend when not in any maintenance mode
1018
-        if (! EE_Maintenance_Mode::instance()->level()
1019
-            || (
1020
-                is_admin()
1021
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1022
-            )
1023
-        ) {
1024
-            // grab list of installed widgets
1025
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1026
-            // filter list of modules to register
1027
-            $widgets_to_register = apply_filters(
1028
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1029
-                $widgets_to_register
1030
-            );
1031
-            if (! empty($widgets_to_register)) {
1032
-                // cycle thru widget folders
1033
-                foreach ($widgets_to_register as $widget_path) {
1034
-                    // add to list of installed widget modules
1035
-                    EE_Config::register_ee_widget($widget_path);
1036
-                }
1037
-            }
1038
-            // filter list of installed modules
1039
-            EE_Registry::instance()->widgets = apply_filters(
1040
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1041
-                EE_Registry::instance()->widgets
1042
-            );
1043
-        }
1044
-    }
1045
-
1046
-
1047
-    /**
1048
-     *    register_ee_widget - makes core aware of this widget
1049
-     *
1050
-     * @access    public
1051
-     * @param    string $widget_path - full path up to and including widget folder
1052
-     * @return    void
1053
-     */
1054
-    public static function register_ee_widget($widget_path = null)
1055
-    {
1056
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1057
-        $widget_ext = '.widget.php';
1058
-        // make all separators match
1059
-        $widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1060
-        // does the file path INCLUDE the actual file name as part of the path ?
1061
-        if (strpos($widget_path, $widget_ext) !== false) {
1062
-            // grab and shortcode file name from directory name and break apart at dots
1063
-            $file_name = explode('.', basename($widget_path));
1064
-            // take first segment from file name pieces and remove class prefix if it exists
1065
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1066
-            // sanitize shortcode directory name
1067
-            $widget = sanitize_key($widget);
1068
-            // now we need to rebuild the shortcode path
1069
-            $widget_path = explode('/', $widget_path);
1070
-            // remove last segment
1071
-            array_pop($widget_path);
1072
-            // glue it back together
1073
-            $widget_path = implode(DS, $widget_path);
1074
-        } else {
1075
-            // grab and sanitize widget directory name
1076
-            $widget = sanitize_key(basename($widget_path));
1077
-        }
1078
-        // create classname from widget directory name
1079
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1080
-        // add class prefix
1081
-        $widget_class = 'EEW_' . $widget;
1082
-        // does the widget exist ?
1083
-        if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1084
-            $msg = sprintf(
1085
-                __(
1086
-                    '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',
1087
-                    'event_espresso'
1088
-                ),
1089
-                $widget_class,
1090
-                $widget_path . '/' . $widget_class . $widget_ext
1091
-            );
1092
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1093
-            return;
1094
-        }
1095
-        // load the widget class file
1096
-        require_once($widget_path . '/' . $widget_class . $widget_ext);
1097
-        // verify that class exists
1098
-        if (! class_exists($widget_class)) {
1099
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1100
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1101
-            return;
1102
-        }
1103
-        register_widget($widget_class);
1104
-        // add to array of registered widgets
1105
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1106
-    }
1107
-
1108
-
1109
-    /**
1110
-     *        _register_modules
1111
-     *
1112
-     * @access private
1113
-     * @return array
1114
-     */
1115
-    private function _register_modules()
1116
-    {
1117
-        // grab list of installed modules
1118
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1119
-        // filter list of modules to register
1120
-        $modules_to_register = apply_filters(
1121
-            'FHEE__EE_Config__register_modules__modules_to_register',
1122
-            $modules_to_register
1123
-        );
1124
-        if (! empty($modules_to_register)) {
1125
-            // loop through folders
1126
-            foreach ($modules_to_register as $module_path) {
1127
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1128
-                if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1129
-                    && $module_path !== EE_MODULES . 'gateways'
1130
-                ) {
1131
-                    // add to list of installed modules
1132
-                    EE_Config::register_module($module_path);
1133
-                }
1134
-            }
1135
-        }
1136
-        // filter list of installed modules
1137
-        return apply_filters(
1138
-            'FHEE__EE_Config___register_modules__installed_modules',
1139
-            EE_Registry::instance()->modules
1140
-        );
1141
-    }
1142
-
1143
-
1144
-    /**
1145
-     *    register_module - makes core aware of this module
1146
-     *
1147
-     * @access    public
1148
-     * @param    string $module_path - full path up to and including module folder
1149
-     * @return    bool
1150
-     */
1151
-    public static function register_module($module_path = null)
1152
-    {
1153
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1154
-        $module_ext = '.module.php';
1155
-        // make all separators match
1156
-        $module_path = str_replace(array('\\', '/'), '/', $module_path);
1157
-        // does the file path INCLUDE the actual file name as part of the path ?
1158
-        if (strpos($module_path, $module_ext) !== false) {
1159
-            // grab and shortcode file name from directory name and break apart at dots
1160
-            $module_file = explode('.', basename($module_path));
1161
-            // now we need to rebuild the shortcode path
1162
-            $module_path = explode('/', $module_path);
1163
-            // remove last segment
1164
-            array_pop($module_path);
1165
-            // glue it back together
1166
-            $module_path = implode('/', $module_path) . '/';
1167
-            // take first segment from file name pieces and sanitize it
1168
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1169
-            // ensure class prefix is added
1170
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1171
-        } else {
1172
-            // we need to generate the filename based off of the folder name
1173
-            // grab and sanitize module name
1174
-            $module = strtolower(basename($module_path));
1175
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1176
-            // like trailingslashit()
1177
-            $module_path = rtrim($module_path, '/') . '/';
1178
-            // create classname from module directory name
1179
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1180
-            // add class prefix
1181
-            $module_class = 'EED_' . $module;
1182
-        }
1183
-        // does the module exist ?
1184
-        if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1185
-            $msg = sprintf(
1186
-                __(
1187
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1188
-                    'event_espresso'
1189
-                ),
1190
-                $module
1191
-            );
1192
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1193
-            return false;
1194
-        }
1195
-        // load the module class file
1196
-        require_once($module_path . $module_class . $module_ext);
1197
-        // verify that class exists
1198
-        if (! class_exists($module_class)) {
1199
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1200
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1201
-            return false;
1202
-        }
1203
-        // add to array of registered modules
1204
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1205
-        do_action(
1206
-            'AHEE__EE_Config__register_module__complete',
1207
-            $module_class,
1208
-            EE_Registry::instance()->modules->{$module_class}
1209
-        );
1210
-        return true;
1211
-    }
1212
-
1213
-
1214
-    /**
1215
-     *    _initialize_modules
1216
-     *    allow modules to set hooks for the rest of the system
1217
-     *
1218
-     * @access private
1219
-     * @return void
1220
-     */
1221
-    private function _initialize_modules()
1222
-    {
1223
-        // cycle thru shortcode folders
1224
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1225
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1226
-            // which set hooks ?
1227
-            if (is_admin()) {
1228
-                // fire immediately
1229
-                call_user_func(array($module_class, 'set_hooks_admin'));
1230
-            } else {
1231
-                // delay until other systems are online
1232
-                add_action(
1233
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1234
-                    array($module_class, 'set_hooks')
1235
-                );
1236
-            }
1237
-        }
1238
-    }
1239
-
1240
-
1241
-    /**
1242
-     *    register_route - adds module method routes to route_map
1243
-     *
1244
-     * @access    public
1245
-     * @param    string $route       - "pretty" public alias for module method
1246
-     * @param    string $module      - module name (classname without EED_ prefix)
1247
-     * @param    string $method_name - the actual module method to be routed to
1248
-     * @param    string $key         - url param key indicating a route is being called
1249
-     * @return    bool
1250
-     */
1251
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1252
-    {
1253
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1254
-        $module = str_replace('EED_', '', $module);
1255
-        $module_class = 'EED_' . $module;
1256
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1257
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1258
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1259
-            return false;
1260
-        }
1261
-        if (empty($route)) {
1262
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1263
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1264
-            return false;
1265
-        }
1266
-        if (! method_exists('EED_' . $module, $method_name)) {
1267
-            $msg = sprintf(
1268
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1269
-                $route
1270
-            );
1271
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1272
-            return false;
1273
-        }
1274
-        EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1275
-        return true;
1276
-    }
1277
-
1278
-
1279
-    /**
1280
-     *    get_route - get module method route
1281
-     *
1282
-     * @access    public
1283
-     * @param    string $route - "pretty" public alias for module method
1284
-     * @param    string $key   - url param key indicating a route is being called
1285
-     * @return    string
1286
-     */
1287
-    public static function get_route($route = null, $key = 'ee')
1288
-    {
1289
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1290
-        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1291
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1292
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1293
-        }
1294
-        return null;
1295
-    }
1296
-
1297
-
1298
-    /**
1299
-     *    get_routes - get ALL module method routes
1300
-     *
1301
-     * @access    public
1302
-     * @return    array
1303
-     */
1304
-    public static function get_routes()
1305
-    {
1306
-        return EE_Config::$_module_route_map;
1307
-    }
1308
-
1309
-
1310
-    /**
1311
-     *    register_forward - allows modules to forward request to another module for further processing
1312
-     *
1313
-     * @access    public
1314
-     * @param    string       $route   - "pretty" public alias for module method
1315
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1316
-     *                                 class, allows different forwards to be served based on status
1317
-     * @param    array|string $forward - function name or array( class, method )
1318
-     * @param    string       $key     - url param key indicating a route is being called
1319
-     * @return    bool
1320
-     */
1321
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1322
-    {
1323
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1324
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1325
-            $msg = sprintf(
1326
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1327
-                $route
1328
-            );
1329
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1330
-            return false;
1331
-        }
1332
-        if (empty($forward)) {
1333
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1334
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1335
-            return false;
1336
-        }
1337
-        if (is_array($forward)) {
1338
-            if (! isset($forward[1])) {
1339
-                $msg = sprintf(
1340
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1341
-                    $route
1342
-                );
1343
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1344
-                return false;
1345
-            }
1346
-            if (! method_exists($forward[0], $forward[1])) {
1347
-                $msg = sprintf(
1348
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1349
-                    $forward[1],
1350
-                    $route
1351
-                );
1352
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1353
-                return false;
1354
-            }
1355
-        } elseif (! function_exists($forward)) {
1356
-            $msg = sprintf(
1357
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1358
-                $forward,
1359
-                $route
1360
-            );
1361
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1362
-            return false;
1363
-        }
1364
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1365
-        return true;
1366
-    }
1367
-
1368
-
1369
-    /**
1370
-     *    get_forward - get forwarding route
1371
-     *
1372
-     * @access    public
1373
-     * @param    string  $route  - "pretty" public alias for module method
1374
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1375
-     *                           allows different forwards to be served based on status
1376
-     * @param    string  $key    - url param key indicating a route is being called
1377
-     * @return    string
1378
-     */
1379
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1380
-    {
1381
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1382
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1383
-            return apply_filters(
1384
-                'FHEE__EE_Config__get_forward',
1385
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1386
-                $route,
1387
-                $status
1388
-            );
1389
-        }
1390
-        return null;
1391
-    }
1392
-
1393
-
1394
-    /**
1395
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1396
-     *    results
1397
-     *
1398
-     * @access    public
1399
-     * @param    string  $route  - "pretty" public alias for module method
1400
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1401
-     *                           allows different views to be served based on status
1402
-     * @param    string  $view
1403
-     * @param    string  $key    - url param key indicating a route is being called
1404
-     * @return    bool
1405
-     */
1406
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1407
-    {
1408
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1409
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1410
-            $msg = sprintf(
1411
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1412
-                $route
1413
-            );
1414
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1415
-            return false;
1416
-        }
1417
-        if (! is_readable($view)) {
1418
-            $msg = sprintf(
1419
-                __(
1420
-                    'The %s view file could not be found or is not readable due to file permissions.',
1421
-                    'event_espresso'
1422
-                ),
1423
-                $view
1424
-            );
1425
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1426
-            return false;
1427
-        }
1428
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1429
-        return true;
1430
-    }
1431
-
1432
-
1433
-    /**
1434
-     *    get_view - get view for route and status
1435
-     *
1436
-     * @access    public
1437
-     * @param    string  $route  - "pretty" public alias for module method
1438
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1439
-     *                           allows different views to be served based on status
1440
-     * @param    string  $key    - url param key indicating a route is being called
1441
-     * @return    string
1442
-     */
1443
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1444
-    {
1445
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1446
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1447
-            return apply_filters(
1448
-                'FHEE__EE_Config__get_view',
1449
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1450
-                $route,
1451
-                $status
1452
-            );
1453
-        }
1454
-        return null;
1455
-    }
1456
-
1457
-
1458
-    public function update_addon_option_names()
1459
-    {
1460
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1461
-    }
1462
-
1463
-
1464
-    public function shutdown()
1465
-    {
1466
-        $this->update_addon_option_names();
1467
-    }
1468
-
1469
-
1470
-    /**
1471
-     * @return LegacyShortcodesManager
1472
-     */
1473
-    public static function getLegacyShortcodesManager()
1474
-    {
1475
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1476
-            EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1477
-                LegacyShortcodesManager::class
1478
-            );
1479
-        }
1480
-        return EE_Config::instance()->legacy_shortcodes_manager;
1481
-    }
1482
-
1483
-
1484
-    /**
1485
-     * register_shortcode - makes core aware of this shortcode
1486
-     *
1487
-     * @deprecated 4.9.26
1488
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1489
-     * @return    bool
1490
-     */
1491
-    public static function register_shortcode($shortcode_path = null)
1492
-    {
1493
-        EE_Error::doing_it_wrong(
1494
-            __METHOD__,
1495
-            __(
1496
-                '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.',
1497
-                'event_espresso'
1498
-            ),
1499
-            '4.9.26'
1500
-        );
1501
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1502
-    }
1503
-}
1504
-
1505
-/**
1506
- * Base class used for config classes. These classes should generally not have
1507
- * magic functions in use, except we'll allow them to magically set and get stuff...
1508
- * basically, they should just be well-defined stdClasses
1509
- */
1510
-class EE_Config_Base
1511
-{
1512
-
1513
-    /**
1514
-     * Utility function for escaping the value of a property and returning.
1515
-     *
1516
-     * @param string $property property name (checks to see if exists).
1517
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1518
-     * @throws \EE_Error
1519
-     */
1520
-    public function get_pretty($property)
1521
-    {
1522
-        if (! property_exists($this, $property)) {
1523
-            throw new EE_Error(
1524
-                sprintf(
1525
-                    __(
1526
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1527
-                        'event_espresso'
1528
-                    ),
1529
-                    get_class($this),
1530
-                    $property
1531
-                )
1532
-            );
1533
-        }
1534
-        // just handling escaping of strings for now.
1535
-        if (is_string($this->{$property})) {
1536
-            return stripslashes($this->{$property});
1537
-        }
1538
-        return $this->{$property};
1539
-    }
1540
-
1541
-
1542
-    public function populate()
1543
-    {
1544
-        // grab defaults via a new instance of this class.
1545
-        $class_name = get_class($this);
1546
-        $defaults = new $class_name;
1547
-        // loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1548
-        // default from our $defaults object.
1549
-        foreach (get_object_vars($defaults) as $property => $value) {
1550
-            if ($this->{$property} === null) {
1551
-                $this->{$property} = $value;
1552
-            }
1553
-        }
1554
-        // cleanup
1555
-        unset($defaults);
1556
-    }
1557
-
1558
-
1559
-    /**
1560
-     *        __isset
1561
-     *
1562
-     * @param $a
1563
-     * @return bool
1564
-     */
1565
-    public function __isset($a)
1566
-    {
1567
-        return false;
1568
-    }
1569
-
1570
-
1571
-    /**
1572
-     *        __unset
1573
-     *
1574
-     * @param $a
1575
-     * @return bool
1576
-     */
1577
-    public function __unset($a)
1578
-    {
1579
-        return false;
1580
-    }
1581
-
1582
-
1583
-    /**
1584
-     *        __clone
1585
-     */
1586
-    public function __clone()
1587
-    {
1588
-    }
1589
-
1590
-
1591
-    /**
1592
-     *        __wakeup
1593
-     */
1594
-    public function __wakeup()
1595
-    {
1596
-    }
1597
-
1598
-
1599
-    /**
1600
-     *        __destruct
1601
-     */
1602
-    public function __destruct()
1603
-    {
1604
-    }
1605
-}
1606
-
1607
-/**
1608
- * Class for defining what's in the EE_Config relating to registration settings
1609
- */
1610
-class EE_Core_Config extends EE_Config_Base
1611
-{
1612
-
1613
-    const OPTION_NAME_UXIP = 'ee_ueip_optin';
1614
-
1615
-
1616
-    public $current_blog_id;
1617
-
1618
-    public $ee_ueip_optin;
1619
-
1620
-    public $ee_ueip_has_notified;
1621
-
1622
-    /**
1623
-     * Not to be confused with the 4 critical page variables (See
1624
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1625
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1626
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1627
-     *
1628
-     * @var array
1629
-     */
1630
-    public $post_shortcodes;
1631
-
1632
-    public $module_route_map;
1633
-
1634
-    public $module_forward_map;
1635
-
1636
-    public $module_view_map;
1637
-
1638
-    /**
1639
-     * The next 4 vars are the IDs of critical EE pages.
1640
-     *
1641
-     * @var int
1642
-     */
1643
-    public $reg_page_id;
1644
-
1645
-    public $txn_page_id;
1646
-
1647
-    public $thank_you_page_id;
1648
-
1649
-    public $cancel_page_id;
1650
-
1651
-    /**
1652
-     * The next 4 vars are the URLs of critical EE pages.
1653
-     *
1654
-     * @var int
1655
-     */
1656
-    public $reg_page_url;
1657
-
1658
-    public $txn_page_url;
1659
-
1660
-    public $thank_you_page_url;
1661
-
1662
-    public $cancel_page_url;
1663
-
1664
-    /**
1665
-     * The next vars relate to the custom slugs for EE CPT routes
1666
-     */
1667
-    public $event_cpt_slug;
1668
-
1669
-    /**
1670
-     * This caches the _ee_ueip_option in case this config is reset in the same
1671
-     * request across blog switches in a multisite context.
1672
-     * Avoids extra queries to the db for this option.
1673
-     *
1674
-     * @var bool
1675
-     */
1676
-    public static $ee_ueip_option;
1677
-
1678
-
1679
-    /**
1680
-     *    class constructor
1681
-     *
1682
-     * @access    public
1683
-     */
1684
-    public function __construct()
1685
-    {
1686
-        // set default organization settings
1687
-        $this->current_blog_id = get_current_blog_id();
1688
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1689
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1690
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1691
-        $this->post_shortcodes = array();
1692
-        $this->module_route_map = array();
1693
-        $this->module_forward_map = array();
1694
-        $this->module_view_map = array();
1695
-        // critical EE page IDs
1696
-        $this->reg_page_id = 0;
1697
-        $this->txn_page_id = 0;
1698
-        $this->thank_you_page_id = 0;
1699
-        $this->cancel_page_id = 0;
1700
-        // critical EE page URLs
1701
-        $this->reg_page_url = '';
1702
-        $this->txn_page_url = '';
1703
-        $this->thank_you_page_url = '';
1704
-        $this->cancel_page_url = '';
1705
-        // cpt slugs
1706
-        $this->event_cpt_slug = __('events', 'event_espresso');
1707
-        // ueip constant check
1708
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1709
-            $this->ee_ueip_optin = false;
1710
-            $this->ee_ueip_has_notified = true;
1711
-        }
1712
-    }
1713
-
1714
-
1715
-    /**
1716
-     * @return array
1717
-     */
1718
-    public function get_critical_pages_array()
1719
-    {
1720
-        return array(
1721
-            $this->reg_page_id,
1722
-            $this->txn_page_id,
1723
-            $this->thank_you_page_id,
1724
-            $this->cancel_page_id,
1725
-        );
1726
-    }
1727
-
1728
-
1729
-    /**
1730
-     * @return array
1731
-     */
1732
-    public function get_critical_pages_shortcodes_array()
1733
-    {
1734
-        return array(
1735
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1736
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1737
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1738
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1739
-        );
1740
-    }
1741
-
1742
-
1743
-    /**
1744
-     *  gets/returns URL for EE reg_page
1745
-     *
1746
-     * @access    public
1747
-     * @return    string
1748
-     */
1749
-    public function reg_page_url()
1750
-    {
1751
-        if (! $this->reg_page_url) {
1752
-            $this->reg_page_url = add_query_arg(
1753
-                array('uts' => time()),
1754
-                get_permalink($this->reg_page_id)
1755
-            ) . '#checkout';
1756
-        }
1757
-        return $this->reg_page_url;
1758
-    }
1759
-
1760
-
1761
-    /**
1762
-     *  gets/returns URL for EE txn_page
1763
-     *
1764
-     * @param array $query_args like what gets passed to
1765
-     *                          add_query_arg() as the first argument
1766
-     * @access    public
1767
-     * @return    string
1768
-     */
1769
-    public function txn_page_url($query_args = array())
1770
-    {
1771
-        if (! $this->txn_page_url) {
1772
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1773
-        }
1774
-        if ($query_args) {
1775
-            return add_query_arg($query_args, $this->txn_page_url);
1776
-        } else {
1777
-            return $this->txn_page_url;
1778
-        }
1779
-    }
1780
-
1781
-
1782
-    /**
1783
-     *  gets/returns URL for EE thank_you_page
1784
-     *
1785
-     * @param array $query_args like what gets passed to
1786
-     *                          add_query_arg() as the first argument
1787
-     * @access    public
1788
-     * @return    string
1789
-     */
1790
-    public function thank_you_page_url($query_args = array())
1791
-    {
1792
-        if (! $this->thank_you_page_url) {
1793
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1794
-        }
1795
-        if ($query_args) {
1796
-            return add_query_arg($query_args, $this->thank_you_page_url);
1797
-        } else {
1798
-            return $this->thank_you_page_url;
1799
-        }
1800
-    }
1801
-
1802
-
1803
-    /**
1804
-     *  gets/returns URL for EE cancel_page
1805
-     *
1806
-     * @access    public
1807
-     * @return    string
1808
-     */
1809
-    public function cancel_page_url()
1810
-    {
1811
-        if (! $this->cancel_page_url) {
1812
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1813
-        }
1814
-        return $this->cancel_page_url;
1815
-    }
1816
-
1817
-
1818
-    /**
1819
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1820
-     *
1821
-     * @since 4.7.5
1822
-     */
1823
-    protected function _reset_urls()
1824
-    {
1825
-        $this->reg_page_url = '';
1826
-        $this->txn_page_url = '';
1827
-        $this->cancel_page_url = '';
1828
-        $this->thank_you_page_url = '';
1829
-    }
1830
-
1831
-
1832
-    /**
1833
-     * Used to return what the optin value is set for the EE User Experience Program.
1834
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1835
-     * on the main site only.
1836
-     *
1837
-     * @return bool
1838
-     */
1839
-    protected function _get_main_ee_ueip_optin()
1840
-    {
1841
-        // if this is the main site then we can just bypass our direct query.
1842
-        if (is_main_site()) {
1843
-            return get_option(self::OPTION_NAME_UXIP, false);
1844
-        }
1845
-        // is this already cached for this request?  If so use it.
1846
-        if (EE_Core_Config::$ee_ueip_option !== null) {
1847
-            return EE_Core_Config::$ee_ueip_option;
1848
-        }
1849
-        global $wpdb;
1850
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1851
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1852
-        $option = self::OPTION_NAME_UXIP;
1853
-        // set correct table for query
1854
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1855
-        // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1856
-        // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1857
-        // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1858
-        // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1859
-        // for the purpose of caching.
1860
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1861
-        if (false !== $pre) {
1862
-            EE_Core_Config::$ee_ueip_option = $pre;
1863
-            return EE_Core_Config::$ee_ueip_option;
1864
-        }
1865
-        $row = $wpdb->get_row(
1866
-            $wpdb->prepare(
1867
-                "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1868
-                $option
1869
-            )
1870
-        );
1871
-        if (is_object($row)) {
1872
-            $value = $row->option_value;
1873
-        } else { // option does not exist so use default.
1874
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1875
-            return EE_Core_Config::$ee_ueip_option;
1876
-        }
1877
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1878
-        return EE_Core_Config::$ee_ueip_option;
1879
-    }
1880
-
1881
-
1882
-    /**
1883
-     * Utility function for escaping the value of a property and returning.
1884
-     *
1885
-     * @param string $property property name (checks to see if exists).
1886
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1887
-     * @throws \EE_Error
1888
-     */
1889
-    public function get_pretty($property)
1890
-    {
1891
-        if ($property === self::OPTION_NAME_UXIP) {
1892
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1893
-        }
1894
-        return parent::get_pretty($property);
1895
-    }
1896
-
1897
-
1898
-    /**
1899
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1900
-     * on the object.
1901
-     *
1902
-     * @return array
1903
-     */
1904
-    public function __sleep()
1905
-    {
1906
-        // reset all url properties
1907
-        $this->_reset_urls();
1908
-        // return what to save to db
1909
-        return array_keys(get_object_vars($this));
1910
-    }
1911
-}
1912
-
1913
-/**
1914
- * Config class for storing info on the Organization
1915
- */
1916
-class EE_Organization_Config extends EE_Config_Base
1917
-{
1918
-
1919
-    /**
1920
-     * @var string $name
1921
-     * eg EE4.1
1922
-     */
1923
-    public $name;
1924
-
1925
-    /**
1926
-     * @var string $address_1
1927
-     * eg 123 Onna Road
1928
-     */
1929
-    public $address_1 = '';
1930
-
1931
-    /**
1932
-     * @var string $address_2
1933
-     * eg PO Box 123
1934
-     */
1935
-    public $address_2 = '';
1936
-
1937
-    /**
1938
-     * @var string $city
1939
-     * eg Inna City
1940
-     */
1941
-    public $city = '';
1942
-
1943
-    /**
1944
-     * @var int $STA_ID
1945
-     * eg 4
1946
-     */
1947
-    public $STA_ID = 0;
1948
-
1949
-    /**
1950
-     * @var string $CNT_ISO
1951
-     * eg US
1952
-     */
1953
-    public $CNT_ISO = '';
1954
-
1955
-    /**
1956
-     * @var string $zip
1957
-     * eg 12345  or V1A 2B3
1958
-     */
1959
-    public $zip = '';
1960
-
1961
-    /**
1962
-     * @var string $email
1963
-     * eg [email protected]
1964
-     */
1965
-    public $email;
1966
-
1967
-    /**
1968
-     * @var string $phone
1969
-     * eg. 111-111-1111
1970
-     */
1971
-    public $phone = '';
1972
-
1973
-    /**
1974
-     * @var string $vat
1975
-     * VAT/Tax Number
1976
-     */
1977
-    public $vat = '';
1978
-
1979
-    /**
1980
-     * @var string $logo_url
1981
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1982
-     */
1983
-    public $logo_url = '';
1984
-
1985
-    /**
1986
-     * The below are all various properties for holding links to organization social network profiles
1987
-     *
1988
-     * @var string
1989
-     */
1990
-    /**
1991
-     * facebook (facebook.com/profile.name)
1992
-     *
1993
-     * @var string
1994
-     */
1995
-    public $facebook = '';
1996
-
1997
-    /**
1998
-     * twitter (twitter.com/twitter_handle)
1999
-     *
2000
-     * @var string
2001
-     */
2002
-    public $twitter = '';
2003
-
2004
-    /**
2005
-     * linkedin (linkedin.com/in/profile_name)
2006
-     *
2007
-     * @var string
2008
-     */
2009
-    public $linkedin = '';
2010
-
2011
-    /**
2012
-     * pinterest (www.pinterest.com/profile_name)
2013
-     *
2014
-     * @var string
2015
-     */
2016
-    public $pinterest = '';
2017
-
2018
-    /**
2019
-     * google+ (google.com/+profileName)
2020
-     *
2021
-     * @var string
2022
-     */
2023
-    public $google = '';
2024
-
2025
-    /**
2026
-     * instagram (instagram.com/handle)
2027
-     *
2028
-     * @var string
2029
-     */
2030
-    public $instagram = '';
2031
-
2032
-
2033
-    /**
2034
-     *    class constructor
2035
-     *
2036
-     * @access    public
2037
-     */
2038
-    public function __construct()
2039
-    {
2040
-        // set default organization settings
2041
-        // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2042
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2043
-        $this->email = get_bloginfo('admin_email');
2044
-    }
2045
-}
2046
-
2047
-/**
2048
- * Class for defining what's in the EE_Config relating to currency
2049
- */
2050
-class EE_Currency_Config extends EE_Config_Base
2051
-{
2052
-
2053
-    /**
2054
-     * @var string $code
2055
-     * eg 'US'
2056
-     */
2057
-    public $code;
2058
-
2059
-    /**
2060
-     * @var string $name
2061
-     * eg 'Dollar'
2062
-     */
2063
-    public $name;
2064
-
2065
-    /**
2066
-     * plural name
2067
-     *
2068
-     * @var string $plural
2069
-     * eg 'Dollars'
2070
-     */
2071
-    public $plural;
2072
-
2073
-    /**
2074
-     * currency sign
2075
-     *
2076
-     * @var string $sign
2077
-     * eg '$'
2078
-     */
2079
-    public $sign;
2080
-
2081
-    /**
2082
-     * Whether the currency sign should come before the number or not
2083
-     *
2084
-     * @var boolean $sign_b4
2085
-     */
2086
-    public $sign_b4;
2087
-
2088
-    /**
2089
-     * How many digits should come after the decimal place
2090
-     *
2091
-     * @var int $dec_plc
2092
-     */
2093
-    public $dec_plc;
2094
-
2095
-    /**
2096
-     * Symbol to use for decimal mark
2097
-     *
2098
-     * @var string $dec_mrk
2099
-     * eg '.'
2100
-     */
2101
-    public $dec_mrk;
2102
-
2103
-    /**
2104
-     * Symbol to use for thousands
2105
-     *
2106
-     * @var string $thsnds
2107
-     * eg ','
2108
-     */
2109
-    public $thsnds;
2110
-
2111
-
2112
-    /**
2113
-     *    class constructor
2114
-     *
2115
-     * @access    public
2116
-     * @param string $CNT_ISO
2117
-     * @throws \EE_Error
2118
-     */
2119
-    public function __construct($CNT_ISO = '')
2120
-    {
2121
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2122
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2123
-        // get country code from organization settings or use default
2124
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2125
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2126
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2127
-            : '';
2128
-        // but override if requested
2129
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2130
-        // 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
2131
-        if (! empty($CNT_ISO)
2132
-            && EE_Maintenance_Mode::instance()->models_can_query()
2133
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2134
-        ) {
2135
-            // retrieve the country settings from the db, just in case they have been customized
2136
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2137
-            if ($country instanceof EE_Country) {
2138
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2139
-                $this->name = $country->currency_name_single();    // Dollar
2140
-                $this->plural = $country->currency_name_plural();    // Dollars
2141
-                $this->sign = $country->currency_sign();            // currency sign: $
2142
-                $this->sign_b4 = $country->currency_sign_before(
2143
-                );        // currency sign before or after: $TRUE  or  FALSE$
2144
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2145
-                $this->dec_mrk = $country->currency_decimal_mark(
2146
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2147
-                $this->thsnds = $country->currency_thousands_separator(
2148
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2149
-            }
2150
-        }
2151
-        // fallback to hardcoded defaults, in case the above failed
2152
-        if (empty($this->code)) {
2153
-            // set default currency settings
2154
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2155
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2156
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2157
-            $this->sign = '$';    // currency sign: $
2158
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2159
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2160
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2161
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2162
-        }
2163
-    }
2164
-}
2165
-
2166
-/**
2167
- * Class for defining what's in the EE_Config relating to registration settings
2168
- */
2169
-class EE_Registration_Config extends EE_Config_Base
2170
-{
2171
-
2172
-    /**
2173
-     * Default registration status
2174
-     *
2175
-     * @var string $default_STS_ID
2176
-     * eg 'RPP'
2177
-     */
2178
-    public $default_STS_ID;
2179
-
2180
-    /**
2181
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2182
-     * registrations)
2183
-     *
2184
-     * @var int
2185
-     */
2186
-    public $default_maximum_number_of_tickets;
2187
-
2188
-    /**
2189
-     * level of validation to apply to email addresses
2190
-     *
2191
-     * @var string $email_validation_level
2192
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2193
-     */
2194
-    public $email_validation_level;
2195
-
2196
-    /**
2197
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2198
-     *
2199
-     * @var boolean $show_pending_payment_options
2200
-     */
2201
-    public $show_pending_payment_options;
2202
-
2203
-    /**
2204
-     * Whether to skip the registration confirmation page
2205
-     *
2206
-     * @var boolean $skip_reg_confirmation
2207
-     */
2208
-    public $skip_reg_confirmation;
2209
-
2210
-    /**
2211
-     * an array of SPCO reg steps where:
2212
-     *        the keys denotes the reg step order
2213
-     *        each element consists of an array with the following elements:
2214
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2215
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2216
-     *            "slug" => the URL param used to trigger the reg step
2217
-     *
2218
-     * @var array $reg_steps
2219
-     */
2220
-    public $reg_steps;
2221
-
2222
-    /**
2223
-     * Whether registration confirmation should be the last page of SPCO
2224
-     *
2225
-     * @var boolean $reg_confirmation_last
2226
-     */
2227
-    public $reg_confirmation_last;
2228
-
2229
-    /**
2230
-     * Whether or not to enable the EE Bot Trap
2231
-     *
2232
-     * @var boolean $use_bot_trap
2233
-     */
2234
-    public $use_bot_trap;
2235
-
2236
-    /**
2237
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2238
-     *
2239
-     * @var boolean $use_encryption
2240
-     */
2241
-    public $use_encryption;
2242
-
2243
-    /**
2244
-     * Whether or not to use ReCaptcha
2245
-     *
2246
-     * @var boolean $use_captcha
2247
-     */
2248
-    public $use_captcha;
2249
-
2250
-    /**
2251
-     * ReCaptcha Theme
2252
-     *
2253
-     * @var string $recaptcha_theme
2254
-     *    options: 'dark', 'light', 'invisible'
2255
-     */
2256
-    public $recaptcha_theme;
2257
-
2258
-    /**
2259
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2260
-     *
2261
-     * @var string $recaptcha_badge
2262
-     *    options: 'bottomright', 'bottomleft', 'inline'
2263
-     */
2264
-    public $recaptcha_badge;
19
+	const OPTION_NAME = 'ee_config';
20
+
21
+	const LOG_NAME = 'ee_config_log';
22
+
23
+	const LOG_LENGTH = 100;
24
+
25
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
26
+
27
+	/**
28
+	 *    instance of the EE_Config object
29
+	 *
30
+	 * @var    EE_Config $_instance
31
+	 * @access    private
32
+	 */
33
+	private static $_instance;
34
+
35
+	/**
36
+	 * @var boolean $_logging_enabled
37
+	 */
38
+	private static $_logging_enabled = false;
39
+
40
+	/**
41
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
42
+	 */
43
+	private $legacy_shortcodes_manager;
44
+
45
+	/**
46
+	 * An StdClass whose property names are addon slugs,
47
+	 * and values are their config classes
48
+	 *
49
+	 * @var StdClass
50
+	 */
51
+	public $addons;
52
+
53
+	/**
54
+	 * @var EE_Admin_Config
55
+	 */
56
+	public $admin;
57
+
58
+	/**
59
+	 * @var EE_Core_Config
60
+	 */
61
+	public $core;
62
+
63
+	/**
64
+	 * @var EE_Currency_Config
65
+	 */
66
+	public $currency;
67
+
68
+	/**
69
+	 * @var EE_Organization_Config
70
+	 */
71
+	public $organization;
72
+
73
+	/**
74
+	 * @var EE_Registration_Config
75
+	 */
76
+	public $registration;
77
+
78
+	/**
79
+	 * @var EE_Template_Config
80
+	 */
81
+	public $template_settings;
82
+
83
+	/**
84
+	 * Holds EE environment values.
85
+	 *
86
+	 * @var EE_Environment_Config
87
+	 */
88
+	public $environment;
89
+
90
+	/**
91
+	 * settings pertaining to Google maps
92
+	 *
93
+	 * @var EE_Map_Config
94
+	 */
95
+	public $map_settings;
96
+
97
+	/**
98
+	 * settings pertaining to Taxes
99
+	 *
100
+	 * @var EE_Tax_Config
101
+	 */
102
+	public $tax_settings;
103
+
104
+	/**
105
+	 * Settings pertaining to global messages settings.
106
+	 *
107
+	 * @var EE_Messages_Config
108
+	 */
109
+	public $messages;
110
+
111
+	/**
112
+	 * @deprecated
113
+	 * @var EE_Gateway_Config
114
+	 */
115
+	public $gateway;
116
+
117
+	/**
118
+	 * @var    array $_addon_option_names
119
+	 * @access    private
120
+	 */
121
+	private $_addon_option_names = array();
122
+
123
+	/**
124
+	 * @var    array $_module_route_map
125
+	 * @access    private
126
+	 */
127
+	private static $_module_route_map = array();
128
+
129
+	/**
130
+	 * @var    array $_module_forward_map
131
+	 * @access    private
132
+	 */
133
+	private static $_module_forward_map = array();
134
+
135
+	/**
136
+	 * @var    array $_module_view_map
137
+	 * @access    private
138
+	 */
139
+	private static $_module_view_map = array();
140
+
141
+
142
+	/**
143
+	 * @singleton method used to instantiate class object
144
+	 * @access    public
145
+	 * @return EE_Config instance
146
+	 */
147
+	public static function instance()
148
+	{
149
+		// check if class object is instantiated, and instantiated properly
150
+		if (! self::$_instance instanceof EE_Config) {
151
+			self::$_instance = new self();
152
+		}
153
+		return self::$_instance;
154
+	}
155
+
156
+
157
+	/**
158
+	 * Resets the config
159
+	 *
160
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
161
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
162
+	 *                               reflect its state in the database
163
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
164
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
165
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
166
+	 *                               site was put into maintenance mode)
167
+	 * @return EE_Config
168
+	 */
169
+	public static function reset($hard_reset = false, $reinstantiate = true)
170
+	{
171
+		if (self::$_instance instanceof EE_Config) {
172
+			if ($hard_reset) {
173
+				self::$_instance->legacy_shortcodes_manager = null;
174
+				self::$_instance->_addon_option_names = array();
175
+				self::$_instance->_initialize_config();
176
+				self::$_instance->update_espresso_config();
177
+			}
178
+			self::$_instance->update_addon_option_names();
179
+		}
180
+		self::$_instance = null;
181
+		// we don't need to reset the static properties imo because those should
182
+		// only change when a module is added or removed. Currently we don't
183
+		// support removing a module during a request when it previously existed
184
+		if ($reinstantiate) {
185
+			return self::instance();
186
+		} else {
187
+			return null;
188
+		}
189
+	}
190
+
191
+
192
+	/**
193
+	 *    class constructor
194
+	 *
195
+	 * @access    private
196
+	 */
197
+	private function __construct()
198
+	{
199
+		do_action('AHEE__EE_Config__construct__begin', $this);
200
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
201
+		// setup empty config classes
202
+		$this->_initialize_config();
203
+		// load existing EE site settings
204
+		$this->_load_core_config();
205
+		// confirm everything loaded correctly and set filtered defaults if not
206
+		$this->_verify_config();
207
+		//  register shortcodes and modules
208
+		add_action(
209
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
210
+			array($this, 'register_shortcodes_and_modules'),
211
+			999
212
+		);
213
+		//  initialize shortcodes and modules
214
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
215
+		// register widgets
216
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
217
+		// shutdown
218
+		add_action('shutdown', array($this, 'shutdown'), 10);
219
+		// construct__end hook
220
+		do_action('AHEE__EE_Config__construct__end', $this);
221
+		// hardcoded hack
222
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
223
+	}
224
+
225
+
226
+	/**
227
+	 * @return boolean
228
+	 */
229
+	public static function logging_enabled()
230
+	{
231
+		return self::$_logging_enabled;
232
+	}
233
+
234
+
235
+	/**
236
+	 * use to get the current theme if needed from static context
237
+	 *
238
+	 * @return string current theme set.
239
+	 */
240
+	public static function get_current_theme()
241
+	{
242
+		return isset(self::$_instance->template_settings->current_espresso_theme)
243
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
244
+	}
245
+
246
+
247
+	/**
248
+	 *        _initialize_config
249
+	 *
250
+	 * @access private
251
+	 * @return void
252
+	 */
253
+	private function _initialize_config()
254
+	{
255
+		EE_Config::trim_log();
256
+		// set defaults
257
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
258
+		$this->addons = new stdClass();
259
+		// set _module_route_map
260
+		EE_Config::$_module_route_map = array();
261
+		// set _module_forward_map
262
+		EE_Config::$_module_forward_map = array();
263
+		// set _module_view_map
264
+		EE_Config::$_module_view_map = array();
265
+	}
266
+
267
+
268
+	/**
269
+	 *        load core plugin configuration
270
+	 *
271
+	 * @access private
272
+	 * @return void
273
+	 */
274
+	private function _load_core_config()
275
+	{
276
+		// load_core_config__start hook
277
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
278
+		$espresso_config = $this->get_espresso_config();
279
+		foreach ($espresso_config as $config => $settings) {
280
+			// load_core_config__start hook
281
+			$settings = apply_filters(
282
+				'FHEE__EE_Config___load_core_config__config_settings',
283
+				$settings,
284
+				$config,
285
+				$this
286
+			);
287
+			if (is_object($settings) && property_exists($this, $config)) {
288
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
289
+				// call configs populate method to ensure any defaults are set for empty values.
290
+				if (method_exists($settings, 'populate')) {
291
+					$this->{$config}->populate();
292
+				}
293
+				if (method_exists($settings, 'do_hooks')) {
294
+					$this->{$config}->do_hooks();
295
+				}
296
+			}
297
+		}
298
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
299
+			$this->update_espresso_config();
300
+		}
301
+		// load_core_config__end hook
302
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
303
+	}
304
+
305
+
306
+	/**
307
+	 *    _verify_config
308
+	 *
309
+	 * @access    protected
310
+	 * @return    void
311
+	 */
312
+	protected function _verify_config()
313
+	{
314
+		$this->core = $this->core instanceof EE_Core_Config
315
+			? $this->core
316
+			: new EE_Core_Config();
317
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
318
+		$this->organization = $this->organization instanceof EE_Organization_Config
319
+			? $this->organization
320
+			: new EE_Organization_Config();
321
+		$this->organization = apply_filters(
322
+			'FHEE__EE_Config___initialize_config__organization',
323
+			$this->organization
324
+		);
325
+		$this->currency = $this->currency instanceof EE_Currency_Config
326
+			? $this->currency
327
+			: new EE_Currency_Config();
328
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
329
+		$this->registration = $this->registration instanceof EE_Registration_Config
330
+			? $this->registration
331
+			: new EE_Registration_Config();
332
+		$this->registration = apply_filters(
333
+			'FHEE__EE_Config___initialize_config__registration',
334
+			$this->registration
335
+		);
336
+		$this->admin = $this->admin instanceof EE_Admin_Config
337
+			? $this->admin
338
+			: new EE_Admin_Config();
339
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
340
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
341
+			? $this->template_settings
342
+			: new EE_Template_Config();
343
+		$this->template_settings = apply_filters(
344
+			'FHEE__EE_Config___initialize_config__template_settings',
345
+			$this->template_settings
346
+		);
347
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
348
+			? $this->map_settings
349
+			: new EE_Map_Config();
350
+		$this->map_settings = apply_filters(
351
+			'FHEE__EE_Config___initialize_config__map_settings',
352
+			$this->map_settings
353
+		);
354
+		$this->environment = $this->environment instanceof EE_Environment_Config
355
+			? $this->environment
356
+			: new EE_Environment_Config();
357
+		$this->environment = apply_filters(
358
+			'FHEE__EE_Config___initialize_config__environment',
359
+			$this->environment
360
+		);
361
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
362
+			? $this->tax_settings
363
+			: new EE_Tax_Config();
364
+		$this->tax_settings = apply_filters(
365
+			'FHEE__EE_Config___initialize_config__tax_settings',
366
+			$this->tax_settings
367
+		);
368
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
369
+		$this->messages = $this->messages instanceof EE_Messages_Config
370
+			? $this->messages
371
+			: new EE_Messages_Config();
372
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
373
+			? $this->gateway
374
+			: new EE_Gateway_Config();
375
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
376
+		$this->legacy_shortcodes_manager = null;
377
+	}
378
+
379
+
380
+	/**
381
+	 *    get_espresso_config
382
+	 *
383
+	 * @access    public
384
+	 * @return    array of espresso config stuff
385
+	 */
386
+	public function get_espresso_config()
387
+	{
388
+		// grab espresso configuration
389
+		return apply_filters(
390
+			'FHEE__EE_Config__get_espresso_config__CFG',
391
+			get_option(EE_Config::OPTION_NAME, array())
392
+		);
393
+	}
394
+
395
+
396
+	/**
397
+	 *    double_check_config_comparison
398
+	 *
399
+	 * @access    public
400
+	 * @param string $option
401
+	 * @param        $old_value
402
+	 * @param        $value
403
+	 */
404
+	public function double_check_config_comparison($option = '', $old_value, $value)
405
+	{
406
+		// make sure we're checking the ee config
407
+		if ($option === EE_Config::OPTION_NAME) {
408
+			// run a loose comparison of the old value against the new value for type and properties,
409
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
410
+			if ($value != $old_value) {
411
+				// if they are NOT the same, then remove the hook,
412
+				// which means the subsequent update results will be based solely on the update query results
413
+				// the reason we do this is because, as stated above,
414
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
415
+				// this happens PRIOR to serialization and any subsequent update.
416
+				// If values are found to match their previous old value,
417
+				// then WP bails before performing any update.
418
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
419
+				// it just pulled from the db, with the one being passed to it (which will not match).
420
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
421
+				// MySQL MAY ALSO NOT perform the update because
422
+				// the string it sees in the db looks the same as the new one it has been passed!!!
423
+				// This results in the query returning an "affected rows" value of ZERO,
424
+				// which gets returned immediately by WP update_option and looks like an error.
425
+				remove_action('update_option', array($this, 'check_config_updated'));
426
+			}
427
+		}
428
+	}
429
+
430
+
431
+	/**
432
+	 *    update_espresso_config
433
+	 *
434
+	 * @access   public
435
+	 */
436
+	protected function _reset_espresso_addon_config()
437
+	{
438
+		$this->_addon_option_names = array();
439
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
440
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
441
+			if ($addon_config_obj instanceof EE_Config_Base) {
442
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
443
+			}
444
+			$this->addons->{$addon_name} = null;
445
+		}
446
+	}
447
+
448
+
449
+	/**
450
+	 *    update_espresso_config
451
+	 *
452
+	 * @access   public
453
+	 * @param   bool $add_success
454
+	 * @param   bool $add_error
455
+	 * @return   bool
456
+	 */
457
+	public function update_espresso_config($add_success = false, $add_error = true)
458
+	{
459
+		// don't allow config updates during WP heartbeats
460
+		/** @var RequestInterface $request */
461
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
462
+		if ($request->isWordPressHeartbeat()) {
463
+			return false;
464
+		}
465
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
466
+		// $clone = clone( self::$_instance );
467
+		// self::$_instance = NULL;
468
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
469
+		$this->_reset_espresso_addon_config();
470
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
471
+		// but BEFORE the actual update occurs
472
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
473
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
474
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
475
+		$this->legacy_shortcodes_manager = null;
476
+		// now update "ee_config"
477
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
478
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
479
+		EE_Config::log(EE_Config::OPTION_NAME);
480
+		// if not saved... check if the hook we just added still exists;
481
+		// if it does, it means one of two things:
482
+		// that update_option bailed at the($value === $old_value) conditional,
483
+		// or...
484
+		// the db update query returned 0 rows affected
485
+		// (probably because the data  value was the same from it's perspective)
486
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
487
+		// but just means no update occurred, so don't display an error to the user.
488
+		// BUT... if update_option returns FALSE, AND the hook is missing,
489
+		// then it means that something truly went wrong
490
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
491
+		// remove our action since we don't want it in the system anymore
492
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
493
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
494
+		// self::$_instance = $clone;
495
+		// unset( $clone );
496
+		// if config remains the same or was updated successfully
497
+		if ($saved) {
498
+			if ($add_success) {
499
+				EE_Error::add_success(
500
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
501
+					__FILE__,
502
+					__FUNCTION__,
503
+					__LINE__
504
+				);
505
+			}
506
+			return true;
507
+		} else {
508
+			if ($add_error) {
509
+				EE_Error::add_error(
510
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
511
+					__FILE__,
512
+					__FUNCTION__,
513
+					__LINE__
514
+				);
515
+			}
516
+			return false;
517
+		}
518
+	}
519
+
520
+
521
+	/**
522
+	 *    _verify_config_params
523
+	 *
524
+	 * @access    private
525
+	 * @param    string         $section
526
+	 * @param    string         $name
527
+	 * @param    string         $config_class
528
+	 * @param    EE_Config_Base $config_obj
529
+	 * @param    array          $tests_to_run
530
+	 * @param    bool           $display_errors
531
+	 * @return    bool    TRUE on success, FALSE on fail
532
+	 */
533
+	private function _verify_config_params(
534
+		$section = '',
535
+		$name = '',
536
+		$config_class = '',
537
+		$config_obj = null,
538
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
539
+		$display_errors = true
540
+	) {
541
+		try {
542
+			foreach ($tests_to_run as $test) {
543
+				switch ($test) {
544
+					// TEST #1 : check that section was set
545
+					case 1:
546
+						if (empty($section)) {
547
+							if ($display_errors) {
548
+								throw new EE_Error(
549
+									sprintf(
550
+										__(
551
+											'No configuration section has been provided while attempting to save "%s".',
552
+											'event_espresso'
553
+										),
554
+										$config_class
555
+									)
556
+								);
557
+							}
558
+							return false;
559
+						}
560
+						break;
561
+					// TEST #2 : check that settings section exists
562
+					case 2:
563
+						if (! isset($this->{$section})) {
564
+							if ($display_errors) {
565
+								throw new EE_Error(
566
+									sprintf(
567
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
568
+										$section
569
+									)
570
+								);
571
+							}
572
+							return false;
573
+						}
574
+						break;
575
+					// TEST #3 : check that section is the proper format
576
+					case 3:
577
+						if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
578
+						) {
579
+							if ($display_errors) {
580
+								throw new EE_Error(
581
+									sprintf(
582
+										__(
583
+											'The "%s" configuration settings have not been formatted correctly.',
584
+											'event_espresso'
585
+										),
586
+										$section
587
+									)
588
+								);
589
+							}
590
+							return false;
591
+						}
592
+						break;
593
+					// TEST #4 : check that config section name has been set
594
+					case 4:
595
+						if (empty($name)) {
596
+							if ($display_errors) {
597
+								throw new EE_Error(
598
+									__(
599
+										'No name has been provided for the specific configuration section.',
600
+										'event_espresso'
601
+									)
602
+								);
603
+							}
604
+							return false;
605
+						}
606
+						break;
607
+					// TEST #5 : check that a config class name has been set
608
+					case 5:
609
+						if (empty($config_class)) {
610
+							if ($display_errors) {
611
+								throw new EE_Error(
612
+									__(
613
+										'No class name has been provided for the specific configuration section.',
614
+										'event_espresso'
615
+									)
616
+								);
617
+							}
618
+							return false;
619
+						}
620
+						break;
621
+					// TEST #6 : verify config class is accessible
622
+					case 6:
623
+						if (! class_exists($config_class)) {
624
+							if ($display_errors) {
625
+								throw new EE_Error(
626
+									sprintf(
627
+										__(
628
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
629
+											'event_espresso'
630
+										),
631
+										$config_class
632
+									)
633
+								);
634
+							}
635
+							return false;
636
+						}
637
+						break;
638
+					// TEST #7 : check that config has even been set
639
+					case 7:
640
+						if (! isset($this->{$section}->{$name})) {
641
+							if ($display_errors) {
642
+								throw new EE_Error(
643
+									sprintf(
644
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
645
+										$section,
646
+										$name
647
+									)
648
+								);
649
+							}
650
+							return false;
651
+						} else {
652
+							// and make sure it's not serialized
653
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
654
+						}
655
+						break;
656
+					// TEST #8 : check that config is the requested type
657
+					case 8:
658
+						if (! $this->{$section}->{$name} instanceof $config_class) {
659
+							if ($display_errors) {
660
+								throw new EE_Error(
661
+									sprintf(
662
+										__(
663
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
664
+											'event_espresso'
665
+										),
666
+										$section,
667
+										$name,
668
+										$config_class
669
+									)
670
+								);
671
+							}
672
+							return false;
673
+						}
674
+						break;
675
+					// TEST #9 : verify config object
676
+					case 9:
677
+						if (! $config_obj instanceof EE_Config_Base) {
678
+							if ($display_errors) {
679
+								throw new EE_Error(
680
+									sprintf(
681
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
682
+										print_r($config_obj, true)
683
+									)
684
+								);
685
+							}
686
+							return false;
687
+						}
688
+						break;
689
+				}
690
+			}
691
+		} catch (EE_Error $e) {
692
+			$e->get_error();
693
+		}
694
+		// you have successfully run the gauntlet
695
+		return true;
696
+	}
697
+
698
+
699
+	/**
700
+	 *    _generate_config_option_name
701
+	 *
702
+	 * @access        protected
703
+	 * @param        string $section
704
+	 * @param        string $name
705
+	 * @return        string
706
+	 */
707
+	private function _generate_config_option_name($section = '', $name = '')
708
+	{
709
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
710
+	}
711
+
712
+
713
+	/**
714
+	 *    _set_config_class
715
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
716
+	 *
717
+	 * @access    private
718
+	 * @param    string $config_class
719
+	 * @param    string $name
720
+	 * @return    string
721
+	 */
722
+	private function _set_config_class($config_class = '', $name = '')
723
+	{
724
+		return ! empty($config_class)
725
+			? $config_class
726
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
727
+	}
728
+
729
+
730
+	/**
731
+	 *    set_config
732
+	 *
733
+	 * @access    protected
734
+	 * @param    string         $section
735
+	 * @param    string         $name
736
+	 * @param    string         $config_class
737
+	 * @param    EE_Config_Base $config_obj
738
+	 * @return    EE_Config_Base
739
+	 */
740
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
741
+	{
742
+		// ensure config class is set to something
743
+		$config_class = $this->_set_config_class($config_class, $name);
744
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
745
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
746
+			return null;
747
+		}
748
+		$config_option_name = $this->_generate_config_option_name($section, $name);
749
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
750
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
751
+			$this->_addon_option_names[ $config_option_name ] = $config_class;
752
+			$this->update_addon_option_names();
753
+		}
754
+		// verify the incoming config object but suppress errors
755
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
756
+			$config_obj = new $config_class();
757
+		}
758
+		if (get_option($config_option_name)) {
759
+			EE_Config::log($config_option_name);
760
+			update_option($config_option_name, $config_obj);
761
+			$this->{$section}->{$name} = $config_obj;
762
+			return $this->{$section}->{$name};
763
+		} else {
764
+			// create a wp-option for this config
765
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
766
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
767
+				return $this->{$section}->{$name};
768
+			} else {
769
+				EE_Error::add_error(
770
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
771
+					__FILE__,
772
+					__FUNCTION__,
773
+					__LINE__
774
+				);
775
+				return null;
776
+			}
777
+		}
778
+	}
779
+
780
+
781
+	/**
782
+	 *    update_config
783
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
784
+	 *
785
+	 * @access    public
786
+	 * @param    string                $section
787
+	 * @param    string                $name
788
+	 * @param    EE_Config_Base|string $config_obj
789
+	 * @param    bool                  $throw_errors
790
+	 * @return    bool
791
+	 */
792
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
793
+	{
794
+		// don't allow config updates during WP heartbeats
795
+		/** @var RequestInterface $request */
796
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
797
+		if ($request->isWordPressHeartbeat()) {
798
+			return false;
799
+		}
800
+		$config_obj = maybe_unserialize($config_obj);
801
+		// get class name of the incoming object
802
+		$config_class = get_class($config_obj);
803
+		// run tests 1-5 and 9 to verify config
804
+		if (! $this->_verify_config_params(
805
+			$section,
806
+			$name,
807
+			$config_class,
808
+			$config_obj,
809
+			array(1, 2, 3, 4, 7, 9)
810
+		)
811
+		) {
812
+			return false;
813
+		}
814
+		$config_option_name = $this->_generate_config_option_name($section, $name);
815
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
816
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
817
+			// save new config to db
818
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
819
+				return true;
820
+			}
821
+		} else {
822
+			// first check if the record already exists
823
+			$existing_config = get_option($config_option_name);
824
+			$config_obj = serialize($config_obj);
825
+			// just return if db record is already up to date (NOT type safe comparison)
826
+			if ($existing_config == $config_obj) {
827
+				$this->{$section}->{$name} = $config_obj;
828
+				return true;
829
+			} elseif (update_option($config_option_name, $config_obj)) {
830
+				EE_Config::log($config_option_name);
831
+				// update wp-option for this config class
832
+				$this->{$section}->{$name} = $config_obj;
833
+				return true;
834
+			} elseif ($throw_errors) {
835
+				EE_Error::add_error(
836
+					sprintf(
837
+						__(
838
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
839
+							'event_espresso'
840
+						),
841
+						$config_class,
842
+						'EE_Config->' . $section . '->' . $name
843
+					),
844
+					__FILE__,
845
+					__FUNCTION__,
846
+					__LINE__
847
+				);
848
+			}
849
+		}
850
+		return false;
851
+	}
852
+
853
+
854
+	/**
855
+	 *    get_config
856
+	 *
857
+	 * @access    public
858
+	 * @param    string $section
859
+	 * @param    string $name
860
+	 * @param    string $config_class
861
+	 * @return    mixed EE_Config_Base | NULL
862
+	 */
863
+	public function get_config($section = '', $name = '', $config_class = '')
864
+	{
865
+		// ensure config class is set to something
866
+		$config_class = $this->_set_config_class($config_class, $name);
867
+		// run tests 1-4, 6 and 7 to verify that all params have been set
868
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
869
+			return null;
870
+		}
871
+		// now test if the requested config object exists, but suppress errors
872
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
873
+			// config already exists, so pass it back
874
+			return $this->{$section}->{$name};
875
+		}
876
+		// load config option from db if it exists
877
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
878
+		// verify the newly retrieved config object, but suppress errors
879
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
880
+			// config is good, so set it and pass it back
881
+			$this->{$section}->{$name} = $config_obj;
882
+			return $this->{$section}->{$name};
883
+		}
884
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
885
+		$config_obj = $this->set_config($section, $name, $config_class);
886
+		// verify the newly created config object
887
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
888
+			return $this->{$section}->{$name};
889
+		} else {
890
+			EE_Error::add_error(
891
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
892
+				__FILE__,
893
+				__FUNCTION__,
894
+				__LINE__
895
+			);
896
+		}
897
+		return null;
898
+	}
899
+
900
+
901
+	/**
902
+	 *    get_config_option
903
+	 *
904
+	 * @access    public
905
+	 * @param    string $config_option_name
906
+	 * @return    mixed EE_Config_Base | FALSE
907
+	 */
908
+	public function get_config_option($config_option_name = '')
909
+	{
910
+		// retrieve the wp-option for this config class.
911
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
912
+		if (empty($config_option)) {
913
+			EE_Config::log($config_option_name . '-NOT-FOUND');
914
+		}
915
+		return $config_option;
916
+	}
917
+
918
+
919
+	/**
920
+	 * log
921
+	 *
922
+	 * @param string $config_option_name
923
+	 */
924
+	public static function log($config_option_name = '')
925
+	{
926
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
927
+			$config_log = get_option(EE_Config::LOG_NAME, array());
928
+			/** @var RequestParams $request */
929
+			$request = LoaderFactory::getLoader()->getShared(RequestParams::class);
930
+			$config_log[ (string) microtime(true) ] = array(
931
+				'config_name' => $config_option_name,
932
+				'request'     => $request->requestParams(),
933
+			);
934
+			update_option(EE_Config::LOG_NAME, $config_log);
935
+		}
936
+	}
937
+
938
+
939
+	/**
940
+	 * trim_log
941
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
942
+	 */
943
+	public static function trim_log()
944
+	{
945
+		if (! EE_Config::logging_enabled()) {
946
+			return;
947
+		}
948
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
949
+		$log_length = count($config_log);
950
+		if ($log_length > EE_Config::LOG_LENGTH) {
951
+			ksort($config_log);
952
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
953
+			update_option(EE_Config::LOG_NAME, $config_log);
954
+		}
955
+	}
956
+
957
+
958
+	/**
959
+	 *    get_page_for_posts
960
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
961
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
962
+	 *
963
+	 * @access    public
964
+	 * @return    string
965
+	 */
966
+	public static function get_page_for_posts()
967
+	{
968
+		$page_for_posts = get_option('page_for_posts');
969
+		if (! $page_for_posts) {
970
+			return 'posts';
971
+		}
972
+		global $wpdb;
973
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
974
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
975
+	}
976
+
977
+
978
+	/**
979
+	 *    register_shortcodes_and_modules.
980
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
981
+	 *    In fact, this is where we give modules a chance to let core know they exist
982
+	 *    so they can help trigger maintenance mode if it's needed
983
+	 *
984
+	 * @access    public
985
+	 * @return    void
986
+	 */
987
+	public function register_shortcodes_and_modules()
988
+	{
989
+		// allow modules to set hooks for the rest of the system
990
+		EE_Registry::instance()->modules = $this->_register_modules();
991
+	}
992
+
993
+
994
+	/**
995
+	 *    initialize_shortcodes_and_modules
996
+	 *    meaning they can start adding their hooks to get stuff done
997
+	 *
998
+	 * @access    public
999
+	 * @return    void
1000
+	 */
1001
+	public function initialize_shortcodes_and_modules()
1002
+	{
1003
+		// allow modules to set hooks for the rest of the system
1004
+		$this->_initialize_modules();
1005
+	}
1006
+
1007
+
1008
+	/**
1009
+	 *    widgets_init
1010
+	 *
1011
+	 * @access private
1012
+	 * @return void
1013
+	 */
1014
+	public function widgets_init()
1015
+	{
1016
+		// only init widgets on admin pages when not in complete maintenance, and
1017
+		// on frontend when not in any maintenance mode
1018
+		if (! EE_Maintenance_Mode::instance()->level()
1019
+			|| (
1020
+				is_admin()
1021
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1022
+			)
1023
+		) {
1024
+			// grab list of installed widgets
1025
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1026
+			// filter list of modules to register
1027
+			$widgets_to_register = apply_filters(
1028
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1029
+				$widgets_to_register
1030
+			);
1031
+			if (! empty($widgets_to_register)) {
1032
+				// cycle thru widget folders
1033
+				foreach ($widgets_to_register as $widget_path) {
1034
+					// add to list of installed widget modules
1035
+					EE_Config::register_ee_widget($widget_path);
1036
+				}
1037
+			}
1038
+			// filter list of installed modules
1039
+			EE_Registry::instance()->widgets = apply_filters(
1040
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1041
+				EE_Registry::instance()->widgets
1042
+			);
1043
+		}
1044
+	}
1045
+
1046
+
1047
+	/**
1048
+	 *    register_ee_widget - makes core aware of this widget
1049
+	 *
1050
+	 * @access    public
1051
+	 * @param    string $widget_path - full path up to and including widget folder
1052
+	 * @return    void
1053
+	 */
1054
+	public static function register_ee_widget($widget_path = null)
1055
+	{
1056
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1057
+		$widget_ext = '.widget.php';
1058
+		// make all separators match
1059
+		$widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1060
+		// does the file path INCLUDE the actual file name as part of the path ?
1061
+		if (strpos($widget_path, $widget_ext) !== false) {
1062
+			// grab and shortcode file name from directory name and break apart at dots
1063
+			$file_name = explode('.', basename($widget_path));
1064
+			// take first segment from file name pieces and remove class prefix if it exists
1065
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1066
+			// sanitize shortcode directory name
1067
+			$widget = sanitize_key($widget);
1068
+			// now we need to rebuild the shortcode path
1069
+			$widget_path = explode('/', $widget_path);
1070
+			// remove last segment
1071
+			array_pop($widget_path);
1072
+			// glue it back together
1073
+			$widget_path = implode(DS, $widget_path);
1074
+		} else {
1075
+			// grab and sanitize widget directory name
1076
+			$widget = sanitize_key(basename($widget_path));
1077
+		}
1078
+		// create classname from widget directory name
1079
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1080
+		// add class prefix
1081
+		$widget_class = 'EEW_' . $widget;
1082
+		// does the widget exist ?
1083
+		if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1084
+			$msg = sprintf(
1085
+				__(
1086
+					'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',
1087
+					'event_espresso'
1088
+				),
1089
+				$widget_class,
1090
+				$widget_path . '/' . $widget_class . $widget_ext
1091
+			);
1092
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1093
+			return;
1094
+		}
1095
+		// load the widget class file
1096
+		require_once($widget_path . '/' . $widget_class . $widget_ext);
1097
+		// verify that class exists
1098
+		if (! class_exists($widget_class)) {
1099
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1100
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1101
+			return;
1102
+		}
1103
+		register_widget($widget_class);
1104
+		// add to array of registered widgets
1105
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1106
+	}
1107
+
1108
+
1109
+	/**
1110
+	 *        _register_modules
1111
+	 *
1112
+	 * @access private
1113
+	 * @return array
1114
+	 */
1115
+	private function _register_modules()
1116
+	{
1117
+		// grab list of installed modules
1118
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1119
+		// filter list of modules to register
1120
+		$modules_to_register = apply_filters(
1121
+			'FHEE__EE_Config__register_modules__modules_to_register',
1122
+			$modules_to_register
1123
+		);
1124
+		if (! empty($modules_to_register)) {
1125
+			// loop through folders
1126
+			foreach ($modules_to_register as $module_path) {
1127
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1128
+				if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1129
+					&& $module_path !== EE_MODULES . 'gateways'
1130
+				) {
1131
+					// add to list of installed modules
1132
+					EE_Config::register_module($module_path);
1133
+				}
1134
+			}
1135
+		}
1136
+		// filter list of installed modules
1137
+		return apply_filters(
1138
+			'FHEE__EE_Config___register_modules__installed_modules',
1139
+			EE_Registry::instance()->modules
1140
+		);
1141
+	}
1142
+
1143
+
1144
+	/**
1145
+	 *    register_module - makes core aware of this module
1146
+	 *
1147
+	 * @access    public
1148
+	 * @param    string $module_path - full path up to and including module folder
1149
+	 * @return    bool
1150
+	 */
1151
+	public static function register_module($module_path = null)
1152
+	{
1153
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1154
+		$module_ext = '.module.php';
1155
+		// make all separators match
1156
+		$module_path = str_replace(array('\\', '/'), '/', $module_path);
1157
+		// does the file path INCLUDE the actual file name as part of the path ?
1158
+		if (strpos($module_path, $module_ext) !== false) {
1159
+			// grab and shortcode file name from directory name and break apart at dots
1160
+			$module_file = explode('.', basename($module_path));
1161
+			// now we need to rebuild the shortcode path
1162
+			$module_path = explode('/', $module_path);
1163
+			// remove last segment
1164
+			array_pop($module_path);
1165
+			// glue it back together
1166
+			$module_path = implode('/', $module_path) . '/';
1167
+			// take first segment from file name pieces and sanitize it
1168
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1169
+			// ensure class prefix is added
1170
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1171
+		} else {
1172
+			// we need to generate the filename based off of the folder name
1173
+			// grab and sanitize module name
1174
+			$module = strtolower(basename($module_path));
1175
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1176
+			// like trailingslashit()
1177
+			$module_path = rtrim($module_path, '/') . '/';
1178
+			// create classname from module directory name
1179
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1180
+			// add class prefix
1181
+			$module_class = 'EED_' . $module;
1182
+		}
1183
+		// does the module exist ?
1184
+		if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1185
+			$msg = sprintf(
1186
+				__(
1187
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1188
+					'event_espresso'
1189
+				),
1190
+				$module
1191
+			);
1192
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1193
+			return false;
1194
+		}
1195
+		// load the module class file
1196
+		require_once($module_path . $module_class . $module_ext);
1197
+		// verify that class exists
1198
+		if (! class_exists($module_class)) {
1199
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1200
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1201
+			return false;
1202
+		}
1203
+		// add to array of registered modules
1204
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1205
+		do_action(
1206
+			'AHEE__EE_Config__register_module__complete',
1207
+			$module_class,
1208
+			EE_Registry::instance()->modules->{$module_class}
1209
+		);
1210
+		return true;
1211
+	}
1212
+
1213
+
1214
+	/**
1215
+	 *    _initialize_modules
1216
+	 *    allow modules to set hooks for the rest of the system
1217
+	 *
1218
+	 * @access private
1219
+	 * @return void
1220
+	 */
1221
+	private function _initialize_modules()
1222
+	{
1223
+		// cycle thru shortcode folders
1224
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1225
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1226
+			// which set hooks ?
1227
+			if (is_admin()) {
1228
+				// fire immediately
1229
+				call_user_func(array($module_class, 'set_hooks_admin'));
1230
+			} else {
1231
+				// delay until other systems are online
1232
+				add_action(
1233
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1234
+					array($module_class, 'set_hooks')
1235
+				);
1236
+			}
1237
+		}
1238
+	}
1239
+
1240
+
1241
+	/**
1242
+	 *    register_route - adds module method routes to route_map
1243
+	 *
1244
+	 * @access    public
1245
+	 * @param    string $route       - "pretty" public alias for module method
1246
+	 * @param    string $module      - module name (classname without EED_ prefix)
1247
+	 * @param    string $method_name - the actual module method to be routed to
1248
+	 * @param    string $key         - url param key indicating a route is being called
1249
+	 * @return    bool
1250
+	 */
1251
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1252
+	{
1253
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1254
+		$module = str_replace('EED_', '', $module);
1255
+		$module_class = 'EED_' . $module;
1256
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1257
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1258
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1259
+			return false;
1260
+		}
1261
+		if (empty($route)) {
1262
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1263
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1264
+			return false;
1265
+		}
1266
+		if (! method_exists('EED_' . $module, $method_name)) {
1267
+			$msg = sprintf(
1268
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1269
+				$route
1270
+			);
1271
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1272
+			return false;
1273
+		}
1274
+		EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1275
+		return true;
1276
+	}
1277
+
1278
+
1279
+	/**
1280
+	 *    get_route - get module method route
1281
+	 *
1282
+	 * @access    public
1283
+	 * @param    string $route - "pretty" public alias for module method
1284
+	 * @param    string $key   - url param key indicating a route is being called
1285
+	 * @return    string
1286
+	 */
1287
+	public static function get_route($route = null, $key = 'ee')
1288
+	{
1289
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1290
+		$route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1291
+		if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1292
+			return EE_Config::$_module_route_map[ $key ][ $route ];
1293
+		}
1294
+		return null;
1295
+	}
1296
+
1297
+
1298
+	/**
1299
+	 *    get_routes - get ALL module method routes
1300
+	 *
1301
+	 * @access    public
1302
+	 * @return    array
1303
+	 */
1304
+	public static function get_routes()
1305
+	{
1306
+		return EE_Config::$_module_route_map;
1307
+	}
1308
+
1309
+
1310
+	/**
1311
+	 *    register_forward - allows modules to forward request to another module for further processing
1312
+	 *
1313
+	 * @access    public
1314
+	 * @param    string       $route   - "pretty" public alias for module method
1315
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1316
+	 *                                 class, allows different forwards to be served based on status
1317
+	 * @param    array|string $forward - function name or array( class, method )
1318
+	 * @param    string       $key     - url param key indicating a route is being called
1319
+	 * @return    bool
1320
+	 */
1321
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1322
+	{
1323
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1324
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1325
+			$msg = sprintf(
1326
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1327
+				$route
1328
+			);
1329
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1330
+			return false;
1331
+		}
1332
+		if (empty($forward)) {
1333
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1334
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1335
+			return false;
1336
+		}
1337
+		if (is_array($forward)) {
1338
+			if (! isset($forward[1])) {
1339
+				$msg = sprintf(
1340
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1341
+					$route
1342
+				);
1343
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1344
+				return false;
1345
+			}
1346
+			if (! method_exists($forward[0], $forward[1])) {
1347
+				$msg = sprintf(
1348
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1349
+					$forward[1],
1350
+					$route
1351
+				);
1352
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1353
+				return false;
1354
+			}
1355
+		} elseif (! function_exists($forward)) {
1356
+			$msg = sprintf(
1357
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1358
+				$forward,
1359
+				$route
1360
+			);
1361
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1362
+			return false;
1363
+		}
1364
+		EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1365
+		return true;
1366
+	}
1367
+
1368
+
1369
+	/**
1370
+	 *    get_forward - get forwarding route
1371
+	 *
1372
+	 * @access    public
1373
+	 * @param    string  $route  - "pretty" public alias for module method
1374
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1375
+	 *                           allows different forwards to be served based on status
1376
+	 * @param    string  $key    - url param key indicating a route is being called
1377
+	 * @return    string
1378
+	 */
1379
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1380
+	{
1381
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1382
+		if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1383
+			return apply_filters(
1384
+				'FHEE__EE_Config__get_forward',
1385
+				EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1386
+				$route,
1387
+				$status
1388
+			);
1389
+		}
1390
+		return null;
1391
+	}
1392
+
1393
+
1394
+	/**
1395
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1396
+	 *    results
1397
+	 *
1398
+	 * @access    public
1399
+	 * @param    string  $route  - "pretty" public alias for module method
1400
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1401
+	 *                           allows different views to be served based on status
1402
+	 * @param    string  $view
1403
+	 * @param    string  $key    - url param key indicating a route is being called
1404
+	 * @return    bool
1405
+	 */
1406
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1407
+	{
1408
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1409
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1410
+			$msg = sprintf(
1411
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1412
+				$route
1413
+			);
1414
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1415
+			return false;
1416
+		}
1417
+		if (! is_readable($view)) {
1418
+			$msg = sprintf(
1419
+				__(
1420
+					'The %s view file could not be found or is not readable due to file permissions.',
1421
+					'event_espresso'
1422
+				),
1423
+				$view
1424
+			);
1425
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1426
+			return false;
1427
+		}
1428
+		EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1429
+		return true;
1430
+	}
1431
+
1432
+
1433
+	/**
1434
+	 *    get_view - get view for route and status
1435
+	 *
1436
+	 * @access    public
1437
+	 * @param    string  $route  - "pretty" public alias for module method
1438
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1439
+	 *                           allows different views to be served based on status
1440
+	 * @param    string  $key    - url param key indicating a route is being called
1441
+	 * @return    string
1442
+	 */
1443
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1444
+	{
1445
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1446
+		if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1447
+			return apply_filters(
1448
+				'FHEE__EE_Config__get_view',
1449
+				EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1450
+				$route,
1451
+				$status
1452
+			);
1453
+		}
1454
+		return null;
1455
+	}
1456
+
1457
+
1458
+	public function update_addon_option_names()
1459
+	{
1460
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1461
+	}
1462
+
1463
+
1464
+	public function shutdown()
1465
+	{
1466
+		$this->update_addon_option_names();
1467
+	}
1468
+
1469
+
1470
+	/**
1471
+	 * @return LegacyShortcodesManager
1472
+	 */
1473
+	public static function getLegacyShortcodesManager()
1474
+	{
1475
+		if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1476
+			EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1477
+				LegacyShortcodesManager::class
1478
+			);
1479
+		}
1480
+		return EE_Config::instance()->legacy_shortcodes_manager;
1481
+	}
1482
+
1483
+
1484
+	/**
1485
+	 * register_shortcode - makes core aware of this shortcode
1486
+	 *
1487
+	 * @deprecated 4.9.26
1488
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1489
+	 * @return    bool
1490
+	 */
1491
+	public static function register_shortcode($shortcode_path = null)
1492
+	{
1493
+		EE_Error::doing_it_wrong(
1494
+			__METHOD__,
1495
+			__(
1496
+				'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.',
1497
+				'event_espresso'
1498
+			),
1499
+			'4.9.26'
1500
+		);
1501
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1502
+	}
1503
+}
2265 1504
 
2266
-    /**
2267
-     * ReCaptcha Type
2268
-     *
2269
-     * @var string $recaptcha_type
2270
-     *    options: 'audio', 'image'
2271
-     */
2272
-    public $recaptcha_type;
1505
+/**
1506
+ * Base class used for config classes. These classes should generally not have
1507
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1508
+ * basically, they should just be well-defined stdClasses
1509
+ */
1510
+class EE_Config_Base
1511
+{
2273 1512
 
2274
-    /**
2275
-     * ReCaptcha language
2276
-     *
2277
-     * @var string $recaptcha_language
2278
-     * eg 'en'
2279
-     */
2280
-    public $recaptcha_language;
1513
+	/**
1514
+	 * Utility function for escaping the value of a property and returning.
1515
+	 *
1516
+	 * @param string $property property name (checks to see if exists).
1517
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1518
+	 * @throws \EE_Error
1519
+	 */
1520
+	public function get_pretty($property)
1521
+	{
1522
+		if (! property_exists($this, $property)) {
1523
+			throw new EE_Error(
1524
+				sprintf(
1525
+					__(
1526
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1527
+						'event_espresso'
1528
+					),
1529
+					get_class($this),
1530
+					$property
1531
+				)
1532
+			);
1533
+		}
1534
+		// just handling escaping of strings for now.
1535
+		if (is_string($this->{$property})) {
1536
+			return stripslashes($this->{$property});
1537
+		}
1538
+		return $this->{$property};
1539
+	}
1540
+
1541
+
1542
+	public function populate()
1543
+	{
1544
+		// grab defaults via a new instance of this class.
1545
+		$class_name = get_class($this);
1546
+		$defaults = new $class_name;
1547
+		// loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1548
+		// default from our $defaults object.
1549
+		foreach (get_object_vars($defaults) as $property => $value) {
1550
+			if ($this->{$property} === null) {
1551
+				$this->{$property} = $value;
1552
+			}
1553
+		}
1554
+		// cleanup
1555
+		unset($defaults);
1556
+	}
1557
+
1558
+
1559
+	/**
1560
+	 *        __isset
1561
+	 *
1562
+	 * @param $a
1563
+	 * @return bool
1564
+	 */
1565
+	public function __isset($a)
1566
+	{
1567
+		return false;
1568
+	}
1569
+
1570
+
1571
+	/**
1572
+	 *        __unset
1573
+	 *
1574
+	 * @param $a
1575
+	 * @return bool
1576
+	 */
1577
+	public function __unset($a)
1578
+	{
1579
+		return false;
1580
+	}
1581
+
1582
+
1583
+	/**
1584
+	 *        __clone
1585
+	 */
1586
+	public function __clone()
1587
+	{
1588
+	}
1589
+
1590
+
1591
+	/**
1592
+	 *        __wakeup
1593
+	 */
1594
+	public function __wakeup()
1595
+	{
1596
+	}
1597
+
1598
+
1599
+	/**
1600
+	 *        __destruct
1601
+	 */
1602
+	public function __destruct()
1603
+	{
1604
+	}
1605
+}
2281 1606
 
2282
-    /**
2283
-     * ReCaptcha public key
2284
-     *
2285
-     * @var string $recaptcha_publickey
2286
-     */
2287
-    public $recaptcha_publickey;
1607
+/**
1608
+ * Class for defining what's in the EE_Config relating to registration settings
1609
+ */
1610
+class EE_Core_Config extends EE_Config_Base
1611
+{
2288 1612
 
2289
-    /**
2290
-     * ReCaptcha private key
2291
-     *
2292
-     * @var string $recaptcha_privatekey
2293
-     */
2294
-    public $recaptcha_privatekey;
1613
+	const OPTION_NAME_UXIP = 'ee_ueip_optin';
1614
+
1615
+
1616
+	public $current_blog_id;
1617
+
1618
+	public $ee_ueip_optin;
1619
+
1620
+	public $ee_ueip_has_notified;
1621
+
1622
+	/**
1623
+	 * Not to be confused with the 4 critical page variables (See
1624
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1625
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1626
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1627
+	 *
1628
+	 * @var array
1629
+	 */
1630
+	public $post_shortcodes;
1631
+
1632
+	public $module_route_map;
1633
+
1634
+	public $module_forward_map;
1635
+
1636
+	public $module_view_map;
1637
+
1638
+	/**
1639
+	 * The next 4 vars are the IDs of critical EE pages.
1640
+	 *
1641
+	 * @var int
1642
+	 */
1643
+	public $reg_page_id;
1644
+
1645
+	public $txn_page_id;
1646
+
1647
+	public $thank_you_page_id;
1648
+
1649
+	public $cancel_page_id;
1650
+
1651
+	/**
1652
+	 * The next 4 vars are the URLs of critical EE pages.
1653
+	 *
1654
+	 * @var int
1655
+	 */
1656
+	public $reg_page_url;
1657
+
1658
+	public $txn_page_url;
1659
+
1660
+	public $thank_you_page_url;
1661
+
1662
+	public $cancel_page_url;
1663
+
1664
+	/**
1665
+	 * The next vars relate to the custom slugs for EE CPT routes
1666
+	 */
1667
+	public $event_cpt_slug;
1668
+
1669
+	/**
1670
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1671
+	 * request across blog switches in a multisite context.
1672
+	 * Avoids extra queries to the db for this option.
1673
+	 *
1674
+	 * @var bool
1675
+	 */
1676
+	public static $ee_ueip_option;
1677
+
1678
+
1679
+	/**
1680
+	 *    class constructor
1681
+	 *
1682
+	 * @access    public
1683
+	 */
1684
+	public function __construct()
1685
+	{
1686
+		// set default organization settings
1687
+		$this->current_blog_id = get_current_blog_id();
1688
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1689
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1690
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1691
+		$this->post_shortcodes = array();
1692
+		$this->module_route_map = array();
1693
+		$this->module_forward_map = array();
1694
+		$this->module_view_map = array();
1695
+		// critical EE page IDs
1696
+		$this->reg_page_id = 0;
1697
+		$this->txn_page_id = 0;
1698
+		$this->thank_you_page_id = 0;
1699
+		$this->cancel_page_id = 0;
1700
+		// critical EE page URLs
1701
+		$this->reg_page_url = '';
1702
+		$this->txn_page_url = '';
1703
+		$this->thank_you_page_url = '';
1704
+		$this->cancel_page_url = '';
1705
+		// cpt slugs
1706
+		$this->event_cpt_slug = __('events', 'event_espresso');
1707
+		// ueip constant check
1708
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1709
+			$this->ee_ueip_optin = false;
1710
+			$this->ee_ueip_has_notified = true;
1711
+		}
1712
+	}
1713
+
1714
+
1715
+	/**
1716
+	 * @return array
1717
+	 */
1718
+	public function get_critical_pages_array()
1719
+	{
1720
+		return array(
1721
+			$this->reg_page_id,
1722
+			$this->txn_page_id,
1723
+			$this->thank_you_page_id,
1724
+			$this->cancel_page_id,
1725
+		);
1726
+	}
1727
+
1728
+
1729
+	/**
1730
+	 * @return array
1731
+	 */
1732
+	public function get_critical_pages_shortcodes_array()
1733
+	{
1734
+		return array(
1735
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1736
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1737
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1738
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1739
+		);
1740
+	}
1741
+
1742
+
1743
+	/**
1744
+	 *  gets/returns URL for EE reg_page
1745
+	 *
1746
+	 * @access    public
1747
+	 * @return    string
1748
+	 */
1749
+	public function reg_page_url()
1750
+	{
1751
+		if (! $this->reg_page_url) {
1752
+			$this->reg_page_url = add_query_arg(
1753
+				array('uts' => time()),
1754
+				get_permalink($this->reg_page_id)
1755
+			) . '#checkout';
1756
+		}
1757
+		return $this->reg_page_url;
1758
+	}
1759
+
1760
+
1761
+	/**
1762
+	 *  gets/returns URL for EE txn_page
1763
+	 *
1764
+	 * @param array $query_args like what gets passed to
1765
+	 *                          add_query_arg() as the first argument
1766
+	 * @access    public
1767
+	 * @return    string
1768
+	 */
1769
+	public function txn_page_url($query_args = array())
1770
+	{
1771
+		if (! $this->txn_page_url) {
1772
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1773
+		}
1774
+		if ($query_args) {
1775
+			return add_query_arg($query_args, $this->txn_page_url);
1776
+		} else {
1777
+			return $this->txn_page_url;
1778
+		}
1779
+	}
1780
+
1781
+
1782
+	/**
1783
+	 *  gets/returns URL for EE thank_you_page
1784
+	 *
1785
+	 * @param array $query_args like what gets passed to
1786
+	 *                          add_query_arg() as the first argument
1787
+	 * @access    public
1788
+	 * @return    string
1789
+	 */
1790
+	public function thank_you_page_url($query_args = array())
1791
+	{
1792
+		if (! $this->thank_you_page_url) {
1793
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1794
+		}
1795
+		if ($query_args) {
1796
+			return add_query_arg($query_args, $this->thank_you_page_url);
1797
+		} else {
1798
+			return $this->thank_you_page_url;
1799
+		}
1800
+	}
1801
+
1802
+
1803
+	/**
1804
+	 *  gets/returns URL for EE cancel_page
1805
+	 *
1806
+	 * @access    public
1807
+	 * @return    string
1808
+	 */
1809
+	public function cancel_page_url()
1810
+	{
1811
+		if (! $this->cancel_page_url) {
1812
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1813
+		}
1814
+		return $this->cancel_page_url;
1815
+	}
1816
+
1817
+
1818
+	/**
1819
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1820
+	 *
1821
+	 * @since 4.7.5
1822
+	 */
1823
+	protected function _reset_urls()
1824
+	{
1825
+		$this->reg_page_url = '';
1826
+		$this->txn_page_url = '';
1827
+		$this->cancel_page_url = '';
1828
+		$this->thank_you_page_url = '';
1829
+	}
1830
+
1831
+
1832
+	/**
1833
+	 * Used to return what the optin value is set for the EE User Experience Program.
1834
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1835
+	 * on the main site only.
1836
+	 *
1837
+	 * @return bool
1838
+	 */
1839
+	protected function _get_main_ee_ueip_optin()
1840
+	{
1841
+		// if this is the main site then we can just bypass our direct query.
1842
+		if (is_main_site()) {
1843
+			return get_option(self::OPTION_NAME_UXIP, false);
1844
+		}
1845
+		// is this already cached for this request?  If so use it.
1846
+		if (EE_Core_Config::$ee_ueip_option !== null) {
1847
+			return EE_Core_Config::$ee_ueip_option;
1848
+		}
1849
+		global $wpdb;
1850
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1851
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1852
+		$option = self::OPTION_NAME_UXIP;
1853
+		// set correct table for query
1854
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1855
+		// rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1856
+		// get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1857
+		// re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1858
+		// this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1859
+		// for the purpose of caching.
1860
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1861
+		if (false !== $pre) {
1862
+			EE_Core_Config::$ee_ueip_option = $pre;
1863
+			return EE_Core_Config::$ee_ueip_option;
1864
+		}
1865
+		$row = $wpdb->get_row(
1866
+			$wpdb->prepare(
1867
+				"SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1868
+				$option
1869
+			)
1870
+		);
1871
+		if (is_object($row)) {
1872
+			$value = $row->option_value;
1873
+		} else { // option does not exist so use default.
1874
+			EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1875
+			return EE_Core_Config::$ee_ueip_option;
1876
+		}
1877
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1878
+		return EE_Core_Config::$ee_ueip_option;
1879
+	}
1880
+
1881
+
1882
+	/**
1883
+	 * Utility function for escaping the value of a property and returning.
1884
+	 *
1885
+	 * @param string $property property name (checks to see if exists).
1886
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1887
+	 * @throws \EE_Error
1888
+	 */
1889
+	public function get_pretty($property)
1890
+	{
1891
+		if ($property === self::OPTION_NAME_UXIP) {
1892
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1893
+		}
1894
+		return parent::get_pretty($property);
1895
+	}
1896
+
1897
+
1898
+	/**
1899
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1900
+	 * on the object.
1901
+	 *
1902
+	 * @return array
1903
+	 */
1904
+	public function __sleep()
1905
+	{
1906
+		// reset all url properties
1907
+		$this->_reset_urls();
1908
+		// return what to save to db
1909
+		return array_keys(get_object_vars($this));
1910
+	}
1911
+}
2295 1912
 
2296
-    /**
2297
-     * array of form names protected by ReCaptcha
2298
-     *
2299
-     * @var array $recaptcha_protected_forms
2300
-     */
2301
-    public $recaptcha_protected_forms;
1913
+/**
1914
+ * Config class for storing info on the Organization
1915
+ */
1916
+class EE_Organization_Config extends EE_Config_Base
1917
+{
2302 1918
 
2303
-    /**
2304
-     * ReCaptcha width
2305
-     *
2306
-     * @var int $recaptcha_width
2307
-     * @deprecated
2308
-     */
2309
-    public $recaptcha_width;
1919
+	/**
1920
+	 * @var string $name
1921
+	 * eg EE4.1
1922
+	 */
1923
+	public $name;
1924
+
1925
+	/**
1926
+	 * @var string $address_1
1927
+	 * eg 123 Onna Road
1928
+	 */
1929
+	public $address_1 = '';
1930
+
1931
+	/**
1932
+	 * @var string $address_2
1933
+	 * eg PO Box 123
1934
+	 */
1935
+	public $address_2 = '';
1936
+
1937
+	/**
1938
+	 * @var string $city
1939
+	 * eg Inna City
1940
+	 */
1941
+	public $city = '';
1942
+
1943
+	/**
1944
+	 * @var int $STA_ID
1945
+	 * eg 4
1946
+	 */
1947
+	public $STA_ID = 0;
1948
+
1949
+	/**
1950
+	 * @var string $CNT_ISO
1951
+	 * eg US
1952
+	 */
1953
+	public $CNT_ISO = '';
1954
+
1955
+	/**
1956
+	 * @var string $zip
1957
+	 * eg 12345  or V1A 2B3
1958
+	 */
1959
+	public $zip = '';
1960
+
1961
+	/**
1962
+	 * @var string $email
1963
+	 * eg [email protected]
1964
+	 */
1965
+	public $email;
1966
+
1967
+	/**
1968
+	 * @var string $phone
1969
+	 * eg. 111-111-1111
1970
+	 */
1971
+	public $phone = '';
1972
+
1973
+	/**
1974
+	 * @var string $vat
1975
+	 * VAT/Tax Number
1976
+	 */
1977
+	public $vat = '';
1978
+
1979
+	/**
1980
+	 * @var string $logo_url
1981
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1982
+	 */
1983
+	public $logo_url = '';
1984
+
1985
+	/**
1986
+	 * The below are all various properties for holding links to organization social network profiles
1987
+	 *
1988
+	 * @var string
1989
+	 */
1990
+	/**
1991
+	 * facebook (facebook.com/profile.name)
1992
+	 *
1993
+	 * @var string
1994
+	 */
1995
+	public $facebook = '';
1996
+
1997
+	/**
1998
+	 * twitter (twitter.com/twitter_handle)
1999
+	 *
2000
+	 * @var string
2001
+	 */
2002
+	public $twitter = '';
2003
+
2004
+	/**
2005
+	 * linkedin (linkedin.com/in/profile_name)
2006
+	 *
2007
+	 * @var string
2008
+	 */
2009
+	public $linkedin = '';
2010
+
2011
+	/**
2012
+	 * pinterest (www.pinterest.com/profile_name)
2013
+	 *
2014
+	 * @var string
2015
+	 */
2016
+	public $pinterest = '';
2017
+
2018
+	/**
2019
+	 * google+ (google.com/+profileName)
2020
+	 *
2021
+	 * @var string
2022
+	 */
2023
+	public $google = '';
2024
+
2025
+	/**
2026
+	 * instagram (instagram.com/handle)
2027
+	 *
2028
+	 * @var string
2029
+	 */
2030
+	public $instagram = '';
2031
+
2032
+
2033
+	/**
2034
+	 *    class constructor
2035
+	 *
2036
+	 * @access    public
2037
+	 */
2038
+	public function __construct()
2039
+	{
2040
+		// set default organization settings
2041
+		// decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2042
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2043
+		$this->email = get_bloginfo('admin_email');
2044
+	}
2045
+}
2310 2046
 
2311
-    /**
2312
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2313
-     *
2314
-     * @var boolean $track_invalid_checkout_access
2315
-     */
2316
-    protected $track_invalid_checkout_access = true;
2047
+/**
2048
+ * Class for defining what's in the EE_Config relating to currency
2049
+ */
2050
+class EE_Currency_Config extends EE_Config_Base
2051
+{
2317 2052
 
2318
-    /**
2319
-     * Whether or not to show the privacy policy consent checkbox
2320
-     *
2321
-     * @var bool
2322
-     */
2323
-    public $consent_checkbox_enabled;
2053
+	/**
2054
+	 * @var string $code
2055
+	 * eg 'US'
2056
+	 */
2057
+	public $code;
2058
+
2059
+	/**
2060
+	 * @var string $name
2061
+	 * eg 'Dollar'
2062
+	 */
2063
+	public $name;
2064
+
2065
+	/**
2066
+	 * plural name
2067
+	 *
2068
+	 * @var string $plural
2069
+	 * eg 'Dollars'
2070
+	 */
2071
+	public $plural;
2072
+
2073
+	/**
2074
+	 * currency sign
2075
+	 *
2076
+	 * @var string $sign
2077
+	 * eg '$'
2078
+	 */
2079
+	public $sign;
2080
+
2081
+	/**
2082
+	 * Whether the currency sign should come before the number or not
2083
+	 *
2084
+	 * @var boolean $sign_b4
2085
+	 */
2086
+	public $sign_b4;
2087
+
2088
+	/**
2089
+	 * How many digits should come after the decimal place
2090
+	 *
2091
+	 * @var int $dec_plc
2092
+	 */
2093
+	public $dec_plc;
2094
+
2095
+	/**
2096
+	 * Symbol to use for decimal mark
2097
+	 *
2098
+	 * @var string $dec_mrk
2099
+	 * eg '.'
2100
+	 */
2101
+	public $dec_mrk;
2102
+
2103
+	/**
2104
+	 * Symbol to use for thousands
2105
+	 *
2106
+	 * @var string $thsnds
2107
+	 * eg ','
2108
+	 */
2109
+	public $thsnds;
2110
+
2111
+
2112
+	/**
2113
+	 *    class constructor
2114
+	 *
2115
+	 * @access    public
2116
+	 * @param string $CNT_ISO
2117
+	 * @throws \EE_Error
2118
+	 */
2119
+	public function __construct($CNT_ISO = '')
2120
+	{
2121
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2122
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2123
+		// get country code from organization settings or use default
2124
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2125
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2126
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2127
+			: '';
2128
+		// but override if requested
2129
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2130
+		// 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
2131
+		if (! empty($CNT_ISO)
2132
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2133
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2134
+		) {
2135
+			// retrieve the country settings from the db, just in case they have been customized
2136
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2137
+			if ($country instanceof EE_Country) {
2138
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2139
+				$this->name = $country->currency_name_single();    // Dollar
2140
+				$this->plural = $country->currency_name_plural();    // Dollars
2141
+				$this->sign = $country->currency_sign();            // currency sign: $
2142
+				$this->sign_b4 = $country->currency_sign_before(
2143
+				);        // currency sign before or after: $TRUE  or  FALSE$
2144
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2145
+				$this->dec_mrk = $country->currency_decimal_mark(
2146
+				);    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2147
+				$this->thsnds = $country->currency_thousands_separator(
2148
+				);    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2149
+			}
2150
+		}
2151
+		// fallback to hardcoded defaults, in case the above failed
2152
+		if (empty($this->code)) {
2153
+			// set default currency settings
2154
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2155
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2156
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2157
+			$this->sign = '$';    // currency sign: $
2158
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2159
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2160
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2161
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2162
+		}
2163
+	}
2164
+}
2324 2165
 
2325
-    /**
2326
-     * Label text to show on the checkbox
2327
-     *
2328
-     * @var string
2329
-     */
2330
-    public $consent_checkbox_label_text;
2166
+/**
2167
+ * Class for defining what's in the EE_Config relating to registration settings
2168
+ */
2169
+class EE_Registration_Config extends EE_Config_Base
2170
+{
2331 2171
 
2332
-    /*
2172
+	/**
2173
+	 * Default registration status
2174
+	 *
2175
+	 * @var string $default_STS_ID
2176
+	 * eg 'RPP'
2177
+	 */
2178
+	public $default_STS_ID;
2179
+
2180
+	/**
2181
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2182
+	 * registrations)
2183
+	 *
2184
+	 * @var int
2185
+	 */
2186
+	public $default_maximum_number_of_tickets;
2187
+
2188
+	/**
2189
+	 * level of validation to apply to email addresses
2190
+	 *
2191
+	 * @var string $email_validation_level
2192
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2193
+	 */
2194
+	public $email_validation_level;
2195
+
2196
+	/**
2197
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2198
+	 *
2199
+	 * @var boolean $show_pending_payment_options
2200
+	 */
2201
+	public $show_pending_payment_options;
2202
+
2203
+	/**
2204
+	 * Whether to skip the registration confirmation page
2205
+	 *
2206
+	 * @var boolean $skip_reg_confirmation
2207
+	 */
2208
+	public $skip_reg_confirmation;
2209
+
2210
+	/**
2211
+	 * an array of SPCO reg steps where:
2212
+	 *        the keys denotes the reg step order
2213
+	 *        each element consists of an array with the following elements:
2214
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2215
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2216
+	 *            "slug" => the URL param used to trigger the reg step
2217
+	 *
2218
+	 * @var array $reg_steps
2219
+	 */
2220
+	public $reg_steps;
2221
+
2222
+	/**
2223
+	 * Whether registration confirmation should be the last page of SPCO
2224
+	 *
2225
+	 * @var boolean $reg_confirmation_last
2226
+	 */
2227
+	public $reg_confirmation_last;
2228
+
2229
+	/**
2230
+	 * Whether or not to enable the EE Bot Trap
2231
+	 *
2232
+	 * @var boolean $use_bot_trap
2233
+	 */
2234
+	public $use_bot_trap;
2235
+
2236
+	/**
2237
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2238
+	 *
2239
+	 * @var boolean $use_encryption
2240
+	 */
2241
+	public $use_encryption;
2242
+
2243
+	/**
2244
+	 * Whether or not to use ReCaptcha
2245
+	 *
2246
+	 * @var boolean $use_captcha
2247
+	 */
2248
+	public $use_captcha;
2249
+
2250
+	/**
2251
+	 * ReCaptcha Theme
2252
+	 *
2253
+	 * @var string $recaptcha_theme
2254
+	 *    options: 'dark', 'light', 'invisible'
2255
+	 */
2256
+	public $recaptcha_theme;
2257
+
2258
+	/**
2259
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2260
+	 *
2261
+	 * @var string $recaptcha_badge
2262
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2263
+	 */
2264
+	public $recaptcha_badge;
2265
+
2266
+	/**
2267
+	 * ReCaptcha Type
2268
+	 *
2269
+	 * @var string $recaptcha_type
2270
+	 *    options: 'audio', 'image'
2271
+	 */
2272
+	public $recaptcha_type;
2273
+
2274
+	/**
2275
+	 * ReCaptcha language
2276
+	 *
2277
+	 * @var string $recaptcha_language
2278
+	 * eg 'en'
2279
+	 */
2280
+	public $recaptcha_language;
2281
+
2282
+	/**
2283
+	 * ReCaptcha public key
2284
+	 *
2285
+	 * @var string $recaptcha_publickey
2286
+	 */
2287
+	public $recaptcha_publickey;
2288
+
2289
+	/**
2290
+	 * ReCaptcha private key
2291
+	 *
2292
+	 * @var string $recaptcha_privatekey
2293
+	 */
2294
+	public $recaptcha_privatekey;
2295
+
2296
+	/**
2297
+	 * array of form names protected by ReCaptcha
2298
+	 *
2299
+	 * @var array $recaptcha_protected_forms
2300
+	 */
2301
+	public $recaptcha_protected_forms;
2302
+
2303
+	/**
2304
+	 * ReCaptcha width
2305
+	 *
2306
+	 * @var int $recaptcha_width
2307
+	 * @deprecated
2308
+	 */
2309
+	public $recaptcha_width;
2310
+
2311
+	/**
2312
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2313
+	 *
2314
+	 * @var boolean $track_invalid_checkout_access
2315
+	 */
2316
+	protected $track_invalid_checkout_access = true;
2317
+
2318
+	/**
2319
+	 * Whether or not to show the privacy policy consent checkbox
2320
+	 *
2321
+	 * @var bool
2322
+	 */
2323
+	public $consent_checkbox_enabled;
2324
+
2325
+	/**
2326
+	 * Label text to show on the checkbox
2327
+	 *
2328
+	 * @var string
2329
+	 */
2330
+	public $consent_checkbox_label_text;
2331
+
2332
+	/*
2333 2333
      * String describing how long to keep payment logs. Passed into DateTime constructor
2334 2334
      * @var string
2335 2335
      */
2336
-    public $gateway_log_lifespan = '1 week';
2337
-
2338
-    /**
2339
-     * Enable copy attendee info at form
2340
-     *
2341
-     * @var boolean $enable_copy_attendee
2342
-     */
2343
-    protected $copy_attendee_info = true;
2344
-
2345
-
2346
-    /**
2347
-     *    class constructor
2348
-     *
2349
-     * @access    public
2350
-     */
2351
-    public function __construct()
2352
-    {
2353
-        // set default registration settings
2354
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2355
-        $this->email_validation_level = 'wp_default';
2356
-        $this->show_pending_payment_options = true;
2357
-        $this->skip_reg_confirmation = true;
2358
-        $this->reg_steps = array();
2359
-        $this->reg_confirmation_last = false;
2360
-        $this->use_bot_trap = true;
2361
-        $this->use_encryption = true;
2362
-        $this->use_captcha = false;
2363
-        $this->recaptcha_theme = 'light';
2364
-        $this->recaptcha_badge = 'bottomleft';
2365
-        $this->recaptcha_type = 'image';
2366
-        $this->recaptcha_language = 'en';
2367
-        $this->recaptcha_publickey = null;
2368
-        $this->recaptcha_privatekey = null;
2369
-        $this->recaptcha_protected_forms = array();
2370
-        $this->recaptcha_width = 500;
2371
-        $this->default_maximum_number_of_tickets = 10;
2372
-        $this->consent_checkbox_enabled = false;
2373
-        $this->consent_checkbox_label_text = '';
2374
-        $this->gateway_log_lifespan = '7 days';
2375
-        $this->copy_attendee_info = true;
2376
-    }
2377
-
2378
-
2379
-    /**
2380
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2381
-     *
2382
-     * @since 4.8.8.rc.019
2383
-     */
2384
-    public function do_hooks()
2385
-    {
2386
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2387
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2388
-        add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2389
-    }
2390
-
2391
-
2392
-    /**
2393
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2394
-     * EVT_default_registration_status field matches the config setting for default_STS_ID.
2395
-     */
2396
-    public function set_default_reg_status_on_EEM_Event()
2397
-    {
2398
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2399
-    }
2400
-
2401
-
2402
-    /**
2403
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2404
-     * for Events matches the config setting for default_maximum_number_of_tickets
2405
-     */
2406
-    public function set_default_max_ticket_on_EEM_Event()
2407
-    {
2408
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2409
-    }
2410
-
2411
-
2412
-    /**
2413
-     * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2414
-     * constructed because that happens before we can get the privacy policy page's permalink.
2415
-     *
2416
-     * @throws InvalidArgumentException
2417
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2418
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2419
-     */
2420
-    public function setDefaultCheckboxLabelText()
2421
-    {
2422
-        if ($this->getConsentCheckboxLabelText() === null
2423
-            || $this->getConsentCheckboxLabelText() === '') {
2424
-            $opening_a_tag = '';
2425
-            $closing_a_tag = '';
2426
-            if (function_exists('get_privacy_policy_url')) {
2427
-                $privacy_page_url = get_privacy_policy_url();
2428
-                if (! empty($privacy_page_url)) {
2429
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2430
-                    $closing_a_tag = '</a>';
2431
-                }
2432
-            }
2433
-            $loader = LoaderFactory::getLoader();
2434
-            $org_config = $loader->getShared('EE_Organization_Config');
2435
-            /**
2436
-             * @var $org_config EE_Organization_Config
2437
-             */
2438
-
2439
-            $this->setConsentCheckboxLabelText(
2440
-                sprintf(
2441
-                    esc_html__(
2442
-                        'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2443
-                        'event_espresso'
2444
-                    ),
2445
-                    $org_config->name,
2446
-                    $opening_a_tag,
2447
-                    $closing_a_tag
2448
-                )
2449
-            );
2450
-        }
2451
-    }
2452
-
2453
-
2454
-    /**
2455
-     * @return boolean
2456
-     */
2457
-    public function track_invalid_checkout_access()
2458
-    {
2459
-        return $this->track_invalid_checkout_access;
2460
-    }
2461
-
2462
-
2463
-    /**
2464
-     * @param boolean $track_invalid_checkout_access
2465
-     */
2466
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2467
-    {
2468
-        $this->track_invalid_checkout_access = filter_var(
2469
-            $track_invalid_checkout_access,
2470
-            FILTER_VALIDATE_BOOLEAN
2471
-        );
2472
-    }
2473
-
2474
-    /**
2475
-     * @return boolean
2476
-     */
2477
-    public function copyAttendeeInfo()
2478
-    {
2479
-        return $this->copy_attendee_info;
2480
-    }
2481
-
2482
-
2483
-    /**
2484
-     * @param boolean $copy_attendee_info
2485
-     */
2486
-    public function setCopyAttendeeInfo($copy_attendee_info)
2487
-    {
2488
-        $this->copy_attendee_info = filter_var(
2489
-            $copy_attendee_info,
2490
-            FILTER_VALIDATE_BOOLEAN
2491
-        );
2492
-    }
2493
-
2494
-
2495
-    /**
2496
-     * Gets the options to make availalbe for the gateway log lifespan
2497
-     * @return array
2498
-     */
2499
-    public function gatewayLogLifespanOptions()
2500
-    {
2501
-        return (array) apply_filters(
2502
-            'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2503
-            array(
2504
-                '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2505
-                '1 day' => esc_html__('1 Day', 'event_espresso'),
2506
-                '7 days' => esc_html__('7 Days', 'event_espresso'),
2507
-                '14 days' => esc_html__('14 Days', 'event_espresso'),
2508
-                '30 days' => esc_html__('30 Days', 'event_espresso')
2509
-            )
2510
-        );
2511
-    }
2512
-
2513
-
2514
-    /**
2515
-     * @return bool
2516
-     */
2517
-    public function isConsentCheckboxEnabled()
2518
-    {
2519
-        return $this->consent_checkbox_enabled;
2520
-    }
2521
-
2522
-
2523
-    /**
2524
-     * @param bool $consent_checkbox_enabled
2525
-     */
2526
-    public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2527
-    {
2528
-        $this->consent_checkbox_enabled = filter_var(
2529
-            $consent_checkbox_enabled,
2530
-            FILTER_VALIDATE_BOOLEAN
2531
-        );
2532
-    }
2533
-
2534
-
2535
-    /**
2536
-     * @return string
2537
-     */
2538
-    public function getConsentCheckboxLabelText()
2539
-    {
2540
-        return $this->consent_checkbox_label_text;
2541
-    }
2542
-
2543
-
2544
-    /**
2545
-     * @param string $consent_checkbox_label_text
2546
-     */
2547
-    public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2548
-    {
2549
-        $this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2550
-    }
2336
+	public $gateway_log_lifespan = '1 week';
2337
+
2338
+	/**
2339
+	 * Enable copy attendee info at form
2340
+	 *
2341
+	 * @var boolean $enable_copy_attendee
2342
+	 */
2343
+	protected $copy_attendee_info = true;
2344
+
2345
+
2346
+	/**
2347
+	 *    class constructor
2348
+	 *
2349
+	 * @access    public
2350
+	 */
2351
+	public function __construct()
2352
+	{
2353
+		// set default registration settings
2354
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2355
+		$this->email_validation_level = 'wp_default';
2356
+		$this->show_pending_payment_options = true;
2357
+		$this->skip_reg_confirmation = true;
2358
+		$this->reg_steps = array();
2359
+		$this->reg_confirmation_last = false;
2360
+		$this->use_bot_trap = true;
2361
+		$this->use_encryption = true;
2362
+		$this->use_captcha = false;
2363
+		$this->recaptcha_theme = 'light';
2364
+		$this->recaptcha_badge = 'bottomleft';
2365
+		$this->recaptcha_type = 'image';
2366
+		$this->recaptcha_language = 'en';
2367
+		$this->recaptcha_publickey = null;
2368
+		$this->recaptcha_privatekey = null;
2369
+		$this->recaptcha_protected_forms = array();
2370
+		$this->recaptcha_width = 500;
2371
+		$this->default_maximum_number_of_tickets = 10;
2372
+		$this->consent_checkbox_enabled = false;
2373
+		$this->consent_checkbox_label_text = '';
2374
+		$this->gateway_log_lifespan = '7 days';
2375
+		$this->copy_attendee_info = true;
2376
+	}
2377
+
2378
+
2379
+	/**
2380
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2381
+	 *
2382
+	 * @since 4.8.8.rc.019
2383
+	 */
2384
+	public function do_hooks()
2385
+	{
2386
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2387
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2388
+		add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2389
+	}
2390
+
2391
+
2392
+	/**
2393
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2394
+	 * EVT_default_registration_status field matches the config setting for default_STS_ID.
2395
+	 */
2396
+	public function set_default_reg_status_on_EEM_Event()
2397
+	{
2398
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2399
+	}
2400
+
2401
+
2402
+	/**
2403
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2404
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2405
+	 */
2406
+	public function set_default_max_ticket_on_EEM_Event()
2407
+	{
2408
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2409
+	}
2410
+
2411
+
2412
+	/**
2413
+	 * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2414
+	 * constructed because that happens before we can get the privacy policy page's permalink.
2415
+	 *
2416
+	 * @throws InvalidArgumentException
2417
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2418
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2419
+	 */
2420
+	public function setDefaultCheckboxLabelText()
2421
+	{
2422
+		if ($this->getConsentCheckboxLabelText() === null
2423
+			|| $this->getConsentCheckboxLabelText() === '') {
2424
+			$opening_a_tag = '';
2425
+			$closing_a_tag = '';
2426
+			if (function_exists('get_privacy_policy_url')) {
2427
+				$privacy_page_url = get_privacy_policy_url();
2428
+				if (! empty($privacy_page_url)) {
2429
+					$opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2430
+					$closing_a_tag = '</a>';
2431
+				}
2432
+			}
2433
+			$loader = LoaderFactory::getLoader();
2434
+			$org_config = $loader->getShared('EE_Organization_Config');
2435
+			/**
2436
+			 * @var $org_config EE_Organization_Config
2437
+			 */
2438
+
2439
+			$this->setConsentCheckboxLabelText(
2440
+				sprintf(
2441
+					esc_html__(
2442
+						'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2443
+						'event_espresso'
2444
+					),
2445
+					$org_config->name,
2446
+					$opening_a_tag,
2447
+					$closing_a_tag
2448
+				)
2449
+			);
2450
+		}
2451
+	}
2452
+
2453
+
2454
+	/**
2455
+	 * @return boolean
2456
+	 */
2457
+	public function track_invalid_checkout_access()
2458
+	{
2459
+		return $this->track_invalid_checkout_access;
2460
+	}
2461
+
2462
+
2463
+	/**
2464
+	 * @param boolean $track_invalid_checkout_access
2465
+	 */
2466
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2467
+	{
2468
+		$this->track_invalid_checkout_access = filter_var(
2469
+			$track_invalid_checkout_access,
2470
+			FILTER_VALIDATE_BOOLEAN
2471
+		);
2472
+	}
2473
+
2474
+	/**
2475
+	 * @return boolean
2476
+	 */
2477
+	public function copyAttendeeInfo()
2478
+	{
2479
+		return $this->copy_attendee_info;
2480
+	}
2481
+
2482
+
2483
+	/**
2484
+	 * @param boolean $copy_attendee_info
2485
+	 */
2486
+	public function setCopyAttendeeInfo($copy_attendee_info)
2487
+	{
2488
+		$this->copy_attendee_info = filter_var(
2489
+			$copy_attendee_info,
2490
+			FILTER_VALIDATE_BOOLEAN
2491
+		);
2492
+	}
2493
+
2494
+
2495
+	/**
2496
+	 * Gets the options to make availalbe for the gateway log lifespan
2497
+	 * @return array
2498
+	 */
2499
+	public function gatewayLogLifespanOptions()
2500
+	{
2501
+		return (array) apply_filters(
2502
+			'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2503
+			array(
2504
+				'1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2505
+				'1 day' => esc_html__('1 Day', 'event_espresso'),
2506
+				'7 days' => esc_html__('7 Days', 'event_espresso'),
2507
+				'14 days' => esc_html__('14 Days', 'event_espresso'),
2508
+				'30 days' => esc_html__('30 Days', 'event_espresso')
2509
+			)
2510
+		);
2511
+	}
2512
+
2513
+
2514
+	/**
2515
+	 * @return bool
2516
+	 */
2517
+	public function isConsentCheckboxEnabled()
2518
+	{
2519
+		return $this->consent_checkbox_enabled;
2520
+	}
2521
+
2522
+
2523
+	/**
2524
+	 * @param bool $consent_checkbox_enabled
2525
+	 */
2526
+	public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2527
+	{
2528
+		$this->consent_checkbox_enabled = filter_var(
2529
+			$consent_checkbox_enabled,
2530
+			FILTER_VALIDATE_BOOLEAN
2531
+		);
2532
+	}
2533
+
2534
+
2535
+	/**
2536
+	 * @return string
2537
+	 */
2538
+	public function getConsentCheckboxLabelText()
2539
+	{
2540
+		return $this->consent_checkbox_label_text;
2541
+	}
2542
+
2543
+
2544
+	/**
2545
+	 * @param string $consent_checkbox_label_text
2546
+	 */
2547
+	public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2548
+	{
2549
+		$this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2550
+	}
2551 2551
 }
2552 2552
 
2553 2553
 /**
@@ -2556,151 +2556,151 @@  discard block
 block discarded – undo
2556 2556
 class EE_Admin_Config extends EE_Config_Base
2557 2557
 {
2558 2558
 
2559
-    /**
2560
-     * @var boolean $use_personnel_manager
2561
-     */
2562
-    public $use_personnel_manager;
2563
-
2564
-    /**
2565
-     * @var boolean $use_dashboard_widget
2566
-     */
2567
-    public $use_dashboard_widget;
2568
-
2569
-    /**
2570
-     * @var int $events_in_dashboard
2571
-     */
2572
-    public $events_in_dashboard;
2573
-
2574
-    /**
2575
-     * @var boolean $use_event_timezones
2576
-     */
2577
-    public $use_event_timezones;
2578
-
2579
-    /**
2580
-     * @var string $log_file_name
2581
-     */
2582
-    public $log_file_name;
2583
-
2584
-    /**
2585
-     * @var string $debug_file_name
2586
-     */
2587
-    public $debug_file_name;
2588
-
2589
-    /**
2590
-     * @var boolean $use_remote_logging
2591
-     */
2592
-    public $use_remote_logging;
2593
-
2594
-    /**
2595
-     * @var string $remote_logging_url
2596
-     */
2597
-    public $remote_logging_url;
2598
-
2599
-    /**
2600
-     * @var boolean $show_reg_footer
2601
-     */
2602
-    public $show_reg_footer;
2603
-
2604
-    /**
2605
-     * @var string $affiliate_id
2606
-     */
2607
-    public $affiliate_id;
2608
-
2609
-    /**
2610
-     * help tours on or off (global setting)
2611
-     *
2612
-     * @var boolean
2613
-     */
2614
-    public $help_tour_activation;
2615
-
2616
-    /**
2617
-     * adds extra layer of encoding to session data to prevent serialization errors
2618
-     * but is incompatible with some server configuration errors
2619
-     * if you get "500 internal server errors" during registration, try turning this on
2620
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2621
-     *
2622
-     * @var boolean $encode_session_data
2623
-     */
2624
-    private $encode_session_data = false;
2625
-
2626
-
2627
-    /**
2628
-     *    class constructor
2629
-     *
2630
-     * @access    public
2631
-     */
2632
-    public function __construct()
2633
-    {
2634
-        // set default general admin settings
2635
-        $this->use_personnel_manager = true;
2636
-        $this->use_dashboard_widget = true;
2637
-        $this->events_in_dashboard = 30;
2638
-        $this->use_event_timezones = false;
2639
-        $this->use_remote_logging = false;
2640
-        $this->remote_logging_url = null;
2641
-        $this->show_reg_footer = apply_filters(
2642
-            'FHEE__EE_Admin_Config__show_reg_footer__default',
2643
-            false
2644
-        );
2645
-        $this->affiliate_id = 'default';
2646
-        $this->help_tour_activation = false;
2647
-        $this->encode_session_data = false;
2648
-    }
2649
-
2650
-
2651
-    /**
2652
-     * @param bool $reset
2653
-     * @return string
2654
-     */
2655
-    public function log_file_name($reset = false)
2656
-    {
2657
-        if (empty($this->log_file_name) || $reset) {
2658
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2659
-            EE_Config::instance()->update_espresso_config(false, false);
2660
-        }
2661
-        return $this->log_file_name;
2662
-    }
2663
-
2664
-
2665
-    /**
2666
-     * @param bool $reset
2667
-     * @return string
2668
-     */
2669
-    public function debug_file_name($reset = false)
2670
-    {
2671
-        if (empty($this->debug_file_name) || $reset) {
2672
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2673
-            EE_Config::instance()->update_espresso_config(false, false);
2674
-        }
2675
-        return $this->debug_file_name;
2676
-    }
2677
-
2678
-
2679
-    /**
2680
-     * @return string
2681
-     */
2682
-    public function affiliate_id()
2683
-    {
2684
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2685
-    }
2686
-
2687
-
2688
-    /**
2689
-     * @return boolean
2690
-     */
2691
-    public function encode_session_data()
2692
-    {
2693
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2694
-    }
2695
-
2696
-
2697
-    /**
2698
-     * @param boolean $encode_session_data
2699
-     */
2700
-    public function set_encode_session_data($encode_session_data)
2701
-    {
2702
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2703
-    }
2559
+	/**
2560
+	 * @var boolean $use_personnel_manager
2561
+	 */
2562
+	public $use_personnel_manager;
2563
+
2564
+	/**
2565
+	 * @var boolean $use_dashboard_widget
2566
+	 */
2567
+	public $use_dashboard_widget;
2568
+
2569
+	/**
2570
+	 * @var int $events_in_dashboard
2571
+	 */
2572
+	public $events_in_dashboard;
2573
+
2574
+	/**
2575
+	 * @var boolean $use_event_timezones
2576
+	 */
2577
+	public $use_event_timezones;
2578
+
2579
+	/**
2580
+	 * @var string $log_file_name
2581
+	 */
2582
+	public $log_file_name;
2583
+
2584
+	/**
2585
+	 * @var string $debug_file_name
2586
+	 */
2587
+	public $debug_file_name;
2588
+
2589
+	/**
2590
+	 * @var boolean $use_remote_logging
2591
+	 */
2592
+	public $use_remote_logging;
2593
+
2594
+	/**
2595
+	 * @var string $remote_logging_url
2596
+	 */
2597
+	public $remote_logging_url;
2598
+
2599
+	/**
2600
+	 * @var boolean $show_reg_footer
2601
+	 */
2602
+	public $show_reg_footer;
2603
+
2604
+	/**
2605
+	 * @var string $affiliate_id
2606
+	 */
2607
+	public $affiliate_id;
2608
+
2609
+	/**
2610
+	 * help tours on or off (global setting)
2611
+	 *
2612
+	 * @var boolean
2613
+	 */
2614
+	public $help_tour_activation;
2615
+
2616
+	/**
2617
+	 * adds extra layer of encoding to session data to prevent serialization errors
2618
+	 * but is incompatible with some server configuration errors
2619
+	 * if you get "500 internal server errors" during registration, try turning this on
2620
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2621
+	 *
2622
+	 * @var boolean $encode_session_data
2623
+	 */
2624
+	private $encode_session_data = false;
2625
+
2626
+
2627
+	/**
2628
+	 *    class constructor
2629
+	 *
2630
+	 * @access    public
2631
+	 */
2632
+	public function __construct()
2633
+	{
2634
+		// set default general admin settings
2635
+		$this->use_personnel_manager = true;
2636
+		$this->use_dashboard_widget = true;
2637
+		$this->events_in_dashboard = 30;
2638
+		$this->use_event_timezones = false;
2639
+		$this->use_remote_logging = false;
2640
+		$this->remote_logging_url = null;
2641
+		$this->show_reg_footer = apply_filters(
2642
+			'FHEE__EE_Admin_Config__show_reg_footer__default',
2643
+			false
2644
+		);
2645
+		$this->affiliate_id = 'default';
2646
+		$this->help_tour_activation = false;
2647
+		$this->encode_session_data = false;
2648
+	}
2649
+
2650
+
2651
+	/**
2652
+	 * @param bool $reset
2653
+	 * @return string
2654
+	 */
2655
+	public function log_file_name($reset = false)
2656
+	{
2657
+		if (empty($this->log_file_name) || $reset) {
2658
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2659
+			EE_Config::instance()->update_espresso_config(false, false);
2660
+		}
2661
+		return $this->log_file_name;
2662
+	}
2663
+
2664
+
2665
+	/**
2666
+	 * @param bool $reset
2667
+	 * @return string
2668
+	 */
2669
+	public function debug_file_name($reset = false)
2670
+	{
2671
+		if (empty($this->debug_file_name) || $reset) {
2672
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2673
+			EE_Config::instance()->update_espresso_config(false, false);
2674
+		}
2675
+		return $this->debug_file_name;
2676
+	}
2677
+
2678
+
2679
+	/**
2680
+	 * @return string
2681
+	 */
2682
+	public function affiliate_id()
2683
+	{
2684
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2685
+	}
2686
+
2687
+
2688
+	/**
2689
+	 * @return boolean
2690
+	 */
2691
+	public function encode_session_data()
2692
+	{
2693
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2694
+	}
2695
+
2696
+
2697
+	/**
2698
+	 * @param boolean $encode_session_data
2699
+	 */
2700
+	public function set_encode_session_data($encode_session_data)
2701
+	{
2702
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2703
+	}
2704 2704
 }
2705 2705
 
2706 2706
 /**
@@ -2709,70 +2709,70 @@  discard block
 block discarded – undo
2709 2709
 class EE_Template_Config extends EE_Config_Base
2710 2710
 {
2711 2711
 
2712
-    /**
2713
-     * @var boolean $enable_default_style
2714
-     */
2715
-    public $enable_default_style;
2716
-
2717
-    /**
2718
-     * @var string $custom_style_sheet
2719
-     */
2720
-    public $custom_style_sheet;
2721
-
2722
-    /**
2723
-     * @var boolean $display_address_in_regform
2724
-     */
2725
-    public $display_address_in_regform;
2726
-
2727
-    /**
2728
-     * @var int $display_description_on_multi_reg_page
2729
-     */
2730
-    public $display_description_on_multi_reg_page;
2731
-
2732
-    /**
2733
-     * @var boolean $use_custom_templates
2734
-     */
2735
-    public $use_custom_templates;
2736
-
2737
-    /**
2738
-     * @var string $current_espresso_theme
2739
-     */
2740
-    public $current_espresso_theme;
2741
-
2742
-    /**
2743
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2744
-     */
2745
-    public $EED_Ticket_Selector;
2746
-
2747
-    /**
2748
-     * @var EE_Event_Single_Config $EED_Event_Single
2749
-     */
2750
-    public $EED_Event_Single;
2751
-
2752
-    /**
2753
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2754
-     */
2755
-    public $EED_Events_Archive;
2756
-
2757
-
2758
-    /**
2759
-     *    class constructor
2760
-     *
2761
-     * @access    public
2762
-     */
2763
-    public function __construct()
2764
-    {
2765
-        // set default template settings
2766
-        $this->enable_default_style = true;
2767
-        $this->custom_style_sheet = null;
2768
-        $this->display_address_in_regform = true;
2769
-        $this->display_description_on_multi_reg_page = false;
2770
-        $this->use_custom_templates = false;
2771
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2772
-        $this->EED_Event_Single = null;
2773
-        $this->EED_Events_Archive = null;
2774
-        $this->EED_Ticket_Selector = null;
2775
-    }
2712
+	/**
2713
+	 * @var boolean $enable_default_style
2714
+	 */
2715
+	public $enable_default_style;
2716
+
2717
+	/**
2718
+	 * @var string $custom_style_sheet
2719
+	 */
2720
+	public $custom_style_sheet;
2721
+
2722
+	/**
2723
+	 * @var boolean $display_address_in_regform
2724
+	 */
2725
+	public $display_address_in_regform;
2726
+
2727
+	/**
2728
+	 * @var int $display_description_on_multi_reg_page
2729
+	 */
2730
+	public $display_description_on_multi_reg_page;
2731
+
2732
+	/**
2733
+	 * @var boolean $use_custom_templates
2734
+	 */
2735
+	public $use_custom_templates;
2736
+
2737
+	/**
2738
+	 * @var string $current_espresso_theme
2739
+	 */
2740
+	public $current_espresso_theme;
2741
+
2742
+	/**
2743
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2744
+	 */
2745
+	public $EED_Ticket_Selector;
2746
+
2747
+	/**
2748
+	 * @var EE_Event_Single_Config $EED_Event_Single
2749
+	 */
2750
+	public $EED_Event_Single;
2751
+
2752
+	/**
2753
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2754
+	 */
2755
+	public $EED_Events_Archive;
2756
+
2757
+
2758
+	/**
2759
+	 *    class constructor
2760
+	 *
2761
+	 * @access    public
2762
+	 */
2763
+	public function __construct()
2764
+	{
2765
+		// set default template settings
2766
+		$this->enable_default_style = true;
2767
+		$this->custom_style_sheet = null;
2768
+		$this->display_address_in_regform = true;
2769
+		$this->display_description_on_multi_reg_page = false;
2770
+		$this->use_custom_templates = false;
2771
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2772
+		$this->EED_Event_Single = null;
2773
+		$this->EED_Events_Archive = null;
2774
+		$this->EED_Ticket_Selector = null;
2775
+	}
2776 2776
 }
2777 2777
 
2778 2778
 /**
@@ -2781,114 +2781,114 @@  discard block
 block discarded – undo
2781 2781
 class EE_Map_Config extends EE_Config_Base
2782 2782
 {
2783 2783
 
2784
-    /**
2785
-     * @var boolean $use_google_maps
2786
-     */
2787
-    public $use_google_maps;
2788
-
2789
-    /**
2790
-     * @var string $api_key
2791
-     */
2792
-    public $google_map_api_key;
2793
-
2794
-    /**
2795
-     * @var int $event_details_map_width
2796
-     */
2797
-    public $event_details_map_width;
2798
-
2799
-    /**
2800
-     * @var int $event_details_map_height
2801
-     */
2802
-    public $event_details_map_height;
2803
-
2804
-    /**
2805
-     * @var int $event_details_map_zoom
2806
-     */
2807
-    public $event_details_map_zoom;
2808
-
2809
-    /**
2810
-     * @var boolean $event_details_display_nav
2811
-     */
2812
-    public $event_details_display_nav;
2813
-
2814
-    /**
2815
-     * @var boolean $event_details_nav_size
2816
-     */
2817
-    public $event_details_nav_size;
2818
-
2819
-    /**
2820
-     * @var string $event_details_control_type
2821
-     */
2822
-    public $event_details_control_type;
2823
-
2824
-    /**
2825
-     * @var string $event_details_map_align
2826
-     */
2827
-    public $event_details_map_align;
2828
-
2829
-    /**
2830
-     * @var int $event_list_map_width
2831
-     */
2832
-    public $event_list_map_width;
2833
-
2834
-    /**
2835
-     * @var int $event_list_map_height
2836
-     */
2837
-    public $event_list_map_height;
2838
-
2839
-    /**
2840
-     * @var int $event_list_map_zoom
2841
-     */
2842
-    public $event_list_map_zoom;
2843
-
2844
-    /**
2845
-     * @var boolean $event_list_display_nav
2846
-     */
2847
-    public $event_list_display_nav;
2848
-
2849
-    /**
2850
-     * @var boolean $event_list_nav_size
2851
-     */
2852
-    public $event_list_nav_size;
2853
-
2854
-    /**
2855
-     * @var string $event_list_control_type
2856
-     */
2857
-    public $event_list_control_type;
2858
-
2859
-    /**
2860
-     * @var string $event_list_map_align
2861
-     */
2862
-    public $event_list_map_align;
2863
-
2864
-
2865
-    /**
2866
-     *    class constructor
2867
-     *
2868
-     * @access    public
2869
-     */
2870
-    public function __construct()
2871
-    {
2872
-        // set default map settings
2873
-        $this->use_google_maps = true;
2874
-        $this->google_map_api_key = '';
2875
-        // for event details pages (reg page)
2876
-        $this->event_details_map_width = 585;            // ee_map_width_single
2877
-        $this->event_details_map_height = 362;            // ee_map_height_single
2878
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2879
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2880
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2881
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2882
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2883
-        // for event list pages
2884
-        $this->event_list_map_width = 300;            // ee_map_width
2885
-        $this->event_list_map_height = 185;        // ee_map_height
2886
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2887
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2888
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2889
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2890
-        $this->event_list_map_align = 'center';            // ee_map_align
2891
-    }
2784
+	/**
2785
+	 * @var boolean $use_google_maps
2786
+	 */
2787
+	public $use_google_maps;
2788
+
2789
+	/**
2790
+	 * @var string $api_key
2791
+	 */
2792
+	public $google_map_api_key;
2793
+
2794
+	/**
2795
+	 * @var int $event_details_map_width
2796
+	 */
2797
+	public $event_details_map_width;
2798
+
2799
+	/**
2800
+	 * @var int $event_details_map_height
2801
+	 */
2802
+	public $event_details_map_height;
2803
+
2804
+	/**
2805
+	 * @var int $event_details_map_zoom
2806
+	 */
2807
+	public $event_details_map_zoom;
2808
+
2809
+	/**
2810
+	 * @var boolean $event_details_display_nav
2811
+	 */
2812
+	public $event_details_display_nav;
2813
+
2814
+	/**
2815
+	 * @var boolean $event_details_nav_size
2816
+	 */
2817
+	public $event_details_nav_size;
2818
+
2819
+	/**
2820
+	 * @var string $event_details_control_type
2821
+	 */
2822
+	public $event_details_control_type;
2823
+
2824
+	/**
2825
+	 * @var string $event_details_map_align
2826
+	 */
2827
+	public $event_details_map_align;
2828
+
2829
+	/**
2830
+	 * @var int $event_list_map_width
2831
+	 */
2832
+	public $event_list_map_width;
2833
+
2834
+	/**
2835
+	 * @var int $event_list_map_height
2836
+	 */
2837
+	public $event_list_map_height;
2838
+
2839
+	/**
2840
+	 * @var int $event_list_map_zoom
2841
+	 */
2842
+	public $event_list_map_zoom;
2843
+
2844
+	/**
2845
+	 * @var boolean $event_list_display_nav
2846
+	 */
2847
+	public $event_list_display_nav;
2848
+
2849
+	/**
2850
+	 * @var boolean $event_list_nav_size
2851
+	 */
2852
+	public $event_list_nav_size;
2853
+
2854
+	/**
2855
+	 * @var string $event_list_control_type
2856
+	 */
2857
+	public $event_list_control_type;
2858
+
2859
+	/**
2860
+	 * @var string $event_list_map_align
2861
+	 */
2862
+	public $event_list_map_align;
2863
+
2864
+
2865
+	/**
2866
+	 *    class constructor
2867
+	 *
2868
+	 * @access    public
2869
+	 */
2870
+	public function __construct()
2871
+	{
2872
+		// set default map settings
2873
+		$this->use_google_maps = true;
2874
+		$this->google_map_api_key = '';
2875
+		// for event details pages (reg page)
2876
+		$this->event_details_map_width = 585;            // ee_map_width_single
2877
+		$this->event_details_map_height = 362;            // ee_map_height_single
2878
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2879
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2880
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2881
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2882
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2883
+		// for event list pages
2884
+		$this->event_list_map_width = 300;            // ee_map_width
2885
+		$this->event_list_map_height = 185;        // ee_map_height
2886
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2887
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2888
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2889
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2890
+		$this->event_list_map_align = 'center';            // ee_map_align
2891
+	}
2892 2892
 }
2893 2893
 
2894 2894
 /**
@@ -2897,46 +2897,46 @@  discard block
 block discarded – undo
2897 2897
 class EE_Events_Archive_Config extends EE_Config_Base
2898 2898
 {
2899 2899
 
2900
-    public $display_status_banner;
2900
+	public $display_status_banner;
2901 2901
 
2902
-    public $display_description;
2902
+	public $display_description;
2903 2903
 
2904
-    public $display_ticket_selector;
2904
+	public $display_ticket_selector;
2905 2905
 
2906
-    public $display_datetimes;
2906
+	public $display_datetimes;
2907 2907
 
2908
-    public $display_venue;
2908
+	public $display_venue;
2909 2909
 
2910
-    public $display_expired_events;
2910
+	public $display_expired_events;
2911 2911
 
2912
-    public $use_sortable_display_order;
2912
+	public $use_sortable_display_order;
2913 2913
 
2914
-    public $display_order_tickets;
2914
+	public $display_order_tickets;
2915 2915
 
2916
-    public $display_order_datetimes;
2916
+	public $display_order_datetimes;
2917 2917
 
2918
-    public $display_order_event;
2918
+	public $display_order_event;
2919 2919
 
2920
-    public $display_order_venue;
2920
+	public $display_order_venue;
2921 2921
 
2922 2922
 
2923
-    /**
2924
-     *    class constructor
2925
-     */
2926
-    public function __construct()
2927
-    {
2928
-        $this->display_status_banner = 0;
2929
-        $this->display_description = 1;
2930
-        $this->display_ticket_selector = 0;
2931
-        $this->display_datetimes = 1;
2932
-        $this->display_venue = 0;
2933
-        $this->display_expired_events = 0;
2934
-        $this->use_sortable_display_order = false;
2935
-        $this->display_order_tickets = 100;
2936
-        $this->display_order_datetimes = 110;
2937
-        $this->display_order_event = 120;
2938
-        $this->display_order_venue = 130;
2939
-    }
2923
+	/**
2924
+	 *    class constructor
2925
+	 */
2926
+	public function __construct()
2927
+	{
2928
+		$this->display_status_banner = 0;
2929
+		$this->display_description = 1;
2930
+		$this->display_ticket_selector = 0;
2931
+		$this->display_datetimes = 1;
2932
+		$this->display_venue = 0;
2933
+		$this->display_expired_events = 0;
2934
+		$this->use_sortable_display_order = false;
2935
+		$this->display_order_tickets = 100;
2936
+		$this->display_order_datetimes = 110;
2937
+		$this->display_order_event = 120;
2938
+		$this->display_order_venue = 130;
2939
+	}
2940 2940
 }
2941 2941
 
2942 2942
 /**
@@ -2945,34 +2945,34 @@  discard block
 block discarded – undo
2945 2945
 class EE_Event_Single_Config extends EE_Config_Base
2946 2946
 {
2947 2947
 
2948
-    public $display_status_banner_single;
2948
+	public $display_status_banner_single;
2949 2949
 
2950
-    public $display_venue;
2950
+	public $display_venue;
2951 2951
 
2952
-    public $use_sortable_display_order;
2952
+	public $use_sortable_display_order;
2953 2953
 
2954
-    public $display_order_tickets;
2954
+	public $display_order_tickets;
2955 2955
 
2956
-    public $display_order_datetimes;
2956
+	public $display_order_datetimes;
2957 2957
 
2958
-    public $display_order_event;
2958
+	public $display_order_event;
2959 2959
 
2960
-    public $display_order_venue;
2960
+	public $display_order_venue;
2961 2961
 
2962 2962
 
2963
-    /**
2964
-     *    class constructor
2965
-     */
2966
-    public function __construct()
2967
-    {
2968
-        $this->display_status_banner_single = 0;
2969
-        $this->display_venue = 1;
2970
-        $this->use_sortable_display_order = false;
2971
-        $this->display_order_tickets = 100;
2972
-        $this->display_order_datetimes = 110;
2973
-        $this->display_order_event = 120;
2974
-        $this->display_order_venue = 130;
2975
-    }
2963
+	/**
2964
+	 *    class constructor
2965
+	 */
2966
+	public function __construct()
2967
+	{
2968
+		$this->display_status_banner_single = 0;
2969
+		$this->display_venue = 1;
2970
+		$this->use_sortable_display_order = false;
2971
+		$this->display_order_tickets = 100;
2972
+		$this->display_order_datetimes = 110;
2973
+		$this->display_order_event = 120;
2974
+		$this->display_order_venue = 130;
2975
+	}
2976 2976
 }
2977 2977
 
2978 2978
 /**
@@ -2981,172 +2981,172 @@  discard block
 block discarded – undo
2981 2981
 class EE_Ticket_Selector_Config extends EE_Config_Base
2982 2982
 {
2983 2983
 
2984
-    /**
2985
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2986
-     */
2987
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2988
-
2989
-    /**
2990
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2991
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2992
-     */
2993
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2994
-
2995
-    /**
2996
-     * @var boolean $show_ticket_sale_columns
2997
-     */
2998
-    public $show_ticket_sale_columns;
2999
-
3000
-    /**
3001
-     * @var boolean $show_ticket_details
3002
-     */
3003
-    public $show_ticket_details;
3004
-
3005
-    /**
3006
-     * @var boolean $show_expired_tickets
3007
-     */
3008
-    public $show_expired_tickets;
3009
-
3010
-    /**
3011
-     * whether or not to display a dropdown box populated with event datetimes
3012
-     * that toggles which tickets are displayed for a ticket selector.
3013
-     * uses one of the *_DATETIME_SELECTOR constants defined above
3014
-     *
3015
-     * @var string $show_datetime_selector
3016
-     */
3017
-    private $show_datetime_selector = 'no_datetime_selector';
3018
-
3019
-    /**
3020
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
3021
-     *
3022
-     * @var int $datetime_selector_threshold
3023
-     */
3024
-    private $datetime_selector_threshold = 3;
3025
-
3026
-    /**
3027
-     * determines the maximum number of "checked" dates in the date and time filter
3028
-     *
3029
-     * @var int $datetime_selector_checked
3030
-     */
3031
-    private $datetime_selector_max_checked = 10;
3032
-
3033
-
3034
-    /**
3035
-     *    class constructor
3036
-     */
3037
-    public function __construct()
3038
-    {
3039
-        $this->show_ticket_sale_columns = true;
3040
-        $this->show_ticket_details = true;
3041
-        $this->show_expired_tickets = true;
3042
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3043
-        $this->datetime_selector_threshold = 3;
3044
-        $this->datetime_selector_max_checked = 10;
3045
-    }
3046
-
3047
-
3048
-    /**
3049
-     * returns true if a datetime selector should be displayed
3050
-     *
3051
-     * @param array $datetimes
3052
-     * @return bool
3053
-     */
3054
-    public function showDatetimeSelector(array $datetimes)
3055
-    {
3056
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3057
-        return ! (
3058
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3059
-            || (
3060
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3061
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3062
-            )
3063
-        );
3064
-    }
3065
-
3066
-
3067
-    /**
3068
-     * @return string
3069
-     */
3070
-    public function getShowDatetimeSelector()
3071
-    {
3072
-        return $this->show_datetime_selector;
3073
-    }
3074
-
3075
-
3076
-    /**
3077
-     * @param bool $keys_only
3078
-     * @return array
3079
-     */
3080
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3081
-    {
3082
-        return $keys_only
3083
-            ? array(
3084
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3085
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3086
-            )
3087
-            : array(
3088
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3089
-                    'Do not show date & time filter',
3090
-                    'event_espresso'
3091
-                ),
3092
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3093
-                    'Maybe show date & time filter',
3094
-                    'event_espresso'
3095
-                ),
3096
-            );
3097
-    }
3098
-
3099
-
3100
-    /**
3101
-     * @param string $show_datetime_selector
3102
-     */
3103
-    public function setShowDatetimeSelector($show_datetime_selector)
3104
-    {
3105
-        $this->show_datetime_selector = in_array(
3106
-            $show_datetime_selector,
3107
-            $this->getShowDatetimeSelectorOptions(),
3108
-            true
3109
-        )
3110
-            ? $show_datetime_selector
3111
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3112
-    }
3113
-
3114
-
3115
-    /**
3116
-     * @return int
3117
-     */
3118
-    public function getDatetimeSelectorThreshold()
3119
-    {
3120
-        return $this->datetime_selector_threshold;
3121
-    }
3122
-
3123
-
3124
-    /**
3125
-     * @param int $datetime_selector_threshold
3126
-     */
3127
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3128
-    {
3129
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3130
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3131
-    }
3132
-
3133
-
3134
-    /**
3135
-     * @return int
3136
-     */
3137
-    public function getDatetimeSelectorMaxChecked()
3138
-    {
3139
-        return $this->datetime_selector_max_checked;
3140
-    }
3141
-
3142
-
3143
-    /**
3144
-     * @param int $datetime_selector_max_checked
3145
-     */
3146
-    public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3147
-    {
3148
-        $this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3149
-    }
2984
+	/**
2985
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2986
+	 */
2987
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2988
+
2989
+	/**
2990
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2991
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2992
+	 */
2993
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2994
+
2995
+	/**
2996
+	 * @var boolean $show_ticket_sale_columns
2997
+	 */
2998
+	public $show_ticket_sale_columns;
2999
+
3000
+	/**
3001
+	 * @var boolean $show_ticket_details
3002
+	 */
3003
+	public $show_ticket_details;
3004
+
3005
+	/**
3006
+	 * @var boolean $show_expired_tickets
3007
+	 */
3008
+	public $show_expired_tickets;
3009
+
3010
+	/**
3011
+	 * whether or not to display a dropdown box populated with event datetimes
3012
+	 * that toggles which tickets are displayed for a ticket selector.
3013
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
3014
+	 *
3015
+	 * @var string $show_datetime_selector
3016
+	 */
3017
+	private $show_datetime_selector = 'no_datetime_selector';
3018
+
3019
+	/**
3020
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
3021
+	 *
3022
+	 * @var int $datetime_selector_threshold
3023
+	 */
3024
+	private $datetime_selector_threshold = 3;
3025
+
3026
+	/**
3027
+	 * determines the maximum number of "checked" dates in the date and time filter
3028
+	 *
3029
+	 * @var int $datetime_selector_checked
3030
+	 */
3031
+	private $datetime_selector_max_checked = 10;
3032
+
3033
+
3034
+	/**
3035
+	 *    class constructor
3036
+	 */
3037
+	public function __construct()
3038
+	{
3039
+		$this->show_ticket_sale_columns = true;
3040
+		$this->show_ticket_details = true;
3041
+		$this->show_expired_tickets = true;
3042
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3043
+		$this->datetime_selector_threshold = 3;
3044
+		$this->datetime_selector_max_checked = 10;
3045
+	}
3046
+
3047
+
3048
+	/**
3049
+	 * returns true if a datetime selector should be displayed
3050
+	 *
3051
+	 * @param array $datetimes
3052
+	 * @return bool
3053
+	 */
3054
+	public function showDatetimeSelector(array $datetimes)
3055
+	{
3056
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3057
+		return ! (
3058
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3059
+			|| (
3060
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3061
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3062
+			)
3063
+		);
3064
+	}
3065
+
3066
+
3067
+	/**
3068
+	 * @return string
3069
+	 */
3070
+	public function getShowDatetimeSelector()
3071
+	{
3072
+		return $this->show_datetime_selector;
3073
+	}
3074
+
3075
+
3076
+	/**
3077
+	 * @param bool $keys_only
3078
+	 * @return array
3079
+	 */
3080
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3081
+	{
3082
+		return $keys_only
3083
+			? array(
3084
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3085
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3086
+			)
3087
+			: array(
3088
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3089
+					'Do not show date & time filter',
3090
+					'event_espresso'
3091
+				),
3092
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3093
+					'Maybe show date & time filter',
3094
+					'event_espresso'
3095
+				),
3096
+			);
3097
+	}
3098
+
3099
+
3100
+	/**
3101
+	 * @param string $show_datetime_selector
3102
+	 */
3103
+	public function setShowDatetimeSelector($show_datetime_selector)
3104
+	{
3105
+		$this->show_datetime_selector = in_array(
3106
+			$show_datetime_selector,
3107
+			$this->getShowDatetimeSelectorOptions(),
3108
+			true
3109
+		)
3110
+			? $show_datetime_selector
3111
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3112
+	}
3113
+
3114
+
3115
+	/**
3116
+	 * @return int
3117
+	 */
3118
+	public function getDatetimeSelectorThreshold()
3119
+	{
3120
+		return $this->datetime_selector_threshold;
3121
+	}
3122
+
3123
+
3124
+	/**
3125
+	 * @param int $datetime_selector_threshold
3126
+	 */
3127
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3128
+	{
3129
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3130
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3131
+	}
3132
+
3133
+
3134
+	/**
3135
+	 * @return int
3136
+	 */
3137
+	public function getDatetimeSelectorMaxChecked()
3138
+	{
3139
+		return $this->datetime_selector_max_checked;
3140
+	}
3141
+
3142
+
3143
+	/**
3144
+	 * @param int $datetime_selector_max_checked
3145
+	 */
3146
+	public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3147
+	{
3148
+		$this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3149
+	}
3150 3150
 }
3151 3151
 
3152 3152
 /**
@@ -3159,86 +3159,86 @@  discard block
 block discarded – undo
3159 3159
 class EE_Environment_Config extends EE_Config_Base
3160 3160
 {
3161 3161
 
3162
-    /**
3163
-     * Hold any php environment variables that we want to track.
3164
-     *
3165
-     * @var stdClass;
3166
-     */
3167
-    public $php;
3168
-
3169
-
3170
-    /**
3171
-     *    constructor
3172
-     */
3173
-    public function __construct()
3174
-    {
3175
-        $this->php = new stdClass();
3176
-        $this->_set_php_values();
3177
-    }
3178
-
3179
-
3180
-    /**
3181
-     * This sets the php environment variables.
3182
-     *
3183
-     * @since 4.4.0
3184
-     * @return void
3185
-     */
3186
-    protected function _set_php_values()
3187
-    {
3188
-        $this->php->max_input_vars = ini_get('max_input_vars');
3189
-        $this->php->version = phpversion();
3190
-    }
3191
-
3192
-
3193
-    /**
3194
-     * helper method for determining whether input_count is
3195
-     * reaching the potential maximum the server can handle
3196
-     * according to max_input_vars
3197
-     *
3198
-     * @param int   $input_count the count of input vars.
3199
-     * @return array {
3200
-     *                           An array that represents whether available space and if no available space the error
3201
-     *                           message.
3202
-     * @type bool   $has_space   whether more inputs can be added.
3203
-     * @type string $msg         Any message to be displayed.
3204
-     *                           }
3205
-     */
3206
-    public function max_input_vars_limit_check($input_count = 0)
3207
-    {
3208
-        if (! empty($this->php->max_input_vars)
3209
-            && ($input_count >= $this->php->max_input_vars)
3210
-        ) {
3211
-            // check the server setting because the config value could be stale
3212
-            $max_input_vars = ini_get('max_input_vars');
3213
-            if ($input_count >= $max_input_vars) {
3214
-                return sprintf(
3215
-                    esc_html__(
3216
-                        'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3217
-                        'event_espresso'
3218
-                    ),
3219
-                    '<br>',
3220
-                    $input_count,
3221
-                    $max_input_vars
3222
-                );
3223
-            } else {
3224
-                return '';
3225
-            }
3226
-        } else {
3227
-            return '';
3228
-        }
3229
-    }
3230
-
3231
-
3232
-    /**
3233
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3234
-     *
3235
-     * @since 4.4.1
3236
-     * @return void
3237
-     */
3238
-    public function recheck_values()
3239
-    {
3240
-        $this->_set_php_values();
3241
-    }
3162
+	/**
3163
+	 * Hold any php environment variables that we want to track.
3164
+	 *
3165
+	 * @var stdClass;
3166
+	 */
3167
+	public $php;
3168
+
3169
+
3170
+	/**
3171
+	 *    constructor
3172
+	 */
3173
+	public function __construct()
3174
+	{
3175
+		$this->php = new stdClass();
3176
+		$this->_set_php_values();
3177
+	}
3178
+
3179
+
3180
+	/**
3181
+	 * This sets the php environment variables.
3182
+	 *
3183
+	 * @since 4.4.0
3184
+	 * @return void
3185
+	 */
3186
+	protected function _set_php_values()
3187
+	{
3188
+		$this->php->max_input_vars = ini_get('max_input_vars');
3189
+		$this->php->version = phpversion();
3190
+	}
3191
+
3192
+
3193
+	/**
3194
+	 * helper method for determining whether input_count is
3195
+	 * reaching the potential maximum the server can handle
3196
+	 * according to max_input_vars
3197
+	 *
3198
+	 * @param int   $input_count the count of input vars.
3199
+	 * @return array {
3200
+	 *                           An array that represents whether available space and if no available space the error
3201
+	 *                           message.
3202
+	 * @type bool   $has_space   whether more inputs can be added.
3203
+	 * @type string $msg         Any message to be displayed.
3204
+	 *                           }
3205
+	 */
3206
+	public function max_input_vars_limit_check($input_count = 0)
3207
+	{
3208
+		if (! empty($this->php->max_input_vars)
3209
+			&& ($input_count >= $this->php->max_input_vars)
3210
+		) {
3211
+			// check the server setting because the config value could be stale
3212
+			$max_input_vars = ini_get('max_input_vars');
3213
+			if ($input_count >= $max_input_vars) {
3214
+				return sprintf(
3215
+					esc_html__(
3216
+						'The maximum number of inputs on this page has been exceeded. You cannot make edits to this page because of your server\'s PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.%1$sPlease contact your web host and ask them to raise the "max_input_vars" limit.',
3217
+						'event_espresso'
3218
+					),
3219
+					'<br>',
3220
+					$input_count,
3221
+					$max_input_vars
3222
+				);
3223
+			} else {
3224
+				return '';
3225
+			}
3226
+		} else {
3227
+			return '';
3228
+		}
3229
+	}
3230
+
3231
+
3232
+	/**
3233
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3234
+	 *
3235
+	 * @since 4.4.1
3236
+	 * @return void
3237
+	 */
3238
+	public function recheck_values()
3239
+	{
3240
+		$this->_set_php_values();
3241
+	}
3242 3242
 }
3243 3243
 
3244 3244
 /**
@@ -3251,21 +3251,21 @@  discard block
 block discarded – undo
3251 3251
 class EE_Tax_Config extends EE_Config_Base
3252 3252
 {
3253 3253
 
3254
-    /*
3254
+	/*
3255 3255
      * flag to indicate whether or not to display ticket prices with the taxes included
3256 3256
      *
3257 3257
      * @var boolean $prices_displayed_including_taxes
3258 3258
      */
3259
-    public $prices_displayed_including_taxes;
3259
+	public $prices_displayed_including_taxes;
3260 3260
 
3261 3261
 
3262
-    /**
3263
-     *    class constructor
3264
-     */
3265
-    public function __construct()
3266
-    {
3267
-        $this->prices_displayed_including_taxes = true;
3268
-    }
3262
+	/**
3263
+	 *    class constructor
3264
+	 */
3265
+	public function __construct()
3266
+	{
3267
+		$this->prices_displayed_including_taxes = true;
3268
+	}
3269 3269
 }
3270 3270
 
3271 3271
 /**
@@ -3279,19 +3279,19 @@  discard block
 block discarded – undo
3279 3279
 class EE_Messages_Config extends EE_Config_Base
3280 3280
 {
3281 3281
 
3282
-    /**
3283
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3284
-     * A value of 0 represents never deleting.  Default is 0.
3285
-     *
3286
-     * @var integer
3287
-     */
3288
-    public $delete_threshold;
3282
+	/**
3283
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3284
+	 * A value of 0 represents never deleting.  Default is 0.
3285
+	 *
3286
+	 * @var integer
3287
+	 */
3288
+	public $delete_threshold;
3289 3289
 
3290 3290
 
3291
-    public function __construct()
3292
-    {
3293
-        $this->delete_threshold = 0;
3294
-    }
3291
+	public function __construct()
3292
+	{
3293
+		$this->delete_threshold = 0;
3294
+	}
3295 3295
 }
3296 3296
 
3297 3297
 /**
@@ -3302,31 +3302,31 @@  discard block
 block discarded – undo
3302 3302
 class EE_Gateway_Config extends EE_Config_Base
3303 3303
 {
3304 3304
 
3305
-    /**
3306
-     * Array with keys that are payment gateways slugs, and values are arrays
3307
-     * with any config info the gateway wants to store
3308
-     *
3309
-     * @var array
3310
-     */
3311
-    public $payment_settings;
3312
-
3313
-    /**
3314
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3315
-     * the gateway is stored in the uploads directory
3316
-     *
3317
-     * @var array
3318
-     */
3319
-    public $active_gateways;
3320
-
3321
-
3322
-    /**
3323
-     *    class constructor
3324
-     *
3325
-     * @deprecated
3326
-     */
3327
-    public function __construct()
3328
-    {
3329
-        $this->payment_settings = array();
3330
-        $this->active_gateways = array('Invoice' => false);
3331
-    }
3305
+	/**
3306
+	 * Array with keys that are payment gateways slugs, and values are arrays
3307
+	 * with any config info the gateway wants to store
3308
+	 *
3309
+	 * @var array
3310
+	 */
3311
+	public $payment_settings;
3312
+
3313
+	/**
3314
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3315
+	 * the gateway is stored in the uploads directory
3316
+	 *
3317
+	 * @var array
3318
+	 */
3319
+	public $active_gateways;
3320
+
3321
+
3322
+	/**
3323
+	 *    class constructor
3324
+	 *
3325
+	 * @deprecated
3326
+	 */
3327
+	public function __construct()
3328
+	{
3329
+		$this->payment_settings = array();
3330
+		$this->active_gateways = array('Invoice' => false);
3331
+	}
3332 3332
 }
Please login to merge, or discard this patch.
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     public static function instance()
148 148
     {
149 149
         // check if class object is instantiated, and instantiated properly
150
-        if (! self::$_instance instanceof EE_Config) {
150
+        if ( ! self::$_instance instanceof EE_Config) {
151 151
             self::$_instance = new self();
152 152
         }
153 153
         return self::$_instance;
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
                 $this
286 286
             );
287 287
             if (is_object($settings) && property_exists($this, $config)) {
288
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
288
+                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__'.$config, $settings);
289 289
                 // call configs populate method to ensure any defaults are set for empty values.
290 290
                 if (method_exists($settings, 'populate')) {
291 291
                     $this->{$config}->populate();
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
                         break;
561 561
                     // TEST #2 : check that settings section exists
562 562
                     case 2:
563
-                        if (! isset($this->{$section})) {
563
+                        if ( ! isset($this->{$section})) {
564 564
                             if ($display_errors) {
565 565
                                 throw new EE_Error(
566 566
                                     sprintf(
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
                         break;
575 575
                     // TEST #3 : check that section is the proper format
576 576
                     case 3:
577
-                        if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
577
+                        if ( ! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
578 578
                         ) {
579 579
                             if ($display_errors) {
580 580
                                 throw new EE_Error(
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
                         break;
621 621
                     // TEST #6 : verify config class is accessible
622 622
                     case 6:
623
-                        if (! class_exists($config_class)) {
623
+                        if ( ! class_exists($config_class)) {
624 624
                             if ($display_errors) {
625 625
                                 throw new EE_Error(
626 626
                                     sprintf(
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
                         break;
638 638
                     // TEST #7 : check that config has even been set
639 639
                     case 7:
640
-                        if (! isset($this->{$section}->{$name})) {
640
+                        if ( ! isset($this->{$section}->{$name})) {
641 641
                             if ($display_errors) {
642 642
                                 throw new EE_Error(
643 643
                                     sprintf(
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
                         break;
656 656
                     // TEST #8 : check that config is the requested type
657 657
                     case 8:
658
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
658
+                        if ( ! $this->{$section}->{$name} instanceof $config_class) {
659 659
                             if ($display_errors) {
660 660
                                 throw new EE_Error(
661 661
                                     sprintf(
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
                         break;
675 675
                     // TEST #9 : verify config object
676 676
                     case 9:
677
-                        if (! $config_obj instanceof EE_Config_Base) {
677
+                        if ( ! $config_obj instanceof EE_Config_Base) {
678 678
                             if ($display_errors) {
679 679
                                 throw new EE_Error(
680 680
                                     sprintf(
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
      */
707 707
     private function _generate_config_option_name($section = '', $name = '')
708 708
     {
709
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
709
+        return 'ee_config-'.strtolower($section.'-'.str_replace(array('EE_', 'EED_'), '', $name));
710 710
     }
711 711
 
712 712
 
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
     {
724 724
         return ! empty($config_class)
725 725
             ? $config_class
726
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
726
+            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))).'_Config';
727 727
     }
728 728
 
729 729
 
@@ -742,17 +742,17 @@  discard block
 block discarded – undo
742 742
         // ensure config class is set to something
743 743
         $config_class = $this->_set_config_class($config_class, $name);
744 744
         // run tests 1-4, 6, and 7 to verify all config params are set and valid
745
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
745
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
746 746
             return null;
747 747
         }
748 748
         $config_option_name = $this->_generate_config_option_name($section, $name);
749 749
         // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
750
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
751
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
750
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
751
+            $this->_addon_option_names[$config_option_name] = $config_class;
752 752
             $this->update_addon_option_names();
753 753
         }
754 754
         // verify the incoming config object but suppress errors
755
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
755
+        if ( ! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
756 756
             $config_obj = new $config_class();
757 757
         }
758 758
         if (get_option($config_option_name)) {
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
         // get class name of the incoming object
802 802
         $config_class = get_class($config_obj);
803 803
         // run tests 1-5 and 9 to verify config
804
-        if (! $this->_verify_config_params(
804
+        if ( ! $this->_verify_config_params(
805 805
             $section,
806 806
             $name,
807 807
             $config_class,
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
         }
814 814
         $config_option_name = $this->_generate_config_option_name($section, $name);
815 815
         // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
816
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
816
+        if ( ! isset($this->_addon_option_names[$config_option_name])) {
817 817
             // save new config to db
818 818
             if ($this->set_config($section, $name, $config_class, $config_obj)) {
819 819
                 return true;
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
                             'event_espresso'
840 840
                         ),
841 841
                         $config_class,
842
-                        'EE_Config->' . $section . '->' . $name
842
+                        'EE_Config->'.$section.'->'.$name
843 843
                     ),
844 844
                     __FILE__,
845 845
                     __FUNCTION__,
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
         // ensure config class is set to something
866 866
         $config_class = $this->_set_config_class($config_class, $name);
867 867
         // run tests 1-4, 6 and 7 to verify that all params have been set
868
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
868
+        if ( ! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
869 869
             return null;
870 870
         }
871 871
         // now test if the requested config object exists, but suppress errors
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
         // retrieve the wp-option for this config class.
911 911
         $config_option = maybe_unserialize(get_option($config_option_name, array()));
912 912
         if (empty($config_option)) {
913
-            EE_Config::log($config_option_name . '-NOT-FOUND');
913
+            EE_Config::log($config_option_name.'-NOT-FOUND');
914 914
         }
915 915
         return $config_option;
916 916
     }
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
             $config_log = get_option(EE_Config::LOG_NAME, array());
928 928
             /** @var RequestParams $request */
929 929
             $request = LoaderFactory::getLoader()->getShared(RequestParams::class);
930
-            $config_log[ (string) microtime(true) ] = array(
930
+            $config_log[(string) microtime(true)] = array(
931 931
                 'config_name' => $config_option_name,
932 932
                 'request'     => $request->requestParams(),
933 933
             );
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
      */
943 943
     public static function trim_log()
944 944
     {
945
-        if (! EE_Config::logging_enabled()) {
945
+        if ( ! EE_Config::logging_enabled()) {
946 946
             return;
947 947
         }
948 948
         $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
     public static function get_page_for_posts()
967 967
     {
968 968
         $page_for_posts = get_option('page_for_posts');
969
-        if (! $page_for_posts) {
969
+        if ( ! $page_for_posts) {
970 970
             return 'posts';
971 971
         }
972 972
         global $wpdb;
@@ -1015,20 +1015,20 @@  discard block
 block discarded – undo
1015 1015
     {
1016 1016
         // only init widgets on admin pages when not in complete maintenance, and
1017 1017
         // on frontend when not in any maintenance mode
1018
-        if (! EE_Maintenance_Mode::instance()->level()
1018
+        if ( ! EE_Maintenance_Mode::instance()->level()
1019 1019
             || (
1020 1020
                 is_admin()
1021 1021
                 && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1022 1022
             )
1023 1023
         ) {
1024 1024
             // grab list of installed widgets
1025
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1025
+            $widgets_to_register = glob(EE_WIDGETS.'*', GLOB_ONLYDIR);
1026 1026
             // filter list of modules to register
1027 1027
             $widgets_to_register = apply_filters(
1028 1028
                 'FHEE__EE_Config__register_widgets__widgets_to_register',
1029 1029
                 $widgets_to_register
1030 1030
             );
1031
-            if (! empty($widgets_to_register)) {
1031
+            if ( ! empty($widgets_to_register)) {
1032 1032
                 // cycle thru widget folders
1033 1033
                 foreach ($widgets_to_register as $widget_path) {
1034 1034
                     // add to list of installed widget modules
@@ -1078,31 +1078,31 @@  discard block
 block discarded – undo
1078 1078
         // create classname from widget directory name
1079 1079
         $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1080 1080
         // add class prefix
1081
-        $widget_class = 'EEW_' . $widget;
1081
+        $widget_class = 'EEW_'.$widget;
1082 1082
         // does the widget exist ?
1083
-        if (! is_readable($widget_path . '/' . $widget_class . $widget_ext)) {
1083
+        if ( ! is_readable($widget_path.'/'.$widget_class.$widget_ext)) {
1084 1084
             $msg = sprintf(
1085 1085
                 __(
1086 1086
                     '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',
1087 1087
                     'event_espresso'
1088 1088
                 ),
1089 1089
                 $widget_class,
1090
-                $widget_path . '/' . $widget_class . $widget_ext
1090
+                $widget_path.'/'.$widget_class.$widget_ext
1091 1091
             );
1092
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1092
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1093 1093
             return;
1094 1094
         }
1095 1095
         // load the widget class file
1096
-        require_once($widget_path . '/' . $widget_class . $widget_ext);
1096
+        require_once($widget_path.'/'.$widget_class.$widget_ext);
1097 1097
         // verify that class exists
1098
-        if (! class_exists($widget_class)) {
1098
+        if ( ! class_exists($widget_class)) {
1099 1099
             $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1100
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1100
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1101 1101
             return;
1102 1102
         }
1103 1103
         register_widget($widget_class);
1104 1104
         // add to array of registered widgets
1105
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . '/' . $widget_class . $widget_ext;
1105
+        EE_Registry::instance()->widgets->{$widget_class} = $widget_path.'/'.$widget_class.$widget_ext;
1106 1106
     }
1107 1107
 
1108 1108
 
@@ -1115,18 +1115,18 @@  discard block
 block discarded – undo
1115 1115
     private function _register_modules()
1116 1116
     {
1117 1117
         // grab list of installed modules
1118
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1118
+        $modules_to_register = glob(EE_MODULES.'*', GLOB_ONLYDIR);
1119 1119
         // filter list of modules to register
1120 1120
         $modules_to_register = apply_filters(
1121 1121
             'FHEE__EE_Config__register_modules__modules_to_register',
1122 1122
             $modules_to_register
1123 1123
         );
1124
-        if (! empty($modules_to_register)) {
1124
+        if ( ! empty($modules_to_register)) {
1125 1125
             // loop through folders
1126 1126
             foreach ($modules_to_register as $module_path) {
1127 1127
                 /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1128
-                if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1129
-                    && $module_path !== EE_MODULES . 'gateways'
1128
+                if ($module_path !== EE_MODULES.'zzz-copy-this-module-template'
1129
+                    && $module_path !== EE_MODULES.'gateways'
1130 1130
                 ) {
1131 1131
                     // add to list of installed modules
1132 1132
                     EE_Config::register_module($module_path);
@@ -1163,25 +1163,25 @@  discard block
 block discarded – undo
1163 1163
             // remove last segment
1164 1164
             array_pop($module_path);
1165 1165
             // glue it back together
1166
-            $module_path = implode('/', $module_path) . '/';
1166
+            $module_path = implode('/', $module_path).'/';
1167 1167
             // take first segment from file name pieces and sanitize it
1168 1168
             $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1169 1169
             // ensure class prefix is added
1170
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1170
+            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_'.$module : $module;
1171 1171
         } else {
1172 1172
             // we need to generate the filename based off of the folder name
1173 1173
             // grab and sanitize module name
1174 1174
             $module = strtolower(basename($module_path));
1175 1175
             $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1176 1176
             // like trailingslashit()
1177
-            $module_path = rtrim($module_path, '/') . '/';
1177
+            $module_path = rtrim($module_path, '/').'/';
1178 1178
             // create classname from module directory name
1179 1179
             $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1180 1180
             // add class prefix
1181
-            $module_class = 'EED_' . $module;
1181
+            $module_class = 'EED_'.$module;
1182 1182
         }
1183 1183
         // does the module exist ?
1184
-        if (! is_readable($module_path . '/' . $module_class . $module_ext)) {
1184
+        if ( ! is_readable($module_path.'/'.$module_class.$module_ext)) {
1185 1185
             $msg = sprintf(
1186 1186
                 __(
1187 1187
                     'The requested %s module file could not be found or is not readable due to file permissions.',
@@ -1189,19 +1189,19 @@  discard block
 block discarded – undo
1189 1189
                 ),
1190 1190
                 $module
1191 1191
             );
1192
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1192
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1193 1193
             return false;
1194 1194
         }
1195 1195
         // load the module class file
1196
-        require_once($module_path . $module_class . $module_ext);
1196
+        require_once($module_path.$module_class.$module_ext);
1197 1197
         // verify that class exists
1198
-        if (! class_exists($module_class)) {
1198
+        if ( ! class_exists($module_class)) {
1199 1199
             $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1200
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1200
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1201 1201
             return false;
1202 1202
         }
1203 1203
         // add to array of registered modules
1204
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1204
+        EE_Registry::instance()->modules->{$module_class} = $module_path.$module_class.$module_ext;
1205 1205
         do_action(
1206 1206
             'AHEE__EE_Config__register_module__complete',
1207 1207
             $module_class,
@@ -1252,26 +1252,26 @@  discard block
 block discarded – undo
1252 1252
     {
1253 1253
         do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1254 1254
         $module = str_replace('EED_', '', $module);
1255
-        $module_class = 'EED_' . $module;
1256
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1255
+        $module_class = 'EED_'.$module;
1256
+        if ( ! isset(EE_Registry::instance()->modules->{$module_class})) {
1257 1257
             $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1258
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1258
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1259 1259
             return false;
1260 1260
         }
1261 1261
         if (empty($route)) {
1262 1262
             $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1263
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1263
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1264 1264
             return false;
1265 1265
         }
1266
-        if (! method_exists('EED_' . $module, $method_name)) {
1266
+        if ( ! method_exists('EED_'.$module, $method_name)) {
1267 1267
             $msg = sprintf(
1268 1268
                 __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1269 1269
                 $route
1270 1270
             );
1271
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1271
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1272 1272
             return false;
1273 1273
         }
1274
-        EE_Config::$_module_route_map[ (string) $key ][ (string) $route ] = array('EED_' . $module, $method_name);
1274
+        EE_Config::$_module_route_map[(string) $key][(string) $route] = array('EED_'.$module, $method_name);
1275 1275
         return true;
1276 1276
     }
1277 1277
 
@@ -1288,8 +1288,8 @@  discard block
 block discarded – undo
1288 1288
     {
1289 1289
         do_action('AHEE__EE_Config__get_route__begin', $route);
1290 1290
         $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1291
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1292
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1291
+        if (isset(EE_Config::$_module_route_map[$key][$route])) {
1292
+            return EE_Config::$_module_route_map[$key][$route];
1293 1293
         }
1294 1294
         return null;
1295 1295
     }
@@ -1321,47 +1321,47 @@  discard block
 block discarded – undo
1321 1321
     public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1322 1322
     {
1323 1323
         do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1324
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1324
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1325 1325
             $msg = sprintf(
1326 1326
                 __('The module route %s for this forward has not been registered.', 'event_espresso'),
1327 1327
                 $route
1328 1328
             );
1329
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1329
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1330 1330
             return false;
1331 1331
         }
1332 1332
         if (empty($forward)) {
1333 1333
             $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1334
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1334
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1335 1335
             return false;
1336 1336
         }
1337 1337
         if (is_array($forward)) {
1338
-            if (! isset($forward[1])) {
1338
+            if ( ! isset($forward[1])) {
1339 1339
                 $msg = sprintf(
1340 1340
                     __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1341 1341
                     $route
1342 1342
                 );
1343
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1343
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1344 1344
                 return false;
1345 1345
             }
1346
-            if (! method_exists($forward[0], $forward[1])) {
1346
+            if ( ! method_exists($forward[0], $forward[1])) {
1347 1347
                 $msg = sprintf(
1348 1348
                     __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1349 1349
                     $forward[1],
1350 1350
                     $route
1351 1351
                 );
1352
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1352
+                EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1353 1353
                 return false;
1354 1354
             }
1355
-        } elseif (! function_exists($forward)) {
1355
+        } elseif ( ! function_exists($forward)) {
1356 1356
             $msg = sprintf(
1357 1357
                 __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1358 1358
                 $forward,
1359 1359
                 $route
1360 1360
             );
1361
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1361
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1362 1362
             return false;
1363 1363
         }
1364
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1364
+        EE_Config::$_module_forward_map[$key][$route][absint($status)] = $forward;
1365 1365
         return true;
1366 1366
     }
1367 1367
 
@@ -1379,10 +1379,10 @@  discard block
 block discarded – undo
1379 1379
     public static function get_forward($route = null, $status = 0, $key = 'ee')
1380 1380
     {
1381 1381
         do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1382
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1382
+        if (isset(EE_Config::$_module_forward_map[$key][$route][$status])) {
1383 1383
             return apply_filters(
1384 1384
                 'FHEE__EE_Config__get_forward',
1385
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1385
+                EE_Config::$_module_forward_map[$key][$route][$status],
1386 1386
                 $route,
1387 1387
                 $status
1388 1388
             );
@@ -1406,15 +1406,15 @@  discard block
 block discarded – undo
1406 1406
     public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1407 1407
     {
1408 1408
         do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1409
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1409
+        if ( ! isset(EE_Config::$_module_route_map[$key][$route]) || empty($route)) {
1410 1410
             $msg = sprintf(
1411 1411
                 __('The module route %s for this view has not been registered.', 'event_espresso'),
1412 1412
                 $route
1413 1413
             );
1414
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1414
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1415 1415
             return false;
1416 1416
         }
1417
-        if (! is_readable($view)) {
1417
+        if ( ! is_readable($view)) {
1418 1418
             $msg = sprintf(
1419 1419
                 __(
1420 1420
                     'The %s view file could not be found or is not readable due to file permissions.',
@@ -1422,10 +1422,10 @@  discard block
 block discarded – undo
1422 1422
                 ),
1423 1423
                 $view
1424 1424
             );
1425
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1425
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
1426 1426
             return false;
1427 1427
         }
1428
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1428
+        EE_Config::$_module_view_map[$key][$route][absint($status)] = $view;
1429 1429
         return true;
1430 1430
     }
1431 1431
 
@@ -1443,10 +1443,10 @@  discard block
 block discarded – undo
1443 1443
     public static function get_view($route = null, $status = 0, $key = 'ee')
1444 1444
     {
1445 1445
         do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1446
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1446
+        if (isset(EE_Config::$_module_view_map[$key][$route][$status])) {
1447 1447
             return apply_filters(
1448 1448
                 'FHEE__EE_Config__get_view',
1449
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1449
+                EE_Config::$_module_view_map[$key][$route][$status],
1450 1450
                 $route,
1451 1451
                 $status
1452 1452
             );
@@ -1472,7 +1472,7 @@  discard block
 block discarded – undo
1472 1472
      */
1473 1473
     public static function getLegacyShortcodesManager()
1474 1474
     {
1475
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1475
+        if ( ! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1476 1476
             EE_Config::instance()->legacy_shortcodes_manager = LoaderFactory::getLoader()->getShared(
1477 1477
                 LegacyShortcodesManager::class
1478 1478
             );
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
      */
1520 1520
     public function get_pretty($property)
1521 1521
     {
1522
-        if (! property_exists($this, $property)) {
1522
+        if ( ! property_exists($this, $property)) {
1523 1523
             throw new EE_Error(
1524 1524
                 sprintf(
1525 1525
                     __(
@@ -1748,11 +1748,11 @@  discard block
 block discarded – undo
1748 1748
      */
1749 1749
     public function reg_page_url()
1750 1750
     {
1751
-        if (! $this->reg_page_url) {
1751
+        if ( ! $this->reg_page_url) {
1752 1752
             $this->reg_page_url = add_query_arg(
1753 1753
                 array('uts' => time()),
1754 1754
                 get_permalink($this->reg_page_id)
1755
-            ) . '#checkout';
1755
+            ).'#checkout';
1756 1756
         }
1757 1757
         return $this->reg_page_url;
1758 1758
     }
@@ -1768,7 +1768,7 @@  discard block
 block discarded – undo
1768 1768
      */
1769 1769
     public function txn_page_url($query_args = array())
1770 1770
     {
1771
-        if (! $this->txn_page_url) {
1771
+        if ( ! $this->txn_page_url) {
1772 1772
             $this->txn_page_url = get_permalink($this->txn_page_id);
1773 1773
         }
1774 1774
         if ($query_args) {
@@ -1789,7 +1789,7 @@  discard block
 block discarded – undo
1789 1789
      */
1790 1790
     public function thank_you_page_url($query_args = array())
1791 1791
     {
1792
-        if (! $this->thank_you_page_url) {
1792
+        if ( ! $this->thank_you_page_url) {
1793 1793
             $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1794 1794
         }
1795 1795
         if ($query_args) {
@@ -1808,7 +1808,7 @@  discard block
 block discarded – undo
1808 1808
      */
1809 1809
     public function cancel_page_url()
1810 1810
     {
1811
-        if (! $this->cancel_page_url) {
1811
+        if ( ! $this->cancel_page_url) {
1812 1812
             $this->cancel_page_url = get_permalink($this->cancel_page_id);
1813 1813
         }
1814 1814
         return $this->cancel_page_url;
@@ -1851,13 +1851,13 @@  discard block
 block discarded – undo
1851 1851
         $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1852 1852
         $option = self::OPTION_NAME_UXIP;
1853 1853
         // set correct table for query
1854
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1854
+        $table_name = $wpdb->get_blog_prefix($current_main_site_id).'options';
1855 1855
         // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1856 1856
         // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1857 1857
         // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1858 1858
         // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1859 1859
         // for the purpose of caching.
1860
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1860
+        $pre = apply_filters('pre_option_'.$option, false, $option);
1861 1861
         if (false !== $pre) {
1862 1862
             EE_Core_Config::$ee_ueip_option = $pre;
1863 1863
             return EE_Core_Config::$ee_ueip_option;
@@ -1871,10 +1871,10 @@  discard block
 block discarded – undo
1871 1871
         if (is_object($row)) {
1872 1872
             $value = $row->option_value;
1873 1873
         } else { // option does not exist so use default.
1874
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1874
+            EE_Core_Config::$ee_ueip_option = apply_filters('default_option_'.$option, false, $option);
1875 1875
             return EE_Core_Config::$ee_ueip_option;
1876 1876
         }
1877
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1877
+        EE_Core_Config::$ee_ueip_option = apply_filters('option_'.$option, maybe_unserialize($value), $option);
1878 1878
         return EE_Core_Config::$ee_ueip_option;
1879 1879
     }
1880 1880
 
@@ -2128,37 +2128,37 @@  discard block
 block discarded – undo
2128 2128
         // but override if requested
2129 2129
         $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2130 2130
         // 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
2131
-        if (! empty($CNT_ISO)
2131
+        if ( ! empty($CNT_ISO)
2132 2132
             && EE_Maintenance_Mode::instance()->models_can_query()
2133 2133
             && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2134 2134
         ) {
2135 2135
             // retrieve the country settings from the db, just in case they have been customized
2136 2136
             $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2137 2137
             if ($country instanceof EE_Country) {
2138
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2139
-                $this->name = $country->currency_name_single();    // Dollar
2140
-                $this->plural = $country->currency_name_plural();    // Dollars
2141
-                $this->sign = $country->currency_sign();            // currency sign: $
2138
+                $this->code = $country->currency_code(); // currency code: USD, CAD, EUR
2139
+                $this->name = $country->currency_name_single(); // Dollar
2140
+                $this->plural = $country->currency_name_plural(); // Dollars
2141
+                $this->sign = $country->currency_sign(); // currency sign: $
2142 2142
                 $this->sign_b4 = $country->currency_sign_before(
2143
-                );        // currency sign before or after: $TRUE  or  FALSE$
2144
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2143
+                ); // currency sign before or after: $TRUE  or  FALSE$
2144
+                $this->dec_plc = $country->currency_decimal_places(); // decimal places: 2 = 0.00  3 = 0.000
2145 2145
                 $this->dec_mrk = $country->currency_decimal_mark(
2146
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2146
+                ); // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2147 2147
                 $this->thsnds = $country->currency_thousands_separator(
2148
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2148
+                ); // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2149 2149
             }
2150 2150
         }
2151 2151
         // fallback to hardcoded defaults, in case the above failed
2152 2152
         if (empty($this->code)) {
2153 2153
             // set default currency settings
2154
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2155
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2156
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2157
-            $this->sign = '$';    // currency sign: $
2158
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2159
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2160
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2161
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2154
+            $this->code = 'USD'; // currency code: USD, CAD, EUR
2155
+            $this->name = __('Dollar', 'event_espresso'); // Dollar
2156
+            $this->plural = __('Dollars', 'event_espresso'); // Dollars
2157
+            $this->sign = '$'; // currency sign: $
2158
+            $this->sign_b4 = true; // currency sign before or after: $TRUE  or  FALSE$
2159
+            $this->dec_plc = 2; // decimal places: 2 = 0.00  3 = 0.000
2160
+            $this->dec_mrk = '.'; // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2161
+            $this->thsnds = ','; // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2162 2162
         }
2163 2163
     }
2164 2164
 }
@@ -2425,8 +2425,8 @@  discard block
 block discarded – undo
2425 2425
             $closing_a_tag = '';
2426 2426
             if (function_exists('get_privacy_policy_url')) {
2427 2427
                 $privacy_page_url = get_privacy_policy_url();
2428
-                if (! empty($privacy_page_url)) {
2429
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2428
+                if ( ! empty($privacy_page_url)) {
2429
+                    $opening_a_tag = '<a href="'.$privacy_page_url.'" target="_blank">';
2430 2430
                     $closing_a_tag = '</a>';
2431 2431
                 }
2432 2432
             }
@@ -2655,7 +2655,7 @@  discard block
 block discarded – undo
2655 2655
     public function log_file_name($reset = false)
2656 2656
     {
2657 2657
         if (empty($this->log_file_name) || $reset) {
2658
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2658
+            $this->log_file_name = sanitize_key('espresso_log_'.md5(uniqid('', true))).'.txt';
2659 2659
             EE_Config::instance()->update_espresso_config(false, false);
2660 2660
         }
2661 2661
         return $this->log_file_name;
@@ -2669,7 +2669,7 @@  discard block
 block discarded – undo
2669 2669
     public function debug_file_name($reset = false)
2670 2670
     {
2671 2671
         if (empty($this->debug_file_name) || $reset) {
2672
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2672
+            $this->debug_file_name = sanitize_key('espresso_debug_'.md5(uniqid('', true))).'.txt';
2673 2673
             EE_Config::instance()->update_espresso_config(false, false);
2674 2674
         }
2675 2675
         return $this->debug_file_name;
@@ -2873,21 +2873,21 @@  discard block
 block discarded – undo
2873 2873
         $this->use_google_maps = true;
2874 2874
         $this->google_map_api_key = '';
2875 2875
         // for event details pages (reg page)
2876
-        $this->event_details_map_width = 585;            // ee_map_width_single
2877
-        $this->event_details_map_height = 362;            // ee_map_height_single
2878
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2879
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2880
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2881
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2882
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2876
+        $this->event_details_map_width = 585; // ee_map_width_single
2877
+        $this->event_details_map_height = 362; // ee_map_height_single
2878
+        $this->event_details_map_zoom = 14; // ee_map_zoom_single
2879
+        $this->event_details_display_nav = true; // ee_map_nav_display_single
2880
+        $this->event_details_nav_size = false; // ee_map_nav_size_single
2881
+        $this->event_details_control_type = 'default'; // ee_map_type_control_single
2882
+        $this->event_details_map_align = 'center'; // ee_map_align_single
2883 2883
         // for event list pages
2884
-        $this->event_list_map_width = 300;            // ee_map_width
2885
-        $this->event_list_map_height = 185;        // ee_map_height
2886
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2887
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2888
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2889
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2890
-        $this->event_list_map_align = 'center';            // ee_map_align
2884
+        $this->event_list_map_width = 300; // ee_map_width
2885
+        $this->event_list_map_height = 185; // ee_map_height
2886
+        $this->event_list_map_zoom = 12; // ee_map_zoom
2887
+        $this->event_list_display_nav = false; // ee_map_nav_display
2888
+        $this->event_list_nav_size = true; // ee_map_nav_size
2889
+        $this->event_list_control_type = 'dropdown'; // ee_map_type_control
2890
+        $this->event_list_map_align = 'center'; // ee_map_align
2891 2891
     }
2892 2892
 }
2893 2893
 
@@ -3205,7 +3205,7 @@  discard block
 block discarded – undo
3205 3205
      */
3206 3206
     public function max_input_vars_limit_check($input_count = 0)
3207 3207
     {
3208
-        if (! empty($this->php->max_input_vars)
3208
+        if ( ! empty($this->php->max_input_vars)
3209 3209
             && ($input_count >= $this->php->max_input_vars)
3210 3210
         ) {
3211 3211
             // check the server setting because the config value could be stale
Please login to merge, or discard this patch.
core/db_models/EEM_Transaction.model.php 1 patch
Indentation   +457 added lines, -457 removed lines patch added patch discarded remove patch
@@ -20,231 +20,231 @@  discard block
 block discarded – undo
20 20
 class EEM_Transaction extends EEM_Base
21 21
 {
22 22
 
23
-    // private instance of the Transaction object
24
-    protected static $_instance;
25
-
26
-    /**
27
-     * Status ID(STS_ID on esp_status table) to indicate the transaction is complete,
28
-     * but payment is pending. This is the state for transactions where payment is promised
29
-     * from an offline gateway.
30
-     */
31
-    //  const open_status_code = 'TPN';
32
-
33
-    /**
34
-     * Status ID(STS_ID on esp_status table) to indicate the transaction failed,
35
-     * either due to a technical reason (server or computer crash during registration),
36
-     *  or some other reason that prevent the collection of any useful contact information from any of the registrants
37
-     */
38
-    const failed_status_code = 'TFL';
39
-
40
-    /**
41
-     * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned,
42
-     * either due to a technical reason (server or computer crash during registration),
43
-     * or due to an abandoned cart after registrant chose not to complete the registration process
44
-     * HOWEVER...
45
-     * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one
46
-     * registrant
47
-     */
48
-    const abandoned_status_code = 'TAB';
49
-
50
-    /**
51
-     * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction,
52
-     * meaning that monies are still owing: TXN_paid < TXN_total
53
-     */
54
-    const incomplete_status_code = 'TIN';
55
-
56
-    /**
57
-     * Status ID (STS_ID on esp_status table) to indicate a complete transaction.
58
-     * meaning that NO monies are owing: TXN_paid == TXN_total
59
-     */
60
-    const complete_status_code = 'TCM';
61
-
62
-    /**
63
-     *  Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid.
64
-     *  This is the same as complete, but site admins actually owe clients the moneys!  TXN_paid > TXN_total
65
-     */
66
-    const overpaid_status_code = 'TOP';
67
-
68
-
69
-    /**
70
-     *    private constructor to prevent direct creation
71
-     *
72
-     * @Constructor
73
-     * @access protected
74
-     *
75
-     * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
76
-     *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
77
-     *                         date time model field objects.  Default is NULL (and will be assumed using the set
78
-     *                         timezone in the 'timezone_string' wp option)
79
-     *
80
-     * @throws EE_Error
81
-     */
82
-    protected function __construct($timezone)
83
-    {
84
-        $this->singular_item = __('Transaction', 'event_espresso');
85
-        $this->plural_item   = __('Transactions', 'event_espresso');
86
-
87
-        $this->_tables                 = [
88
-            'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID'),
89
-        ];
90
-        $this->_fields                 = [
91
-            'TransactionTable' => [
92
-                'TXN_ID'           => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')),
93
-                'TXN_timestamp'    => new EE_Datetime_Field(
94
-                    'TXN_timestamp',
95
-                    __('date when transaction was created', 'event_espresso'),
96
-                    false,
97
-                    EE_Datetime_Field::now,
98
-                    $timezone
99
-                ),
100
-                'TXN_total'        => new EE_Money_Field(
101
-                    'TXN_total',
102
-                    __('Total value of Transaction', 'event_espresso'),
103
-                    false,
104
-                    0
105
-                ),
106
-                'TXN_paid'         => new EE_Money_Field(
107
-                    'TXN_paid',
108
-                    __('Amount paid towards transaction to date', 'event_espresso'),
109
-                    false,
110
-                    0
111
-                ),
112
-                'STS_ID'           => new EE_Foreign_Key_String_Field(
113
-                    'STS_ID',
114
-                    __('Status ID', 'event_espresso'),
115
-                    false,
116
-                    EEM_Transaction::failed_status_code,
117
-                    'Status'
118
-                ),
119
-                'TXN_session_data' => new EE_Serialized_Text_Field(
120
-                    'TXN_session_data',
121
-                    __('Serialized session data', 'event_espresso'),
122
-                    true,
123
-                    ''
124
-                ),
125
-                'TXN_hash_salt'    => new EE_Plain_Text_Field(
126
-                    'TXN_hash_salt',
127
-                    __('Transaction Hash Salt', 'event_espresso'),
128
-                    true,
129
-                    ''
130
-                ),
131
-                'PMD_ID'           => new EE_Foreign_Key_Int_Field(
132
-                    'PMD_ID',
133
-                    __("Last Used Payment Method", 'event_espresso'),
134
-                    true,
135
-                    null,
136
-                    'Payment_Method'
137
-                ),
138
-                'TXN_reg_steps'    => new EE_Serialized_Text_Field(
139
-                    'TXN_reg_steps',
140
-                    __('Registration Steps', 'event_espresso'),
141
-                    false,
142
-                    []
143
-                ),
144
-            ],
145
-        ];
146
-        $this->_model_relations        = [
147
-            'Registration'   => new EE_Has_Many_Relation(),
148
-            'Payment'        => new EE_Has_Many_Relation(),
149
-            'Status'         => new EE_Belongs_To_Relation(),
150
-            'Line_Item'      => new EE_Has_Many_Relation(false),
151
-            // you can delete a transaction without needing to delete its line items
152
-            'Payment_Method' => new EE_Belongs_To_Relation(),
153
-            'Message'        => new EE_Has_Many_Relation(),
154
-        ];
155
-        $this->_model_chain_to_wp_user = 'Registration.Event';
156
-        parent::__construct($timezone);
157
-    }
158
-
159
-
160
-    /**
161
-     *    txn_status_array
162
-     * get list of transaction statuses
163
-     *
164
-     * @access public
165
-     * @return array
166
-     */
167
-    public static function txn_status_array()
168
-    {
169
-        return apply_filters(
170
-            'FHEE__EEM_Transaction__txn_status_array',
171
-            [
172
-                EEM_Transaction::overpaid_status_code,
173
-                EEM_Transaction::complete_status_code,
174
-                EEM_Transaction::incomplete_status_code,
175
-                EEM_Transaction::abandoned_status_code,
176
-                EEM_Transaction::failed_status_code,
177
-            ]
178
-        );
179
-    }
180
-
181
-
182
-    /**
183
-     *        get the revenue per day  for the Transaction Admin page Reports Tab
184
-     *
185
-     * @access        public
186
-     *
187
-     * @param string $period
188
-     *
189
-     * @return stdClass[]
190
-     * @throws EE_Error
191
-     * @throws EE_Error
192
-     */
193
-    public function get_revenue_per_day_report($period = '-1 month')
194
-    {
195
-        $sql_date = $this->convert_datetime_for_query(
196
-            'TXN_timestamp',
197
-            date('Y-m-d H:i:s', strtotime($period)),
198
-            'Y-m-d H:i:s',
199
-            'UTC'
200
-        );
201
-
202
-        $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp');
203
-
204
-        return $this->_get_all_wpdb_results(
205
-            [
206
-                [
207
-                    'TXN_timestamp' => ['>=', $sql_date],
208
-                ],
209
-                'group_by' => 'txnDate',
210
-                'order_by' => ['TXN_timestamp' => 'ASC'],
211
-            ],
212
-            OBJECT,
213
-            [
214
-                'txnDate' => ['DATE(' . $query_interval . ')', '%s'],
215
-                'revenue' => ['SUM(TransactionTable.TXN_paid)', '%d'],
216
-            ]
217
-        );
218
-    }
219
-
220
-
221
-    /**
222
-     *        get the revenue per event  for the Transaction Admin page Reports Tab
223
-     *
224
-     * @access        public
225
-     *
226
-     * @param string $period
227
-     *
228
-     * @return EE_Transaction[]
229
-     */
230
-    public function get_revenue_per_event_report($period = '-1 month')
231
-    {
232
-        global $wpdb;
233
-        $transaction_table          = $wpdb->prefix . 'esp_transaction';
234
-        $registration_table         = $wpdb->prefix . 'esp_registration';
235
-        $registration_payment_table = $wpdb->prefix . 'esp_registration_payment';
236
-        $event_table                = $wpdb->posts;
237
-        $payment_table              = $wpdb->prefix . 'esp_payment';
238
-        $sql_date                   = date('Y-m-d H:i:s', strtotime($period));
239
-        $approved_payment_status    = EEM_Payment::status_id_approved;
240
-        $extra_event_on_join        = '';
241
-        // exclude events not authored by user if permissions in effect
242
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
243
-            $extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
244
-        }
245
-
246
-        return $wpdb->get_results(
247
-            "SELECT
23
+	// private instance of the Transaction object
24
+	protected static $_instance;
25
+
26
+	/**
27
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction is complete,
28
+	 * but payment is pending. This is the state for transactions where payment is promised
29
+	 * from an offline gateway.
30
+	 */
31
+	//  const open_status_code = 'TPN';
32
+
33
+	/**
34
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction failed,
35
+	 * either due to a technical reason (server or computer crash during registration),
36
+	 *  or some other reason that prevent the collection of any useful contact information from any of the registrants
37
+	 */
38
+	const failed_status_code = 'TFL';
39
+
40
+	/**
41
+	 * Status ID(STS_ID on esp_status table) to indicate the transaction was abandoned,
42
+	 * either due to a technical reason (server or computer crash during registration),
43
+	 * or due to an abandoned cart after registrant chose not to complete the registration process
44
+	 * HOWEVER...
45
+	 * an abandoned TXN differs from a failed TXN in that it was able to capture contact information for at least one
46
+	 * registrant
47
+	 */
48
+	const abandoned_status_code = 'TAB';
49
+
50
+	/**
51
+	 * Status ID(STS_ID on esp_status table) to indicate an incomplete transaction,
52
+	 * meaning that monies are still owing: TXN_paid < TXN_total
53
+	 */
54
+	const incomplete_status_code = 'TIN';
55
+
56
+	/**
57
+	 * Status ID (STS_ID on esp_status table) to indicate a complete transaction.
58
+	 * meaning that NO monies are owing: TXN_paid == TXN_total
59
+	 */
60
+	const complete_status_code = 'TCM';
61
+
62
+	/**
63
+	 *  Status ID(STS_ID on esp_status table) to indicate the transaction is overpaid.
64
+	 *  This is the same as complete, but site admins actually owe clients the moneys!  TXN_paid > TXN_total
65
+	 */
66
+	const overpaid_status_code = 'TOP';
67
+
68
+
69
+	/**
70
+	 *    private constructor to prevent direct creation
71
+	 *
72
+	 * @Constructor
73
+	 * @access protected
74
+	 *
75
+	 * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any
76
+	 *                         incoming timezone data that gets saved). Note this just sends the timezone info to the
77
+	 *                         date time model field objects.  Default is NULL (and will be assumed using the set
78
+	 *                         timezone in the 'timezone_string' wp option)
79
+	 *
80
+	 * @throws EE_Error
81
+	 */
82
+	protected function __construct($timezone)
83
+	{
84
+		$this->singular_item = __('Transaction', 'event_espresso');
85
+		$this->plural_item   = __('Transactions', 'event_espresso');
86
+
87
+		$this->_tables                 = [
88
+			'TransactionTable' => new EE_Primary_Table('esp_transaction', 'TXN_ID'),
89
+		];
90
+		$this->_fields                 = [
91
+			'TransactionTable' => [
92
+				'TXN_ID'           => new EE_Primary_Key_Int_Field('TXN_ID', __('Transaction ID', 'event_espresso')),
93
+				'TXN_timestamp'    => new EE_Datetime_Field(
94
+					'TXN_timestamp',
95
+					__('date when transaction was created', 'event_espresso'),
96
+					false,
97
+					EE_Datetime_Field::now,
98
+					$timezone
99
+				),
100
+				'TXN_total'        => new EE_Money_Field(
101
+					'TXN_total',
102
+					__('Total value of Transaction', 'event_espresso'),
103
+					false,
104
+					0
105
+				),
106
+				'TXN_paid'         => new EE_Money_Field(
107
+					'TXN_paid',
108
+					__('Amount paid towards transaction to date', 'event_espresso'),
109
+					false,
110
+					0
111
+				),
112
+				'STS_ID'           => new EE_Foreign_Key_String_Field(
113
+					'STS_ID',
114
+					__('Status ID', 'event_espresso'),
115
+					false,
116
+					EEM_Transaction::failed_status_code,
117
+					'Status'
118
+				),
119
+				'TXN_session_data' => new EE_Serialized_Text_Field(
120
+					'TXN_session_data',
121
+					__('Serialized session data', 'event_espresso'),
122
+					true,
123
+					''
124
+				),
125
+				'TXN_hash_salt'    => new EE_Plain_Text_Field(
126
+					'TXN_hash_salt',
127
+					__('Transaction Hash Salt', 'event_espresso'),
128
+					true,
129
+					''
130
+				),
131
+				'PMD_ID'           => new EE_Foreign_Key_Int_Field(
132
+					'PMD_ID',
133
+					__("Last Used Payment Method", 'event_espresso'),
134
+					true,
135
+					null,
136
+					'Payment_Method'
137
+				),
138
+				'TXN_reg_steps'    => new EE_Serialized_Text_Field(
139
+					'TXN_reg_steps',
140
+					__('Registration Steps', 'event_espresso'),
141
+					false,
142
+					[]
143
+				),
144
+			],
145
+		];
146
+		$this->_model_relations        = [
147
+			'Registration'   => new EE_Has_Many_Relation(),
148
+			'Payment'        => new EE_Has_Many_Relation(),
149
+			'Status'         => new EE_Belongs_To_Relation(),
150
+			'Line_Item'      => new EE_Has_Many_Relation(false),
151
+			// you can delete a transaction without needing to delete its line items
152
+			'Payment_Method' => new EE_Belongs_To_Relation(),
153
+			'Message'        => new EE_Has_Many_Relation(),
154
+		];
155
+		$this->_model_chain_to_wp_user = 'Registration.Event';
156
+		parent::__construct($timezone);
157
+	}
158
+
159
+
160
+	/**
161
+	 *    txn_status_array
162
+	 * get list of transaction statuses
163
+	 *
164
+	 * @access public
165
+	 * @return array
166
+	 */
167
+	public static function txn_status_array()
168
+	{
169
+		return apply_filters(
170
+			'FHEE__EEM_Transaction__txn_status_array',
171
+			[
172
+				EEM_Transaction::overpaid_status_code,
173
+				EEM_Transaction::complete_status_code,
174
+				EEM_Transaction::incomplete_status_code,
175
+				EEM_Transaction::abandoned_status_code,
176
+				EEM_Transaction::failed_status_code,
177
+			]
178
+		);
179
+	}
180
+
181
+
182
+	/**
183
+	 *        get the revenue per day  for the Transaction Admin page Reports Tab
184
+	 *
185
+	 * @access        public
186
+	 *
187
+	 * @param string $period
188
+	 *
189
+	 * @return stdClass[]
190
+	 * @throws EE_Error
191
+	 * @throws EE_Error
192
+	 */
193
+	public function get_revenue_per_day_report($period = '-1 month')
194
+	{
195
+		$sql_date = $this->convert_datetime_for_query(
196
+			'TXN_timestamp',
197
+			date('Y-m-d H:i:s', strtotime($period)),
198
+			'Y-m-d H:i:s',
199
+			'UTC'
200
+		);
201
+
202
+		$query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'TXN_timestamp');
203
+
204
+		return $this->_get_all_wpdb_results(
205
+			[
206
+				[
207
+					'TXN_timestamp' => ['>=', $sql_date],
208
+				],
209
+				'group_by' => 'txnDate',
210
+				'order_by' => ['TXN_timestamp' => 'ASC'],
211
+			],
212
+			OBJECT,
213
+			[
214
+				'txnDate' => ['DATE(' . $query_interval . ')', '%s'],
215
+				'revenue' => ['SUM(TransactionTable.TXN_paid)', '%d'],
216
+			]
217
+		);
218
+	}
219
+
220
+
221
+	/**
222
+	 *        get the revenue per event  for the Transaction Admin page Reports Tab
223
+	 *
224
+	 * @access        public
225
+	 *
226
+	 * @param string $period
227
+	 *
228
+	 * @return EE_Transaction[]
229
+	 */
230
+	public function get_revenue_per_event_report($period = '-1 month')
231
+	{
232
+		global $wpdb;
233
+		$transaction_table          = $wpdb->prefix . 'esp_transaction';
234
+		$registration_table         = $wpdb->prefix . 'esp_registration';
235
+		$registration_payment_table = $wpdb->prefix . 'esp_registration_payment';
236
+		$event_table                = $wpdb->posts;
237
+		$payment_table              = $wpdb->prefix . 'esp_payment';
238
+		$sql_date                   = date('Y-m-d H:i:s', strtotime($period));
239
+		$approved_payment_status    = EEM_Payment::status_id_approved;
240
+		$extra_event_on_join        = '';
241
+		// exclude events not authored by user if permissions in effect
242
+		if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) {
243
+			$extra_event_on_join = ' AND Event.post_author = ' . get_current_user_id();
244
+		}
245
+
246
+		return $wpdb->get_results(
247
+			"SELECT
248 248
 			Transaction_Event.event_name AS event_name,
249 249
 			SUM(Transaction_Event.paid) AS revenue
250 250
 			FROM
@@ -272,236 +272,236 @@  discard block
 block discarded – undo
272 272
 					$extra_event_on_join
273 273
 				) AS Transaction_Event
274 274
 			GROUP BY event_name"
275
-        );
276
-    }
277
-
278
-
279
-    /**
280
-     * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the
281
-     * request global variable. Either way, tries to find the current transaction (through
282
-     * the registration pointed to by reg_url_link), if not returns null
283
-     *
284
-     * @param string $reg_url_link
285
-     *
286
-     * @return EE_Transaction
287
-     * @throws EE_Error
288
-     */
289
-    public function get_transaction_from_reg_url_link($reg_url_link = '')
290
-    {
291
-        if (empty($reg_url_link)) {
292
-            $request      = LoaderFactory::getLoader()->getShared(RequestInterface::class);
293
-            $reg_url_link = $request->getRequestParam('e_reg_url_link');
294
-        }
295
-        return $this->get_one(
296
-            [
297
-                [
298
-                    'Registration.REG_url_link' => $reg_url_link,
299
-                ],
300
-            ]
301
-        );
302
-    }
303
-
304
-
305
-    /**
306
-     * Updates the provided EE_Transaction with all the applicable payments
307
-     * (or fetch the EE_Transaction from its ID)
308
-     *
309
-     * @param EE_Transaction|int $transaction_obj_or_id
310
-     * @param boolean            $save_txn whether or not to save the transaction during this function call
311
-     *
312
-     * @return array
313
-     * @throws EE_Error
314
-     * @throws ReflectionException
315
-     * @deprecated
316
-     *
317
-     */
318
-    public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
319
-    {
320
-        EE_Error::doing_it_wrong(
321
-            __CLASS__ . '::' . __FUNCTION__,
322
-            sprintf(
323
-                __('This method is deprecated. Please use "%s" instead', 'event_espresso'),
324
-                'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'
325
-            ),
326
-            '4.6.0'
327
-        );
328
-        /** @type EE_Transaction_Processor $transaction_processor */
329
-        $transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
330
-
331
-        return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
332
-            $this->ensure_is_obj($transaction_obj_or_id)
333
-        );
334
-    }
335
-
336
-
337
-    /**
338
-     * Deletes "junk" transactions that were probably added by bots. There might be TONS
339
-     * of these, so we are very careful to NOT select (which the models do even when deleting),
340
-     * and so we only use wpdb directly and only do minimal joins.
341
-     * Transactions are considered "junk" if they're failed for longer than a week.
342
-     * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on
343
-     * it, it's probably not junk (regardless of what status it has).
344
-     * The downside to this approach is that is addons are listening for object deletions
345
-     * on EEM_Base::delete() they won't be notified of this.  However, there is an action that plugins can hook into
346
-     * to catch these types of deletions.
347
-     *
348
-     * @return int
349
-     * @throws EE_Error
350
-     * @throws EE_Error
351
-     * @global WPDB $wpdb
352
-     */
353
-    public function delete_junk_transactions()
354
-    {
355
-        global $wpdb;
356
-        $deleted             = false;
357
-        $time_to_leave_alone = (int) apply_filters(
358
-            'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone',
359
-            WEEK_IN_SECONDS
360
-        );
361
-
362
-
363
-        /**
364
-         * This allows code to filter the query arguments used for retrieving the transaction IDs to delete.
365
-         * Useful for plugins that want to exclude transactions matching certain query parameters.
366
-         * The query parameters should be in the format accepted by the EEM_Base model queries.
367
-         */
368
-        $ids_query = apply_filters(
369
-            'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args',
370
-            [
371
-                0          => [
372
-                    'STS_ID'         => EEM_Transaction::failed_status_code,
373
-                    'Payment.PAY_ID' => ['IS NULL'],
374
-                    'TXN_timestamp'  => ['<', time() - $time_to_leave_alone],
375
-                ],
376
-                'order_by' => ['TXN_timestamp' => 'ASC'],
377
-                'limit'    => 1000,
378
-            ],
379
-            $time_to_leave_alone
380
-        );
381
-
382
-
383
-        /**
384
-         * This filter is for when code needs to filter the list of transaction ids that represent transactions
385
-         * about to be deleted based on some other criteria that isn't easily done via the query args filter.
386
-         */
387
-        $txn_ids = apply_filters(
388
-            'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete',
389
-            EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'),
390
-            $time_to_leave_alone
391
-        );
392
-        // now that we have the ids to delete
393
-        if (! empty($txn_ids) && is_array($txn_ids)) {
394
-            // first, make sure these TXN's are removed the "ee_locked_transactions" array
395
-            EEM_Transaction::unset_locked_transactions($txn_ids);
396
-
397
-            // Create IDs placeholder.
398
-            $placeholders = array_fill(0, count($txn_ids), '%d');
399
-
400
-            // Glue it together to use inside $wpdb->prepare.
401
-            $format = implode(', ', $placeholders);
402
-
403
-            // let's get deleting...
404
-            // We got the ids from the original query to get them FROM
405
-            // the db (which is sanitized) so no need to prepare them again.
406
-            $query   = $wpdb->prepare("DELETE FROM " . $this->table() . " WHERE TXN_ID IN ( $format )", $txn_ids);
407
-            $deleted = $wpdb->query($query);
408
-        }
409
-        if ($deleted) {
410
-            /**
411
-             * Allows code to do something after the transactions have been deleted.
412
-             */
413
-            do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids);
414
-        }
415
-
416
-        return $deleted;
417
-    }
418
-
419
-
420
-    /**
421
-     * @param array $transaction_IDs
422
-     *
423
-     * @return bool
424
-     */
425
-    public static function unset_locked_transactions(array $transaction_IDs)
426
-    {
427
-        $locked_transactions = get_option('ee_locked_transactions', []);
428
-        $update              = false;
429
-        foreach ($transaction_IDs as $TXN_ID) {
430
-            if (isset($locked_transactions[ $TXN_ID ])) {
431
-                unset($locked_transactions[ $TXN_ID ]);
432
-                $update = true;
433
-            }
434
-        }
435
-        if ($update) {
436
-            update_option('ee_locked_transactions', $locked_transactions);
437
-        }
438
-
439
-        return $update;
440
-    }
441
-
442
-
443
-    /**
444
-     * returns an array of EE_Transaction objects whose timestamp is greater than
445
-     * the current time minus the session lifespan, which defaults to 60 minutes
446
-     *
447
-     * @return EE_Base_Class[]|EE_Transaction[]
448
-     * @throws EE_Error
449
-     * @throws InvalidArgumentException
450
-     * @throws InvalidDataTypeException
451
-     * @throws InvalidInterfaceException
452
-     */
453
-    public function get_transactions_in_progress()
454
-    {
455
-        return $this->_get_transactions_in_progress();
456
-    }
457
-
458
-
459
-    /**
460
-     * returns an array of EE_Transaction objects whose timestamp is less than
461
-     * the current time minus the session lifespan, which defaults to 60 minutes
462
-     *
463
-     * @return EE_Base_Class[]|EE_Transaction[]
464
-     * @throws EE_Error
465
-     * @throws InvalidArgumentException
466
-     * @throws InvalidDataTypeException
467
-     * @throws InvalidInterfaceException
468
-     */
469
-    public function get_transactions_not_in_progress()
470
-    {
471
-        return $this->_get_transactions_in_progress('<=');
472
-    }
473
-
474
-
475
-    /**
476
-     * @param string $comparison
477
-     * @return EE_Transaction[]
478
-     * @throws EE_Error
479
-     * @throws InvalidArgumentException
480
-     * @throws InvalidDataTypeException
481
-     * @throws InvalidInterfaceException
482
-     */
483
-    private function _get_transactions_in_progress($comparison = '>=')
484
-    {
485
-        $comparison = $comparison === '>=' || $comparison === '<='
486
-            ? $comparison
487
-            : '>=';
488
-        /** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
489
-        $session_lifespan = LoaderFactory::getLoader()->getShared(
490
-            'EventEspresso\core\domain\values\session\SessionLifespan'
491
-        );
492
-        return $this->get_all(
493
-            [
494
-                [
495
-                    'TXN_timestamp' => [
496
-                        $comparison,
497
-                        $session_lifespan->expiration(),
498
-                    ],
499
-                    'STS_ID'        => [
500
-                        '!=',
501
-                        EEM_Transaction::complete_status_code,
502
-                    ],
503
-                ],
504
-            ]
505
-        );
506
-    }
275
+		);
276
+	}
277
+
278
+
279
+	/**
280
+	 * Gets the current transaction given the reg_url_link, or assumes the reg_url_link is in the
281
+	 * request global variable. Either way, tries to find the current transaction (through
282
+	 * the registration pointed to by reg_url_link), if not returns null
283
+	 *
284
+	 * @param string $reg_url_link
285
+	 *
286
+	 * @return EE_Transaction
287
+	 * @throws EE_Error
288
+	 */
289
+	public function get_transaction_from_reg_url_link($reg_url_link = '')
290
+	{
291
+		if (empty($reg_url_link)) {
292
+			$request      = LoaderFactory::getLoader()->getShared(RequestInterface::class);
293
+			$reg_url_link = $request->getRequestParam('e_reg_url_link');
294
+		}
295
+		return $this->get_one(
296
+			[
297
+				[
298
+					'Registration.REG_url_link' => $reg_url_link,
299
+				],
300
+			]
301
+		);
302
+	}
303
+
304
+
305
+	/**
306
+	 * Updates the provided EE_Transaction with all the applicable payments
307
+	 * (or fetch the EE_Transaction from its ID)
308
+	 *
309
+	 * @param EE_Transaction|int $transaction_obj_or_id
310
+	 * @param boolean            $save_txn whether or not to save the transaction during this function call
311
+	 *
312
+	 * @return array
313
+	 * @throws EE_Error
314
+	 * @throws ReflectionException
315
+	 * @deprecated
316
+	 *
317
+	 */
318
+	public function update_based_on_payments($transaction_obj_or_id, $save_txn = true)
319
+	{
320
+		EE_Error::doing_it_wrong(
321
+			__CLASS__ . '::' . __FUNCTION__,
322
+			sprintf(
323
+				__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
324
+				'EE_Transaction_Processor::update_transaction_and_registrations_after_checkout_or_payment()'
325
+			),
326
+			'4.6.0'
327
+		);
328
+		/** @type EE_Transaction_Processor $transaction_processor */
329
+		$transaction_processor = EE_Registry::instance()->load_class('Transaction_Processor');
330
+
331
+		return $transaction_processor->update_transaction_and_registrations_after_checkout_or_payment(
332
+			$this->ensure_is_obj($transaction_obj_or_id)
333
+		);
334
+	}
335
+
336
+
337
+	/**
338
+	 * Deletes "junk" transactions that were probably added by bots. There might be TONS
339
+	 * of these, so we are very careful to NOT select (which the models do even when deleting),
340
+	 * and so we only use wpdb directly and only do minimal joins.
341
+	 * Transactions are considered "junk" if they're failed for longer than a week.
342
+	 * Also, there is an extra check for payments related to the transaction, because if a transaction has a payment on
343
+	 * it, it's probably not junk (regardless of what status it has).
344
+	 * The downside to this approach is that is addons are listening for object deletions
345
+	 * on EEM_Base::delete() they won't be notified of this.  However, there is an action that plugins can hook into
346
+	 * to catch these types of deletions.
347
+	 *
348
+	 * @return int
349
+	 * @throws EE_Error
350
+	 * @throws EE_Error
351
+	 * @global WPDB $wpdb
352
+	 */
353
+	public function delete_junk_transactions()
354
+	{
355
+		global $wpdb;
356
+		$deleted             = false;
357
+		$time_to_leave_alone = (int) apply_filters(
358
+			'FHEE__EEM_Transaction__delete_junk_transactions__time_to_leave_alone',
359
+			WEEK_IN_SECONDS
360
+		);
361
+
362
+
363
+		/**
364
+		 * This allows code to filter the query arguments used for retrieving the transaction IDs to delete.
365
+		 * Useful for plugins that want to exclude transactions matching certain query parameters.
366
+		 * The query parameters should be in the format accepted by the EEM_Base model queries.
367
+		 */
368
+		$ids_query = apply_filters(
369
+			'FHEE__EEM_Transaction__delete_junk_transactions__initial_query_args',
370
+			[
371
+				0          => [
372
+					'STS_ID'         => EEM_Transaction::failed_status_code,
373
+					'Payment.PAY_ID' => ['IS NULL'],
374
+					'TXN_timestamp'  => ['<', time() - $time_to_leave_alone],
375
+				],
376
+				'order_by' => ['TXN_timestamp' => 'ASC'],
377
+				'limit'    => 1000,
378
+			],
379
+			$time_to_leave_alone
380
+		);
381
+
382
+
383
+		/**
384
+		 * This filter is for when code needs to filter the list of transaction ids that represent transactions
385
+		 * about to be deleted based on some other criteria that isn't easily done via the query args filter.
386
+		 */
387
+		$txn_ids = apply_filters(
388
+			'FHEE__EEM_Transaction__delete_junk_transactions__transaction_ids_to_delete',
389
+			EEM_Transaction::instance()->get_col($ids_query, 'TXN_ID'),
390
+			$time_to_leave_alone
391
+		);
392
+		// now that we have the ids to delete
393
+		if (! empty($txn_ids) && is_array($txn_ids)) {
394
+			// first, make sure these TXN's are removed the "ee_locked_transactions" array
395
+			EEM_Transaction::unset_locked_transactions($txn_ids);
396
+
397
+			// Create IDs placeholder.
398
+			$placeholders = array_fill(0, count($txn_ids), '%d');
399
+
400
+			// Glue it together to use inside $wpdb->prepare.
401
+			$format = implode(', ', $placeholders);
402
+
403
+			// let's get deleting...
404
+			// We got the ids from the original query to get them FROM
405
+			// the db (which is sanitized) so no need to prepare them again.
406
+			$query   = $wpdb->prepare("DELETE FROM " . $this->table() . " WHERE TXN_ID IN ( $format )", $txn_ids);
407
+			$deleted = $wpdb->query($query);
408
+		}
409
+		if ($deleted) {
410
+			/**
411
+			 * Allows code to do something after the transactions have been deleted.
412
+			 */
413
+			do_action('AHEE__EEM_Transaction__delete_junk_transactions__successful_deletion', $txn_ids);
414
+		}
415
+
416
+		return $deleted;
417
+	}
418
+
419
+
420
+	/**
421
+	 * @param array $transaction_IDs
422
+	 *
423
+	 * @return bool
424
+	 */
425
+	public static function unset_locked_transactions(array $transaction_IDs)
426
+	{
427
+		$locked_transactions = get_option('ee_locked_transactions', []);
428
+		$update              = false;
429
+		foreach ($transaction_IDs as $TXN_ID) {
430
+			if (isset($locked_transactions[ $TXN_ID ])) {
431
+				unset($locked_transactions[ $TXN_ID ]);
432
+				$update = true;
433
+			}
434
+		}
435
+		if ($update) {
436
+			update_option('ee_locked_transactions', $locked_transactions);
437
+		}
438
+
439
+		return $update;
440
+	}
441
+
442
+
443
+	/**
444
+	 * returns an array of EE_Transaction objects whose timestamp is greater than
445
+	 * the current time minus the session lifespan, which defaults to 60 minutes
446
+	 *
447
+	 * @return EE_Base_Class[]|EE_Transaction[]
448
+	 * @throws EE_Error
449
+	 * @throws InvalidArgumentException
450
+	 * @throws InvalidDataTypeException
451
+	 * @throws InvalidInterfaceException
452
+	 */
453
+	public function get_transactions_in_progress()
454
+	{
455
+		return $this->_get_transactions_in_progress();
456
+	}
457
+
458
+
459
+	/**
460
+	 * returns an array of EE_Transaction objects whose timestamp is less than
461
+	 * the current time minus the session lifespan, which defaults to 60 minutes
462
+	 *
463
+	 * @return EE_Base_Class[]|EE_Transaction[]
464
+	 * @throws EE_Error
465
+	 * @throws InvalidArgumentException
466
+	 * @throws InvalidDataTypeException
467
+	 * @throws InvalidInterfaceException
468
+	 */
469
+	public function get_transactions_not_in_progress()
470
+	{
471
+		return $this->_get_transactions_in_progress('<=');
472
+	}
473
+
474
+
475
+	/**
476
+	 * @param string $comparison
477
+	 * @return EE_Transaction[]
478
+	 * @throws EE_Error
479
+	 * @throws InvalidArgumentException
480
+	 * @throws InvalidDataTypeException
481
+	 * @throws InvalidInterfaceException
482
+	 */
483
+	private function _get_transactions_in_progress($comparison = '>=')
484
+	{
485
+		$comparison = $comparison === '>=' || $comparison === '<='
486
+			? $comparison
487
+			: '>=';
488
+		/** @var EventEspresso\core\domain\values\session\SessionLifespan $session_lifespan */
489
+		$session_lifespan = LoaderFactory::getLoader()->getShared(
490
+			'EventEspresso\core\domain\values\session\SessionLifespan'
491
+		);
492
+		return $this->get_all(
493
+			[
494
+				[
495
+					'TXN_timestamp' => [
496
+						$comparison,
497
+						$session_lifespan->expiration(),
498
+					],
499
+					'STS_ID'        => [
500
+						'!=',
501
+						EEM_Transaction::complete_status_code,
502
+					],
503
+				],
504
+			]
505
+		);
506
+	}
507 507
 }
Please login to merge, or discard this patch.
core/db_models/EEM_Message_Template_Group.model.php 2 patches
Indentation   +421 added lines, -421 removed lines patch added patch discarded remove patch
@@ -15,425 +15,425 @@
 block discarded – undo
15 15
 class EEM_Message_Template_Group extends EEM_Soft_Delete_Base
16 16
 {
17 17
 
18
-    // private instance of the EEM_Message_Template_Group object
19
-    protected static $_instance = null;
20
-
21
-
22
-
23
-    protected function __construct($timezone = null)
24
-    {
25
-        $this->singular_item = __('Message Template Group', 'event_espresso');
26
-        $this->plural_item = __('Message Template Groups', 'event_espresso');
27
-        $this->_tables = array(
28
-            'Message_Template_Group' => new EE_Primary_Table('esp_message_template_group', 'GRP_ID')
29
-        );
30
-        $this->_fields = array(
31
-            'Message_Template_Group' => array(
32
-                'GRP_ID' => new EE_Primary_Key_Int_Field('GRP_ID', __('Message Template Group ID', 'event_espresso')),
33
-                'MTP_name' => new EE_Plain_Text_Field('MTP_name', __('The name of the template group', 'event_espresso'), false, ''),
34
-                'MTP_description' => new EE_Simple_HTML_Field('MTP_description', __('A brief description about this template.', 'event_espresso'), false, ''),
35
-                'MTP_user_id'=> new EE_WP_User_Field('MTP_user_id', __('Template Creator ID', 'event_espresso'), false, get_current_user_id()),
36
-                'MTP_messenger'=>new EE_Plain_Text_Field('MTP_messenger', __('Messenger Used for Template', 'event_espresso'), false, 'email'),
37
-                'MTP_message_type'=>new EE_Plain_Text_Field('MTP_message_type', __('Message Type', 'event_espresso'), false, 'registration'),
38
-                'MTP_is_global'=>new EE_Boolean_Field('MTP_is_global', __('Flag indicating if Template Group is Global', 'event_espresso'), false, true),
39
-                'MTP_is_override'=>new EE_Boolean_Field('MTP_is_override', __('Flag indicating if Template Group overrides any other Templates for the messenger/messagetype combination', 'event_espresso'), false, false),
40
-                'MTP_deleted'=>new EE_Trashed_Flag_Field('MTP_deleted', __('Flag indicating whether this has been trashed', 'event_espresso'), false, false),
41
-                'MTP_is_active'=>new EE_Boolean_Field('MTP_is_active', __('Flag indicating whether template group is active', 'event_espresso'), false, true)
42
-            )
43
-        );
44
-        $this->_model_relations = array(
45
-            'Message_Template' => new EE_Has_Many_Relation(),
46
-            'Message' => new EE_Has_Many_Relation(),
47
-            'Event' => new EE_HABTM_Relation('Event_Message_Template'),
48
-            'WP_User' => new EE_Belongs_To_Relation()
49
-        );
50
-        foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
51
-            $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global('MTP_is_global');
52
-        }
53
-        $this->_caps_slug = 'messages';
54
-
55
-        parent::__construct($timezone);
56
-    }
57
-
58
-
59
-
60
-    /**
61
-     * get_all_trashed_message_templates_by_event
62
-     *
63
-     * @access public
64
-     * @param int    $EVT_ID specific event id
65
-     * @param string $orderby
66
-     * @param string $order
67
-     * @param null   $limit
68
-     * @param bool   $count
69
-     * @return array message template objects that are attached to a specific event.
70
-     */
71
-    public function get_all_trashed_message_templates_by_event(
72
-        $EVT_ID,
73
-        $orderby = 'GRP_ID',
74
-        $order = 'ASC',
75
-        $limit = null,
76
-        $count = false
77
-    ) {
78
-        $query_params = array( array('Event.EVT_ID' => $EVT_ID), 'order_by' => array($orderby => $order), 'limit' => $limit );
79
-        return $count ? $this->count_deleted($query_params, 'GRP_ID', true) : $this->get_all_deleted($query_params);
80
-    }
81
-
82
-
83
-
84
-    /**
85
-     * get_all_message_templates_by_messenger
86
-     *
87
-     * @access public
88
-     * @param        $messenger
89
-     * @param string $orderby
90
-     * @param string $order
91
-     * @return array all (including trashed or inactive) message template group objects for the given messenger
92
-     */
93
-    public function get_all_message_templates_by_messenger($messenger, $orderby = 'GRP_ID', $order = 'ASC')
94
-    {
95
-        return $this->get_all_deleted_and_undeleted(
96
-            array( array( 'MTP_messenger' => $messenger ), 'order_by' => array( $orderby => $order ) )
97
-        );
98
-    }
99
-
100
-
101
-    /**
102
-     * This simply adds on any messenger/message type filters that may be present in the request
103
-     *
104
-     * @param array $_where any existing where conditions to append these to.
105
-     * @return array          original where conditions or original with additional filters.
106
-     */
107
-    protected function _maybe_mtp_filters($_where = array())
108
-    {
109
-        /** @var RequestInterface $request */
110
-        $request   = LoaderFactory::getLoader()->getShared(RequestInterface::class);
111
-        $messenger = $request->getRequestParam('ee_messenger_filter_by');
112
-        // account for messenger or message type filters
113
-        if ($messenger !== '' && $messenger !== 'none_selected' && $messenger !== 'all') {
114
-            $_where['MTP_messenger'] = $messenger;
115
-        }
116
-        $message_type = $request->getRequestParam('ee_message_type_filter_by');
117
-        if ($message_type !== '' && $message_type !== 'none_selected'
118
-        ) {
119
-            $_where['MTP_message_type'] = $message_type;
120
-        }
121
-
122
-        return $_where;
123
-    }
124
-
125
-
126
-
127
-    /**
128
-     * get_all_active_message_templates groups
129
-     *
130
-     * @access public
131
-     * @param string $orderby
132
-     * @param string $order
133
-     * @param null   $limit
134
-     * @param bool   $count
135
-     * @param bool   $global
136
-     * @param bool   $user_check
137
-     * @return array all active (non_trashed, active) message template objects
138
-     */
139
-    public function get_all_active_message_templates(
140
-        $orderby = 'GRP_ID',
141
-        $order = 'ASC',
142
-        $limit = null,
143
-        $count = false,
144
-        $global = true,
145
-        $user_check = false
146
-    ) {
147
-        $_where = $global ? array('MTP_is_global' => true ) : array('MTP_is_global' => false );
148
-        $_where['MTP_is_active'] = true;
149
-        $_where = $this->_maybe_mtp_filters($_where);
150
-
151
-        if ($user_check
152
-            && ! $global
153
-            && ! EE_Registry::instance()->CAP->current_user_can(
154
-                'ee_read_others_messages',
155
-                'get_all_active_message_templates'
156
-            )
157
-        ) {
158
-            $_where['MTP_user_id'] = get_current_user_id();
159
-        }
160
-
161
-        $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit );
162
-
163
-        return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params);
164
-    }
165
-
166
-
167
-
168
-    /**
169
-     *    retrieve ALL message_template groups from db regardless of wht
170
-     *
171
-     * @access    public
172
-     * @param string $orderby
173
-     * @param string $order
174
-     * @param null   $limit
175
-     * @param bool   $count
176
-     * @return mixed array on success, FALSE on fail
177
-     */
178
-    public function get_all_message_templates($orderby = 'GRP_ID', $order = 'ASC', $limit = null, $count = false)
179
-    {
180
-        $_where = $this->_maybe_mtp_filters();
181
-
182
-        $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit );
183
-
184
-        $r_templates = $count
185
-            ? $this->count_deleted_and_undeleted($query_params, 'GRP_ID', true)
186
-            : $this->get_all_deleted_and_undeleted($query_params);
187
-
188
-        return $r_templates;
189
-    }
190
-
191
-
192
-
193
-
194
-    /**
195
-     * This gets all the custom templates attached to a specific event
196
-     * @param  int      $EVT_ID         event id
197
-     * @param  array  $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
198
-     * @return  EE_Message_Template_Group[]
199
-     */
200
-    public function get_all_custom_templates_by_event($EVT_ID, $query_params = array())
201
-    {
202
-        $where = array_merge($query_params, array( 'Event.EVT_ID' => $EVT_ID ));
203
-        return $this->get_all(
204
-            array( $where )
205
-        );
206
-    }
207
-
208
-
209
-
210
-    /**
211
-     * get_all_trashed_grouped_message_templates
212
-     * this returns ONLY the template groups where ALL contexts are trashed and none of the group are non-trashed
213
-     *
214
-     * @access public
215
-     * @param string $orderby
216
-     * @param string $order
217
-     * @param null   $limit
218
-     * @param bool   $count
219
-     * @param bool   $global
220
-     * @return \EE_Message_Template_Group[] message template groups.
221
-     */
222
-    public function get_all_trashed_grouped_message_templates(
223
-        $orderby = 'GRP_ID',
224
-        $order = 'ASC',
225
-        $limit = null,
226
-        $count = false,
227
-        $global = true
228
-    ) {
229
-        $_where = $global ? array('MTP_is_global' => true ) : array('MTP_is_global' => false );
230
-        $_where['MTP_is_active'] = true;
231
-        $_where = $this->_maybe_mtp_filters($_where);
232
-
233
-        $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit );
234
-
235
-        return $count ? $this->count_deleted($query_params, 'GRP_ID', true) : $this->get_all_deleted($query_params);
236
-    }
237
-
238
-
239
-
240
-    /**
241
-     * this returns the message template group(s) for a given event, messenger, and message template
242
-     *
243
-     * @param  string             $messenger
244
-     * @param  string             $message_type
245
-     * @param                     $evt_id
246
-     * @param  string             $orderby pointless at this point but still included
247
-     * @param  string             $order
248
-     * @param  mixed (array|null) $limit   array($offset, $num)
249
-     * @param  bool               $count   true = just return count, false = objects
250
-     * @param  bool               $active  ignore "active" or not. (default only return active)
251
-     * @return \mixed[]) depending on $count.
252
-     */
253
-    public function get_event_message_templates_by_m_and_mt_and_evt(
254
-        $messenger,
255
-        $message_type,
256
-        $evt_id,
257
-        $orderby = 'GRP_ID',
258
-        $order = 'ASC',
259
-        $limit = null,
260
-        $count = false,
261
-        $active = true
262
-    ) {
263
-        $_where = array(
264
-            'MTP_messenger' => $messenger,
265
-            'MTP_message_type' => $message_type,
266
-            'Event.EVT_ID' => $evt_id,
267
-            'MTP_is_global' => true,
268
-            'MTP_is_active' => $active
269
-        );
270
-
271
-        $query_params = array( $_where, 'order_by' => array($orderby=>$order), 'limit' => $limit );
272
-
273
-        return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params);
274
-    }
275
-
276
-
277
-
278
-
279
-    /**
280
-     * get all GLOBAL message template groups for the given messenger and message type
281
-     *
282
-     * @param  string $messenger    slug for messenger
283
-     * @param  string $message_type slug for message type
284
-     * @param  string $orderby      what column to orderby
285
-     * @param  string $order        ASC or DESC
286
-     * @param  mixed (array|null) $limit array($offset, $num)
287
-     * @param  bool   $count        true = just return count, false = objects
288
-     * @param  bool   $active       ignore "active" or not. (default only return active) -
289
-     *                              'all' means return both inactive AND inactive.
290
-     * @return array               message template objects that are global (i.e. non-event)
291
-     */
292
-    public function get_global_message_template_by_m_and_mt(
293
-        $messenger,
294
-        $message_type,
295
-        $orderby = 'GRP_ID',
296
-        $order = 'ASC',
297
-        $limit = null,
298
-        $count = false,
299
-        $active = true
300
-    ) {
301
-        $_where = array(
302
-            'MTP_messenger' => $messenger,
303
-            'MTP_message_type' => $message_type,
304
-            'MTP_is_global' => true,
305
-        );
306
-
307
-        if ($active != 'all') {
308
-            $_where['MTP_is_active'] = $active;
309
-        }
310
-
311
-        $query_params = array( $_where, 'order_by' => array( $orderby => $order ), 'limit' => $limit );
312
-
313
-        return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params);
314
-    }
315
-
316
-
317
-
318
-
319
-    /**
320
-     * get all custom message template groups for the given messenger and message type
321
-     * @param  string $messenger    messenger
322
-     * @param  string $message_type messagetype
323
-     * @param  array  $query_params same as EEM_Base->get_all()
324
-     * @return EE_Message_Template_Group[]
325
-     */
326
-    public function get_custom_message_template_by_m_and_mt($messenger, $message_type, $query_params = array())
327
-    {
328
-        return $this->get_all(
329
-            array_merge(
330
-                $query_params,
331
-                array(
332
-                    array(
333
-                        'MTP_is_global'    => false,
334
-                        'MTP_messenger'    => $messenger,
335
-                        'MTP_message_type' => $message_type
336
-                    )
337
-                )
338
-            )
339
-        );
340
-    }
341
-
342
-
343
-
344
-    /**
345
-     * This sends things to the validator for the given messenger and message type.
346
-     *
347
-     * @param  array $fields the incoming fields to check.
348
-     *                       Note this array is in the formatted fields from the form fields setup.
349
-     *                       So we need to reformat this into an array of expected field refs by the validator.
350
-     *                       Note also that this is not only the fields for the Message Template Group
351
-     *                       but ALSO for Message Template.
352
-     * @param string $context      The context the fields were obtained from.
353
-     * @param string $messenger    The messenger we are validating
354
-     * @param string $message_type The message type we are validating.
355
-     * @return mixed If the fields all check out then we return true otherwise error messages are returned
356
-     *                       (indexed by field name);
357
-     * @throws \EE_Error
358
-     */
359
-    public function validate($fields, $context, $messenger, $message_type)
360
-    {
361
-
362
-        $assembled_fields = array();
363
-
364
-        // let's loop through all the fields and set them up in the right format
365
-        foreach ($fields as $index => $value) {
366
-            // first let's figure out if the value['content'] in the current index is an array.
367
-            //  If it is then this is special fields that are used in parsing special shortcodes (i.e. 'attendee_list').
368
-            if (is_array($value['content'])) {
369
-                $assembled_fields[ $value['name'] ] = $value['content']['main'];
370
-                // loop through the content and get the other fields.
371
-                foreach ($value['content'] as $name => $val) {
372
-                    if ($name == 'main') {
373
-                        continue;
374
-                    }
375
-                    $assembled_fields[ $name ] = $val;
376
-                }
377
-                continue;
378
-            }
379
-
380
-            // okay if we're here then this is just a straight field=>$value arrangement
381
-            $assembled_fields[ $value['name'] ] = $value['content'];
382
-        }
383
-
384
-        // now we've got the assembled_fields.
385
-        // We need to setup the string for the appropriate validator class and call that.
386
-        $m_ref = ucwords(str_replace('_', ' ', $messenger));
387
-        $m_ref = str_replace(' ', '_', $m_ref);
388
-        $mt_ref = ucwords(str_replace('_', ' ', $message_type));
389
-        $mt_ref = str_replace(' ', '_', $mt_ref);
390
-
391
-        $classname = 'EE_Messages_' . $m_ref . '_' . $mt_ref . '_Validator';
392
-
393
-        if (!class_exists($classname)) {
394
-            $msg[] = __('The Validator class was unable to load', 'event_espresso');
395
-            $msg[] = sprintf(
396
-                __(
397
-                    'The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class',
398
-                    'event_espresso'
399
-                ),
400
-                $classname
401
-            );
402
-            throw new EE_Error(implode('||', $msg));
403
-        }
404
-
405
-        $a = new ReflectionClass($classname);
406
-        $_VLD = $a->newInstance($assembled_fields, $context);
407
-        $result = $_VLD->validate();
408
-        return $result;
409
-    }
410
-
411
-
412
-
413
-    /**
414
-     * Updates all message template groups matching the incoming arguments to inactive status.
415
-     *
416
-     * @param array $messenger_names    The messenger slugs.
417
-     *                              If empty then all templates matching the message types are marked inactive.
418
-     *                              Otherwise only templates matching the messengers and message types.
419
-     * @param array $message_type_names     The message type slugs.
420
-     *                              If empty then all templates matching the messengers are marked inactive.
421
-     *                              Otherwise only templates matching the messengers and message types.
422
-     *
423
-     * @return int  count of updated records.
424
-     */
425
-    public function deactivate_message_template_groups_for($messenger_names = array(), $message_type_names = array())
426
-    {
427
-        $query_args = array();
428
-        if (empty($messenger_names) && empty($message_type_names)) {
429
-            return 0;
430
-        }
431
-        if (! empty($messenger_names)) {
432
-            $query_args[0]['MTP_messenger'] = array( 'IN', (array) $messenger_names );
433
-        }
434
-        if (! empty($message_type_names)) {
435
-            $query_args[0]['MTP_message_type'] = array( 'IN', (array) $message_type_names );
436
-        }
437
-        return $this->update(array( 'MTP_is_active' => false ), $query_args);
438
-    }
18
+	// private instance of the EEM_Message_Template_Group object
19
+	protected static $_instance = null;
20
+
21
+
22
+
23
+	protected function __construct($timezone = null)
24
+	{
25
+		$this->singular_item = __('Message Template Group', 'event_espresso');
26
+		$this->plural_item = __('Message Template Groups', 'event_espresso');
27
+		$this->_tables = array(
28
+			'Message_Template_Group' => new EE_Primary_Table('esp_message_template_group', 'GRP_ID')
29
+		);
30
+		$this->_fields = array(
31
+			'Message_Template_Group' => array(
32
+				'GRP_ID' => new EE_Primary_Key_Int_Field('GRP_ID', __('Message Template Group ID', 'event_espresso')),
33
+				'MTP_name' => new EE_Plain_Text_Field('MTP_name', __('The name of the template group', 'event_espresso'), false, ''),
34
+				'MTP_description' => new EE_Simple_HTML_Field('MTP_description', __('A brief description about this template.', 'event_espresso'), false, ''),
35
+				'MTP_user_id'=> new EE_WP_User_Field('MTP_user_id', __('Template Creator ID', 'event_espresso'), false, get_current_user_id()),
36
+				'MTP_messenger'=>new EE_Plain_Text_Field('MTP_messenger', __('Messenger Used for Template', 'event_espresso'), false, 'email'),
37
+				'MTP_message_type'=>new EE_Plain_Text_Field('MTP_message_type', __('Message Type', 'event_espresso'), false, 'registration'),
38
+				'MTP_is_global'=>new EE_Boolean_Field('MTP_is_global', __('Flag indicating if Template Group is Global', 'event_espresso'), false, true),
39
+				'MTP_is_override'=>new EE_Boolean_Field('MTP_is_override', __('Flag indicating if Template Group overrides any other Templates for the messenger/messagetype combination', 'event_espresso'), false, false),
40
+				'MTP_deleted'=>new EE_Trashed_Flag_Field('MTP_deleted', __('Flag indicating whether this has been trashed', 'event_espresso'), false, false),
41
+				'MTP_is_active'=>new EE_Boolean_Field('MTP_is_active', __('Flag indicating whether template group is active', 'event_espresso'), false, true)
42
+			)
43
+		);
44
+		$this->_model_relations = array(
45
+			'Message_Template' => new EE_Has_Many_Relation(),
46
+			'Message' => new EE_Has_Many_Relation(),
47
+			'Event' => new EE_HABTM_Relation('Event_Message_Template'),
48
+			'WP_User' => new EE_Belongs_To_Relation()
49
+		);
50
+		foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
51
+			$this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global('MTP_is_global');
52
+		}
53
+		$this->_caps_slug = 'messages';
54
+
55
+		parent::__construct($timezone);
56
+	}
57
+
58
+
59
+
60
+	/**
61
+	 * get_all_trashed_message_templates_by_event
62
+	 *
63
+	 * @access public
64
+	 * @param int    $EVT_ID specific event id
65
+	 * @param string $orderby
66
+	 * @param string $order
67
+	 * @param null   $limit
68
+	 * @param bool   $count
69
+	 * @return array message template objects that are attached to a specific event.
70
+	 */
71
+	public function get_all_trashed_message_templates_by_event(
72
+		$EVT_ID,
73
+		$orderby = 'GRP_ID',
74
+		$order = 'ASC',
75
+		$limit = null,
76
+		$count = false
77
+	) {
78
+		$query_params = array( array('Event.EVT_ID' => $EVT_ID), 'order_by' => array($orderby => $order), 'limit' => $limit );
79
+		return $count ? $this->count_deleted($query_params, 'GRP_ID', true) : $this->get_all_deleted($query_params);
80
+	}
81
+
82
+
83
+
84
+	/**
85
+	 * get_all_message_templates_by_messenger
86
+	 *
87
+	 * @access public
88
+	 * @param        $messenger
89
+	 * @param string $orderby
90
+	 * @param string $order
91
+	 * @return array all (including trashed or inactive) message template group objects for the given messenger
92
+	 */
93
+	public function get_all_message_templates_by_messenger($messenger, $orderby = 'GRP_ID', $order = 'ASC')
94
+	{
95
+		return $this->get_all_deleted_and_undeleted(
96
+			array( array( 'MTP_messenger' => $messenger ), 'order_by' => array( $orderby => $order ) )
97
+		);
98
+	}
99
+
100
+
101
+	/**
102
+	 * This simply adds on any messenger/message type filters that may be present in the request
103
+	 *
104
+	 * @param array $_where any existing where conditions to append these to.
105
+	 * @return array          original where conditions or original with additional filters.
106
+	 */
107
+	protected function _maybe_mtp_filters($_where = array())
108
+	{
109
+		/** @var RequestInterface $request */
110
+		$request   = LoaderFactory::getLoader()->getShared(RequestInterface::class);
111
+		$messenger = $request->getRequestParam('ee_messenger_filter_by');
112
+		// account for messenger or message type filters
113
+		if ($messenger !== '' && $messenger !== 'none_selected' && $messenger !== 'all') {
114
+			$_where['MTP_messenger'] = $messenger;
115
+		}
116
+		$message_type = $request->getRequestParam('ee_message_type_filter_by');
117
+		if ($message_type !== '' && $message_type !== 'none_selected'
118
+		) {
119
+			$_where['MTP_message_type'] = $message_type;
120
+		}
121
+
122
+		return $_where;
123
+	}
124
+
125
+
126
+
127
+	/**
128
+	 * get_all_active_message_templates groups
129
+	 *
130
+	 * @access public
131
+	 * @param string $orderby
132
+	 * @param string $order
133
+	 * @param null   $limit
134
+	 * @param bool   $count
135
+	 * @param bool   $global
136
+	 * @param bool   $user_check
137
+	 * @return array all active (non_trashed, active) message template objects
138
+	 */
139
+	public function get_all_active_message_templates(
140
+		$orderby = 'GRP_ID',
141
+		$order = 'ASC',
142
+		$limit = null,
143
+		$count = false,
144
+		$global = true,
145
+		$user_check = false
146
+	) {
147
+		$_where = $global ? array('MTP_is_global' => true ) : array('MTP_is_global' => false );
148
+		$_where['MTP_is_active'] = true;
149
+		$_where = $this->_maybe_mtp_filters($_where);
150
+
151
+		if ($user_check
152
+			&& ! $global
153
+			&& ! EE_Registry::instance()->CAP->current_user_can(
154
+				'ee_read_others_messages',
155
+				'get_all_active_message_templates'
156
+			)
157
+		) {
158
+			$_where['MTP_user_id'] = get_current_user_id();
159
+		}
160
+
161
+		$query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit );
162
+
163
+		return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params);
164
+	}
165
+
166
+
167
+
168
+	/**
169
+	 *    retrieve ALL message_template groups from db regardless of wht
170
+	 *
171
+	 * @access    public
172
+	 * @param string $orderby
173
+	 * @param string $order
174
+	 * @param null   $limit
175
+	 * @param bool   $count
176
+	 * @return mixed array on success, FALSE on fail
177
+	 */
178
+	public function get_all_message_templates($orderby = 'GRP_ID', $order = 'ASC', $limit = null, $count = false)
179
+	{
180
+		$_where = $this->_maybe_mtp_filters();
181
+
182
+		$query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit );
183
+
184
+		$r_templates = $count
185
+			? $this->count_deleted_and_undeleted($query_params, 'GRP_ID', true)
186
+			: $this->get_all_deleted_and_undeleted($query_params);
187
+
188
+		return $r_templates;
189
+	}
190
+
191
+
192
+
193
+
194
+	/**
195
+	 * This gets all the custom templates attached to a specific event
196
+	 * @param  int      $EVT_ID         event id
197
+	 * @param  array  $query_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md
198
+	 * @return  EE_Message_Template_Group[]
199
+	 */
200
+	public function get_all_custom_templates_by_event($EVT_ID, $query_params = array())
201
+	{
202
+		$where = array_merge($query_params, array( 'Event.EVT_ID' => $EVT_ID ));
203
+		return $this->get_all(
204
+			array( $where )
205
+		);
206
+	}
207
+
208
+
209
+
210
+	/**
211
+	 * get_all_trashed_grouped_message_templates
212
+	 * this returns ONLY the template groups where ALL contexts are trashed and none of the group are non-trashed
213
+	 *
214
+	 * @access public
215
+	 * @param string $orderby
216
+	 * @param string $order
217
+	 * @param null   $limit
218
+	 * @param bool   $count
219
+	 * @param bool   $global
220
+	 * @return \EE_Message_Template_Group[] message template groups.
221
+	 */
222
+	public function get_all_trashed_grouped_message_templates(
223
+		$orderby = 'GRP_ID',
224
+		$order = 'ASC',
225
+		$limit = null,
226
+		$count = false,
227
+		$global = true
228
+	) {
229
+		$_where = $global ? array('MTP_is_global' => true ) : array('MTP_is_global' => false );
230
+		$_where['MTP_is_active'] = true;
231
+		$_where = $this->_maybe_mtp_filters($_where);
232
+
233
+		$query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit );
234
+
235
+		return $count ? $this->count_deleted($query_params, 'GRP_ID', true) : $this->get_all_deleted($query_params);
236
+	}
237
+
238
+
239
+
240
+	/**
241
+	 * this returns the message template group(s) for a given event, messenger, and message template
242
+	 *
243
+	 * @param  string             $messenger
244
+	 * @param  string             $message_type
245
+	 * @param                     $evt_id
246
+	 * @param  string             $orderby pointless at this point but still included
247
+	 * @param  string             $order
248
+	 * @param  mixed (array|null) $limit   array($offset, $num)
249
+	 * @param  bool               $count   true = just return count, false = objects
250
+	 * @param  bool               $active  ignore "active" or not. (default only return active)
251
+	 * @return \mixed[]) depending on $count.
252
+	 */
253
+	public function get_event_message_templates_by_m_and_mt_and_evt(
254
+		$messenger,
255
+		$message_type,
256
+		$evt_id,
257
+		$orderby = 'GRP_ID',
258
+		$order = 'ASC',
259
+		$limit = null,
260
+		$count = false,
261
+		$active = true
262
+	) {
263
+		$_where = array(
264
+			'MTP_messenger' => $messenger,
265
+			'MTP_message_type' => $message_type,
266
+			'Event.EVT_ID' => $evt_id,
267
+			'MTP_is_global' => true,
268
+			'MTP_is_active' => $active
269
+		);
270
+
271
+		$query_params = array( $_where, 'order_by' => array($orderby=>$order), 'limit' => $limit );
272
+
273
+		return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params);
274
+	}
275
+
276
+
277
+
278
+
279
+	/**
280
+	 * get all GLOBAL message template groups for the given messenger and message type
281
+	 *
282
+	 * @param  string $messenger    slug for messenger
283
+	 * @param  string $message_type slug for message type
284
+	 * @param  string $orderby      what column to orderby
285
+	 * @param  string $order        ASC or DESC
286
+	 * @param  mixed (array|null) $limit array($offset, $num)
287
+	 * @param  bool   $count        true = just return count, false = objects
288
+	 * @param  bool   $active       ignore "active" or not. (default only return active) -
289
+	 *                              'all' means return both inactive AND inactive.
290
+	 * @return array               message template objects that are global (i.e. non-event)
291
+	 */
292
+	public function get_global_message_template_by_m_and_mt(
293
+		$messenger,
294
+		$message_type,
295
+		$orderby = 'GRP_ID',
296
+		$order = 'ASC',
297
+		$limit = null,
298
+		$count = false,
299
+		$active = true
300
+	) {
301
+		$_where = array(
302
+			'MTP_messenger' => $messenger,
303
+			'MTP_message_type' => $message_type,
304
+			'MTP_is_global' => true,
305
+		);
306
+
307
+		if ($active != 'all') {
308
+			$_where['MTP_is_active'] = $active;
309
+		}
310
+
311
+		$query_params = array( $_where, 'order_by' => array( $orderby => $order ), 'limit' => $limit );
312
+
313
+		return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params);
314
+	}
315
+
316
+
317
+
318
+
319
+	/**
320
+	 * get all custom message template groups for the given messenger and message type
321
+	 * @param  string $messenger    messenger
322
+	 * @param  string $message_type messagetype
323
+	 * @param  array  $query_params same as EEM_Base->get_all()
324
+	 * @return EE_Message_Template_Group[]
325
+	 */
326
+	public function get_custom_message_template_by_m_and_mt($messenger, $message_type, $query_params = array())
327
+	{
328
+		return $this->get_all(
329
+			array_merge(
330
+				$query_params,
331
+				array(
332
+					array(
333
+						'MTP_is_global'    => false,
334
+						'MTP_messenger'    => $messenger,
335
+						'MTP_message_type' => $message_type
336
+					)
337
+				)
338
+			)
339
+		);
340
+	}
341
+
342
+
343
+
344
+	/**
345
+	 * This sends things to the validator for the given messenger and message type.
346
+	 *
347
+	 * @param  array $fields the incoming fields to check.
348
+	 *                       Note this array is in the formatted fields from the form fields setup.
349
+	 *                       So we need to reformat this into an array of expected field refs by the validator.
350
+	 *                       Note also that this is not only the fields for the Message Template Group
351
+	 *                       but ALSO for Message Template.
352
+	 * @param string $context      The context the fields were obtained from.
353
+	 * @param string $messenger    The messenger we are validating
354
+	 * @param string $message_type The message type we are validating.
355
+	 * @return mixed If the fields all check out then we return true otherwise error messages are returned
356
+	 *                       (indexed by field name);
357
+	 * @throws \EE_Error
358
+	 */
359
+	public function validate($fields, $context, $messenger, $message_type)
360
+	{
361
+
362
+		$assembled_fields = array();
363
+
364
+		// let's loop through all the fields and set them up in the right format
365
+		foreach ($fields as $index => $value) {
366
+			// first let's figure out if the value['content'] in the current index is an array.
367
+			//  If it is then this is special fields that are used in parsing special shortcodes (i.e. 'attendee_list').
368
+			if (is_array($value['content'])) {
369
+				$assembled_fields[ $value['name'] ] = $value['content']['main'];
370
+				// loop through the content and get the other fields.
371
+				foreach ($value['content'] as $name => $val) {
372
+					if ($name == 'main') {
373
+						continue;
374
+					}
375
+					$assembled_fields[ $name ] = $val;
376
+				}
377
+				continue;
378
+			}
379
+
380
+			// okay if we're here then this is just a straight field=>$value arrangement
381
+			$assembled_fields[ $value['name'] ] = $value['content'];
382
+		}
383
+
384
+		// now we've got the assembled_fields.
385
+		// We need to setup the string for the appropriate validator class and call that.
386
+		$m_ref = ucwords(str_replace('_', ' ', $messenger));
387
+		$m_ref = str_replace(' ', '_', $m_ref);
388
+		$mt_ref = ucwords(str_replace('_', ' ', $message_type));
389
+		$mt_ref = str_replace(' ', '_', $mt_ref);
390
+
391
+		$classname = 'EE_Messages_' . $m_ref . '_' . $mt_ref . '_Validator';
392
+
393
+		if (!class_exists($classname)) {
394
+			$msg[] = __('The Validator class was unable to load', 'event_espresso');
395
+			$msg[] = sprintf(
396
+				__(
397
+					'The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class',
398
+					'event_espresso'
399
+				),
400
+				$classname
401
+			);
402
+			throw new EE_Error(implode('||', $msg));
403
+		}
404
+
405
+		$a = new ReflectionClass($classname);
406
+		$_VLD = $a->newInstance($assembled_fields, $context);
407
+		$result = $_VLD->validate();
408
+		return $result;
409
+	}
410
+
411
+
412
+
413
+	/**
414
+	 * Updates all message template groups matching the incoming arguments to inactive status.
415
+	 *
416
+	 * @param array $messenger_names    The messenger slugs.
417
+	 *                              If empty then all templates matching the message types are marked inactive.
418
+	 *                              Otherwise only templates matching the messengers and message types.
419
+	 * @param array $message_type_names     The message type slugs.
420
+	 *                              If empty then all templates matching the messengers are marked inactive.
421
+	 *                              Otherwise only templates matching the messengers and message types.
422
+	 *
423
+	 * @return int  count of updated records.
424
+	 */
425
+	public function deactivate_message_template_groups_for($messenger_names = array(), $message_type_names = array())
426
+	{
427
+		$query_args = array();
428
+		if (empty($messenger_names) && empty($message_type_names)) {
429
+			return 0;
430
+		}
431
+		if (! empty($messenger_names)) {
432
+			$query_args[0]['MTP_messenger'] = array( 'IN', (array) $messenger_names );
433
+		}
434
+		if (! empty($message_type_names)) {
435
+			$query_args[0]['MTP_message_type'] = array( 'IN', (array) $message_type_names );
436
+		}
437
+		return $this->update(array( 'MTP_is_active' => false ), $query_args);
438
+	}
439 439
 }
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
             'WP_User' => new EE_Belongs_To_Relation()
49 49
         );
50 50
         foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
51
-            $this->_cap_restriction_generators[ $context ] = new EE_Restriction_Generator_Global('MTP_is_global');
51
+            $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_Global('MTP_is_global');
52 52
         }
53 53
         $this->_caps_slug = 'messages';
54 54
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
         $limit = null,
76 76
         $count = false
77 77
     ) {
78
-        $query_params = array( array('Event.EVT_ID' => $EVT_ID), 'order_by' => array($orderby => $order), 'limit' => $limit );
78
+        $query_params = array(array('Event.EVT_ID' => $EVT_ID), 'order_by' => array($orderby => $order), 'limit' => $limit);
79 79
         return $count ? $this->count_deleted($query_params, 'GRP_ID', true) : $this->get_all_deleted($query_params);
80 80
     }
81 81
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     public function get_all_message_templates_by_messenger($messenger, $orderby = 'GRP_ID', $order = 'ASC')
94 94
     {
95 95
         return $this->get_all_deleted_and_undeleted(
96
-            array( array( 'MTP_messenger' => $messenger ), 'order_by' => array( $orderby => $order ) )
96
+            array(array('MTP_messenger' => $messenger), 'order_by' => array($orderby => $order))
97 97
         );
98 98
     }
99 99
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
         $global = true,
145 145
         $user_check = false
146 146
     ) {
147
-        $_where = $global ? array('MTP_is_global' => true ) : array('MTP_is_global' => false );
147
+        $_where = $global ? array('MTP_is_global' => true) : array('MTP_is_global' => false);
148 148
         $_where['MTP_is_active'] = true;
149 149
         $_where = $this->_maybe_mtp_filters($_where);
150 150
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             $_where['MTP_user_id'] = get_current_user_id();
159 159
         }
160 160
 
161
-        $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit );
161
+        $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit);
162 162
 
163 163
         return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params);
164 164
     }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     {
180 180
         $_where = $this->_maybe_mtp_filters();
181 181
 
182
-        $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit );
182
+        $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit);
183 183
 
184 184
         $r_templates = $count
185 185
             ? $this->count_deleted_and_undeleted($query_params, 'GRP_ID', true)
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
      */
200 200
     public function get_all_custom_templates_by_event($EVT_ID, $query_params = array())
201 201
     {
202
-        $where = array_merge($query_params, array( 'Event.EVT_ID' => $EVT_ID ));
202
+        $where = array_merge($query_params, array('Event.EVT_ID' => $EVT_ID));
203 203
         return $this->get_all(
204
-            array( $where )
204
+            array($where)
205 205
         );
206 206
     }
207 207
 
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
         $count = false,
227 227
         $global = true
228 228
     ) {
229
-        $_where = $global ? array('MTP_is_global' => true ) : array('MTP_is_global' => false );
229
+        $_where = $global ? array('MTP_is_global' => true) : array('MTP_is_global' => false);
230 230
         $_where['MTP_is_active'] = true;
231 231
         $_where = $this->_maybe_mtp_filters($_where);
232 232
 
233
-        $query_params = array( $_where, 'order_by' => array($orderby => $order), 'limit' => $limit );
233
+        $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit);
234 234
 
235 235
         return $count ? $this->count_deleted($query_params, 'GRP_ID', true) : $this->get_all_deleted($query_params);
236 236
     }
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
             'MTP_is_active' => $active
269 269
         );
270 270
 
271
-        $query_params = array( $_where, 'order_by' => array($orderby=>$order), 'limit' => $limit );
271
+        $query_params = array($_where, 'order_by' => array($orderby=>$order), 'limit' => $limit);
272 272
 
273 273
         return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params);
274 274
     }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             $_where['MTP_is_active'] = $active;
309 309
         }
310 310
 
311
-        $query_params = array( $_where, 'order_by' => array( $orderby => $order ), 'limit' => $limit );
311
+        $query_params = array($_where, 'order_by' => array($orderby => $order), 'limit' => $limit);
312 312
 
313 313
         return $count ? $this->count($query_params, 'GRP_ID', true) : $this->get_all($query_params);
314 314
     }
@@ -366,19 +366,19 @@  discard block
 block discarded – undo
366 366
             // first let's figure out if the value['content'] in the current index is an array.
367 367
             //  If it is then this is special fields that are used in parsing special shortcodes (i.e. 'attendee_list').
368 368
             if (is_array($value['content'])) {
369
-                $assembled_fields[ $value['name'] ] = $value['content']['main'];
369
+                $assembled_fields[$value['name']] = $value['content']['main'];
370 370
                 // loop through the content and get the other fields.
371 371
                 foreach ($value['content'] as $name => $val) {
372 372
                     if ($name == 'main') {
373 373
                         continue;
374 374
                     }
375
-                    $assembled_fields[ $name ] = $val;
375
+                    $assembled_fields[$name] = $val;
376 376
                 }
377 377
                 continue;
378 378
             }
379 379
 
380 380
             // okay if we're here then this is just a straight field=>$value arrangement
381
-            $assembled_fields[ $value['name'] ] = $value['content'];
381
+            $assembled_fields[$value['name']] = $value['content'];
382 382
         }
383 383
 
384 384
         // now we've got the assembled_fields.
@@ -388,9 +388,9 @@  discard block
 block discarded – undo
388 388
         $mt_ref = ucwords(str_replace('_', ' ', $message_type));
389 389
         $mt_ref = str_replace(' ', '_', $mt_ref);
390 390
 
391
-        $classname = 'EE_Messages_' . $m_ref . '_' . $mt_ref . '_Validator';
391
+        $classname = 'EE_Messages_'.$m_ref.'_'.$mt_ref.'_Validator';
392 392
 
393
-        if (!class_exists($classname)) {
393
+        if ( ! class_exists($classname)) {
394 394
             $msg[] = __('The Validator class was unable to load', 'event_espresso');
395 395
             $msg[] = sprintf(
396 396
                 __(
@@ -428,12 +428,12 @@  discard block
 block discarded – undo
428 428
         if (empty($messenger_names) && empty($message_type_names)) {
429 429
             return 0;
430 430
         }
431
-        if (! empty($messenger_names)) {
432
-            $query_args[0]['MTP_messenger'] = array( 'IN', (array) $messenger_names );
431
+        if ( ! empty($messenger_names)) {
432
+            $query_args[0]['MTP_messenger'] = array('IN', (array) $messenger_names);
433 433
         }
434
-        if (! empty($message_type_names)) {
435
-            $query_args[0]['MTP_message_type'] = array( 'IN', (array) $message_type_names );
434
+        if ( ! empty($message_type_names)) {
435
+            $query_args[0]['MTP_message_type'] = array('IN', (array) $message_type_names);
436 436
         }
437
-        return $this->update(array( 'MTP_is_active' => false ), $query_args);
437
+        return $this->update(array('MTP_is_active' => false), $query_args);
438 438
     }
439 439
 }
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 2 patches
Indentation   +1161 added lines, -1161 removed lines patch added patch discarded remove patch
@@ -20,1165 +20,1165 @@
 block discarded – undo
20 20
 class EE_Dependency_Map
21 21
 {
22 22
 
23
-    /**
24
-     * This means that the requested class dependency is not present in the dependency map
25
-     */
26
-    const not_registered = 0;
27
-
28
-    /**
29
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
-     */
31
-    const load_new_object = 1;
32
-
33
-    /**
34
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
-     */
37
-    const load_from_cache = 2;
38
-
39
-    /**
40
-     * When registering a dependency,
41
-     * this indicates to keep any existing dependencies that already exist,
42
-     * and simply discard any new dependencies declared in the incoming data
43
-     */
44
-    const KEEP_EXISTING_DEPENDENCIES = 0;
45
-
46
-    /**
47
-     * When registering a dependency,
48
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
-     */
50
-    const OVERWRITE_DEPENDENCIES = 1;
51
-
52
-
53
-    /**
54
-     * @type EE_Dependency_Map $_instance
55
-     */
56
-    protected static $_instance;
57
-
58
-    /**
59
-     * @var ClassInterfaceCache $class_cache
60
-     */
61
-    private $class_cache;
62
-
63
-    /**
64
-     * @type RequestInterface $request
65
-     */
66
-    protected $request;
67
-
68
-    /**
69
-     * @type LegacyRequestInterface $legacy_request
70
-     */
71
-    protected $legacy_request;
72
-
73
-    /**
74
-     * @type ResponseInterface $response
75
-     */
76
-    protected $response;
77
-
78
-    /**
79
-     * @type LoaderInterface $loader
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @type array $_dependency_map
85
-     */
86
-    protected $_dependency_map = [];
87
-
88
-    /**
89
-     * @type array $_class_loaders
90
-     */
91
-    protected $_class_loaders = [];
92
-
93
-
94
-    /**
95
-     * EE_Dependency_Map constructor.
96
-     *
97
-     * @param ClassInterfaceCache $class_cache
98
-     */
99
-    protected function __construct(ClassInterfaceCache $class_cache)
100
-    {
101
-        $this->class_cache = $class_cache;
102
-        do_action('EE_Dependency_Map____construct', $this);
103
-    }
104
-
105
-
106
-    /**
107
-     * @return void
108
-     */
109
-    public function initialize()
110
-    {
111
-        $this->_register_core_dependencies();
112
-        $this->_register_core_class_loaders();
113
-        $this->_register_core_aliases();
114
-    }
115
-
116
-
117
-    /**
118
-     * @singleton method used to instantiate class object
119
-     * @param ClassInterfaceCache|null $class_cache
120
-     * @return EE_Dependency_Map
121
-     */
122
-    public static function instance(ClassInterfaceCache $class_cache = null)
123
-    {
124
-        // check if class object is instantiated, and instantiated properly
125
-        if (! self::$_instance instanceof EE_Dependency_Map
126
-            && $class_cache instanceof ClassInterfaceCache
127
-        ) {
128
-            self::$_instance = new EE_Dependency_Map($class_cache);
129
-        }
130
-        return self::$_instance;
131
-    }
132
-
133
-
134
-    /**
135
-     * @param RequestInterface $request
136
-     */
137
-    public function setRequest(RequestInterface $request)
138
-    {
139
-        $this->request = $request;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param LegacyRequestInterface $legacy_request
145
-     */
146
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
-    {
148
-        $this->legacy_request = $legacy_request;
149
-    }
150
-
151
-
152
-    /**
153
-     * @param ResponseInterface $response
154
-     */
155
-    public function setResponse(ResponseInterface $response)
156
-    {
157
-        $this->response = $response;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param LoaderInterface $loader
163
-     */
164
-    public function setLoader(LoaderInterface $loader)
165
-    {
166
-        $this->loader = $loader;
167
-    }
168
-
169
-
170
-    /**
171
-     * @param string $class
172
-     * @param array  $dependencies
173
-     * @param int    $overwrite
174
-     * @return bool
175
-     */
176
-    public static function register_dependencies(
177
-        $class,
178
-        array $dependencies,
179
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
-    ) {
181
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
-    }
183
-
184
-
185
-    /**
186
-     * Assigns an array of class names and corresponding load sources (new or cached)
187
-     * to the class specified by the first parameter.
188
-     * IMPORTANT !!!
189
-     * The order of elements in the incoming $dependencies array MUST match
190
-     * the order of the constructor parameters for the class in question.
191
-     * This is especially important when overriding any existing dependencies that are registered.
192
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
-     *
194
-     * @param string $class
195
-     * @param array  $dependencies
196
-     * @param int    $overwrite
197
-     * @return bool
198
-     */
199
-    public function registerDependencies(
200
-        $class,
201
-        array $dependencies,
202
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
-    ) {
204
-        $class      = trim($class, '\\');
205
-        $registered = false;
206
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
207
-            self::$_instance->_dependency_map[ $class ] = [];
208
-        }
209
-        // we need to make sure that any aliases used when registering a dependency
210
-        // get resolved to the correct class name
211
-        foreach ($dependencies as $dependency => $load_source) {
212
-            $alias = self::$_instance->getFqnForAlias($dependency);
213
-            if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
-            ) {
216
-                unset($dependencies[ $dependency ]);
217
-                $dependencies[ $alias ] = $load_source;
218
-                $registered             = true;
219
-            }
220
-        }
221
-        // now add our two lists of dependencies together.
222
-        // using Union (+=) favours the arrays in precedence from left to right,
223
-        // so $dependencies is NOT overwritten because it is listed first
224
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
-        // Union is way faster than array_merge() but should be used with caution...
226
-        // especially with numerically indexed arrays
227
-        $dependencies += self::$_instance->_dependency_map[ $class ];
228
-        // now we need to ensure that the resulting dependencies
229
-        // array only has the entries that are required for the class
230
-        // so first count how many dependencies were originally registered for the class
231
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
-        // if that count is non-zero (meaning dependencies were already registered)
233
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
234
-            // then truncate the  final array to match that count
235
-            ? array_slice($dependencies, 0, $dependency_count)
236
-            // otherwise just take the incoming array because nothing previously existed
237
-            : $dependencies;
238
-        return $registered;
239
-    }
240
-
241
-
242
-    /**
243
-     * @param string $class_name
244
-     * @param string $loader
245
-     * @param bool   $overwrite
246
-     * @return bool
247
-     * @throws DomainException
248
-     */
249
-    public static function register_class_loader($class_name, $loader = 'load_core', $overwrite = false)
250
-    {
251
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
252
-            throw new DomainException(
253
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
254
-            );
255
-        }
256
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
257
-        if (! is_callable($loader)
258
-            && (
259
-                strpos($loader, 'load_') !== 0
260
-                || ! method_exists('EE_Registry', $loader)
261
-            )
262
-        ) {
263
-            throw new DomainException(
264
-                sprintf(
265
-                    esc_html__(
266
-                        '"%1$s" is not a valid loader method on EE_Registry.',
267
-                        'event_espresso'
268
-                    ),
269
-                    $loader
270
-                )
271
-            );
272
-        }
273
-        $class_name = self::$_instance->getFqnForAlias($class_name);
274
-        if ($overwrite || ! isset(self::$_instance->_class_loaders[ $class_name ])) {
275
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
276
-            return true;
277
-        }
278
-        return false;
279
-    }
280
-
281
-
282
-    /**
283
-     * @return array
284
-     */
285
-    public function dependency_map()
286
-    {
287
-        return $this->_dependency_map;
288
-    }
289
-
290
-
291
-    /**
292
-     * returns TRUE if dependency map contains a listing for the provided class name
293
-     *
294
-     * @param string $class_name
295
-     * @return boolean
296
-     */
297
-    public function has($class_name = '')
298
-    {
299
-        // all legacy models have the same dependencies
300
-        if (strpos($class_name, 'EEM_') === 0) {
301
-            $class_name = 'LEGACY_MODELS';
302
-        }
303
-        return isset($this->_dependency_map[ $class_name ]);
304
-    }
305
-
306
-
307
-    /**
308
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
309
-     *
310
-     * @param string $class_name
311
-     * @param string $dependency
312
-     * @return bool
313
-     */
314
-    public function has_dependency_for_class($class_name = '', $dependency = '')
315
-    {
316
-        // all legacy models have the same dependencies
317
-        if (strpos($class_name, 'EEM_') === 0) {
318
-            $class_name = 'LEGACY_MODELS';
319
-        }
320
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
321
-        return isset($this->_dependency_map[ $class_name ][ $dependency ]);
322
-    }
323
-
324
-
325
-    /**
326
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
327
-     *
328
-     * @param string $class_name
329
-     * @param string $dependency
330
-     * @return int
331
-     */
332
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
333
-    {
334
-        // all legacy models have the same dependencies
335
-        if (strpos($class_name, 'EEM_') === 0) {
336
-            $class_name = 'LEGACY_MODELS';
337
-        }
338
-        $dependency = $this->getFqnForAlias($dependency);
339
-        return $this->has_dependency_for_class($class_name, $dependency)
340
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
341
-            : EE_Dependency_Map::not_registered;
342
-    }
343
-
344
-
345
-    /**
346
-     * @param string $class_name
347
-     * @return string | Closure
348
-     */
349
-    public function class_loader($class_name)
350
-    {
351
-        // all legacy models use load_model()
352
-        if (strpos($class_name, 'EEM_') === 0) {
353
-            return 'load_model';
354
-        }
355
-        // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
356
-        // perform strpos() first to avoid loading regex every time we load a class
357
-        if (strpos($class_name, 'EE_CPT_') === 0
358
-            && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
359
-        ) {
360
-            return 'load_core';
361
-        }
362
-        $class_name = $this->getFqnForAlias($class_name);
363
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
364
-    }
365
-
366
-
367
-    /**
368
-     * @return array
369
-     */
370
-    public function class_loaders()
371
-    {
372
-        return $this->_class_loaders;
373
-    }
374
-
375
-
376
-    /**
377
-     * adds an alias for a classname
378
-     *
379
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
380
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
381
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
382
-     */
383
-    public function add_alias($fqcn, $alias, $for_class = '')
384
-    {
385
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
386
-    }
387
-
388
-
389
-    /**
390
-     * Returns TRUE if the provided fully qualified name IS an alias
391
-     * WHY?
392
-     * Because if a class is type hinting for a concretion,
393
-     * then why would we need to find another class to supply it?
394
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
395
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
396
-     * Don't go looking for some substitute.
397
-     * Whereas if a class is type hinting for an interface...
398
-     * then we need to find an actual class to use.
399
-     * So the interface IS the alias for some other FQN,
400
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
401
-     * represents some other class.
402
-     *
403
-     * @param string $fqn
404
-     * @param string $for_class
405
-     * @return bool
406
-     */
407
-    public function isAlias($fqn = '', $for_class = '')
408
-    {
409
-        return $this->class_cache->isAlias($fqn, $for_class);
410
-    }
411
-
412
-
413
-    /**
414
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
415
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
416
-     *  for example:
417
-     *      if the following two entries were added to the _aliases array:
418
-     *          array(
419
-     *              'interface_alias'           => 'some\namespace\interface'
420
-     *              'some\namespace\interface'  => 'some\namespace\classname'
421
-     *          )
422
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
423
-     *      to load an instance of 'some\namespace\classname'
424
-     *
425
-     * @param string $alias
426
-     * @param string $for_class
427
-     * @return string
428
-     */
429
-    public function getFqnForAlias($alias = '', $for_class = '')
430
-    {
431
-        return $this->class_cache->getFqnForAlias($alias, $for_class);
432
-    }
433
-
434
-
435
-    /**
436
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
437
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
438
-     * This is done by using the following class constants:
439
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
440
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
441
-     */
442
-    protected function _register_core_dependencies()
443
-    {
444
-        $this->_dependency_map = [
445
-            'EE_Admin'                                                                                          => [
446
-                'EventEspresso\core\services\request\Request'     => EE_Dependency_Map::load_from_cache,
447
-            ],
448
-            'EE_Request_Handler'                                                                                          => [
449
-                'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache,
450
-                'EventEspresso\core\services\request\Request'     => EE_Dependency_Map::load_from_cache,
451
-                'EventEspresso\core\services\request\Response'    => EE_Dependency_Map::load_from_cache,
452
-            ],
453
-            'EE_System'                                                                                                   => [
454
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
455
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
456
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
457
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
458
-            ],
459
-            'EE_Session'                                                                                                  => [
460
-                'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
461
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
462
-                'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
463
-                'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
464
-                'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
465
-            ],
466
-            'EE_Cart'                                                                                                     => [
467
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
468
-            ],
469
-            'EE_Front_Controller'                                                                                         => [
470
-                'EE_Registry'                                     => EE_Dependency_Map::load_from_cache,
471
-                'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache,
472
-                'EE_Module_Request_Router'                        => EE_Dependency_Map::load_from_cache,
473
-            ],
474
-            'EE_Messenger_Collection_Loader'                                                                              => [
475
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
476
-            ],
477
-            'EE_Message_Type_Collection_Loader'                                                                           => [
478
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
479
-            ],
480
-            'EE_Message_Resource_Manager'                                                                                 => [
481
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
482
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
483
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
484
-            ],
485
-            'EE_Message_Factory'                                                                                          => [
486
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
487
-            ],
488
-            'EE_messages'                                                                                                 => [
489
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
490
-            ],
491
-            'EE_Messages_Generator'                                                                                       => [
492
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
493
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
494
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
495
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
496
-            ],
497
-            'EE_Messages_Processor'                                                                                       => [
498
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
499
-            ],
500
-            'EE_Messages_Queue'                                                                                           => [
501
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
502
-            ],
503
-            'EE_Messages_Template_Defaults'                                                                               => [
504
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
505
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
506
-            ],
507
-            'EE_Message_To_Generate_From_Request'                                                                         => [
508
-                'EE_Message_Resource_Manager'                 => EE_Dependency_Map::load_from_cache,
509
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
510
-            ],
511
-            'EventEspresso\core\services\commands\CommandBus'                                                             => [
512
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
513
-            ],
514
-            'EventEspresso\services\commands\CommandHandler'                                                              => [
515
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
516
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
517
-            ],
518
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => [
519
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
520
-            ],
521
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => [
522
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
523
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
524
-            ],
525
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => [
526
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
527
-            ],
528
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => [
529
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
530
-            ],
531
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => [
532
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
533
-            ],
534
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => [
535
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
536
-            ],
537
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => [
538
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
539
-            ],
540
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => [
541
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
542
-            ],
543
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => [
544
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
545
-            ],
546
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => [
547
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
548
-            ],
549
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [
550
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
551
-            ],
552
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => [
553
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
554
-            ],
555
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => [
556
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
557
-            ],
558
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => [
559
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
560
-            ],
561
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => [
562
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
563
-            ],
564
-            'EventEspresso\core\services\database\TableManager'                                                           => [
565
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
566
-            ],
567
-            'EE_Data_Migration_Class_Base'                                                                                => [
568
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
-            ],
571
-            'EE_DMS_Core_4_1_0'                                                                                           => [
572
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
-            ],
575
-            'EE_DMS_Core_4_2_0'                                                                                           => [
576
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
-            ],
579
-            'EE_DMS_Core_4_3_0'                                                                                           => [
580
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
-            ],
583
-            'EE_DMS_Core_4_4_0'                                                                                           => [
584
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
-            ],
587
-            'EE_DMS_Core_4_5_0'                                                                                           => [
588
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
-            ],
591
-            'EE_DMS_Core_4_6_0'                                                                                           => [
592
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
-            ],
595
-            'EE_DMS_Core_4_7_0'                                                                                           => [
596
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
-            ],
599
-            'EE_DMS_Core_4_8_0'                                                                                           => [
600
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
-            ],
603
-            'EE_DMS_Core_4_9_0'                                                                                           => [
604
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
605
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
606
-            ],
607
-            'EE_DMS_Core_4_10_0'                                                                                          => [
608
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
609
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
610
-                'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
611
-            ],
612
-            'EventEspresso\core\services\assets\I18nRegistry'                                                             => [
613
-                [],
614
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
615
-            ],
616
-            'EventEspresso\core\services\assets\Registry'                                                                 => [
617
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
618
-                'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
619
-            ],
620
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => [
621
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
622
-            ],
623
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => [
624
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
625
-            ],
626
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => [
627
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
628
-            ],
629
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => [
630
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
631
-            ],
632
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => [
633
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
634
-            ],
635
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => [
636
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
637
-            ],
638
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => [
639
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
640
-            ],
641
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => [
642
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
643
-            ],
644
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => [
645
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
646
-            ],
647
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => [
648
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
649
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
650
-            ],
651
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => [
652
-                null,
653
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
654
-            ],
655
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => [
656
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
657
-            ],
658
-            'LEGACY_MODELS'                                                                                               => [
659
-                null,
660
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
661
-            ],
662
-            'EE_Module_Request_Router'                                                                                    => [
663
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
664
-            ],
665
-            'EE_Registration_Processor'                                                                                   => [
666
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
667
-            ],
668
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => [
669
-                null,
670
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
671
-                'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
672
-            ],
673
-            'EventEspresso\core\services\licensing\LicenseService'                                                        => [
674
-                'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
675
-                'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
676
-            ],
677
-            'EE_Admin_Transactions_List_Table'                                                                            => [
678
-                null,
679
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
680
-            ],
681
-            'EventEspresso\core\domain\services\pue\Stats'                                                                => [
682
-                'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
683
-                'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
684
-                'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
685
-            ],
686
-            'EventEspresso\core\domain\services\pue\Config'                                                               => [
687
-                'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
688
-                'EE_Config'         => EE_Dependency_Map::load_from_cache,
689
-            ],
690
-            'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => [
691
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
692
-                'EEM_Event'          => EE_Dependency_Map::load_from_cache,
693
-                'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
694
-                'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
695
-                'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
696
-                'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
697
-                'EE_Config'          => EE_Dependency_Map::load_from_cache,
698
-            ],
699
-            'EventEspresso\core\domain\services\admin\ExitModal'                                                          => [
700
-                'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
701
-            ],
702
-            'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => [
703
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
704
-            ],
705
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => [
706
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
707
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
708
-            ],
709
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => [
710
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
711
-            ],
712
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => [
713
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
714
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
715
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
716
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
717
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
718
-            ],
719
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => [
720
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
721
-            ],
722
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => [
723
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
724
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
725
-            ],
726
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => [
727
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
728
-            ],
729
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => [
730
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
731
-            ],
732
-            'EE_CPT_Strategy'                                                                                             => [
733
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
734
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
735
-            ],
736
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => [
737
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
738
-            ],
739
-            'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => [
740
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
741
-                'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
742
-                'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
743
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
744
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
745
-            ],
746
-            'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy'                                       => [
747
-                'EEM_Payment_Method'                                       => EE_Dependency_Map::load_from_cache,
748
-                'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
749
-            ],
750
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee'                                      => [
751
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
752
-            ],
753
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData'                           => [
754
-                'EEM_Attendee'       => EE_Dependency_Map::load_from_cache,
755
-                'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
756
-            ],
757
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins'                                      => [
758
-                'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
759
-            ],
760
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration'                                  => [
761
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
762
-            ],
763
-            'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction'                                   => [
764
-                'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
765
-            ],
766
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData'                                  => [
767
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
768
-            ],
769
-            'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers'                                       => [
770
-                'EEM_Answer'   => EE_Dependency_Map::load_from_cache,
771
-                'EEM_Question' => EE_Dependency_Map::load_from_cache,
772
-            ],
773
-            'EventEspresso\core\CPTs\CptQueryModifier'                                                                    => [
774
-                null,
775
-                null,
776
-                null,
777
-                'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache,
778
-                'EventEspresso\core\services\request\Request'     => EE_Dependency_Map::load_from_cache,
779
-                'EventEspresso\core\services\loaders\Loader'      => EE_Dependency_Map::load_from_cache,
780
-            ],
781
-            'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'                           => [
782
-                'EE_Registry' => EE_Dependency_Map::load_from_cache,
783
-                'EE_Config'   => EE_Dependency_Map::load_from_cache,
784
-            ],
785
-            'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => [
786
-                'EventEspresso\core\services\assets\BlockAssetManagerCollection'         => EE_Dependency_Map::load_from_cache,
787
-                'EventEspresso\core\domain\entities\editor\BlockCollection'              => EE_Dependency_Map::load_from_cache,
788
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
789
-                'EventEspresso\core\services\request\Request'                            => EE_Dependency_Map::load_from_cache,
790
-            ],
791
-            'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager'                                            => [
792
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
793
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
794
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
795
-            ],
796
-            'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer'                                       => [
797
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
798
-                'EEM_Attendee'                     => EE_Dependency_Map::load_from_cache,
799
-            ],
800
-            'EventEspresso\core\domain\entities\editor\blocks\EventAttendees'                                             => [
801
-                'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager'      => self::load_from_cache,
802
-                'EventEspresso\core\services\request\Request'                           => EE_Dependency_Map::load_from_cache,
803
-                'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
804
-            ],
805
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver'                           => [
806
-                'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
807
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
808
-                'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
809
-            ],
810
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory'                                      => [
811
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
812
-                'EventEspresso\core\services\loaders\Loader'                                        => EE_Dependency_Map::load_from_cache,
813
-            ],
814
-            'EventEspresso\core\services\route_match\RouteMatchSpecificationManager'                                      => [
815
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
816
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory'    => EE_Dependency_Map::load_from_cache,
817
-            ],
818
-            'EventEspresso\core\libraries\rest_api\CalculatedModelFields'                                                 => [
819
-                'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache,
820
-            ],
821
-            'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory'                             => [
822
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
823
-            ],
824
-            'EventEspresso\core\libraries\rest_api\controllers\model\Read'                                                => [
825
-                'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache,
826
-            ],
827
-            'EventEspresso\core\libraries\rest_api\calculations\Datetime'                                                 => [
828
-                'EEM_Datetime'     => EE_Dependency_Map::load_from_cache,
829
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
830
-            ],
831
-            'EventEspresso\core\libraries\rest_api\calculations\Event'                                                    => [
832
-                'EEM_Event'        => EE_Dependency_Map::load_from_cache,
833
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
834
-            ],
835
-            'EventEspresso\core\libraries\rest_api\calculations\Registration'                                             => [
836
-                'EEM_Registration' => EE_Dependency_Map::load_from_cache,
837
-            ],
838
-            'EventEspresso\core\services\session\SessionStartHandler'                                                     => [
839
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
840
-            ],
841
-            'EE_URL_Validation_Strategy'                                                                                  => [
842
-                null,
843
-                null,
844
-                'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache,
845
-            ],
846
-            'EventEspresso\admin_pages\general_settings\OrganizationSettings'                                             => [
847
-                'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
848
-                'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
849
-                'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
850
-                'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
851
-                'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
852
-            ],
853
-            'EventEspresso\core\services\address\CountrySubRegionDao'                                                     => [
854
-                'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
855
-                'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache,
856
-            ],
857
-            'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat'                                            => [
858
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
859
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
860
-            ],
861
-            'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat'                                          => [
862
-                'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
863
-                'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
864
-            ],
865
-            'EventEspresso\core\services\request\files\FilesDataHandler'                                                  => [
866
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
867
-            ],
868
-            'EventEspressoBatchRequest\BatchRequestProcessor'                                                             => [
869
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
870
-            ],
871
-            'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder'                              => [
872
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
873
-                'EEM_Registration'                            => EE_Dependency_Map::load_from_cache,
874
-                null,
875
-            ],
876
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader'          => [
877
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
878
-                'EEM_Attendee'                                => EE_Dependency_Map::load_from_cache,
879
-            ],
880
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader'              => [
881
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
882
-                'EEM_Datetime'                                => EE_Dependency_Map::load_from_cache,
883
-            ],
884
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader'             => [
885
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
886
-                'EEM_Event'                                   => EE_Dependency_Map::load_from_cache,
887
-            ],
888
-            'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader'            => [
889
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
890
-                'EEM_Ticket'                                  => EE_Dependency_Map::load_from_cache,
891
-            ],
892
-            'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion'                                                  => [
893
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
894
-            ],
895
-            'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion'                                                  => [
896
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
897
-            ],
898
-            'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion'                                        => [
899
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
900
-                'EEM_Event'                                                   => EE_Dependency_Map::load_from_cache,
901
-                'EEM_Datetime'                                                => EE_Dependency_Map::load_from_cache,
902
-                'EEM_Registration'                                            => EE_Dependency_Map::load_from_cache,
903
-            ],
904
-            'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion'                                        => [
905
-                'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
906
-            ],
907
-            'EventEspresso\core\services\request\CurrentPage'                                                             => [
908
-                'EE_CPT_Strategy'                             => EE_Dependency_Map::load_from_cache,
909
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
910
-            ],
911
-            'EventEspresso\core\services\shortcodes\LegacyShortcodesManager'                                              => [
912
-                'EE_Registry'                                     => EE_Dependency_Map::load_from_cache,
913
-                'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache,
914
-            ],
915
-            'EventEspresso\core\services\shortcodes\ShortcodesManager'                                                    => [
916
-                'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache,
917
-                'EventEspresso\core\services\request\CurrentPage'                => EE_Dependency_Map::load_from_cache,
918
-            ],
919
-        ];
920
-    }
921
-
922
-
923
-    /**
924
-     * Registers how core classes are loaded.
925
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
926
-     *        'EE_Request_Handler' => 'load_core'
927
-     *        'EE_Messages_Queue'  => 'load_lib'
928
-     *        'EEH_Debug_Tools'    => 'load_helper'
929
-     * or, if greater control is required, by providing a custom closure. For example:
930
-     *        'Some_Class' => function () {
931
-     *            return new Some_Class();
932
-     *        },
933
-     * This is required for instantiating dependencies
934
-     * where an interface has been type hinted in a class constructor. For example:
935
-     *        'Required_Interface' => function () {
936
-     *            return new A_Class_That_Implements_Required_Interface();
937
-     *        },
938
-     */
939
-    protected function _register_core_class_loaders()
940
-    {
941
-        $this->_class_loaders = [
942
-            // load_core
943
-            'EE_Dependency_Map'                            => function () {
944
-                return $this;
945
-            },
946
-            'EE_Capabilities'                              => 'load_core',
947
-            'EE_Encryption'                                => 'load_core',
948
-            'EE_Front_Controller'                          => 'load_core',
949
-            'EE_Module_Request_Router'                     => 'load_core',
950
-            'EE_Registry'                                  => 'load_core',
951
-            'EE_Request'                                   => function () {
952
-                return $this->legacy_request;
953
-            },
954
-            'EventEspresso\core\services\request\Request'  => function () {
955
-                return $this->request;
956
-            },
957
-            'EventEspresso\core\services\request\Response' => function () {
958
-                return $this->response;
959
-            },
960
-            'EE_Base'                                      => 'load_core',
961
-            'EE_Request_Handler'                           => 'load_core',
962
-            'EE_Session'                                   => 'load_core',
963
-            'EE_Cron_Tasks'                                => 'load_core',
964
-            'EE_System'                                    => 'load_core',
965
-            'EE_Maintenance_Mode'                          => 'load_core',
966
-            'EE_Register_CPTs'                             => 'load_core',
967
-            'EE_Admin'                                     => 'load_core',
968
-            'EE_CPT_Strategy'                              => 'load_core',
969
-            // load_class
970
-            'EE_Registration_Processor'                    => 'load_class',
971
-            // load_lib
972
-            'EE_Message_Resource_Manager'                  => 'load_lib',
973
-            'EE_Message_Type_Collection'                   => 'load_lib',
974
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
975
-            'EE_Messenger_Collection'                      => 'load_lib',
976
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
977
-            'EE_Messages_Processor'                        => 'load_lib',
978
-            'EE_Message_Repository'                        => 'load_lib',
979
-            'EE_Messages_Queue'                            => 'load_lib',
980
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
981
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
982
-            'EE_Payment_Method_Manager'                    => 'load_lib',
983
-            'EE_DMS_Core_4_1_0'                            => 'load_dms',
984
-            'EE_DMS_Core_4_2_0'                            => 'load_dms',
985
-            'EE_DMS_Core_4_3_0'                            => 'load_dms',
986
-            'EE_DMS_Core_4_5_0'                            => 'load_dms',
987
-            'EE_DMS_Core_4_6_0'                            => 'load_dms',
988
-            'EE_DMS_Core_4_7_0'                            => 'load_dms',
989
-            'EE_DMS_Core_4_8_0'                            => 'load_dms',
990
-            'EE_DMS_Core_4_9_0'                            => 'load_dms',
991
-            'EE_DMS_Core_4_10_0'                           => 'load_dms',
992
-            'EE_Messages_Generator'                        => function () {
993
-                return EE_Registry::instance()->load_lib(
994
-                    'Messages_Generator',
995
-                    [],
996
-                    false,
997
-                    false
998
-                );
999
-            },
1000
-            'EE_Messages_Template_Defaults'                => function ($arguments = []) {
1001
-                return EE_Registry::instance()->load_lib(
1002
-                    'Messages_Template_Defaults',
1003
-                    $arguments,
1004
-                    false,
1005
-                    false
1006
-                );
1007
-            },
1008
-            // load_helper
1009
-            'EEH_Parse_Shortcodes'                         => function () {
1010
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
1011
-                    return new EEH_Parse_Shortcodes();
1012
-                }
1013
-                return null;
1014
-            },
1015
-            'EE_Template_Config'                           => function () {
1016
-                return EE_Config::instance()->template_settings;
1017
-            },
1018
-            'EE_Currency_Config'                           => function () {
1019
-                return EE_Config::instance()->currency;
1020
-            },
1021
-            'EE_Registration_Config'                       => function () {
1022
-                return EE_Config::instance()->registration;
1023
-            },
1024
-            'EE_Core_Config'                               => function () {
1025
-                return EE_Config::instance()->core;
1026
-            },
1027
-            'EventEspresso\core\services\loaders\Loader'   => function () {
1028
-                return LoaderFactory::getLoader();
1029
-            },
1030
-            'EE_Network_Config'                            => function () {
1031
-                return EE_Network_Config::instance();
1032
-            },
1033
-            'EE_Config'                                    => function () {
1034
-                return EE_Config::instance();
1035
-            },
1036
-            'EventEspresso\core\domain\Domain'             => function () {
1037
-                return DomainFactory::getEventEspressoCoreDomain();
1038
-            },
1039
-            'EE_Admin_Config'                              => function () {
1040
-                return EE_Config::instance()->admin;
1041
-            },
1042
-            'EE_Organization_Config'                       => function () {
1043
-                return EE_Config::instance()->organization;
1044
-            },
1045
-            'EE_Network_Core_Config'                       => function () {
1046
-                return EE_Network_Config::instance()->core;
1047
-            },
1048
-            'EE_Environment_Config'                        => function () {
1049
-                return EE_Config::instance()->environment;
1050
-            },
1051
-        ];
1052
-    }
1053
-
1054
-
1055
-    /**
1056
-     * can be used for supplying alternate names for classes,
1057
-     * or for connecting interface names to instantiable classes
1058
-     */
1059
-    protected function _register_core_aliases()
1060
-    {
1061
-        $aliases = [
1062
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1063
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1064
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1065
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1066
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1067
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1068
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1069
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1070
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1071
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1072
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1073
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1074
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1075
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1076
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1077
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1078
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1079
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1080
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1081
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1082
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1083
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1084
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1085
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1086
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1087
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1088
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1089
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1090
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1091
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1092
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1093
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1094
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1095
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1096
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1097
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1098
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1099
-            'Registration_Processor'                                                       => 'EE_Registration_Processor',
1100
-        ];
1101
-        foreach ($aliases as $alias => $fqn) {
1102
-            if (is_array($fqn)) {
1103
-                foreach ($fqn as $class => $for_class) {
1104
-                    $this->class_cache->addAlias($class, $alias, $for_class);
1105
-                }
1106
-                continue;
1107
-            }
1108
-            $this->class_cache->addAlias($fqn, $alias);
1109
-        }
1110
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1111
-            $this->class_cache->addAlias(
1112
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1113
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
1114
-            );
1115
-        }
1116
-    }
1117
-
1118
-
1119
-    public function debug($for_class = '')
1120
-    {
1121
-        $this->class_cache->debug($for_class);
1122
-    }
1123
-
1124
-
1125
-    /**
1126
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1127
-     * request Primarily used by unit tests.
1128
-     */
1129
-    public function reset()
1130
-    {
1131
-        $this->_register_core_class_loaders();
1132
-        $this->_register_core_dependencies();
1133
-    }
1134
-
1135
-
1136
-    /**
1137
-     * PLZ NOTE: a better name for this method would be is_alias()
1138
-     * because it returns TRUE if the provided fully qualified name IS an alias
1139
-     * WHY?
1140
-     * Because if a class is type hinting for a concretion,
1141
-     * then why would we need to find another class to supply it?
1142
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1143
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1144
-     * Don't go looking for some substitute.
1145
-     * Whereas if a class is type hinting for an interface...
1146
-     * then we need to find an actual class to use.
1147
-     * So the interface IS the alias for some other FQN,
1148
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1149
-     * represents some other class.
1150
-     *
1151
-     * @param string $fqn
1152
-     * @param string $for_class
1153
-     * @return bool
1154
-     * @deprecated 4.9.62.p
1155
-     */
1156
-    public function has_alias($fqn = '', $for_class = '')
1157
-    {
1158
-        return $this->isAlias($fqn, $for_class);
1159
-    }
1160
-
1161
-
1162
-    /**
1163
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1164
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1165
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
1166
-     *  for example:
1167
-     *      if the following two entries were added to the _aliases array:
1168
-     *          array(
1169
-     *              'interface_alias'           => 'some\namespace\interface'
1170
-     *              'some\namespace\interface'  => 'some\namespace\classname'
1171
-     *          )
1172
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1173
-     *      to load an instance of 'some\namespace\classname'
1174
-     *
1175
-     * @param string $alias
1176
-     * @param string $for_class
1177
-     * @return string
1178
-     * @deprecated 4.9.62.p
1179
-     */
1180
-    public function get_alias($alias = '', $for_class = '')
1181
-    {
1182
-        return $this->getFqnForAlias($alias, $for_class);
1183
-    }
23
+	/**
24
+	 * This means that the requested class dependency is not present in the dependency map
25
+	 */
26
+	const not_registered = 0;
27
+
28
+	/**
29
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
30
+	 */
31
+	const load_new_object = 1;
32
+
33
+	/**
34
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
35
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
36
+	 */
37
+	const load_from_cache = 2;
38
+
39
+	/**
40
+	 * When registering a dependency,
41
+	 * this indicates to keep any existing dependencies that already exist,
42
+	 * and simply discard any new dependencies declared in the incoming data
43
+	 */
44
+	const KEEP_EXISTING_DEPENDENCIES = 0;
45
+
46
+	/**
47
+	 * When registering a dependency,
48
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
49
+	 */
50
+	const OVERWRITE_DEPENDENCIES = 1;
51
+
52
+
53
+	/**
54
+	 * @type EE_Dependency_Map $_instance
55
+	 */
56
+	protected static $_instance;
57
+
58
+	/**
59
+	 * @var ClassInterfaceCache $class_cache
60
+	 */
61
+	private $class_cache;
62
+
63
+	/**
64
+	 * @type RequestInterface $request
65
+	 */
66
+	protected $request;
67
+
68
+	/**
69
+	 * @type LegacyRequestInterface $legacy_request
70
+	 */
71
+	protected $legacy_request;
72
+
73
+	/**
74
+	 * @type ResponseInterface $response
75
+	 */
76
+	protected $response;
77
+
78
+	/**
79
+	 * @type LoaderInterface $loader
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @type array $_dependency_map
85
+	 */
86
+	protected $_dependency_map = [];
87
+
88
+	/**
89
+	 * @type array $_class_loaders
90
+	 */
91
+	protected $_class_loaders = [];
92
+
93
+
94
+	/**
95
+	 * EE_Dependency_Map constructor.
96
+	 *
97
+	 * @param ClassInterfaceCache $class_cache
98
+	 */
99
+	protected function __construct(ClassInterfaceCache $class_cache)
100
+	{
101
+		$this->class_cache = $class_cache;
102
+		do_action('EE_Dependency_Map____construct', $this);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return void
108
+	 */
109
+	public function initialize()
110
+	{
111
+		$this->_register_core_dependencies();
112
+		$this->_register_core_class_loaders();
113
+		$this->_register_core_aliases();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @singleton method used to instantiate class object
119
+	 * @param ClassInterfaceCache|null $class_cache
120
+	 * @return EE_Dependency_Map
121
+	 */
122
+	public static function instance(ClassInterfaceCache $class_cache = null)
123
+	{
124
+		// check if class object is instantiated, and instantiated properly
125
+		if (! self::$_instance instanceof EE_Dependency_Map
126
+			&& $class_cache instanceof ClassInterfaceCache
127
+		) {
128
+			self::$_instance = new EE_Dependency_Map($class_cache);
129
+		}
130
+		return self::$_instance;
131
+	}
132
+
133
+
134
+	/**
135
+	 * @param RequestInterface $request
136
+	 */
137
+	public function setRequest(RequestInterface $request)
138
+	{
139
+		$this->request = $request;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param LegacyRequestInterface $legacy_request
145
+	 */
146
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
147
+	{
148
+		$this->legacy_request = $legacy_request;
149
+	}
150
+
151
+
152
+	/**
153
+	 * @param ResponseInterface $response
154
+	 */
155
+	public function setResponse(ResponseInterface $response)
156
+	{
157
+		$this->response = $response;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param LoaderInterface $loader
163
+	 */
164
+	public function setLoader(LoaderInterface $loader)
165
+	{
166
+		$this->loader = $loader;
167
+	}
168
+
169
+
170
+	/**
171
+	 * @param string $class
172
+	 * @param array  $dependencies
173
+	 * @param int    $overwrite
174
+	 * @return bool
175
+	 */
176
+	public static function register_dependencies(
177
+		$class,
178
+		array $dependencies,
179
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
180
+	) {
181
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
182
+	}
183
+
184
+
185
+	/**
186
+	 * Assigns an array of class names and corresponding load sources (new or cached)
187
+	 * to the class specified by the first parameter.
188
+	 * IMPORTANT !!!
189
+	 * The order of elements in the incoming $dependencies array MUST match
190
+	 * the order of the constructor parameters for the class in question.
191
+	 * This is especially important when overriding any existing dependencies that are registered.
192
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
193
+	 *
194
+	 * @param string $class
195
+	 * @param array  $dependencies
196
+	 * @param int    $overwrite
197
+	 * @return bool
198
+	 */
199
+	public function registerDependencies(
200
+		$class,
201
+		array $dependencies,
202
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
203
+	) {
204
+		$class      = trim($class, '\\');
205
+		$registered = false;
206
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
207
+			self::$_instance->_dependency_map[ $class ] = [];
208
+		}
209
+		// we need to make sure that any aliases used when registering a dependency
210
+		// get resolved to the correct class name
211
+		foreach ($dependencies as $dependency => $load_source) {
212
+			$alias = self::$_instance->getFqnForAlias($dependency);
213
+			if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
215
+			) {
216
+				unset($dependencies[ $dependency ]);
217
+				$dependencies[ $alias ] = $load_source;
218
+				$registered             = true;
219
+			}
220
+		}
221
+		// now add our two lists of dependencies together.
222
+		// using Union (+=) favours the arrays in precedence from left to right,
223
+		// so $dependencies is NOT overwritten because it is listed first
224
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
225
+		// Union is way faster than array_merge() but should be used with caution...
226
+		// especially with numerically indexed arrays
227
+		$dependencies += self::$_instance->_dependency_map[ $class ];
228
+		// now we need to ensure that the resulting dependencies
229
+		// array only has the entries that are required for the class
230
+		// so first count how many dependencies were originally registered for the class
231
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
232
+		// if that count is non-zero (meaning dependencies were already registered)
233
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
234
+			// then truncate the  final array to match that count
235
+			? array_slice($dependencies, 0, $dependency_count)
236
+			// otherwise just take the incoming array because nothing previously existed
237
+			: $dependencies;
238
+		return $registered;
239
+	}
240
+
241
+
242
+	/**
243
+	 * @param string $class_name
244
+	 * @param string $loader
245
+	 * @param bool   $overwrite
246
+	 * @return bool
247
+	 * @throws DomainException
248
+	 */
249
+	public static function register_class_loader($class_name, $loader = 'load_core', $overwrite = false)
250
+	{
251
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
252
+			throw new DomainException(
253
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
254
+			);
255
+		}
256
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
257
+		if (! is_callable($loader)
258
+			&& (
259
+				strpos($loader, 'load_') !== 0
260
+				|| ! method_exists('EE_Registry', $loader)
261
+			)
262
+		) {
263
+			throw new DomainException(
264
+				sprintf(
265
+					esc_html__(
266
+						'"%1$s" is not a valid loader method on EE_Registry.',
267
+						'event_espresso'
268
+					),
269
+					$loader
270
+				)
271
+			);
272
+		}
273
+		$class_name = self::$_instance->getFqnForAlias($class_name);
274
+		if ($overwrite || ! isset(self::$_instance->_class_loaders[ $class_name ])) {
275
+			self::$_instance->_class_loaders[ $class_name ] = $loader;
276
+			return true;
277
+		}
278
+		return false;
279
+	}
280
+
281
+
282
+	/**
283
+	 * @return array
284
+	 */
285
+	public function dependency_map()
286
+	{
287
+		return $this->_dependency_map;
288
+	}
289
+
290
+
291
+	/**
292
+	 * returns TRUE if dependency map contains a listing for the provided class name
293
+	 *
294
+	 * @param string $class_name
295
+	 * @return boolean
296
+	 */
297
+	public function has($class_name = '')
298
+	{
299
+		// all legacy models have the same dependencies
300
+		if (strpos($class_name, 'EEM_') === 0) {
301
+			$class_name = 'LEGACY_MODELS';
302
+		}
303
+		return isset($this->_dependency_map[ $class_name ]);
304
+	}
305
+
306
+
307
+	/**
308
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
309
+	 *
310
+	 * @param string $class_name
311
+	 * @param string $dependency
312
+	 * @return bool
313
+	 */
314
+	public function has_dependency_for_class($class_name = '', $dependency = '')
315
+	{
316
+		// all legacy models have the same dependencies
317
+		if (strpos($class_name, 'EEM_') === 0) {
318
+			$class_name = 'LEGACY_MODELS';
319
+		}
320
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
321
+		return isset($this->_dependency_map[ $class_name ][ $dependency ]);
322
+	}
323
+
324
+
325
+	/**
326
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
327
+	 *
328
+	 * @param string $class_name
329
+	 * @param string $dependency
330
+	 * @return int
331
+	 */
332
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
333
+	{
334
+		// all legacy models have the same dependencies
335
+		if (strpos($class_name, 'EEM_') === 0) {
336
+			$class_name = 'LEGACY_MODELS';
337
+		}
338
+		$dependency = $this->getFqnForAlias($dependency);
339
+		return $this->has_dependency_for_class($class_name, $dependency)
340
+			? $this->_dependency_map[ $class_name ][ $dependency ]
341
+			: EE_Dependency_Map::not_registered;
342
+	}
343
+
344
+
345
+	/**
346
+	 * @param string $class_name
347
+	 * @return string | Closure
348
+	 */
349
+	public function class_loader($class_name)
350
+	{
351
+		// all legacy models use load_model()
352
+		if (strpos($class_name, 'EEM_') === 0) {
353
+			return 'load_model';
354
+		}
355
+		// EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
356
+		// perform strpos() first to avoid loading regex every time we load a class
357
+		if (strpos($class_name, 'EE_CPT_') === 0
358
+			&& preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
359
+		) {
360
+			return 'load_core';
361
+		}
362
+		$class_name = $this->getFqnForAlias($class_name);
363
+		return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
364
+	}
365
+
366
+
367
+	/**
368
+	 * @return array
369
+	 */
370
+	public function class_loaders()
371
+	{
372
+		return $this->_class_loaders;
373
+	}
374
+
375
+
376
+	/**
377
+	 * adds an alias for a classname
378
+	 *
379
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
380
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
381
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
382
+	 */
383
+	public function add_alias($fqcn, $alias, $for_class = '')
384
+	{
385
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
386
+	}
387
+
388
+
389
+	/**
390
+	 * Returns TRUE if the provided fully qualified name IS an alias
391
+	 * WHY?
392
+	 * Because if a class is type hinting for a concretion,
393
+	 * then why would we need to find another class to supply it?
394
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
395
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
396
+	 * Don't go looking for some substitute.
397
+	 * Whereas if a class is type hinting for an interface...
398
+	 * then we need to find an actual class to use.
399
+	 * So the interface IS the alias for some other FQN,
400
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
401
+	 * represents some other class.
402
+	 *
403
+	 * @param string $fqn
404
+	 * @param string $for_class
405
+	 * @return bool
406
+	 */
407
+	public function isAlias($fqn = '', $for_class = '')
408
+	{
409
+		return $this->class_cache->isAlias($fqn, $for_class);
410
+	}
411
+
412
+
413
+	/**
414
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
415
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
416
+	 *  for example:
417
+	 *      if the following two entries were added to the _aliases array:
418
+	 *          array(
419
+	 *              'interface_alias'           => 'some\namespace\interface'
420
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
421
+	 *          )
422
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
423
+	 *      to load an instance of 'some\namespace\classname'
424
+	 *
425
+	 * @param string $alias
426
+	 * @param string $for_class
427
+	 * @return string
428
+	 */
429
+	public function getFqnForAlias($alias = '', $for_class = '')
430
+	{
431
+		return $this->class_cache->getFqnForAlias($alias, $for_class);
432
+	}
433
+
434
+
435
+	/**
436
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
437
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
438
+	 * This is done by using the following class constants:
439
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
440
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
441
+	 */
442
+	protected function _register_core_dependencies()
443
+	{
444
+		$this->_dependency_map = [
445
+			'EE_Admin'                                                                                          => [
446
+				'EventEspresso\core\services\request\Request'     => EE_Dependency_Map::load_from_cache,
447
+			],
448
+			'EE_Request_Handler'                                                                                          => [
449
+				'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache,
450
+				'EventEspresso\core\services\request\Request'     => EE_Dependency_Map::load_from_cache,
451
+				'EventEspresso\core\services\request\Response'    => EE_Dependency_Map::load_from_cache,
452
+			],
453
+			'EE_System'                                                                                                   => [
454
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
455
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
456
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
457
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
458
+			],
459
+			'EE_Session'                                                                                                  => [
460
+				'EventEspresso\core\services\cache\TransientCacheStorage'  => EE_Dependency_Map::load_from_cache,
461
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
462
+				'EventEspresso\core\services\request\Request'              => EE_Dependency_Map::load_from_cache,
463
+				'EventEspresso\core\services\session\SessionStartHandler'  => EE_Dependency_Map::load_from_cache,
464
+				'EE_Encryption'                                            => EE_Dependency_Map::load_from_cache,
465
+			],
466
+			'EE_Cart'                                                                                                     => [
467
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
468
+			],
469
+			'EE_Front_Controller'                                                                                         => [
470
+				'EE_Registry'                                     => EE_Dependency_Map::load_from_cache,
471
+				'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache,
472
+				'EE_Module_Request_Router'                        => EE_Dependency_Map::load_from_cache,
473
+			],
474
+			'EE_Messenger_Collection_Loader'                                                                              => [
475
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
476
+			],
477
+			'EE_Message_Type_Collection_Loader'                                                                           => [
478
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
479
+			],
480
+			'EE_Message_Resource_Manager'                                                                                 => [
481
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
482
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
483
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
484
+			],
485
+			'EE_Message_Factory'                                                                                          => [
486
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
487
+			],
488
+			'EE_messages'                                                                                                 => [
489
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
490
+			],
491
+			'EE_Messages_Generator'                                                                                       => [
492
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
493
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
494
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
495
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
496
+			],
497
+			'EE_Messages_Processor'                                                                                       => [
498
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
499
+			],
500
+			'EE_Messages_Queue'                                                                                           => [
501
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
502
+			],
503
+			'EE_Messages_Template_Defaults'                                                                               => [
504
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
505
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
506
+			],
507
+			'EE_Message_To_Generate_From_Request'                                                                         => [
508
+				'EE_Message_Resource_Manager'                 => EE_Dependency_Map::load_from_cache,
509
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
510
+			],
511
+			'EventEspresso\core\services\commands\CommandBus'                                                             => [
512
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
513
+			],
514
+			'EventEspresso\services\commands\CommandHandler'                                                              => [
515
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
516
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
517
+			],
518
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => [
519
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
520
+			],
521
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => [
522
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
523
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
524
+			],
525
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => [
526
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
527
+			],
528
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => [
529
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
530
+			],
531
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => [
532
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
533
+			],
534
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => [
535
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
536
+			],
537
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => [
538
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
539
+			],
540
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => [
541
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
542
+			],
543
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => [
544
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
545
+			],
546
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => [
547
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
548
+			],
549
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [
550
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
551
+			],
552
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => [
553
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
554
+			],
555
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => [
556
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
557
+			],
558
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => [
559
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
560
+			],
561
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => [
562
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
563
+			],
564
+			'EventEspresso\core\services\database\TableManager'                                                           => [
565
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
566
+			],
567
+			'EE_Data_Migration_Class_Base'                                                                                => [
568
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
569
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
570
+			],
571
+			'EE_DMS_Core_4_1_0'                                                                                           => [
572
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
573
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
574
+			],
575
+			'EE_DMS_Core_4_2_0'                                                                                           => [
576
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
577
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
578
+			],
579
+			'EE_DMS_Core_4_3_0'                                                                                           => [
580
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
581
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
582
+			],
583
+			'EE_DMS_Core_4_4_0'                                                                                           => [
584
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
585
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
586
+			],
587
+			'EE_DMS_Core_4_5_0'                                                                                           => [
588
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
589
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
590
+			],
591
+			'EE_DMS_Core_4_6_0'                                                                                           => [
592
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
593
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
594
+			],
595
+			'EE_DMS_Core_4_7_0'                                                                                           => [
596
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
597
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
598
+			],
599
+			'EE_DMS_Core_4_8_0'                                                                                           => [
600
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
601
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
602
+			],
603
+			'EE_DMS_Core_4_9_0'                                                                                           => [
604
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
605
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
606
+			],
607
+			'EE_DMS_Core_4_10_0'                                                                                          => [
608
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
609
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
610
+				'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
611
+			],
612
+			'EventEspresso\core\services\assets\I18nRegistry'                                                             => [
613
+				[],
614
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
615
+			],
616
+			'EventEspresso\core\services\assets\Registry'                                                                 => [
617
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
618
+				'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
619
+			],
620
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => [
621
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
622
+			],
623
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => [
624
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
625
+			],
626
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => [
627
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
628
+			],
629
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => [
630
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
631
+			],
632
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => [
633
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
634
+			],
635
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => [
636
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
637
+			],
638
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => [
639
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
640
+			],
641
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => [
642
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
643
+			],
644
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => [
645
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
646
+			],
647
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => [
648
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
649
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
650
+			],
651
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => [
652
+				null,
653
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
654
+			],
655
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => [
656
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
657
+			],
658
+			'LEGACY_MODELS'                                                                                               => [
659
+				null,
660
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
661
+			],
662
+			'EE_Module_Request_Router'                                                                                    => [
663
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
664
+			],
665
+			'EE_Registration_Processor'                                                                                   => [
666
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
667
+			],
668
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => [
669
+				null,
670
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
671
+				'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
672
+			],
673
+			'EventEspresso\core\services\licensing\LicenseService'                                                        => [
674
+				'EventEspresso\core\domain\services\pue\Stats'  => EE_Dependency_Map::load_from_cache,
675
+				'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache,
676
+			],
677
+			'EE_Admin_Transactions_List_Table'                                                                            => [
678
+				null,
679
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
680
+			],
681
+			'EventEspresso\core\domain\services\pue\Stats'                                                                => [
682
+				'EventEspresso\core\domain\services\pue\Config'        => EE_Dependency_Map::load_from_cache,
683
+				'EE_Maintenance_Mode'                                  => EE_Dependency_Map::load_from_cache,
684
+				'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache,
685
+			],
686
+			'EventEspresso\core\domain\services\pue\Config'                                                               => [
687
+				'EE_Network_Config' => EE_Dependency_Map::load_from_cache,
688
+				'EE_Config'         => EE_Dependency_Map::load_from_cache,
689
+			],
690
+			'EventEspresso\core\domain\services\pue\StatsGatherer'                                                        => [
691
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
692
+				'EEM_Event'          => EE_Dependency_Map::load_from_cache,
693
+				'EEM_Datetime'       => EE_Dependency_Map::load_from_cache,
694
+				'EEM_Ticket'         => EE_Dependency_Map::load_from_cache,
695
+				'EEM_Registration'   => EE_Dependency_Map::load_from_cache,
696
+				'EEM_Transaction'    => EE_Dependency_Map::load_from_cache,
697
+				'EE_Config'          => EE_Dependency_Map::load_from_cache,
698
+			],
699
+			'EventEspresso\core\domain\services\admin\ExitModal'                                                          => [
700
+				'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache,
701
+			],
702
+			'EventEspresso\core\domain\services\admin\PluginUpsells'                                                      => [
703
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
704
+			],
705
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => [
706
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
707
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
708
+			],
709
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings'                                => [
710
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
711
+			],
712
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => [
713
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
714
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
715
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
716
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
717
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
718
+			],
719
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => [
720
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
721
+			],
722
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => [
723
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
724
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
725
+			],
726
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => [
727
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
728
+			],
729
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => [
730
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
731
+			],
732
+			'EE_CPT_Strategy'                                                                                             => [
733
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
734
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
735
+			],
736
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => [
737
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
738
+			],
739
+			'EventEspresso\core\domain\services\assets\CoreAssetManager'                                                  => [
740
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
741
+				'EE_Currency_Config'                                 => EE_Dependency_Map::load_from_cache,
742
+				'EE_Template_Config'                                 => EE_Dependency_Map::load_from_cache,
743
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
744
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
745
+			],
746
+			'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy'                                       => [
747
+				'EEM_Payment_Method'                                       => EE_Dependency_Map::load_from_cache,
748
+				'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache,
749
+			],
750
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee'                                      => [
751
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
752
+			],
753
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData'                           => [
754
+				'EEM_Attendee'       => EE_Dependency_Map::load_from_cache,
755
+				'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache,
756
+			],
757
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins'                                      => [
758
+				'EEM_Checkin' => EE_Dependency_Map::load_from_cache,
759
+			],
760
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration'                                  => [
761
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
762
+			],
763
+			'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction'                                   => [
764
+				'EEM_Transaction' => EE_Dependency_Map::load_from_cache,
765
+			],
766
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData'                                  => [
767
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
768
+			],
769
+			'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers'                                       => [
770
+				'EEM_Answer'   => EE_Dependency_Map::load_from_cache,
771
+				'EEM_Question' => EE_Dependency_Map::load_from_cache,
772
+			],
773
+			'EventEspresso\core\CPTs\CptQueryModifier'                                                                    => [
774
+				null,
775
+				null,
776
+				null,
777
+				'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache,
778
+				'EventEspresso\core\services\request\Request'     => EE_Dependency_Map::load_from_cache,
779
+				'EventEspresso\core\services\loaders\Loader'      => EE_Dependency_Map::load_from_cache,
780
+			],
781
+			'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler'                           => [
782
+				'EE_Registry' => EE_Dependency_Map::load_from_cache,
783
+				'EE_Config'   => EE_Dependency_Map::load_from_cache,
784
+			],
785
+			'EventEspresso\core\services\editor\BlockRegistrationManager'                                                 => [
786
+				'EventEspresso\core\services\assets\BlockAssetManagerCollection'         => EE_Dependency_Map::load_from_cache,
787
+				'EventEspresso\core\domain\entities\editor\BlockCollection'              => EE_Dependency_Map::load_from_cache,
788
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache,
789
+				'EventEspresso\core\services\request\Request'                            => EE_Dependency_Map::load_from_cache,
790
+			],
791
+			'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager'                                            => [
792
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
793
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
794
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
795
+			],
796
+			'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer'                                       => [
797
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
798
+				'EEM_Attendee'                     => EE_Dependency_Map::load_from_cache,
799
+			],
800
+			'EventEspresso\core\domain\entities\editor\blocks\EventAttendees'                                             => [
801
+				'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager'      => self::load_from_cache,
802
+				'EventEspresso\core\services\request\Request'                           => EE_Dependency_Map::load_from_cache,
803
+				'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache,
804
+			],
805
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver'                           => [
806
+				'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
807
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
808
+				'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
809
+			],
810
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory'                                      => [
811
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
812
+				'EventEspresso\core\services\loaders\Loader'                                        => EE_Dependency_Map::load_from_cache,
813
+			],
814
+			'EventEspresso\core\services\route_match\RouteMatchSpecificationManager'                                      => [
815
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
816
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory'    => EE_Dependency_Map::load_from_cache,
817
+			],
818
+			'EventEspresso\core\libraries\rest_api\CalculatedModelFields'                                                 => [
819
+				'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache,
820
+			],
821
+			'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory'                             => [
822
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
823
+			],
824
+			'EventEspresso\core\libraries\rest_api\controllers\model\Read'                                                => [
825
+				'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache,
826
+			],
827
+			'EventEspresso\core\libraries\rest_api\calculations\Datetime'                                                 => [
828
+				'EEM_Datetime'     => EE_Dependency_Map::load_from_cache,
829
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
830
+			],
831
+			'EventEspresso\core\libraries\rest_api\calculations\Event'                                                    => [
832
+				'EEM_Event'        => EE_Dependency_Map::load_from_cache,
833
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
834
+			],
835
+			'EventEspresso\core\libraries\rest_api\calculations\Registration'                                             => [
836
+				'EEM_Registration' => EE_Dependency_Map::load_from_cache,
837
+			],
838
+			'EventEspresso\core\services\session\SessionStartHandler'                                                     => [
839
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
840
+			],
841
+			'EE_URL_Validation_Strategy'                                                                                  => [
842
+				null,
843
+				null,
844
+				'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache,
845
+			],
846
+			'EventEspresso\admin_pages\general_settings\OrganizationSettings'                                             => [
847
+				'EE_Registry'                                             => EE_Dependency_Map::load_from_cache,
848
+				'EE_Organization_Config'                                  => EE_Dependency_Map::load_from_cache,
849
+				'EE_Core_Config'                                          => EE_Dependency_Map::load_from_cache,
850
+				'EE_Network_Core_Config'                                  => EE_Dependency_Map::load_from_cache,
851
+				'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache,
852
+			],
853
+			'EventEspresso\core\services\address\CountrySubRegionDao'                                                     => [
854
+				'EEM_State'                                            => EE_Dependency_Map::load_from_cache,
855
+				'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache,
856
+			],
857
+			'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat'                                            => [
858
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
859
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
860
+			],
861
+			'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat'                                          => [
862
+				'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache,
863
+				'EE_Environment_Config'            => EE_Dependency_Map::load_from_cache,
864
+			],
865
+			'EventEspresso\core\services\request\files\FilesDataHandler'                                                  => [
866
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
867
+			],
868
+			'EventEspressoBatchRequest\BatchRequestProcessor'                                                             => [
869
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
870
+			],
871
+			'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder'                              => [
872
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
873
+				'EEM_Registration'                            => EE_Dependency_Map::load_from_cache,
874
+				null,
875
+			],
876
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader'          => [
877
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
878
+				'EEM_Attendee'                                => EE_Dependency_Map::load_from_cache,
879
+			],
880
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader'              => [
881
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
882
+				'EEM_Datetime'                                => EE_Dependency_Map::load_from_cache,
883
+			],
884
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader'             => [
885
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
886
+				'EEM_Event'                                   => EE_Dependency_Map::load_from_cache,
887
+			],
888
+			'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader'            => [
889
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
890
+				'EEM_Ticket'                                  => EE_Dependency_Map::load_from_cache,
891
+			],
892
+			'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion'                                                  => [
893
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
894
+			],
895
+			'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion'                                                  => [
896
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
897
+			],
898
+			'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion'                                        => [
899
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
900
+				'EEM_Event'                                                   => EE_Dependency_Map::load_from_cache,
901
+				'EEM_Datetime'                                                => EE_Dependency_Map::load_from_cache,
902
+				'EEM_Registration'                                            => EE_Dependency_Map::load_from_cache,
903
+			],
904
+			'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion'                                        => [
905
+				'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache,
906
+			],
907
+			'EventEspresso\core\services\request\CurrentPage'                                                             => [
908
+				'EE_CPT_Strategy'                             => EE_Dependency_Map::load_from_cache,
909
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
910
+			],
911
+			'EventEspresso\core\services\shortcodes\LegacyShortcodesManager'                                              => [
912
+				'EE_Registry'                                     => EE_Dependency_Map::load_from_cache,
913
+				'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache,
914
+			],
915
+			'EventEspresso\core\services\shortcodes\ShortcodesManager'                                                    => [
916
+				'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache,
917
+				'EventEspresso\core\services\request\CurrentPage'                => EE_Dependency_Map::load_from_cache,
918
+			],
919
+		];
920
+	}
921
+
922
+
923
+	/**
924
+	 * Registers how core classes are loaded.
925
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
926
+	 *        'EE_Request_Handler' => 'load_core'
927
+	 *        'EE_Messages_Queue'  => 'load_lib'
928
+	 *        'EEH_Debug_Tools'    => 'load_helper'
929
+	 * or, if greater control is required, by providing a custom closure. For example:
930
+	 *        'Some_Class' => function () {
931
+	 *            return new Some_Class();
932
+	 *        },
933
+	 * This is required for instantiating dependencies
934
+	 * where an interface has been type hinted in a class constructor. For example:
935
+	 *        'Required_Interface' => function () {
936
+	 *            return new A_Class_That_Implements_Required_Interface();
937
+	 *        },
938
+	 */
939
+	protected function _register_core_class_loaders()
940
+	{
941
+		$this->_class_loaders = [
942
+			// load_core
943
+			'EE_Dependency_Map'                            => function () {
944
+				return $this;
945
+			},
946
+			'EE_Capabilities'                              => 'load_core',
947
+			'EE_Encryption'                                => 'load_core',
948
+			'EE_Front_Controller'                          => 'load_core',
949
+			'EE_Module_Request_Router'                     => 'load_core',
950
+			'EE_Registry'                                  => 'load_core',
951
+			'EE_Request'                                   => function () {
952
+				return $this->legacy_request;
953
+			},
954
+			'EventEspresso\core\services\request\Request'  => function () {
955
+				return $this->request;
956
+			},
957
+			'EventEspresso\core\services\request\Response' => function () {
958
+				return $this->response;
959
+			},
960
+			'EE_Base'                                      => 'load_core',
961
+			'EE_Request_Handler'                           => 'load_core',
962
+			'EE_Session'                                   => 'load_core',
963
+			'EE_Cron_Tasks'                                => 'load_core',
964
+			'EE_System'                                    => 'load_core',
965
+			'EE_Maintenance_Mode'                          => 'load_core',
966
+			'EE_Register_CPTs'                             => 'load_core',
967
+			'EE_Admin'                                     => 'load_core',
968
+			'EE_CPT_Strategy'                              => 'load_core',
969
+			// load_class
970
+			'EE_Registration_Processor'                    => 'load_class',
971
+			// load_lib
972
+			'EE_Message_Resource_Manager'                  => 'load_lib',
973
+			'EE_Message_Type_Collection'                   => 'load_lib',
974
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
975
+			'EE_Messenger_Collection'                      => 'load_lib',
976
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
977
+			'EE_Messages_Processor'                        => 'load_lib',
978
+			'EE_Message_Repository'                        => 'load_lib',
979
+			'EE_Messages_Queue'                            => 'load_lib',
980
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
981
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
982
+			'EE_Payment_Method_Manager'                    => 'load_lib',
983
+			'EE_DMS_Core_4_1_0'                            => 'load_dms',
984
+			'EE_DMS_Core_4_2_0'                            => 'load_dms',
985
+			'EE_DMS_Core_4_3_0'                            => 'load_dms',
986
+			'EE_DMS_Core_4_5_0'                            => 'load_dms',
987
+			'EE_DMS_Core_4_6_0'                            => 'load_dms',
988
+			'EE_DMS_Core_4_7_0'                            => 'load_dms',
989
+			'EE_DMS_Core_4_8_0'                            => 'load_dms',
990
+			'EE_DMS_Core_4_9_0'                            => 'load_dms',
991
+			'EE_DMS_Core_4_10_0'                           => 'load_dms',
992
+			'EE_Messages_Generator'                        => function () {
993
+				return EE_Registry::instance()->load_lib(
994
+					'Messages_Generator',
995
+					[],
996
+					false,
997
+					false
998
+				);
999
+			},
1000
+			'EE_Messages_Template_Defaults'                => function ($arguments = []) {
1001
+				return EE_Registry::instance()->load_lib(
1002
+					'Messages_Template_Defaults',
1003
+					$arguments,
1004
+					false,
1005
+					false
1006
+				);
1007
+			},
1008
+			// load_helper
1009
+			'EEH_Parse_Shortcodes'                         => function () {
1010
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
1011
+					return new EEH_Parse_Shortcodes();
1012
+				}
1013
+				return null;
1014
+			},
1015
+			'EE_Template_Config'                           => function () {
1016
+				return EE_Config::instance()->template_settings;
1017
+			},
1018
+			'EE_Currency_Config'                           => function () {
1019
+				return EE_Config::instance()->currency;
1020
+			},
1021
+			'EE_Registration_Config'                       => function () {
1022
+				return EE_Config::instance()->registration;
1023
+			},
1024
+			'EE_Core_Config'                               => function () {
1025
+				return EE_Config::instance()->core;
1026
+			},
1027
+			'EventEspresso\core\services\loaders\Loader'   => function () {
1028
+				return LoaderFactory::getLoader();
1029
+			},
1030
+			'EE_Network_Config'                            => function () {
1031
+				return EE_Network_Config::instance();
1032
+			},
1033
+			'EE_Config'                                    => function () {
1034
+				return EE_Config::instance();
1035
+			},
1036
+			'EventEspresso\core\domain\Domain'             => function () {
1037
+				return DomainFactory::getEventEspressoCoreDomain();
1038
+			},
1039
+			'EE_Admin_Config'                              => function () {
1040
+				return EE_Config::instance()->admin;
1041
+			},
1042
+			'EE_Organization_Config'                       => function () {
1043
+				return EE_Config::instance()->organization;
1044
+			},
1045
+			'EE_Network_Core_Config'                       => function () {
1046
+				return EE_Network_Config::instance()->core;
1047
+			},
1048
+			'EE_Environment_Config'                        => function () {
1049
+				return EE_Config::instance()->environment;
1050
+			},
1051
+		];
1052
+	}
1053
+
1054
+
1055
+	/**
1056
+	 * can be used for supplying alternate names for classes,
1057
+	 * or for connecting interface names to instantiable classes
1058
+	 */
1059
+	protected function _register_core_aliases()
1060
+	{
1061
+		$aliases = [
1062
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
1063
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
1064
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
1065
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
1066
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
1067
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
1068
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1069
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
1070
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
1071
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
1072
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
1073
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
1074
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
1075
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
1076
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
1077
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
1078
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
1079
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
1080
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
1081
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
1082
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1083
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
1084
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
1085
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
1086
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
1087
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
1088
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
1089
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
1090
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
1091
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
1092
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
1093
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
1094
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
1095
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
1096
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
1097
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
1098
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
1099
+			'Registration_Processor'                                                       => 'EE_Registration_Processor',
1100
+		];
1101
+		foreach ($aliases as $alias => $fqn) {
1102
+			if (is_array($fqn)) {
1103
+				foreach ($fqn as $class => $for_class) {
1104
+					$this->class_cache->addAlias($class, $alias, $for_class);
1105
+				}
1106
+				continue;
1107
+			}
1108
+			$this->class_cache->addAlias($fqn, $alias);
1109
+		}
1110
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1111
+			$this->class_cache->addAlias(
1112
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1113
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
1114
+			);
1115
+		}
1116
+	}
1117
+
1118
+
1119
+	public function debug($for_class = '')
1120
+	{
1121
+		$this->class_cache->debug($for_class);
1122
+	}
1123
+
1124
+
1125
+	/**
1126
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
1127
+	 * request Primarily used by unit tests.
1128
+	 */
1129
+	public function reset()
1130
+	{
1131
+		$this->_register_core_class_loaders();
1132
+		$this->_register_core_dependencies();
1133
+	}
1134
+
1135
+
1136
+	/**
1137
+	 * PLZ NOTE: a better name for this method would be is_alias()
1138
+	 * because it returns TRUE if the provided fully qualified name IS an alias
1139
+	 * WHY?
1140
+	 * Because if a class is type hinting for a concretion,
1141
+	 * then why would we need to find another class to supply it?
1142
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
1143
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
1144
+	 * Don't go looking for some substitute.
1145
+	 * Whereas if a class is type hinting for an interface...
1146
+	 * then we need to find an actual class to use.
1147
+	 * So the interface IS the alias for some other FQN,
1148
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
1149
+	 * represents some other class.
1150
+	 *
1151
+	 * @param string $fqn
1152
+	 * @param string $for_class
1153
+	 * @return bool
1154
+	 * @deprecated 4.9.62.p
1155
+	 */
1156
+	public function has_alias($fqn = '', $for_class = '')
1157
+	{
1158
+		return $this->isAlias($fqn, $for_class);
1159
+	}
1160
+
1161
+
1162
+	/**
1163
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
1164
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
1165
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
1166
+	 *  for example:
1167
+	 *      if the following two entries were added to the _aliases array:
1168
+	 *          array(
1169
+	 *              'interface_alias'           => 'some\namespace\interface'
1170
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
1171
+	 *          )
1172
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
1173
+	 *      to load an instance of 'some\namespace\classname'
1174
+	 *
1175
+	 * @param string $alias
1176
+	 * @param string $for_class
1177
+	 * @return string
1178
+	 * @deprecated 4.9.62.p
1179
+	 */
1180
+	public function get_alias($alias = '', $for_class = '')
1181
+	{
1182
+		return $this->getFqnForAlias($alias, $for_class);
1183
+	}
1184 1184
 }
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     public static function instance(ClassInterfaceCache $class_cache = null)
123 123
     {
124 124
         // check if class object is instantiated, and instantiated properly
125
-        if (! self::$_instance instanceof EE_Dependency_Map
125
+        if ( ! self::$_instance instanceof EE_Dependency_Map
126 126
             && $class_cache instanceof ClassInterfaceCache
127 127
         ) {
128 128
             self::$_instance = new EE_Dependency_Map($class_cache);
@@ -203,18 +203,18 @@  discard block
 block discarded – undo
203 203
     ) {
204 204
         $class      = trim($class, '\\');
205 205
         $registered = false;
206
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
207
-            self::$_instance->_dependency_map[ $class ] = [];
206
+        if (empty(self::$_instance->_dependency_map[$class])) {
207
+            self::$_instance->_dependency_map[$class] = [];
208 208
         }
209 209
         // we need to make sure that any aliases used when registering a dependency
210 210
         // get resolved to the correct class name
211 211
         foreach ($dependencies as $dependency => $load_source) {
212 212
             $alias = self::$_instance->getFqnForAlias($dependency);
213 213
             if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
214
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
214
+                || ! isset(self::$_instance->_dependency_map[$class][$alias])
215 215
             ) {
216
-                unset($dependencies[ $dependency ]);
217
-                $dependencies[ $alias ] = $load_source;
216
+                unset($dependencies[$dependency]);
217
+                $dependencies[$alias] = $load_source;
218 218
                 $registered             = true;
219 219
             }
220 220
         }
@@ -224,13 +224,13 @@  discard block
 block discarded – undo
224 224
         // ie: with A = B + C, entries in B take precedence over duplicate entries in C
225 225
         // Union is way faster than array_merge() but should be used with caution...
226 226
         // especially with numerically indexed arrays
227
-        $dependencies += self::$_instance->_dependency_map[ $class ];
227
+        $dependencies += self::$_instance->_dependency_map[$class];
228 228
         // now we need to ensure that the resulting dependencies
229 229
         // array only has the entries that are required for the class
230 230
         // so first count how many dependencies were originally registered for the class
231
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
231
+        $dependency_count = count(self::$_instance->_dependency_map[$class]);
232 232
         // if that count is non-zero (meaning dependencies were already registered)
233
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
233
+        self::$_instance->_dependency_map[$class] = $dependency_count
234 234
             // then truncate the  final array to match that count
235 235
             ? array_slice($dependencies, 0, $dependency_count)
236 236
             // otherwise just take the incoming array because nothing previously existed
@@ -248,13 +248,13 @@  discard block
 block discarded – undo
248 248
      */
249 249
     public static function register_class_loader($class_name, $loader = 'load_core', $overwrite = false)
250 250
     {
251
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
251
+        if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
252 252
             throw new DomainException(
253 253
                 esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
254 254
             );
255 255
         }
256 256
         // check that loader is callable or method starts with "load_" and exists in EE_Registry
257
-        if (! is_callable($loader)
257
+        if ( ! is_callable($loader)
258 258
             && (
259 259
                 strpos($loader, 'load_') !== 0
260 260
                 || ! method_exists('EE_Registry', $loader)
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
             );
272 272
         }
273 273
         $class_name = self::$_instance->getFqnForAlias($class_name);
274
-        if ($overwrite || ! isset(self::$_instance->_class_loaders[ $class_name ])) {
275
-            self::$_instance->_class_loaders[ $class_name ] = $loader;
274
+        if ($overwrite || ! isset(self::$_instance->_class_loaders[$class_name])) {
275
+            self::$_instance->_class_loaders[$class_name] = $loader;
276 276
             return true;
277 277
         }
278 278
         return false;
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
         if (strpos($class_name, 'EEM_') === 0) {
301 301
             $class_name = 'LEGACY_MODELS';
302 302
         }
303
-        return isset($this->_dependency_map[ $class_name ]);
303
+        return isset($this->_dependency_map[$class_name]);
304 304
     }
305 305
 
306 306
 
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
             $class_name = 'LEGACY_MODELS';
319 319
         }
320 320
         $dependency = $this->getFqnForAlias($dependency, $class_name);
321
-        return isset($this->_dependency_map[ $class_name ][ $dependency ]);
321
+        return isset($this->_dependency_map[$class_name][$dependency]);
322 322
     }
323 323
 
324 324
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
         }
338 338
         $dependency = $this->getFqnForAlias($dependency);
339 339
         return $this->has_dependency_for_class($class_name, $dependency)
340
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
340
+            ? $this->_dependency_map[$class_name][$dependency]
341 341
             : EE_Dependency_Map::not_registered;
342 342
     }
343 343
 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
             return 'load_core';
361 361
         }
362 362
         $class_name = $this->getFqnForAlias($class_name);
363
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
363
+        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
364 364
     }
365 365
 
366 366
 
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
     {
941 941
         $this->_class_loaders = [
942 942
             // load_core
943
-            'EE_Dependency_Map'                            => function () {
943
+            'EE_Dependency_Map'                            => function() {
944 944
                 return $this;
945 945
             },
946 946
             'EE_Capabilities'                              => 'load_core',
@@ -948,13 +948,13 @@  discard block
 block discarded – undo
948 948
             'EE_Front_Controller'                          => 'load_core',
949 949
             'EE_Module_Request_Router'                     => 'load_core',
950 950
             'EE_Registry'                                  => 'load_core',
951
-            'EE_Request'                                   => function () {
951
+            'EE_Request'                                   => function() {
952 952
                 return $this->legacy_request;
953 953
             },
954
-            'EventEspresso\core\services\request\Request'  => function () {
954
+            'EventEspresso\core\services\request\Request'  => function() {
955 955
                 return $this->request;
956 956
             },
957
-            'EventEspresso\core\services\request\Response' => function () {
957
+            'EventEspresso\core\services\request\Response' => function() {
958 958
                 return $this->response;
959 959
             },
960 960
             'EE_Base'                                      => 'load_core',
@@ -989,7 +989,7 @@  discard block
 block discarded – undo
989 989
             'EE_DMS_Core_4_8_0'                            => 'load_dms',
990 990
             'EE_DMS_Core_4_9_0'                            => 'load_dms',
991 991
             'EE_DMS_Core_4_10_0'                           => 'load_dms',
992
-            'EE_Messages_Generator'                        => function () {
992
+            'EE_Messages_Generator'                        => function() {
993 993
                 return EE_Registry::instance()->load_lib(
994 994
                     'Messages_Generator',
995 995
                     [],
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
                     false
998 998
                 );
999 999
             },
1000
-            'EE_Messages_Template_Defaults'                => function ($arguments = []) {
1000
+            'EE_Messages_Template_Defaults'                => function($arguments = []) {
1001 1001
                 return EE_Registry::instance()->load_lib(
1002 1002
                     'Messages_Template_Defaults',
1003 1003
                     $arguments,
@@ -1006,46 +1006,46 @@  discard block
 block discarded – undo
1006 1006
                 );
1007 1007
             },
1008 1008
             // load_helper
1009
-            'EEH_Parse_Shortcodes'                         => function () {
1009
+            'EEH_Parse_Shortcodes'                         => function() {
1010 1010
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
1011 1011
                     return new EEH_Parse_Shortcodes();
1012 1012
                 }
1013 1013
                 return null;
1014 1014
             },
1015
-            'EE_Template_Config'                           => function () {
1015
+            'EE_Template_Config'                           => function() {
1016 1016
                 return EE_Config::instance()->template_settings;
1017 1017
             },
1018
-            'EE_Currency_Config'                           => function () {
1018
+            'EE_Currency_Config'                           => function() {
1019 1019
                 return EE_Config::instance()->currency;
1020 1020
             },
1021
-            'EE_Registration_Config'                       => function () {
1021
+            'EE_Registration_Config'                       => function() {
1022 1022
                 return EE_Config::instance()->registration;
1023 1023
             },
1024
-            'EE_Core_Config'                               => function () {
1024
+            'EE_Core_Config'                               => function() {
1025 1025
                 return EE_Config::instance()->core;
1026 1026
             },
1027
-            'EventEspresso\core\services\loaders\Loader'   => function () {
1027
+            'EventEspresso\core\services\loaders\Loader'   => function() {
1028 1028
                 return LoaderFactory::getLoader();
1029 1029
             },
1030
-            'EE_Network_Config'                            => function () {
1030
+            'EE_Network_Config'                            => function() {
1031 1031
                 return EE_Network_Config::instance();
1032 1032
             },
1033
-            'EE_Config'                                    => function () {
1033
+            'EE_Config'                                    => function() {
1034 1034
                 return EE_Config::instance();
1035 1035
             },
1036
-            'EventEspresso\core\domain\Domain'             => function () {
1036
+            'EventEspresso\core\domain\Domain'             => function() {
1037 1037
                 return DomainFactory::getEventEspressoCoreDomain();
1038 1038
             },
1039
-            'EE_Admin_Config'                              => function () {
1039
+            'EE_Admin_Config'                              => function() {
1040 1040
                 return EE_Config::instance()->admin;
1041 1041
             },
1042
-            'EE_Organization_Config'                       => function () {
1042
+            'EE_Organization_Config'                       => function() {
1043 1043
                 return EE_Config::instance()->organization;
1044 1044
             },
1045
-            'EE_Network_Core_Config'                       => function () {
1045
+            'EE_Network_Core_Config'                       => function() {
1046 1046
                 return EE_Network_Config::instance()->core;
1047 1047
             },
1048
-            'EE_Environment_Config'                        => function () {
1048
+            'EE_Environment_Config'                        => function() {
1049 1049
                 return EE_Config::instance()->environment;
1050 1050
             },
1051 1051
         ];
@@ -1107,7 +1107,7 @@  discard block
 block discarded – undo
1107 1107
             }
1108 1108
             $this->class_cache->addAlias($fqn, $alias);
1109 1109
         }
1110
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1110
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
1111 1111
             $this->class_cache->addAlias(
1112 1112
                 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
1113 1113
                 'EventEspresso\core\services\notices\NoticeConverterInterface'
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +4065 added lines, -4065 removed lines patch added patch discarded remove patch
@@ -18,4134 +18,4134 @@
 block discarded – undo
18 18
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var LoaderInterface
23
-     */
24
-    protected $loader;
21
+	/**
22
+	 * @var LoaderInterface
23
+	 */
24
+	protected $loader;
25 25
 
26
-    /**
27
-     * @var RequestInterface
28
-     */
29
-    protected $request;
26
+	/**
27
+	 * @var RequestInterface
28
+	 */
29
+	protected $request;
30 30
 
31
-    // set in _init_page_props()
32
-    public $page_slug;
31
+	// set in _init_page_props()
32
+	public $page_slug;
33 33
 
34
-    public $page_label;
34
+	public $page_label;
35 35
 
36
-    public $page_folder;
36
+	public $page_folder;
37 37
 
38
-    // set in define_page_props()
39
-    protected $_admin_base_url;
38
+	// set in define_page_props()
39
+	protected $_admin_base_url;
40 40
 
41
-    protected $_admin_base_path;
41
+	protected $_admin_base_path;
42 42
 
43
-    protected $_admin_page_title;
43
+	protected $_admin_page_title;
44 44
 
45
-    protected $_labels;
45
+	protected $_labels;
46 46
 
47 47
 
48
-    // set early within EE_Admin_Init
49
-    protected $_wp_page_slug;
48
+	// set early within EE_Admin_Init
49
+	protected $_wp_page_slug;
50 50
 
51
-    // navtabs
52
-    protected $_nav_tabs;
51
+	// navtabs
52
+	protected $_nav_tabs;
53 53
 
54
-    protected $_default_nav_tab_name;
54
+	protected $_default_nav_tab_name;
55 55
 
56
-    /**
57
-     * @var array $_help_tour
58
-     */
59
-    protected $_help_tour = [];
56
+	/**
57
+	 * @var array $_help_tour
58
+	 */
59
+	protected $_help_tour = [];
60 60
 
61 61
 
62
-    // template variables (used by templates)
63
-    protected $_template_path;
62
+	// template variables (used by templates)
63
+	protected $_template_path;
64 64
 
65
-    protected $_column_template_path;
65
+	protected $_column_template_path;
66 66
 
67
-    /**
68
-     * @var array $_template_args
69
-     */
70
-    protected $_template_args = [];
67
+	/**
68
+	 * @var array $_template_args
69
+	 */
70
+	protected $_template_args = [];
71 71
 
72
-    /**
73
-     * this will hold the list table object for a given view.
74
-     *
75
-     * @var EE_Admin_List_Table $_list_table_object
76
-     */
77
-    protected $_list_table_object;
72
+	/**
73
+	 * this will hold the list table object for a given view.
74
+	 *
75
+	 * @var EE_Admin_List_Table $_list_table_object
76
+	 */
77
+	protected $_list_table_object;
78 78
 
79
-    // bools
80
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
79
+	// bools
80
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
81 81
 
82
-    protected $_routing;
82
+	protected $_routing;
83 83
 
84
-    // list table args
85
-    protected $_view;
84
+	// list table args
85
+	protected $_view;
86 86
 
87
-    protected $_views;
87
+	protected $_views;
88 88
 
89 89
 
90
-    // action => method pairs used for routing incoming requests
91
-    protected $_page_routes;
90
+	// action => method pairs used for routing incoming requests
91
+	protected $_page_routes;
92 92
 
93
-    /**
94
-     * @var array $_page_config
95
-     */
96
-    protected $_page_config;
93
+	/**
94
+	 * @var array $_page_config
95
+	 */
96
+	protected $_page_config;
97 97
 
98
-    /**
99
-     * the current page route and route config
100
-     *
101
-     * @var string $_route
102
-     */
103
-    protected $_route;
98
+	/**
99
+	 * the current page route and route config
100
+	 *
101
+	 * @var string $_route
102
+	 */
103
+	protected $_route;
104 104
 
105
-    /**
106
-     * @var string $_cpt_route
107
-     */
108
-    protected $_cpt_route;
105
+	/**
106
+	 * @var string $_cpt_route
107
+	 */
108
+	protected $_cpt_route;
109 109
 
110
-    /**
111
-     * @var array $_route_config
112
-     */
113
-    protected $_route_config;
110
+	/**
111
+	 * @var array $_route_config
112
+	 */
113
+	protected $_route_config;
114 114
 
115
-    /**
116
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
117
-     * actions.
118
-     *
119
-     * @since 4.6.x
120
-     * @var array.
121
-     */
122
-    protected $_default_route_query_args;
123
-
124
-    // set via request page and action args.
125
-    protected $_current_page;
126
-
127
-    protected $_current_view;
128
-
129
-    protected $_current_page_view_url;
130
-
131
-    // sanitized request action (and nonce)
132
-
133
-    /**
134
-     * @var string $_req_action
135
-     */
136
-    protected $_req_action;
137
-
138
-    /**
139
-     * @var string $_req_nonce
140
-     */
141
-    protected $_req_nonce;
142
-
143
-    // search related
144
-    protected $_search_btn_label;
145
-
146
-    protected $_search_box_callback;
147
-
148
-    /**
149
-     * WP Current Screen object
150
-     *
151
-     * @var WP_Screen
152
-     */
153
-    protected $_current_screen;
154
-
155
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
156
-    protected $_hook_obj;
157
-
158
-    // for holding incoming request data
159
-    protected $_req_data = [];
160
-
161
-    // yes / no array for admin form fields
162
-    protected $_yes_no_values = [];
163
-
164
-    // some default things shared by all child classes
165
-    protected $_default_espresso_metaboxes;
166
-
167
-    /**
168
-     *    EE_Registry Object
169
-     *
170
-     * @var    EE_Registry
171
-     */
172
-    protected $EE = null;
173
-
174
-
175
-    /**
176
-     * This is just a property that flags whether the given route is a caffeinated route or not.
177
-     *
178
-     * @var boolean
179
-     */
180
-    protected $_is_caf = false;
181
-
182
-
183
-    /**
184
-     * @Constructor
185
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
186
-     * @throws EE_Error
187
-     * @throws InvalidArgumentException
188
-     * @throws ReflectionException
189
-     * @throws InvalidDataTypeException
190
-     * @throws InvalidInterfaceException
191
-     */
192
-    public function __construct($routing = true)
193
-    {
194
-        $this->loader  = LoaderFactory::getLoader();
195
-        $this->request = $this->loader->getShared(RequestInterface::class);
196
-
197
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
198
-            $this->_is_caf = true;
199
-        }
200
-        $this->_yes_no_values = [
201
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
202
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
203
-        ];
204
-        // set the _req_data property.
205
-        $this->_req_data = $this->request->requestParams();
206
-        // routing enabled?
207
-        $this->_routing = $routing;
208
-        // set initial page props (child method)
209
-        $this->_init_page_props();
210
-        // set global defaults
211
-        $this->_set_defaults();
212
-        // set early because incoming requests could be ajax related and we need to register those hooks.
213
-        $this->_global_ajax_hooks();
214
-        $this->_ajax_hooks();
215
-        // other_page_hooks have to be early too.
216
-        $this->_do_other_page_hooks();
217
-        // This just allows us to have extending classes do something specific
218
-        // before the parent constructor runs _page_setup().
219
-        if (method_exists($this, '_before_page_setup')) {
220
-            $this->_before_page_setup();
221
-        }
222
-        // set up page dependencies
223
-        $this->_page_setup();
224
-    }
225
-
226
-
227
-    /**
228
-     * _init_page_props
229
-     * Child classes use to set at least the following properties:
230
-     * $page_slug.
231
-     * $page_label.
232
-     *
233
-     * @abstract
234
-     * @return void
235
-     */
236
-    abstract protected function _init_page_props();
237
-
238
-
239
-    /**
240
-     * _ajax_hooks
241
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
242
-     * Note: within the ajax callback methods.
243
-     *
244
-     * @abstract
245
-     * @return void
246
-     */
247
-    abstract protected function _ajax_hooks();
248
-
249
-
250
-    /**
251
-     * _define_page_props
252
-     * child classes define page properties in here.  Must include at least:
253
-     * $_admin_base_url = base_url for all admin pages
254
-     * $_admin_page_title = default admin_page_title for admin pages
255
-     * $_labels = array of default labels for various automatically generated elements:
256
-     *    array(
257
-     *        'buttons' => array(
258
-     *            'add' => esc_html__('label for add new button'),
259
-     *            'edit' => esc_html__('label for edit button'),
260
-     *            'delete' => esc_html__('label for delete button')
261
-     *            )
262
-     *        )
263
-     *
264
-     * @abstract
265
-     * @return void
266
-     */
267
-    abstract protected function _define_page_props();
268
-
269
-
270
-    /**
271
-     * _set_page_routes
272
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
273
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
274
-     * have a 'default' route. Here's the format
275
-     * $this->_page_routes = array(
276
-     *        'default' => array(
277
-     *            'func' => '_default_method_handling_route',
278
-     *            'args' => array('array','of','args'),
279
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
280
-     *            ajax request, backend processing)
281
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
282
-     *            headers route after.  The string you enter here should match the defined route reference for a
283
-     *            headers sent route.
284
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
285
-     *            this route.
286
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
287
-     *            checks).
288
-     *        ),
289
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
290
-     *        handling method.
291
-     *        )
292
-     * )
293
-     *
294
-     * @abstract
295
-     * @return void
296
-     */
297
-    abstract protected function _set_page_routes();
298
-
299
-
300
-    /**
301
-     * _set_page_config
302
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
303
-     * array corresponds to the page_route for the loaded page. Format:
304
-     * $this->_page_config = array(
305
-     *        'default' => array(
306
-     *            'labels' => array(
307
-     *                'buttons' => array(
308
-     *                    'add' => esc_html__('label for adding item'),
309
-     *                    'edit' => esc_html__('label for editing item'),
310
-     *                    'delete' => esc_html__('label for deleting item')
311
-     *                ),
312
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
313
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
314
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
315
-     *            _define_page_props() method
316
-     *            'nav' => array(
317
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
318
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
319
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
320
-     *                'order' => 10, //required to indicate tab position.
321
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
322
-     *                displayed then add this parameter.
323
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
324
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
325
-     *            metaboxes set for eventespresso admin pages.
326
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
327
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
328
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
329
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
330
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
331
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
332
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
333
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
334
-     *            want to display.
335
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
336
-     *                'tab_id' => array(
337
-     *                    'title' => 'tab_title',
338
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
339
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
340
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
341
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
342
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
343
-     *                    attempt to use the callback which should match the name of a method in the class
344
-     *                    ),
345
-     *                'tab2_id' => array(
346
-     *                    'title' => 'tab2 title',
347
-     *                    'filename' => 'file_name_2'
348
-     *                    'callback' => 'callback_method_for_content',
349
-     *                 ),
350
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
351
-     *            help tab area on an admin page. @return void
352
-     *
353
-     * @link
354
-     *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
355
-     *                'help_tour' => array(
356
-     *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
357
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
358
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
359
-     *                ),
360
-     *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
361
-     *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
362
-     *                visited just set
363
-     *                'require_nonce' to FALSE
364
-     *                )
365
-     *                )
366
-     *
367
-     * @abstract
368
-     */
369
-    abstract protected function _set_page_config();
370
-
371
-
372
-
373
-
374
-
375
-    /** end sample help_tour methods **/
376
-    /**
377
-     * _add_screen_options
378
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
379
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
380
-     * to a particular view.
381
-     *
382
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
383
-     *         see also WP_Screen object documents...
384
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
385
-     * @abstract
386
-     * @return void
387
-     */
388
-    abstract protected function _add_screen_options();
389
-
390
-
391
-    /**
392
-     * _add_feature_pointers
393
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
394
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
395
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
396
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
397
-     * extended) also see:
398
-     *
399
-     * @link   http://eamann.com/tech/wordpress-portland/
400
-     * @abstract
401
-     * @return void
402
-     */
403
-    abstract protected function _add_feature_pointers();
404
-
405
-
406
-    /**
407
-     * load_scripts_styles
408
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
409
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
410
-     * scripts/styles per view by putting them in a dynamic function in this format
411
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
412
-     *
413
-     * @abstract
414
-     * @return void
415
-     */
416
-    abstract public function load_scripts_styles();
417
-
418
-
419
-    /**
420
-     * admin_init
421
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
422
-     * all pages/views loaded by child class.
423
-     *
424
-     * @abstract
425
-     * @return void
426
-     */
427
-    abstract public function admin_init();
428
-
429
-
430
-    /**
431
-     * admin_notices
432
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
433
-     * all pages/views loaded by child class.
434
-     *
435
-     * @abstract
436
-     * @return void
437
-     */
438
-    abstract public function admin_notices();
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
-     * admin_footer
453
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
454
-     * apply to all pages/views loaded by child class.
455
-     *
456
-     * @return void
457
-     */
458
-    public function admin_footer()
459
-    {
460
-    }
461
-
462
-
463
-    /**
464
-     * _global_ajax_hooks
465
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
466
-     * Note: within the ajax callback methods.
467
-     *
468
-     * @abstract
469
-     * @return void
470
-     */
471
-    protected function _global_ajax_hooks()
472
-    {
473
-        // for lazy loading of metabox content
474
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
475
-    }
476
-
477
-
478
-    public function ajax_metabox_content()
479
-    {
480
-        $content_id  = $this->request->getRequestParam('contentid', '');
481
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
482
-        self::cached_rss_display($content_id, $content_url);
483
-        wp_die();
484
-    }
485
-
486
-
487
-    /**
488
-     * _page_setup
489
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
490
-     * doesn't match the object.
491
-     *
492
-     * @final
493
-     * @return void
494
-     * @throws EE_Error
495
-     * @throws InvalidArgumentException
496
-     * @throws ReflectionException
497
-     * @throws InvalidDataTypeException
498
-     * @throws InvalidInterfaceException
499
-     */
500
-    final protected function _page_setup()
501
-    {
502
-        // requires?
503
-        // admin_init stuff - global - we're setting this REALLY early
504
-        // so if EE_Admin pages have to hook into other WP pages they can.
505
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
506
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
507
-        // next verify if we need to load anything...
508
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
509
-        $this->page_folder   = strtolower(
510
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
511
-        );
512
-        global $ee_menu_slugs;
513
-        $ee_menu_slugs = (array) $ee_menu_slugs;
514
-        if (
515
-            ! defined('DOING_AJAX')
516
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
517
-        ) {
518
-            return;
519
-        }
520
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
521
-        // we need to copy the action from the second to the first
522
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
523
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
524
-        $action     = $action !== '-1' ? $action : $action2;
525
-        $req_action = $action !== '-1' ? $action : 'default';
526
-
527
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
528
-        // then let's use the route as the action.
529
-        // This covers cases where we're coming in from a list table that isn't on the default route.
530
-        $route = $this->request->getRequestParam('route');
531
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
532
-            ? $route
533
-            : $req_action;
534
-        $this->_current_view = $this->_req_action;
535
-        $this->_req_nonce    = $this->_req_action . '_nonce';
536
-        $this->_define_page_props();
537
-        $this->_current_page_view_url = add_query_arg(
538
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
539
-            $this->_admin_base_url
540
-        );
541
-        // default things
542
-        $this->_default_espresso_metaboxes = [
543
-            '_espresso_news_post_box',
544
-            '_espresso_links_post_box',
545
-            '_espresso_ratings_request',
546
-            '_espresso_sponsors_post_box',
547
-        ];
548
-        // set page configs
549
-        $this->_set_page_routes();
550
-        $this->_set_page_config();
551
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
552
-        if ($this->request->requestParamIsSet('wp_referer')) {
553
-            $this->_default_route_query_args['wp_referer'] = $this->request->getRequestParam(
554
-                'wp_referer',
555
-                null,
556
-                'url'
557
-            );
558
-        }
559
-        // for caffeinated and other extended functionality.
560
-        //  If there is a _extend_page_config method
561
-        // then let's run that to modify the all the various page configuration arrays
562
-        if (method_exists($this, '_extend_page_config')) {
563
-            $this->_extend_page_config();
564
-        }
565
-        // for CPT and other extended functionality.
566
-        // If there is an _extend_page_config_for_cpt
567
-        // then let's run that to modify all the various page configuration arrays.
568
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
569
-            $this->_extend_page_config_for_cpt();
570
-        }
571
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
572
-        $this->_page_routes = apply_filters(
573
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
574
-            $this->_page_routes,
575
-            $this
576
-        );
577
-        $this->_page_config = apply_filters(
578
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
579
-            $this->_page_config,
580
-            $this
581
-        );
582
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
583
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
584
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
585
-            add_action(
586
-                'AHEE__EE_Admin_Page__route_admin_request',
587
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
588
-                10,
589
-                2
590
-            );
591
-        }
592
-        // next route only if routing enabled
593
-        if ($this->_routing && ! defined('DOING_AJAX')) {
594
-            $this->_verify_routes();
595
-            // next let's just check user_access and kill if no access
596
-            $this->check_user_access();
597
-            if ($this->_is_UI_request) {
598
-                // admin_init stuff - global, all views for this page class, specific view
599
-                add_action('admin_init', [$this, 'admin_init'], 10);
600
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
601
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
602
-                }
603
-            } else {
604
-                // hijack regular WP loading and route admin request immediately
605
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
606
-                $this->route_admin_request();
607
-            }
608
-        }
609
-    }
610
-
611
-
612
-    /**
613
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
614
-     *
615
-     * @return void
616
-     * @throws ReflectionException
617
-     * @throws EE_Error
618
-     */
619
-    private function _do_other_page_hooks()
620
-    {
621
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
622
-        foreach ($registered_pages as $page) {
623
-            // now let's setup the file name and class that should be present
624
-            $classname = str_replace('.class.php', '', $page);
625
-            // autoloaders should take care of loading file
626
-            if (! class_exists($classname)) {
627
-                $error_msg[] = sprintf(
628
-                    esc_html__(
629
-                        'Something went wrong with loading the %s admin hooks page.',
630
-                        'event_espresso'
631
-                    ),
632
-                    $page
633
-                );
634
-                $error_msg[] = $error_msg[0]
635
-                               . "\r\n"
636
-                               . sprintf(
637
-                                   esc_html__(
638
-                                       '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',
639
-                                       'event_espresso'
640
-                                   ),
641
-                                   $page,
642
-                                   '<br />',
643
-                                   '<strong>' . $classname . '</strong>'
644
-                               );
645
-                throw new EE_Error(implode('||', $error_msg));
646
-            }
647
-            $a = new ReflectionClass($classname);
648
-            // notice we are passing the instance of this class to the hook object.
649
-            $hookobj[] = $a->newInstance($this);
650
-        }
651
-    }
652
-
653
-
654
-    /**
655
-     * @throws ReflectionException
656
-     * @throws EE_Error
657
-     */
658
-    public function load_page_dependencies()
659
-    {
660
-        try {
661
-            $this->_load_page_dependencies();
662
-        } catch (EE_Error $e) {
663
-            $e->get_error();
664
-        }
665
-    }
666
-
667
-
668
-    /**
669
-     * load_page_dependencies
670
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
671
-     *
672
-     * @return void
673
-     * @throws DomainException
674
-     * @throws EE_Error
675
-     * @throws InvalidArgumentException
676
-     * @throws InvalidDataTypeException
677
-     * @throws InvalidInterfaceException
678
-     */
679
-    protected function _load_page_dependencies()
680
-    {
681
-        // let's set the current_screen and screen options to override what WP set
682
-        $this->_current_screen = get_current_screen();
683
-        // load admin_notices - global, page class, and view specific
684
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
685
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
686
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
687
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
688
-        }
689
-        // load network admin_notices - global, page class, and view specific
690
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
691
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
692
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
693
-        }
694
-        // this will save any per_page screen options if they are present
695
-        $this->_set_per_page_screen_options();
696
-        // setup list table properties
697
-        $this->_set_list_table();
698
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
699
-        // However in some cases the metaboxes will need to be added within a route handling callback.
700
-        $this->_add_registered_meta_boxes();
701
-        $this->_add_screen_columns();
702
-        // add screen options - global, page child class, and view specific
703
-        $this->_add_global_screen_options();
704
-        $this->_add_screen_options();
705
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
706
-        if (method_exists($this, $add_screen_options)) {
707
-            $this->{$add_screen_options}();
708
-        }
709
-        // add help tab(s) and tours- set via page_config and qtips.
710
-        // $this->_add_help_tour();
711
-        $this->_add_help_tabs();
712
-        $this->_add_qtips();
713
-        // add feature_pointers - global, page child class, and view specific
714
-        $this->_add_feature_pointers();
715
-        $this->_add_global_feature_pointers();
716
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
717
-        if (method_exists($this, $add_feature_pointer)) {
718
-            $this->{$add_feature_pointer}();
719
-        }
720
-        // enqueue scripts/styles - global, page class, and view specific
721
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
722
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
723
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
724
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
725
-        }
726
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
727
-        // admin_print_footer_scripts - global, page child class, and view specific.
728
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
729
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
730
-        // is a good use case. Notice the late priority we're giving these
731
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
732
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
733
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
734
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
735
-        }
736
-        // admin footer scripts
737
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
738
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
739
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
740
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
741
-        }
742
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
743
-        // targeted hook
744
-        do_action(
745
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
746
-        );
747
-    }
748
-
749
-
750
-    /**
751
-     * _set_defaults
752
-     * This sets some global defaults for class properties.
753
-     */
754
-    private function _set_defaults()
755
-    {
756
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
757
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
758
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
759
-        $this->_page_config          = $this->_default_route_query_args = [];
760
-        $this->_default_nav_tab_name = 'overview';
761
-        // init template args
762
-        $this->_template_args = [
763
-            'admin_page_header'  => '',
764
-            'admin_page_content' => '',
765
-            'post_body_content'  => '',
766
-            'before_list_table'  => '',
767
-            'after_list_table'   => '',
768
-        ];
769
-    }
770
-
771
-
772
-    /**
773
-     * route_admin_request
774
-     *
775
-     * @return void
776
-     * @throws InvalidArgumentException
777
-     * @throws InvalidInterfaceException
778
-     * @throws InvalidDataTypeException
779
-     * @throws EE_Error
780
-     * @throws ReflectionException
781
-     * @see    _route_admin_request()
782
-     */
783
-    public function route_admin_request()
784
-    {
785
-        try {
786
-            $this->_route_admin_request();
787
-        } catch (EE_Error $e) {
788
-            $e->get_error();
789
-        }
790
-    }
791
-
792
-
793
-    public function set_wp_page_slug($wp_page_slug)
794
-    {
795
-        $this->_wp_page_slug = $wp_page_slug;
796
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
797
-        if (is_network_admin()) {
798
-            $this->_wp_page_slug .= '-network';
799
-        }
800
-    }
801
-
802
-
803
-    /**
804
-     * _verify_routes
805
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
806
-     * we know if we need to drop out.
807
-     *
808
-     * @return bool
809
-     * @throws EE_Error
810
-     */
811
-    protected function _verify_routes()
812
-    {
813
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
814
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
815
-            return false;
816
-        }
817
-        $this->_route = false;
818
-        // check that the page_routes array is not empty
819
-        if (empty($this->_page_routes)) {
820
-            // user error msg
821
-            $error_msg = sprintf(
822
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
823
-                $this->_admin_page_title
824
-            );
825
-            // developer error msg
826
-            $error_msg .= '||' . $error_msg
827
-                          . esc_html__(
828
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
829
-                              'event_espresso'
830
-                          );
831
-            throw new EE_Error($error_msg);
832
-        }
833
-        // and that the requested page route exists
834
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
835
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
836
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
837
-                ? $this->_page_config[ $this->_req_action ] : [];
838
-        } else {
839
-            // user error msg
840
-            $error_msg = sprintf(
841
-                esc_html__(
842
-                    'The requested page route does not exist for the %s admin page.',
843
-                    'event_espresso'
844
-                ),
845
-                $this->_admin_page_title
846
-            );
847
-            // developer error msg
848
-            $error_msg .= '||' . $error_msg
849
-                          . sprintf(
850
-                              esc_html__(
851
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
852
-                                  'event_espresso'
853
-                              ),
854
-                              $this->_req_action
855
-                          );
856
-            throw new EE_Error($error_msg);
857
-        }
858
-        // and that a default route exists
859
-        if (! array_key_exists('default', $this->_page_routes)) {
860
-            // user error msg
861
-            $error_msg = sprintf(
862
-                esc_html__(
863
-                    'A default page route has not been set for the % admin page.',
864
-                    'event_espresso'
865
-                ),
866
-                $this->_admin_page_title
867
-            );
868
-            // developer error msg
869
-            $error_msg .= '||' . $error_msg
870
-                          . esc_html__(
871
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
872
-                              'event_espresso'
873
-                          );
874
-            throw new EE_Error($error_msg);
875
-        }
876
-        // first lets' catch if the UI request has EVER been set.
877
-        if ($this->_is_UI_request === null) {
878
-            // lets set if this is a UI request or not.
879
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
880
-            // wait a minute... we might have a noheader in the route array
881
-            $this->_is_UI_request = ! (
882
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
883
-            )
884
-                ? $this->_is_UI_request
885
-                : false;
886
-        }
887
-        $this->_set_current_labels();
888
-        return true;
889
-    }
890
-
891
-
892
-    /**
893
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
894
-     *
895
-     * @param string $route the route name we're verifying
896
-     * @return bool we'll throw an exception if this isn't a valid route.
897
-     * @throws EE_Error
898
-     */
899
-    protected function _verify_route($route)
900
-    {
901
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
902
-            return true;
903
-        }
904
-        // user error msg
905
-        $error_msg = sprintf(
906
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
907
-            $this->_admin_page_title
908
-        );
909
-        // developer error msg
910
-        $error_msg .= '||' . $error_msg
911
-                      . sprintf(
912
-                          esc_html__(
913
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
914
-                              'event_espresso'
915
-                          ),
916
-                          $route
917
-                      );
918
-        throw new EE_Error($error_msg);
919
-    }
920
-
921
-
922
-    /**
923
-     * perform nonce verification
924
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
925
-     * using this method (and save retyping!)
926
-     *
927
-     * @param string $nonce     The nonce sent
928
-     * @param string $nonce_ref The nonce reference string (name0)
929
-     * @return void
930
-     * @throws EE_Error
931
-     */
932
-    protected function _verify_nonce($nonce, $nonce_ref)
933
-    {
934
-        // verify nonce against expected value
935
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
936
-            // these are not the droids you are looking for !!!
937
-            $msg = sprintf(
938
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
939
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
940
-                '</a>'
941
-            );
942
-            if (WP_DEBUG) {
943
-                $msg .= "\n  ";
944
-                $msg .= sprintf(
945
-                    esc_html__(
946
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
947
-                        'event_espresso'
948
-                    ),
949
-                    __CLASS__
950
-                );
951
-            }
952
-            if (! defined('DOING_AJAX')) {
953
-                wp_die($msg);
954
-            }
955
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
956
-            $this->_return_json();
957
-        }
958
-    }
959
-
960
-
961
-    /**
962
-     * _route_admin_request()
963
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
964
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
965
-     * in the page routes and then will try to load the corresponding method.
966
-     *
967
-     * @return void
968
-     * @throws EE_Error
969
-     * @throws InvalidArgumentException
970
-     * @throws InvalidDataTypeException
971
-     * @throws InvalidInterfaceException
972
-     * @throws ReflectionException
973
-     */
974
-    protected function _route_admin_request()
975
-    {
976
-        if (! $this->_is_UI_request) {
977
-            $this->_verify_routes();
978
-        }
979
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
980
-        if ($this->_req_action !== 'default' && $nonce_check) {
981
-            // set nonce from post data
982
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
983
-            $this->_verify_nonce($nonce, $this->_req_nonce);
984
-        }
985
-        // set the nav_tabs array but ONLY if this is  UI_request
986
-        if ($this->_is_UI_request) {
987
-            $this->_set_nav_tabs();
988
-        }
989
-        // grab callback function
990
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
991
-        // check if callback has args
992
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
993
-        $error_msg = '';
994
-        // action right before calling route
995
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
996
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
997
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
998
-        }
999
-        // right before calling the route, let's clean the _wp_http_referer
1000
-        $this->request->setServerParam(
1001
-            'REQUEST_URI',
1002
-            remove_query_arg(
1003
-                '_wp_http_referer',
1004
-                wp_unslash($this->request->getServerParam('REQUEST_URI'))
1005
-            )
1006
-        );
1007
-        if (! empty($func)) {
1008
-            if (is_array($func)) {
1009
-                list($class, $method) = $func;
1010
-            } elseif (strpos($func, '::') !== false) {
1011
-                list($class, $method) = explode('::', $func);
1012
-            } else {
1013
-                $class  = $this;
1014
-                $method = $func;
1015
-            }
1016
-            if (! (is_object($class) && $class === $this)) {
1017
-                // send along this admin page object for access by addons.
1018
-                $args['admin_page_object'] = $this;
1019
-            }
1020
-            if (// is it a method on a class that doesn't work?
1021
-                (
1022
-                    (
1023
-                        method_exists($class, $method)
1024
-                        && call_user_func_array([$class, $method], $args) === false
1025
-                    )
1026
-                    && (
1027
-                        // is it a standalone function that doesn't work?
1028
-                        function_exists($method)
1029
-                        && call_user_func_array(
1030
-                               $func,
1031
-                               array_merge(['admin_page_object' => $this], $args)
1032
-                           ) === false
1033
-                    )
1034
-                )
1035
-                || (
1036
-                    // is it neither a class method NOR a standalone function?
1037
-                    ! method_exists($class, $method)
1038
-                    && ! function_exists($method)
1039
-                )
1040
-            ) {
1041
-                // user error msg
1042
-                $error_msg = esc_html__(
1043
-                    'An error occurred. The  requested page route could not be found.',
1044
-                    'event_espresso'
1045
-                );
1046
-                // developer error msg
1047
-                $error_msg .= '||';
1048
-                $error_msg .= sprintf(
1049
-                    esc_html__(
1050
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1051
-                        'event_espresso'
1052
-                    ),
1053
-                    $method
1054
-                );
1055
-            }
1056
-            if (! empty($error_msg)) {
1057
-                throw new EE_Error($error_msg);
1058
-            }
1059
-        }
1060
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1061
-        // then we need to reset the routing properties to the new route.
1062
-        // 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.
1063
-        if ($this->_is_UI_request === false
1064
-            && is_array($this->_route)
1065
-            && ! empty($this->_route['headers_sent_route'])
1066
-        ) {
1067
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1068
-        }
1069
-    }
1070
-
1071
-
1072
-    /**
1073
-     * This method just allows the resetting of page properties in the case where a no headers
1074
-     * route redirects to a headers route in its route config.
1075
-     *
1076
-     * @param string $new_route New (non header) route to redirect to.
1077
-     * @return   void
1078
-     * @throws ReflectionException
1079
-     * @throws InvalidArgumentException
1080
-     * @throws InvalidInterfaceException
1081
-     * @throws InvalidDataTypeException
1082
-     * @throws EE_Error
1083
-     * @since   4.3.0
1084
-     */
1085
-    protected function _reset_routing_properties($new_route)
1086
-    {
1087
-        $this->_is_UI_request = true;
1088
-        // now we set the current route to whatever the headers_sent_route is set at
1089
-        $this->request->setRequestParam('action', $new_route);
1090
-        // rerun page setup
1091
-        $this->_page_setup();
1092
-    }
1093
-
1094
-
1095
-    /**
1096
-     * _add_query_arg
1097
-     * adds nonce to array of arguments then calls WP add_query_arg function
1098
-     *(internally just uses EEH_URL's function with the same name)
1099
-     *
1100
-     * @param array  $args
1101
-     * @param string $url
1102
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1103
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1104
-     *                                        Example usage: If the current page is:
1105
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1106
-     *                                        &action=default&event_id=20&month_range=March%202015
1107
-     *                                        &_wpnonce=5467821
1108
-     *                                        and you call:
1109
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1110
-     *                                        array(
1111
-     *                                        'action' => 'resend_something',
1112
-     *                                        'page=>espresso_registrations'
1113
-     *                                        ),
1114
-     *                                        $some_url,
1115
-     *                                        true
1116
-     *                                        );
1117
-     *                                        It will produce a url in this structure:
1118
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1119
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1120
-     *                                        month_range]=March%202015
1121
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1122
-     * @return string
1123
-     */
1124
-    public static function add_query_args_and_nonce(
1125
-        $args = [],
1126
-        $url = false,
1127
-        $sticky = false,
1128
-        $exclude_nonce = false
1129
-    ) {
1130
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1131
-        if ($sticky) {
1132
-            /** @var RequestInterface $request */
1133
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1134
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1135
-            foreach ($request->requestParams() as $key => $value) {
1136
-                // do not add nonces
1137
-                if (strpos($key, 'nonce') !== false) {
1138
-                    continue;
1139
-                }
1140
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1141
-            }
1142
-        }
1143
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1144
-    }
1145
-
1146
-
1147
-    /**
1148
-     * This returns a generated link that will load the related help tab.
1149
-     *
1150
-     * @param string $help_tab_id the id for the connected help tab
1151
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1152
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1153
-     * @return string              generated link
1154
-     * @uses EEH_Template::get_help_tab_link()
1155
-     */
1156
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1157
-    {
1158
-        return EEH_Template::get_help_tab_link(
1159
-            $help_tab_id,
1160
-            $this->page_slug,
1161
-            $this->_req_action,
1162
-            $icon_style,
1163
-            $help_text
1164
-        );
1165
-    }
1166
-
1167
-
1168
-    /**
1169
-     * _add_help_tabs
1170
-     * Note child classes define their help tabs within the page_config array.
1171
-     *
1172
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1173
-     * @return void
1174
-     * @throws DomainException
1175
-     * @throws EE_Error
1176
-     */
1177
-    protected function _add_help_tabs()
1178
-    {
1179
-        $tour_buttons = '';
1180
-        if (isset($this->_page_config[ $this->_req_action ])) {
1181
-            $config = $this->_page_config[ $this->_req_action ];
1182
-            // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1183
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1184
-            // if (isset($this->_help_tour[ $this->_req_action ])) {
1185
-            //     $tb = array();
1186
-            //     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1187
-            //     foreach ($this->_help_tour['tours'] as $tour) {
1188
-            //         // if this is the end tour then we don't need to setup a button
1189
-            //         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1190
-            //             continue;
1191
-            //         }
1192
-            //         $tb[] = '<button id="trigger-tour-'
1193
-            //                 . $tour->get_slug()
1194
-            //                 . '" class="button-primary trigger-ee-help-tour">'
1195
-            //                 . $tour->get_label()
1196
-            //                 . '</button>';
1197
-            //     }
1198
-            //     $tour_buttons .= implode('<br />', $tb);
1199
-            //     $tour_buttons .= '</div></div>';
1200
-            // }
1201
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1202
-            if (is_array($config) && isset($config['help_sidebar'])) {
1203
-                // check that the callback given is valid
1204
-                if (! method_exists($this, $config['help_sidebar'])) {
1205
-                    throw new EE_Error(
1206
-                        sprintf(
1207
-                            esc_html__(
1208
-                                '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',
1209
-                                'event_espresso'
1210
-                            ),
1211
-                            $config['help_sidebar'],
1212
-                            get_class($this)
1213
-                        )
1214
-                    );
1215
-                }
1216
-                $content = apply_filters(
1217
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1218
-                    $this->{$config['help_sidebar']}()
1219
-                );
1220
-                $content .= $tour_buttons; // add help tour buttons.
1221
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1222
-                $this->_current_screen->set_help_sidebar($content);
1223
-            }
1224
-            // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1225
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1226
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1227
-            }
1228
-            // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1229
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1230
-                $_ht['id']      = $this->page_slug;
1231
-                $_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1232
-                $_ht['content'] = '<p>'
1233
-                                  . esc_html__(
1234
-                                      'The buttons to the right allow you to start/restart any help tours available for this page',
1235
-                                      'event_espresso'
1236
-                                  ) . '</p>';
1237
-                $this->_current_screen->add_help_tab($_ht);
1238
-            }
1239
-            if (! isset($config['help_tabs'])) {
1240
-                return;
1241
-            } //no help tabs for this route
1242
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1243
-                // we're here so there ARE help tabs!
1244
-                // make sure we've got what we need
1245
-                if (! isset($cfg['title'])) {
1246
-                    throw new EE_Error(
1247
-                        esc_html__(
1248
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1249
-                            'event_espresso'
1250
-                        )
1251
-                    );
1252
-                }
1253
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1254
-                    throw new EE_Error(
1255
-                        esc_html__(
1256
-                            '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',
1257
-                            'event_espresso'
1258
-                        )
1259
-                    );
1260
-                }
1261
-                // first priority goes to content.
1262
-                if (! empty($cfg['content'])) {
1263
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1264
-                    // second priority goes to filename
1265
-                } elseif (! empty($cfg['filename'])) {
1266
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1267
-                    // 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)
1268
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1269
-                                                             . basename($this->_get_dir())
1270
-                                                             . '/help_tabs/'
1271
-                                                             . $cfg['filename']
1272
-                                                             . '.help_tab.php' : $file_path;
1273
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1274
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1275
-                        EE_Error::add_error(
1276
-                            sprintf(
1277
-                                esc_html__(
1278
-                                    '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',
1279
-                                    'event_espresso'
1280
-                                ),
1281
-                                $tab_id,
1282
-                                key($config),
1283
-                                $file_path
1284
-                            ),
1285
-                            __FILE__,
1286
-                            __FUNCTION__,
1287
-                            __LINE__
1288
-                        );
1289
-                        return;
1290
-                    }
1291
-                    $template_args['admin_page_obj'] = $this;
1292
-                    $content                         = EEH_Template::display_template(
1293
-                        $file_path,
1294
-                        $template_args,
1295
-                        true
1296
-                    );
1297
-                } else {
1298
-                    $content = '';
1299
-                }
1300
-                // check if callback is valid
1301
-                if (empty($content)
1302
-                    && (
1303
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1304
-                    )
1305
-                ) {
1306
-                    EE_Error::add_error(
1307
-                        sprintf(
1308
-                            esc_html__(
1309
-                                '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.',
1310
-                                'event_espresso'
1311
-                            ),
1312
-                            $cfg['title']
1313
-                        ),
1314
-                        __FILE__,
1315
-                        __FUNCTION__,
1316
-                        __LINE__
1317
-                    );
1318
-                    return;
1319
-                }
1320
-                // setup config array for help tab method
1321
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1322
-                $_ht = [
1323
-                    'id'       => $id,
1324
-                    'title'    => $cfg['title'],
1325
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1326
-                    'content'  => $content,
1327
-                ];
1328
-                $this->_current_screen->add_help_tab($_ht);
1329
-            }
1330
-        }
1331
-    }
1332
-
1333
-
1334
-    /**
1335
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1336
-     * an array with properties for setting up usage of the joyride plugin
1337
-     *
1338
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1339
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1340
-     *         _set_page_config() comments
1341
-     * @return void
1342
-     * @throws InvalidArgumentException
1343
-     * @throws InvalidDataTypeException
1344
-     * @throws InvalidInterfaceException
1345
-     */
1346
-    protected function _add_help_tour()
1347
-    {
1348
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1349
-        // $tours = array();
1350
-        // $this->_help_tour = array();
1351
-        // // exit early if help tours are turned off globally
1352
-        // if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1353
-        //     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1354
-        // ) {
1355
-        //     return;
1356
-        // }
1357
-        // // loop through _page_config to find any help_tour defined
1358
-        // foreach ($this->_page_config as $route => $config) {
1359
-        //     // we're only going to set things up for this route
1360
-        //     if ($route !== $this->_req_action) {
1361
-        //         continue;
1362
-        //     }
1363
-        //     if (isset($config['help_tour'])) {
1364
-        //         foreach ($config['help_tour'] as $tour) {
1365
-        //             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1366
-        //             // let's see if we can get that file...
1367
-        //             // if not its possible this is a decaf route not set in caffeinated
1368
-        //             // so lets try and get the caffeinated equivalent
1369
-        //             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1370
-        //                                                      . basename($this->_get_dir())
1371
-        //                                                      . '/help_tours/'
1372
-        //                                                      . $tour
1373
-        //                                                      . '.class.php' : $file_path;
1374
-        //             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1375
-        //             if (! is_readable($file_path)) {
1376
-        //                 EE_Error::add_error(
1377
-        //                     sprintf(
1378
-        //                         esc_html__(
1379
-        //                             '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',
1380
-        //                             'event_espresso'
1381
-        //                         ),
1382
-        //                         $file_path,
1383
-        //                         $tour
1384
-        //                     ),
1385
-        //                     __FILE__,
1386
-        //                     __FUNCTION__,
1387
-        //                     __LINE__
1388
-        //                 );
1389
-        //                 return;
1390
-        //             }
1391
-        //             require_once $file_path;
1392
-        //             if (! class_exists($tour)) {
1393
-        //                 $error_msg[] = sprintf(
1394
-        //                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1395
-        //                     $tour
1396
-        //                 );
1397
-        //                 $error_msg[] = $error_msg[0] . "\r\n"
1398
-        //                                . sprintf(
1399
-        //                                    esc_html__(
1400
-        //                                        '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.',
1401
-        //                                        'event_espresso'
1402
-        //                                    ),
1403
-        //                                    $tour,
1404
-        //                                    '<br />',
1405
-        //                                    $tour,
1406
-        //                                    $this->_req_action,
1407
-        //                                    get_class($this)
1408
-        //                                );
1409
-        //                 throw new EE_Error(implode('||', $error_msg));
1410
-        //             }
1411
-        //             $tour_obj = new $tour($this->_is_caf);
1412
-        //             $tours[] = $tour_obj;
1413
-        //             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1414
-        //         }
1415
-        //         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1416
-        //         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1417
-        //         $tours[] = $end_stop_tour;
1418
-        //         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1419
-        //     }
1420
-        // }
1421
-        //
1422
-        // if (! empty($tours)) {
1423
-        //     $this->_help_tour['tours'] = $tours;
1424
-        // }
1425
-        // // that's it!  Now that the $_help_tours property is set (or not)
1426
-        // // the scripts and html should be taken care of automatically.
1427
-        //
1428
-        // /**
1429
-        //  * Allow extending the help tours variable.
1430
-        //  *
1431
-        //  * @param Array $_help_tour The array containing all help tour information to be displayed.
1432
-        //  */
1433
-        // $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1434
-    }
1435
-
1436
-
1437
-    /**
1438
-     * This simply sets up any qtips that have been defined in the page config
1439
-     *
1440
-     * @return void
1441
-     */
1442
-    protected function _add_qtips()
1443
-    {
1444
-        if (isset($this->_route_config['qtips'])) {
1445
-            $qtips = (array) $this->_route_config['qtips'];
1446
-            // load qtip loader
1447
-            $path = [
1448
-                $this->_get_dir() . '/qtips/',
1449
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1450
-            ];
1451
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1452
-        }
1453
-    }
1454
-
1455
-
1456
-    /**
1457
-     * _set_nav_tabs
1458
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1459
-     * wish to add additional tabs or modify accordingly.
1460
-     *
1461
-     * @return void
1462
-     * @throws InvalidArgumentException
1463
-     * @throws InvalidInterfaceException
1464
-     * @throws InvalidDataTypeException
1465
-     */
1466
-    protected function _set_nav_tabs()
1467
-    {
1468
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1469
-        $i = 0;
1470
-        foreach ($this->_page_config as $slug => $config) {
1471
-            if (! is_array($config) || empty($config['nav'])) {
1472
-                continue;
1473
-            }
1474
-            // no nav tab for this config
1475
-            // check for persistent flag
1476
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1477
-                // nav tab is only to appear when route requested.
1478
-                continue;
1479
-            }
1480
-            if (! $this->check_user_access($slug, true)) {
1481
-                // no nav tab because current user does not have access.
1482
-                continue;
1483
-            }
1484
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1485
-            $this->_nav_tabs[ $slug ] = [
1486
-                'url'       => isset($config['nav']['url'])
1487
-                    ? $config['nav']['url']
1488
-                    : self::add_query_args_and_nonce(
1489
-                        ['action' => $slug],
1490
-                        $this->_admin_base_url
1491
-                    ),
1492
-                'link_text' => isset($config['nav']['label'])
1493
-                    ? $config['nav']['label']
1494
-                    : ucwords(
1495
-                        str_replace('_', ' ', $slug)
1496
-                    ),
1497
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1498
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1499
-            ];
1500
-            $i++;
1501
-        }
1502
-        // if $this->_nav_tabs is empty then lets set the default
1503
-        if (empty($this->_nav_tabs)) {
1504
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1505
-                'url'       => $this->_admin_base_url,
1506
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1507
-                'css_class' => 'nav-tab-active',
1508
-                'order'     => 10,
1509
-            ];
1510
-        }
1511
-        // now let's sort the tabs according to order
1512
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1513
-    }
1514
-
1515
-
1516
-    /**
1517
-     * _set_current_labels
1518
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1519
-     * property array
1520
-     *
1521
-     * @return void
1522
-     */
1523
-    private function _set_current_labels()
1524
-    {
1525
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1526
-            foreach ($this->_route_config['labels'] as $label => $text) {
1527
-                if (is_array($text)) {
1528
-                    foreach ($text as $sublabel => $subtext) {
1529
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1530
-                    }
1531
-                } else {
1532
-                    $this->_labels[ $label ] = $text;
1533
-                }
1534
-            }
1535
-        }
1536
-    }
1537
-
1538
-
1539
-    /**
1540
-     *        verifies user access for this admin page
1541
-     *
1542
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1543
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1544
-     *                               return false if verify fail.
1545
-     * @return bool
1546
-     * @throws InvalidArgumentException
1547
-     * @throws InvalidDataTypeException
1548
-     * @throws InvalidInterfaceException
1549
-     */
1550
-    public function check_user_access($route_to_check = '', $verify_only = false)
1551
-    {
1552
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1553
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1554
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1555
-                          && is_array(
1556
-                              $this->_page_routes[ $route_to_check ]
1557
-                          )
1558
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1559
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1560
-        if (empty($capability) && empty($route_to_check)) {
1561
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1562
-                : $this->_route['capability'];
1563
-        } else {
1564
-            $capability = empty($capability) ? 'manage_options' : $capability;
1565
-        }
1566
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1567
-        if (! defined('DOING_AJAX')
1568
-            && (
1569
-                ! function_exists('is_admin')
1570
-                || ! EE_Registry::instance()->CAP->current_user_can(
1571
-                    $capability,
1572
-                    $this->page_slug
1573
-                    . '_'
1574
-                    . $route_to_check,
1575
-                    $id
1576
-                )
1577
-            )
1578
-        ) {
1579
-            if ($verify_only) {
1580
-                return false;
1581
-            }
1582
-            if (is_user_logged_in()) {
1583
-                wp_die(__('You do not have access to this route.', 'event_espresso'));
1584
-            } else {
1585
-                return false;
1586
-            }
1587
-        }
1588
-        return true;
1589
-    }
1590
-
1591
-
1592
-    /**
1593
-     * admin_init_global
1594
-     * This runs all the code that we want executed within the WP admin_init hook.
1595
-     * This method executes for ALL EE Admin pages.
1596
-     *
1597
-     * @return void
1598
-     */
1599
-    public function admin_init_global()
1600
-    {
1601
-    }
1602
-
1603
-
1604
-    /**
1605
-     * wp_loaded_global
1606
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1607
-     * EE_Admin page and will execute on every EE Admin Page load
1608
-     *
1609
-     * @return void
1610
-     */
1611
-    public function wp_loaded()
1612
-    {
1613
-    }
1614
-
1615
-
1616
-    /**
1617
-     * admin_notices
1618
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1619
-     * ALL EE_Admin pages.
1620
-     *
1621
-     * @return void
1622
-     */
1623
-    public function admin_notices_global()
1624
-    {
1625
-        $this->_display_no_javascript_warning();
1626
-        $this->_display_espresso_notices();
1627
-    }
1628
-
1629
-
1630
-    public function network_admin_notices_global()
1631
-    {
1632
-        $this->_display_no_javascript_warning();
1633
-        $this->_display_espresso_notices();
1634
-    }
1635
-
1636
-
1637
-    /**
1638
-     * admin_footer_scripts_global
1639
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1640
-     * will apply on ALL EE_Admin pages.
1641
-     *
1642
-     * @return void
1643
-     */
1644
-    public function admin_footer_scripts_global()
1645
-    {
1646
-        $this->_add_admin_page_ajax_loading_img();
1647
-        $this->_add_admin_page_overlay();
1648
-        // if metaboxes are present we need to add the nonce field
1649
-        if (isset($this->_route_config['metaboxes'])
1650
-            || isset($this->_route_config['list_table'])
1651
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1652
-        ) {
1653
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1654
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1655
-        }
1656
-    }
1657
-
1658
-
1659
-    /**
1660
-     * admin_footer_global
1661
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1662
-     * ALL EE_Admin Pages.
1663
-     *
1664
-     * @return void
1665
-     */
1666
-    public function admin_footer_global()
1667
-    {
1668
-        // dialog container for dialog helper
1669
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1670
-        $d_cont .= '<div class="ee-notices"></div>';
1671
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1672
-        $d_cont .= '</div>';
1673
-        echo $d_cont;
1674
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1675
-        // help tour stuff?
1676
-        // if (isset($this->_help_tour[ $this->_req_action ])) {
1677
-        //     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1678
-        // }
1679
-        // current set timezone for timezone js
1680
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1681
-    }
1682
-
1683
-
1684
-    /**
1685
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1686
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1687
-     * help popups then in your templates or your content you set "triggers" for the content using the
1688
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1689
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1690
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1691
-     * for the
1692
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1693
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1694
-     *    'help_trigger_id' => array(
1695
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1696
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1697
-     *    )
1698
-     * );
1699
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1700
-     *
1701
-     * @param array $help_array
1702
-     * @param bool  $display
1703
-     * @return string content
1704
-     * @throws DomainException
1705
-     * @throws EE_Error
1706
-     */
1707
-    protected function _set_help_popup_content($help_array = [], $display = false)
1708
-    {
1709
-        $content    = '';
1710
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1711
-        // loop through the array and setup content
1712
-        foreach ($help_array as $trigger => $help) {
1713
-            // make sure the array is setup properly
1714
-            if (! isset($help['title']) || ! isset($help['content'])) {
1715
-                throw new EE_Error(
1716
-                    esc_html__(
1717
-                        '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',
1718
-                        'event_espresso'
1719
-                    )
1720
-                );
1721
-            }
1722
-            // we're good so let'd setup the template vars and then assign parsed template content to our content.
1723
-            $template_args = [
1724
-                'help_popup_id'      => $trigger,
1725
-                'help_popup_title'   => $help['title'],
1726
-                'help_popup_content' => $help['content'],
1727
-            ];
1728
-            $content       .= EEH_Template::display_template(
1729
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1730
-                $template_args,
1731
-                true
1732
-            );
1733
-        }
1734
-        if ($display) {
1735
-            echo $content;
1736
-            return '';
1737
-        }
1738
-        return $content;
1739
-    }
1740
-
1741
-
1742
-    /**
1743
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1744
-     *
1745
-     * @return array properly formatted array for help popup content
1746
-     * @throws EE_Error
1747
-     */
1748
-    private function _get_help_content()
1749
-    {
1750
-        // what is the method we're looking for?
1751
-        $method_name = '_help_popup_content_' . $this->_req_action;
1752
-        // if method doesn't exist let's get out.
1753
-        if (! method_exists($this, $method_name)) {
1754
-            return [];
1755
-        }
1756
-        // k we're good to go let's retrieve the help array
1757
-        $help_array = call_user_func([$this, $method_name]);
1758
-        // make sure we've got an array!
1759
-        if (! is_array($help_array)) {
1760
-            throw new EE_Error(
1761
-                esc_html__(
1762
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1763
-                    'event_espresso'
1764
-                )
1765
-            );
1766
-        }
1767
-        return $help_array;
1768
-    }
1769
-
1770
-
1771
-    /**
1772
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1773
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1774
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1775
-     *
1776
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1777
-     * @param boolean $display    if false then we return the trigger string
1778
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1779
-     * @return string
1780
-     * @throws DomainException
1781
-     * @throws EE_Error
1782
-     */
1783
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1784
-    {
1785
-        if (defined('DOING_AJAX')) {
1786
-            return '';
1787
-        }
1788
-        // 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
1789
-        $help_array   = $this->_get_help_content();
1790
-        $help_content = '';
1791
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1792
-            $help_array[ $trigger_id ] = [
1793
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1794
-                'content' => esc_html__(
1795
-                    '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.)',
1796
-                    'event_espresso'
1797
-                ),
1798
-            ];
1799
-            $help_content              = $this->_set_help_popup_content($help_array, false);
1800
-        }
1801
-        // let's setup the trigger
1802
-        $content = '<a class="ee-dialog" href="?height='
1803
-                   . $dimensions[0]
1804
-                   . '&width='
1805
-                   . $dimensions[1]
1806
-                   . '&inlineId='
1807
-                   . $trigger_id
1808
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1809
-        $content .= $help_content;
1810
-        if ($display) {
1811
-            echo $content;
1812
-            return '';
1813
-        }
1814
-        return $content;
1815
-    }
1816
-
1817
-
1818
-    /**
1819
-     * _add_global_screen_options
1820
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1821
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1822
-     *
1823
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1824
-     *         see also WP_Screen object documents...
1825
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1826
-     * @abstract
1827
-     * @return void
1828
-     */
1829
-    private function _add_global_screen_options()
1830
-    {
1831
-    }
1832
-
1833
-
1834
-    /**
1835
-     * _add_global_feature_pointers
1836
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1837
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1838
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1839
-     *
1840
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1841
-     *         extended) also see:
1842
-     * @link   http://eamann.com/tech/wordpress-portland/
1843
-     * @abstract
1844
-     * @return void
1845
-     */
1846
-    private function _add_global_feature_pointers()
1847
-    {
1848
-    }
1849
-
1850
-
1851
-    /**
1852
-     * load_global_scripts_styles
1853
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1854
-     *
1855
-     * @return void
1856
-     */
1857
-    public function load_global_scripts_styles()
1858
-    {
1859
-        /** STYLES **/
1860
-        // add debugging styles
1861
-        if (WP_DEBUG) {
1862
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1863
-        }
1864
-        // register all styles
1865
-        wp_register_style(
1866
-            'espresso-ui-theme',
1867
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1868
-            [],
1869
-            EVENT_ESPRESSO_VERSION
1870
-        );
1871
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1872
-        // helpers styles
1873
-        wp_register_style(
1874
-            'ee-text-links',
1875
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1876
-            [],
1877
-            EVENT_ESPRESSO_VERSION
1878
-        );
1879
-        /** SCRIPTS **/
1880
-        // register all scripts
1881
-        wp_register_script(
1882
-            'ee-dialog',
1883
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1884
-            ['jquery', 'jquery-ui-draggable'],
1885
-            EVENT_ESPRESSO_VERSION,
1886
-            true
1887
-        );
1888
-        wp_register_script(
1889
-            'ee_admin_js',
1890
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1891
-            ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1892
-            EVENT_ESPRESSO_VERSION,
1893
-            true
1894
-        );
1895
-        wp_register_script(
1896
-            'jquery-ui-timepicker-addon',
1897
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1898
-            ['jquery-ui-datepicker', 'jquery-ui-slider'],
1899
-            EVENT_ESPRESSO_VERSION,
1900
-            true
1901
-        );
1902
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1903
-        // if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1904
-        //     add_filter('FHEE_load_joyride', '__return_true');
1905
-        // }
1906
-        // script for sorting tables
1907
-        wp_register_script(
1908
-            'espresso_ajax_table_sorting',
1909
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1910
-            ['ee_admin_js', 'jquery-ui-sortable'],
1911
-            EVENT_ESPRESSO_VERSION,
1912
-            true
1913
-        );
1914
-        // script for parsing uri's
1915
-        wp_register_script(
1916
-            'ee-parse-uri',
1917
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1918
-            [],
1919
-            EVENT_ESPRESSO_VERSION,
1920
-            true
1921
-        );
1922
-        // and parsing associative serialized form elements
1923
-        wp_register_script(
1924
-            'ee-serialize-full-array',
1925
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1926
-            ['jquery'],
1927
-            EVENT_ESPRESSO_VERSION,
1928
-            true
1929
-        );
1930
-        // helpers scripts
1931
-        wp_register_script(
1932
-            'ee-text-links',
1933
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1934
-            ['jquery'],
1935
-            EVENT_ESPRESSO_VERSION,
1936
-            true
1937
-        );
1938
-        wp_register_script(
1939
-            'ee-moment-core',
1940
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1941
-            [],
1942
-            EVENT_ESPRESSO_VERSION,
1943
-            true
1944
-        );
1945
-        wp_register_script(
1946
-            'ee-moment',
1947
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1948
-            ['ee-moment-core'],
1949
-            EVENT_ESPRESSO_VERSION,
1950
-            true
1951
-        );
1952
-        wp_register_script(
1953
-            'ee-datepicker',
1954
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1955
-            ['jquery-ui-timepicker-addon', 'ee-moment'],
1956
-            EVENT_ESPRESSO_VERSION,
1957
-            true
1958
-        );
1959
-        // google charts
1960
-        wp_register_script(
1961
-            'google-charts',
1962
-            'https://www.gstatic.com/charts/loader.js',
1963
-            [],
1964
-            EVENT_ESPRESSO_VERSION,
1965
-            false
1966
-        );
1967
-        // ENQUEUE ALL BASICS BY DEFAULT
1968
-        wp_enqueue_style('ee-admin-css');
1969
-        wp_enqueue_script('ee_admin_js');
1970
-        wp_enqueue_script('ee-accounting');
1971
-        wp_enqueue_script('jquery-validate');
1972
-        // taking care of metaboxes
1973
-        if (empty($this->_cpt_route)
1974
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1975
-        ) {
1976
-            wp_enqueue_script('dashboard');
1977
-        }
1978
-        // LOCALIZED DATA
1979
-        // localize script for ajax lazy loading
1980
-        $lazy_loader_container_ids = apply_filters(
1981
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1982
-            ['espresso_news_post_box_content']
1983
-        );
1984
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1985
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1986
-        // /**
1987
-        //  * help tour stuff
1988
-        //  */
1989
-        // if (! empty($this->_help_tour)) {
1990
-        //     // register the js for kicking things off
1991
-        //     wp_enqueue_script(
1992
-        //         'ee-help-tour',
1993
-        //         EE_ADMIN_URL . 'assets/ee-help-tour.js',
1994
-        //         array('jquery-joyride'),
1995
-        //         EVENT_ESPRESSO_VERSION,
1996
-        //         true
1997
-        //     );
1998
-        //     $tours = array();
1999
-        //     // setup tours for the js tour object
2000
-        //     foreach ($this->_help_tour['tours'] as $tour) {
2001
-        //         if ($tour instanceof EE_Help_Tour) {
2002
-        //             $tours[] = array(
2003
-        //                 'id'      => $tour->get_slug(),
2004
-        //                 'options' => $tour->get_options(),
2005
-        //             );
2006
-        //         }
2007
-        //     }
2008
-        //     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2009
-        //     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2010
-        // }
2011
-    }
2012
-
2013
-
2014
-    /**
2015
-     *        admin_footer_scripts_eei18n_js_strings
2016
-     *
2017
-     * @return        void
2018
-     */
2019
-    public function admin_footer_scripts_eei18n_js_strings()
2020
-    {
2021
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2022
-        EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2023
-            '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!!!',
2024
-            'event_espresso'
2025
-        );
2026
-        EE_Registry::$i18n_js_strings['January']        = esc_html__('January', 'event_espresso');
2027
-        EE_Registry::$i18n_js_strings['February']       = esc_html__('February', 'event_espresso');
2028
-        EE_Registry::$i18n_js_strings['March']          = esc_html__('March', 'event_espresso');
2029
-        EE_Registry::$i18n_js_strings['April']          = esc_html__('April', 'event_espresso');
2030
-        EE_Registry::$i18n_js_strings['May']            = esc_html__('May', 'event_espresso');
2031
-        EE_Registry::$i18n_js_strings['June']           = esc_html__('June', 'event_espresso');
2032
-        EE_Registry::$i18n_js_strings['July']           = esc_html__('July', 'event_espresso');
2033
-        EE_Registry::$i18n_js_strings['August']         = esc_html__('August', 'event_espresso');
2034
-        EE_Registry::$i18n_js_strings['September']      = esc_html__('September', 'event_espresso');
2035
-        EE_Registry::$i18n_js_strings['October']        = esc_html__('October', 'event_espresso');
2036
-        EE_Registry::$i18n_js_strings['November']       = esc_html__('November', 'event_espresso');
2037
-        EE_Registry::$i18n_js_strings['December']       = esc_html__('December', 'event_espresso');
2038
-        EE_Registry::$i18n_js_strings['Jan']            = esc_html__('Jan', 'event_espresso');
2039
-        EE_Registry::$i18n_js_strings['Feb']            = esc_html__('Feb', 'event_espresso');
2040
-        EE_Registry::$i18n_js_strings['Mar']            = esc_html__('Mar', 'event_espresso');
2041
-        EE_Registry::$i18n_js_strings['Apr']            = esc_html__('Apr', 'event_espresso');
2042
-        EE_Registry::$i18n_js_strings['May']            = esc_html__('May', 'event_espresso');
2043
-        EE_Registry::$i18n_js_strings['Jun']            = esc_html__('Jun', 'event_espresso');
2044
-        EE_Registry::$i18n_js_strings['Jul']            = esc_html__('Jul', 'event_espresso');
2045
-        EE_Registry::$i18n_js_strings['Aug']            = esc_html__('Aug', 'event_espresso');
2046
-        EE_Registry::$i18n_js_strings['Sep']            = esc_html__('Sep', 'event_espresso');
2047
-        EE_Registry::$i18n_js_strings['Oct']            = esc_html__('Oct', 'event_espresso');
2048
-        EE_Registry::$i18n_js_strings['Nov']            = esc_html__('Nov', 'event_espresso');
2049
-        EE_Registry::$i18n_js_strings['Dec']            = esc_html__('Dec', 'event_espresso');
2050
-        EE_Registry::$i18n_js_strings['Sunday']         = esc_html__('Sunday', 'event_espresso');
2051
-        EE_Registry::$i18n_js_strings['Monday']         = esc_html__('Monday', 'event_espresso');
2052
-        EE_Registry::$i18n_js_strings['Tuesday']        = esc_html__('Tuesday', 'event_espresso');
2053
-        EE_Registry::$i18n_js_strings['Wednesday']      = esc_html__('Wednesday', 'event_espresso');
2054
-        EE_Registry::$i18n_js_strings['Thursday']       = esc_html__('Thursday', 'event_espresso');
2055
-        EE_Registry::$i18n_js_strings['Friday']         = esc_html__('Friday', 'event_espresso');
2056
-        EE_Registry::$i18n_js_strings['Saturday']       = esc_html__('Saturday', 'event_espresso');
2057
-        EE_Registry::$i18n_js_strings['Sun']            = esc_html__('Sun', 'event_espresso');
2058
-        EE_Registry::$i18n_js_strings['Mon']            = esc_html__('Mon', 'event_espresso');
2059
-        EE_Registry::$i18n_js_strings['Tue']            = esc_html__('Tue', 'event_espresso');
2060
-        EE_Registry::$i18n_js_strings['Wed']            = esc_html__('Wed', 'event_espresso');
2061
-        EE_Registry::$i18n_js_strings['Thu']            = esc_html__('Thu', 'event_espresso');
2062
-        EE_Registry::$i18n_js_strings['Fri']            = esc_html__('Fri', 'event_espresso');
2063
-        EE_Registry::$i18n_js_strings['Sat']            = esc_html__('Sat', 'event_espresso');
2064
-    }
2065
-
2066
-
2067
-    /**
2068
-     *        load enhanced xdebug styles for ppl with failing eyesight
2069
-     *
2070
-     * @return        void
2071
-     */
2072
-    public function add_xdebug_style()
2073
-    {
2074
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2075
-    }
2076
-
2077
-
2078
-    /************************/
2079
-    /** LIST TABLE METHODS **/
2080
-    /************************/
2081
-    /**
2082
-     * this sets up the list table if the current view requires it.
2083
-     *
2084
-     * @return void
2085
-     * @throws EE_Error
2086
-     */
2087
-    protected function _set_list_table()
2088
-    {
2089
-        // first is this a list_table view?
2090
-        if (! isset($this->_route_config['list_table'])) {
2091
-            return;
2092
-        } //not a list_table view so get out.
2093
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2094
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2095
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2096
-            // user error msg
2097
-            $error_msg = esc_html__(
2098
-                'An error occurred. The requested list table views could not be found.',
2099
-                'event_espresso'
2100
-            );
2101
-            // developer error msg
2102
-            $error_msg .= '||'
2103
-                          . sprintf(
2104
-                              esc_html__(
2105
-                                  '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.',
2106
-                                  'event_espresso'
2107
-                              ),
2108
-                              $this->_req_action,
2109
-                              $list_table_view
2110
-                          );
2111
-            throw new EE_Error($error_msg);
2112
-        }
2113
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2114
-        $this->_views = apply_filters(
2115
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2116
-            $this->_views
2117
-        );
2118
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2119
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2120
-        $this->_set_list_table_view();
2121
-        $this->_set_list_table_object();
2122
-    }
2123
-
2124
-
2125
-    /**
2126
-     * set current view for List Table
2127
-     *
2128
-     * @return void
2129
-     */
2130
-    protected function _set_list_table_view()
2131
-    {
2132
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2133
-        $status = $this->request->getRequestParam('status', null, 'key');
2134
-        $this->_view = $status && array_key_exists($status, $this->_views)
2135
-            ? $status
2136
-            : $this->_view;
2137
-    }
2138
-
2139
-
2140
-    /**
2141
-     * _set_list_table_object
2142
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2143
-     *
2144
-     * @throws InvalidInterfaceException
2145
-     * @throws InvalidArgumentException
2146
-     * @throws InvalidDataTypeException
2147
-     * @throws EE_Error
2148
-     * @throws InvalidInterfaceException
2149
-     */
2150
-    protected function _set_list_table_object()
2151
-    {
2152
-        if (isset($this->_route_config['list_table'])) {
2153
-            if (! class_exists($this->_route_config['list_table'])) {
2154
-                throw new EE_Error(
2155
-                    sprintf(
2156
-                        esc_html__(
2157
-                            '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.',
2158
-                            'event_espresso'
2159
-                        ),
2160
-                        $this->_route_config['list_table'],
2161
-                        get_class($this)
2162
-                    )
2163
-                );
2164
-            }
2165
-            $this->_list_table_object = $this->loader->getShared(
2166
-                $this->_route_config['list_table'],
2167
-                [$this]
2168
-            );
2169
-        }
2170
-    }
2171
-
2172
-
2173
-    /**
2174
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2175
-     *
2176
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2177
-     *                                                    urls.  The array should be indexed by the view it is being
2178
-     *                                                    added to.
2179
-     * @return array
2180
-     */
2181
-    public function get_list_table_view_RLs($extra_query_args = [])
2182
-    {
2183
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2184
-        if (empty($this->_views)) {
2185
-            $this->_views = [];
2186
-        }
2187
-        // cycle thru views
2188
-        foreach ($this->_views as $key => $view) {
2189
-            $query_args = [];
2190
-            // check for current view
2191
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2192
-            $query_args['action']                        = $this->_req_action;
2193
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2194
-            $query_args['status']                        = $view['slug'];
2195
-            // merge any other arguments sent in.
2196
-            if (isset($extra_query_args[ $view['slug'] ])) {
2197
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2198
-            }
2199
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2200
-        }
2201
-        return $this->_views;
2202
-    }
2203
-
2204
-
2205
-    /**
2206
-     * _entries_per_page_dropdown
2207
-     * generates a drop down box for selecting the number of visible rows in an admin page list table
2208
-     *
2209
-     * @param int $max_entries total number of rows in the table
2210
-     * @return string
2211
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2212
-     *         WP does it.
2213
-     */
2214
-    protected function _entries_per_page_dropdown($max_entries = 0)
2215
-    {
2216
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2217
-        $values   = [10, 25, 50, 100];
2218
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2219
-        if ($max_entries) {
2220
-            $values[] = $max_entries;
2221
-            sort($values);
2222
-        }
2223
-        $entries_per_page_dropdown = '
115
+	/**
116
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
117
+	 * actions.
118
+	 *
119
+	 * @since 4.6.x
120
+	 * @var array.
121
+	 */
122
+	protected $_default_route_query_args;
123
+
124
+	// set via request page and action args.
125
+	protected $_current_page;
126
+
127
+	protected $_current_view;
128
+
129
+	protected $_current_page_view_url;
130
+
131
+	// sanitized request action (and nonce)
132
+
133
+	/**
134
+	 * @var string $_req_action
135
+	 */
136
+	protected $_req_action;
137
+
138
+	/**
139
+	 * @var string $_req_nonce
140
+	 */
141
+	protected $_req_nonce;
142
+
143
+	// search related
144
+	protected $_search_btn_label;
145
+
146
+	protected $_search_box_callback;
147
+
148
+	/**
149
+	 * WP Current Screen object
150
+	 *
151
+	 * @var WP_Screen
152
+	 */
153
+	protected $_current_screen;
154
+
155
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
156
+	protected $_hook_obj;
157
+
158
+	// for holding incoming request data
159
+	protected $_req_data = [];
160
+
161
+	// yes / no array for admin form fields
162
+	protected $_yes_no_values = [];
163
+
164
+	// some default things shared by all child classes
165
+	protected $_default_espresso_metaboxes;
166
+
167
+	/**
168
+	 *    EE_Registry Object
169
+	 *
170
+	 * @var    EE_Registry
171
+	 */
172
+	protected $EE = null;
173
+
174
+
175
+	/**
176
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
177
+	 *
178
+	 * @var boolean
179
+	 */
180
+	protected $_is_caf = false;
181
+
182
+
183
+	/**
184
+	 * @Constructor
185
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
186
+	 * @throws EE_Error
187
+	 * @throws InvalidArgumentException
188
+	 * @throws ReflectionException
189
+	 * @throws InvalidDataTypeException
190
+	 * @throws InvalidInterfaceException
191
+	 */
192
+	public function __construct($routing = true)
193
+	{
194
+		$this->loader  = LoaderFactory::getLoader();
195
+		$this->request = $this->loader->getShared(RequestInterface::class);
196
+
197
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
198
+			$this->_is_caf = true;
199
+		}
200
+		$this->_yes_no_values = [
201
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
202
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
203
+		];
204
+		// set the _req_data property.
205
+		$this->_req_data = $this->request->requestParams();
206
+		// routing enabled?
207
+		$this->_routing = $routing;
208
+		// set initial page props (child method)
209
+		$this->_init_page_props();
210
+		// set global defaults
211
+		$this->_set_defaults();
212
+		// set early because incoming requests could be ajax related and we need to register those hooks.
213
+		$this->_global_ajax_hooks();
214
+		$this->_ajax_hooks();
215
+		// other_page_hooks have to be early too.
216
+		$this->_do_other_page_hooks();
217
+		// This just allows us to have extending classes do something specific
218
+		// before the parent constructor runs _page_setup().
219
+		if (method_exists($this, '_before_page_setup')) {
220
+			$this->_before_page_setup();
221
+		}
222
+		// set up page dependencies
223
+		$this->_page_setup();
224
+	}
225
+
226
+
227
+	/**
228
+	 * _init_page_props
229
+	 * Child classes use to set at least the following properties:
230
+	 * $page_slug.
231
+	 * $page_label.
232
+	 *
233
+	 * @abstract
234
+	 * @return void
235
+	 */
236
+	abstract protected function _init_page_props();
237
+
238
+
239
+	/**
240
+	 * _ajax_hooks
241
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
242
+	 * Note: within the ajax callback methods.
243
+	 *
244
+	 * @abstract
245
+	 * @return void
246
+	 */
247
+	abstract protected function _ajax_hooks();
248
+
249
+
250
+	/**
251
+	 * _define_page_props
252
+	 * child classes define page properties in here.  Must include at least:
253
+	 * $_admin_base_url = base_url for all admin pages
254
+	 * $_admin_page_title = default admin_page_title for admin pages
255
+	 * $_labels = array of default labels for various automatically generated elements:
256
+	 *    array(
257
+	 *        'buttons' => array(
258
+	 *            'add' => esc_html__('label for add new button'),
259
+	 *            'edit' => esc_html__('label for edit button'),
260
+	 *            'delete' => esc_html__('label for delete button')
261
+	 *            )
262
+	 *        )
263
+	 *
264
+	 * @abstract
265
+	 * @return void
266
+	 */
267
+	abstract protected function _define_page_props();
268
+
269
+
270
+	/**
271
+	 * _set_page_routes
272
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
273
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
274
+	 * have a 'default' route. Here's the format
275
+	 * $this->_page_routes = array(
276
+	 *        'default' => array(
277
+	 *            'func' => '_default_method_handling_route',
278
+	 *            'args' => array('array','of','args'),
279
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
280
+	 *            ajax request, backend processing)
281
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
282
+	 *            headers route after.  The string you enter here should match the defined route reference for a
283
+	 *            headers sent route.
284
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
285
+	 *            this route.
286
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
287
+	 *            checks).
288
+	 *        ),
289
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
290
+	 *        handling method.
291
+	 *        )
292
+	 * )
293
+	 *
294
+	 * @abstract
295
+	 * @return void
296
+	 */
297
+	abstract protected function _set_page_routes();
298
+
299
+
300
+	/**
301
+	 * _set_page_config
302
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
303
+	 * array corresponds to the page_route for the loaded page. Format:
304
+	 * $this->_page_config = array(
305
+	 *        'default' => array(
306
+	 *            'labels' => array(
307
+	 *                'buttons' => array(
308
+	 *                    'add' => esc_html__('label for adding item'),
309
+	 *                    'edit' => esc_html__('label for editing item'),
310
+	 *                    'delete' => esc_html__('label for deleting item')
311
+	 *                ),
312
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
313
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
314
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
315
+	 *            _define_page_props() method
316
+	 *            'nav' => array(
317
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
318
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
319
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
320
+	 *                'order' => 10, //required to indicate tab position.
321
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
322
+	 *                displayed then add this parameter.
323
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
324
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
325
+	 *            metaboxes set for eventespresso admin pages.
326
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
327
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
328
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
329
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
330
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
331
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
332
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
333
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
334
+	 *            want to display.
335
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
336
+	 *                'tab_id' => array(
337
+	 *                    'title' => 'tab_title',
338
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
339
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
340
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
341
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
342
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
343
+	 *                    attempt to use the callback which should match the name of a method in the class
344
+	 *                    ),
345
+	 *                'tab2_id' => array(
346
+	 *                    'title' => 'tab2 title',
347
+	 *                    'filename' => 'file_name_2'
348
+	 *                    'callback' => 'callback_method_for_content',
349
+	 *                 ),
350
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
351
+	 *            help tab area on an admin page. @return void
352
+	 *
353
+	 * @link
354
+	 *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
355
+	 *                'help_tour' => array(
356
+	 *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
357
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
358
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
359
+	 *                ),
360
+	 *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
361
+	 *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
362
+	 *                visited just set
363
+	 *                'require_nonce' to FALSE
364
+	 *                )
365
+	 *                )
366
+	 *
367
+	 * @abstract
368
+	 */
369
+	abstract protected function _set_page_config();
370
+
371
+
372
+
373
+
374
+
375
+	/** end sample help_tour methods **/
376
+	/**
377
+	 * _add_screen_options
378
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
379
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
380
+	 * to a particular view.
381
+	 *
382
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
383
+	 *         see also WP_Screen object documents...
384
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
385
+	 * @abstract
386
+	 * @return void
387
+	 */
388
+	abstract protected function _add_screen_options();
389
+
390
+
391
+	/**
392
+	 * _add_feature_pointers
393
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
394
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
395
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
396
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
397
+	 * extended) also see:
398
+	 *
399
+	 * @link   http://eamann.com/tech/wordpress-portland/
400
+	 * @abstract
401
+	 * @return void
402
+	 */
403
+	abstract protected function _add_feature_pointers();
404
+
405
+
406
+	/**
407
+	 * load_scripts_styles
408
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
409
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
410
+	 * scripts/styles per view by putting them in a dynamic function in this format
411
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
412
+	 *
413
+	 * @abstract
414
+	 * @return void
415
+	 */
416
+	abstract public function load_scripts_styles();
417
+
418
+
419
+	/**
420
+	 * admin_init
421
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
422
+	 * all pages/views loaded by child class.
423
+	 *
424
+	 * @abstract
425
+	 * @return void
426
+	 */
427
+	abstract public function admin_init();
428
+
429
+
430
+	/**
431
+	 * admin_notices
432
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
433
+	 * all pages/views loaded by child class.
434
+	 *
435
+	 * @abstract
436
+	 * @return void
437
+	 */
438
+	abstract public function admin_notices();
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
+	 * admin_footer
453
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
454
+	 * apply to all pages/views loaded by child class.
455
+	 *
456
+	 * @return void
457
+	 */
458
+	public function admin_footer()
459
+	{
460
+	}
461
+
462
+
463
+	/**
464
+	 * _global_ajax_hooks
465
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
466
+	 * Note: within the ajax callback methods.
467
+	 *
468
+	 * @abstract
469
+	 * @return void
470
+	 */
471
+	protected function _global_ajax_hooks()
472
+	{
473
+		// for lazy loading of metabox content
474
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
475
+	}
476
+
477
+
478
+	public function ajax_metabox_content()
479
+	{
480
+		$content_id  = $this->request->getRequestParam('contentid', '');
481
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
482
+		self::cached_rss_display($content_id, $content_url);
483
+		wp_die();
484
+	}
485
+
486
+
487
+	/**
488
+	 * _page_setup
489
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
490
+	 * doesn't match the object.
491
+	 *
492
+	 * @final
493
+	 * @return void
494
+	 * @throws EE_Error
495
+	 * @throws InvalidArgumentException
496
+	 * @throws ReflectionException
497
+	 * @throws InvalidDataTypeException
498
+	 * @throws InvalidInterfaceException
499
+	 */
500
+	final protected function _page_setup()
501
+	{
502
+		// requires?
503
+		// admin_init stuff - global - we're setting this REALLY early
504
+		// so if EE_Admin pages have to hook into other WP pages they can.
505
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
506
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
507
+		// next verify if we need to load anything...
508
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
509
+		$this->page_folder   = strtolower(
510
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
511
+		);
512
+		global $ee_menu_slugs;
513
+		$ee_menu_slugs = (array) $ee_menu_slugs;
514
+		if (
515
+			! defined('DOING_AJAX')
516
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
517
+		) {
518
+			return;
519
+		}
520
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
521
+		// we need to copy the action from the second to the first
522
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
523
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
524
+		$action     = $action !== '-1' ? $action : $action2;
525
+		$req_action = $action !== '-1' ? $action : 'default';
526
+
527
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
528
+		// then let's use the route as the action.
529
+		// This covers cases where we're coming in from a list table that isn't on the default route.
530
+		$route = $this->request->getRequestParam('route');
531
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
532
+			? $route
533
+			: $req_action;
534
+		$this->_current_view = $this->_req_action;
535
+		$this->_req_nonce    = $this->_req_action . '_nonce';
536
+		$this->_define_page_props();
537
+		$this->_current_page_view_url = add_query_arg(
538
+			['page' => $this->_current_page, 'action' => $this->_current_view],
539
+			$this->_admin_base_url
540
+		);
541
+		// default things
542
+		$this->_default_espresso_metaboxes = [
543
+			'_espresso_news_post_box',
544
+			'_espresso_links_post_box',
545
+			'_espresso_ratings_request',
546
+			'_espresso_sponsors_post_box',
547
+		];
548
+		// set page configs
549
+		$this->_set_page_routes();
550
+		$this->_set_page_config();
551
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
552
+		if ($this->request->requestParamIsSet('wp_referer')) {
553
+			$this->_default_route_query_args['wp_referer'] = $this->request->getRequestParam(
554
+				'wp_referer',
555
+				null,
556
+				'url'
557
+			);
558
+		}
559
+		// for caffeinated and other extended functionality.
560
+		//  If there is a _extend_page_config method
561
+		// then let's run that to modify the all the various page configuration arrays
562
+		if (method_exists($this, '_extend_page_config')) {
563
+			$this->_extend_page_config();
564
+		}
565
+		// for CPT and other extended functionality.
566
+		// If there is an _extend_page_config_for_cpt
567
+		// then let's run that to modify all the various page configuration arrays.
568
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
569
+			$this->_extend_page_config_for_cpt();
570
+		}
571
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
572
+		$this->_page_routes = apply_filters(
573
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
574
+			$this->_page_routes,
575
+			$this
576
+		);
577
+		$this->_page_config = apply_filters(
578
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
579
+			$this->_page_config,
580
+			$this
581
+		);
582
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
583
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
584
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
585
+			add_action(
586
+				'AHEE__EE_Admin_Page__route_admin_request',
587
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
588
+				10,
589
+				2
590
+			);
591
+		}
592
+		// next route only if routing enabled
593
+		if ($this->_routing && ! defined('DOING_AJAX')) {
594
+			$this->_verify_routes();
595
+			// next let's just check user_access and kill if no access
596
+			$this->check_user_access();
597
+			if ($this->_is_UI_request) {
598
+				// admin_init stuff - global, all views for this page class, specific view
599
+				add_action('admin_init', [$this, 'admin_init'], 10);
600
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
601
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
602
+				}
603
+			} else {
604
+				// hijack regular WP loading and route admin request immediately
605
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
606
+				$this->route_admin_request();
607
+			}
608
+		}
609
+	}
610
+
611
+
612
+	/**
613
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
614
+	 *
615
+	 * @return void
616
+	 * @throws ReflectionException
617
+	 * @throws EE_Error
618
+	 */
619
+	private function _do_other_page_hooks()
620
+	{
621
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
622
+		foreach ($registered_pages as $page) {
623
+			// now let's setup the file name and class that should be present
624
+			$classname = str_replace('.class.php', '', $page);
625
+			// autoloaders should take care of loading file
626
+			if (! class_exists($classname)) {
627
+				$error_msg[] = sprintf(
628
+					esc_html__(
629
+						'Something went wrong with loading the %s admin hooks page.',
630
+						'event_espresso'
631
+					),
632
+					$page
633
+				);
634
+				$error_msg[] = $error_msg[0]
635
+							   . "\r\n"
636
+							   . sprintf(
637
+								   esc_html__(
638
+									   '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',
639
+									   'event_espresso'
640
+								   ),
641
+								   $page,
642
+								   '<br />',
643
+								   '<strong>' . $classname . '</strong>'
644
+							   );
645
+				throw new EE_Error(implode('||', $error_msg));
646
+			}
647
+			$a = new ReflectionClass($classname);
648
+			// notice we are passing the instance of this class to the hook object.
649
+			$hookobj[] = $a->newInstance($this);
650
+		}
651
+	}
652
+
653
+
654
+	/**
655
+	 * @throws ReflectionException
656
+	 * @throws EE_Error
657
+	 */
658
+	public function load_page_dependencies()
659
+	{
660
+		try {
661
+			$this->_load_page_dependencies();
662
+		} catch (EE_Error $e) {
663
+			$e->get_error();
664
+		}
665
+	}
666
+
667
+
668
+	/**
669
+	 * load_page_dependencies
670
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
671
+	 *
672
+	 * @return void
673
+	 * @throws DomainException
674
+	 * @throws EE_Error
675
+	 * @throws InvalidArgumentException
676
+	 * @throws InvalidDataTypeException
677
+	 * @throws InvalidInterfaceException
678
+	 */
679
+	protected function _load_page_dependencies()
680
+	{
681
+		// let's set the current_screen and screen options to override what WP set
682
+		$this->_current_screen = get_current_screen();
683
+		// load admin_notices - global, page class, and view specific
684
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
685
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
686
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
687
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
688
+		}
689
+		// load network admin_notices - global, page class, and view specific
690
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
691
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
692
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
693
+		}
694
+		// this will save any per_page screen options if they are present
695
+		$this->_set_per_page_screen_options();
696
+		// setup list table properties
697
+		$this->_set_list_table();
698
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
699
+		// However in some cases the metaboxes will need to be added within a route handling callback.
700
+		$this->_add_registered_meta_boxes();
701
+		$this->_add_screen_columns();
702
+		// add screen options - global, page child class, and view specific
703
+		$this->_add_global_screen_options();
704
+		$this->_add_screen_options();
705
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
706
+		if (method_exists($this, $add_screen_options)) {
707
+			$this->{$add_screen_options}();
708
+		}
709
+		// add help tab(s) and tours- set via page_config and qtips.
710
+		// $this->_add_help_tour();
711
+		$this->_add_help_tabs();
712
+		$this->_add_qtips();
713
+		// add feature_pointers - global, page child class, and view specific
714
+		$this->_add_feature_pointers();
715
+		$this->_add_global_feature_pointers();
716
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
717
+		if (method_exists($this, $add_feature_pointer)) {
718
+			$this->{$add_feature_pointer}();
719
+		}
720
+		// enqueue scripts/styles - global, page class, and view specific
721
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
722
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
723
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
724
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
725
+		}
726
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
727
+		// admin_print_footer_scripts - global, page child class, and view specific.
728
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
729
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
730
+		// is a good use case. Notice the late priority we're giving these
731
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
732
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
733
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
734
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
735
+		}
736
+		// admin footer scripts
737
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
738
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
739
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
740
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
741
+		}
742
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
743
+		// targeted hook
744
+		do_action(
745
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
746
+		);
747
+	}
748
+
749
+
750
+	/**
751
+	 * _set_defaults
752
+	 * This sets some global defaults for class properties.
753
+	 */
754
+	private function _set_defaults()
755
+	{
756
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
757
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
758
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
759
+		$this->_page_config          = $this->_default_route_query_args = [];
760
+		$this->_default_nav_tab_name = 'overview';
761
+		// init template args
762
+		$this->_template_args = [
763
+			'admin_page_header'  => '',
764
+			'admin_page_content' => '',
765
+			'post_body_content'  => '',
766
+			'before_list_table'  => '',
767
+			'after_list_table'   => '',
768
+		];
769
+	}
770
+
771
+
772
+	/**
773
+	 * route_admin_request
774
+	 *
775
+	 * @return void
776
+	 * @throws InvalidArgumentException
777
+	 * @throws InvalidInterfaceException
778
+	 * @throws InvalidDataTypeException
779
+	 * @throws EE_Error
780
+	 * @throws ReflectionException
781
+	 * @see    _route_admin_request()
782
+	 */
783
+	public function route_admin_request()
784
+	{
785
+		try {
786
+			$this->_route_admin_request();
787
+		} catch (EE_Error $e) {
788
+			$e->get_error();
789
+		}
790
+	}
791
+
792
+
793
+	public function set_wp_page_slug($wp_page_slug)
794
+	{
795
+		$this->_wp_page_slug = $wp_page_slug;
796
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
797
+		if (is_network_admin()) {
798
+			$this->_wp_page_slug .= '-network';
799
+		}
800
+	}
801
+
802
+
803
+	/**
804
+	 * _verify_routes
805
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
806
+	 * we know if we need to drop out.
807
+	 *
808
+	 * @return bool
809
+	 * @throws EE_Error
810
+	 */
811
+	protected function _verify_routes()
812
+	{
813
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
814
+		if (! $this->_current_page && ! defined('DOING_AJAX')) {
815
+			return false;
816
+		}
817
+		$this->_route = false;
818
+		// check that the page_routes array is not empty
819
+		if (empty($this->_page_routes)) {
820
+			// user error msg
821
+			$error_msg = sprintf(
822
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
823
+				$this->_admin_page_title
824
+			);
825
+			// developer error msg
826
+			$error_msg .= '||' . $error_msg
827
+						  . esc_html__(
828
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
829
+							  'event_espresso'
830
+						  );
831
+			throw new EE_Error($error_msg);
832
+		}
833
+		// and that the requested page route exists
834
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
835
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
836
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
837
+				? $this->_page_config[ $this->_req_action ] : [];
838
+		} else {
839
+			// user error msg
840
+			$error_msg = sprintf(
841
+				esc_html__(
842
+					'The requested page route does not exist for the %s admin page.',
843
+					'event_espresso'
844
+				),
845
+				$this->_admin_page_title
846
+			);
847
+			// developer error msg
848
+			$error_msg .= '||' . $error_msg
849
+						  . sprintf(
850
+							  esc_html__(
851
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
852
+								  'event_espresso'
853
+							  ),
854
+							  $this->_req_action
855
+						  );
856
+			throw new EE_Error($error_msg);
857
+		}
858
+		// and that a default route exists
859
+		if (! array_key_exists('default', $this->_page_routes)) {
860
+			// user error msg
861
+			$error_msg = sprintf(
862
+				esc_html__(
863
+					'A default page route has not been set for the % admin page.',
864
+					'event_espresso'
865
+				),
866
+				$this->_admin_page_title
867
+			);
868
+			// developer error msg
869
+			$error_msg .= '||' . $error_msg
870
+						  . esc_html__(
871
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
872
+							  'event_espresso'
873
+						  );
874
+			throw new EE_Error($error_msg);
875
+		}
876
+		// first lets' catch if the UI request has EVER been set.
877
+		if ($this->_is_UI_request === null) {
878
+			// lets set if this is a UI request or not.
879
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
880
+			// wait a minute... we might have a noheader in the route array
881
+			$this->_is_UI_request = ! (
882
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
883
+			)
884
+				? $this->_is_UI_request
885
+				: false;
886
+		}
887
+		$this->_set_current_labels();
888
+		return true;
889
+	}
890
+
891
+
892
+	/**
893
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
894
+	 *
895
+	 * @param string $route the route name we're verifying
896
+	 * @return bool we'll throw an exception if this isn't a valid route.
897
+	 * @throws EE_Error
898
+	 */
899
+	protected function _verify_route($route)
900
+	{
901
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
902
+			return true;
903
+		}
904
+		// user error msg
905
+		$error_msg = sprintf(
906
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
907
+			$this->_admin_page_title
908
+		);
909
+		// developer error msg
910
+		$error_msg .= '||' . $error_msg
911
+					  . sprintf(
912
+						  esc_html__(
913
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
914
+							  'event_espresso'
915
+						  ),
916
+						  $route
917
+					  );
918
+		throw new EE_Error($error_msg);
919
+	}
920
+
921
+
922
+	/**
923
+	 * perform nonce verification
924
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
925
+	 * using this method (and save retyping!)
926
+	 *
927
+	 * @param string $nonce     The nonce sent
928
+	 * @param string $nonce_ref The nonce reference string (name0)
929
+	 * @return void
930
+	 * @throws EE_Error
931
+	 */
932
+	protected function _verify_nonce($nonce, $nonce_ref)
933
+	{
934
+		// verify nonce against expected value
935
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
936
+			// these are not the droids you are looking for !!!
937
+			$msg = sprintf(
938
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
939
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
940
+				'</a>'
941
+			);
942
+			if (WP_DEBUG) {
943
+				$msg .= "\n  ";
944
+				$msg .= sprintf(
945
+					esc_html__(
946
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
947
+						'event_espresso'
948
+					),
949
+					__CLASS__
950
+				);
951
+			}
952
+			if (! defined('DOING_AJAX')) {
953
+				wp_die($msg);
954
+			}
955
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
956
+			$this->_return_json();
957
+		}
958
+	}
959
+
960
+
961
+	/**
962
+	 * _route_admin_request()
963
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
964
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
965
+	 * in the page routes and then will try to load the corresponding method.
966
+	 *
967
+	 * @return void
968
+	 * @throws EE_Error
969
+	 * @throws InvalidArgumentException
970
+	 * @throws InvalidDataTypeException
971
+	 * @throws InvalidInterfaceException
972
+	 * @throws ReflectionException
973
+	 */
974
+	protected function _route_admin_request()
975
+	{
976
+		if (! $this->_is_UI_request) {
977
+			$this->_verify_routes();
978
+		}
979
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
980
+		if ($this->_req_action !== 'default' && $nonce_check) {
981
+			// set nonce from post data
982
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
983
+			$this->_verify_nonce($nonce, $this->_req_nonce);
984
+		}
985
+		// set the nav_tabs array but ONLY if this is  UI_request
986
+		if ($this->_is_UI_request) {
987
+			$this->_set_nav_tabs();
988
+		}
989
+		// grab callback function
990
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
991
+		// check if callback has args
992
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
993
+		$error_msg = '';
994
+		// action right before calling route
995
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
996
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
997
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
998
+		}
999
+		// right before calling the route, let's clean the _wp_http_referer
1000
+		$this->request->setServerParam(
1001
+			'REQUEST_URI',
1002
+			remove_query_arg(
1003
+				'_wp_http_referer',
1004
+				wp_unslash($this->request->getServerParam('REQUEST_URI'))
1005
+			)
1006
+		);
1007
+		if (! empty($func)) {
1008
+			if (is_array($func)) {
1009
+				list($class, $method) = $func;
1010
+			} elseif (strpos($func, '::') !== false) {
1011
+				list($class, $method) = explode('::', $func);
1012
+			} else {
1013
+				$class  = $this;
1014
+				$method = $func;
1015
+			}
1016
+			if (! (is_object($class) && $class === $this)) {
1017
+				// send along this admin page object for access by addons.
1018
+				$args['admin_page_object'] = $this;
1019
+			}
1020
+			if (// is it a method on a class that doesn't work?
1021
+				(
1022
+					(
1023
+						method_exists($class, $method)
1024
+						&& call_user_func_array([$class, $method], $args) === false
1025
+					)
1026
+					&& (
1027
+						// is it a standalone function that doesn't work?
1028
+						function_exists($method)
1029
+						&& call_user_func_array(
1030
+							   $func,
1031
+							   array_merge(['admin_page_object' => $this], $args)
1032
+						   ) === false
1033
+					)
1034
+				)
1035
+				|| (
1036
+					// is it neither a class method NOR a standalone function?
1037
+					! method_exists($class, $method)
1038
+					&& ! function_exists($method)
1039
+				)
1040
+			) {
1041
+				// user error msg
1042
+				$error_msg = esc_html__(
1043
+					'An error occurred. The  requested page route could not be found.',
1044
+					'event_espresso'
1045
+				);
1046
+				// developer error msg
1047
+				$error_msg .= '||';
1048
+				$error_msg .= sprintf(
1049
+					esc_html__(
1050
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1051
+						'event_espresso'
1052
+					),
1053
+					$method
1054
+				);
1055
+			}
1056
+			if (! empty($error_msg)) {
1057
+				throw new EE_Error($error_msg);
1058
+			}
1059
+		}
1060
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1061
+		// then we need to reset the routing properties to the new route.
1062
+		// 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.
1063
+		if ($this->_is_UI_request === false
1064
+			&& is_array($this->_route)
1065
+			&& ! empty($this->_route['headers_sent_route'])
1066
+		) {
1067
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1068
+		}
1069
+	}
1070
+
1071
+
1072
+	/**
1073
+	 * This method just allows the resetting of page properties in the case where a no headers
1074
+	 * route redirects to a headers route in its route config.
1075
+	 *
1076
+	 * @param string $new_route New (non header) route to redirect to.
1077
+	 * @return   void
1078
+	 * @throws ReflectionException
1079
+	 * @throws InvalidArgumentException
1080
+	 * @throws InvalidInterfaceException
1081
+	 * @throws InvalidDataTypeException
1082
+	 * @throws EE_Error
1083
+	 * @since   4.3.0
1084
+	 */
1085
+	protected function _reset_routing_properties($new_route)
1086
+	{
1087
+		$this->_is_UI_request = true;
1088
+		// now we set the current route to whatever the headers_sent_route is set at
1089
+		$this->request->setRequestParam('action', $new_route);
1090
+		// rerun page setup
1091
+		$this->_page_setup();
1092
+	}
1093
+
1094
+
1095
+	/**
1096
+	 * _add_query_arg
1097
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1098
+	 *(internally just uses EEH_URL's function with the same name)
1099
+	 *
1100
+	 * @param array  $args
1101
+	 * @param string $url
1102
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1103
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1104
+	 *                                        Example usage: If the current page is:
1105
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1106
+	 *                                        &action=default&event_id=20&month_range=March%202015
1107
+	 *                                        &_wpnonce=5467821
1108
+	 *                                        and you call:
1109
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1110
+	 *                                        array(
1111
+	 *                                        'action' => 'resend_something',
1112
+	 *                                        'page=>espresso_registrations'
1113
+	 *                                        ),
1114
+	 *                                        $some_url,
1115
+	 *                                        true
1116
+	 *                                        );
1117
+	 *                                        It will produce a url in this structure:
1118
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1119
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1120
+	 *                                        month_range]=March%202015
1121
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1122
+	 * @return string
1123
+	 */
1124
+	public static function add_query_args_and_nonce(
1125
+		$args = [],
1126
+		$url = false,
1127
+		$sticky = false,
1128
+		$exclude_nonce = false
1129
+	) {
1130
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1131
+		if ($sticky) {
1132
+			/** @var RequestInterface $request */
1133
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1134
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1135
+			foreach ($request->requestParams() as $key => $value) {
1136
+				// do not add nonces
1137
+				if (strpos($key, 'nonce') !== false) {
1138
+					continue;
1139
+				}
1140
+				$args[ 'wp_referer[' . $key . ']' ] = $value;
1141
+			}
1142
+		}
1143
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1144
+	}
1145
+
1146
+
1147
+	/**
1148
+	 * This returns a generated link that will load the related help tab.
1149
+	 *
1150
+	 * @param string $help_tab_id the id for the connected help tab
1151
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1152
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1153
+	 * @return string              generated link
1154
+	 * @uses EEH_Template::get_help_tab_link()
1155
+	 */
1156
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1157
+	{
1158
+		return EEH_Template::get_help_tab_link(
1159
+			$help_tab_id,
1160
+			$this->page_slug,
1161
+			$this->_req_action,
1162
+			$icon_style,
1163
+			$help_text
1164
+		);
1165
+	}
1166
+
1167
+
1168
+	/**
1169
+	 * _add_help_tabs
1170
+	 * Note child classes define their help tabs within the page_config array.
1171
+	 *
1172
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1173
+	 * @return void
1174
+	 * @throws DomainException
1175
+	 * @throws EE_Error
1176
+	 */
1177
+	protected function _add_help_tabs()
1178
+	{
1179
+		$tour_buttons = '';
1180
+		if (isset($this->_page_config[ $this->_req_action ])) {
1181
+			$config = $this->_page_config[ $this->_req_action ];
1182
+			// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1183
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1184
+			// if (isset($this->_help_tour[ $this->_req_action ])) {
1185
+			//     $tb = array();
1186
+			//     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1187
+			//     foreach ($this->_help_tour['tours'] as $tour) {
1188
+			//         // if this is the end tour then we don't need to setup a button
1189
+			//         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1190
+			//             continue;
1191
+			//         }
1192
+			//         $tb[] = '<button id="trigger-tour-'
1193
+			//                 . $tour->get_slug()
1194
+			//                 . '" class="button-primary trigger-ee-help-tour">'
1195
+			//                 . $tour->get_label()
1196
+			//                 . '</button>';
1197
+			//     }
1198
+			//     $tour_buttons .= implode('<br />', $tb);
1199
+			//     $tour_buttons .= '</div></div>';
1200
+			// }
1201
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1202
+			if (is_array($config) && isset($config['help_sidebar'])) {
1203
+				// check that the callback given is valid
1204
+				if (! method_exists($this, $config['help_sidebar'])) {
1205
+					throw new EE_Error(
1206
+						sprintf(
1207
+							esc_html__(
1208
+								'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',
1209
+								'event_espresso'
1210
+							),
1211
+							$config['help_sidebar'],
1212
+							get_class($this)
1213
+						)
1214
+					);
1215
+				}
1216
+				$content = apply_filters(
1217
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1218
+					$this->{$config['help_sidebar']}()
1219
+				);
1220
+				$content .= $tour_buttons; // add help tour buttons.
1221
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1222
+				$this->_current_screen->set_help_sidebar($content);
1223
+			}
1224
+			// if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1225
+			if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1226
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1227
+			}
1228
+			// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1229
+			if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1230
+				$_ht['id']      = $this->page_slug;
1231
+				$_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1232
+				$_ht['content'] = '<p>'
1233
+								  . esc_html__(
1234
+									  'The buttons to the right allow you to start/restart any help tours available for this page',
1235
+									  'event_espresso'
1236
+								  ) . '</p>';
1237
+				$this->_current_screen->add_help_tab($_ht);
1238
+			}
1239
+			if (! isset($config['help_tabs'])) {
1240
+				return;
1241
+			} //no help tabs for this route
1242
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1243
+				// we're here so there ARE help tabs!
1244
+				// make sure we've got what we need
1245
+				if (! isset($cfg['title'])) {
1246
+					throw new EE_Error(
1247
+						esc_html__(
1248
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1249
+							'event_espresso'
1250
+						)
1251
+					);
1252
+				}
1253
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1254
+					throw new EE_Error(
1255
+						esc_html__(
1256
+							'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',
1257
+							'event_espresso'
1258
+						)
1259
+					);
1260
+				}
1261
+				// first priority goes to content.
1262
+				if (! empty($cfg['content'])) {
1263
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1264
+					// second priority goes to filename
1265
+				} elseif (! empty($cfg['filename'])) {
1266
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1267
+					// 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)
1268
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1269
+															 . basename($this->_get_dir())
1270
+															 . '/help_tabs/'
1271
+															 . $cfg['filename']
1272
+															 . '.help_tab.php' : $file_path;
1273
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1274
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1275
+						EE_Error::add_error(
1276
+							sprintf(
1277
+								esc_html__(
1278
+									'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',
1279
+									'event_espresso'
1280
+								),
1281
+								$tab_id,
1282
+								key($config),
1283
+								$file_path
1284
+							),
1285
+							__FILE__,
1286
+							__FUNCTION__,
1287
+							__LINE__
1288
+						);
1289
+						return;
1290
+					}
1291
+					$template_args['admin_page_obj'] = $this;
1292
+					$content                         = EEH_Template::display_template(
1293
+						$file_path,
1294
+						$template_args,
1295
+						true
1296
+					);
1297
+				} else {
1298
+					$content = '';
1299
+				}
1300
+				// check if callback is valid
1301
+				if (empty($content)
1302
+					&& (
1303
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1304
+					)
1305
+				) {
1306
+					EE_Error::add_error(
1307
+						sprintf(
1308
+							esc_html__(
1309
+								'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.',
1310
+								'event_espresso'
1311
+							),
1312
+							$cfg['title']
1313
+						),
1314
+						__FILE__,
1315
+						__FUNCTION__,
1316
+						__LINE__
1317
+					);
1318
+					return;
1319
+				}
1320
+				// setup config array for help tab method
1321
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1322
+				$_ht = [
1323
+					'id'       => $id,
1324
+					'title'    => $cfg['title'],
1325
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1326
+					'content'  => $content,
1327
+				];
1328
+				$this->_current_screen->add_help_tab($_ht);
1329
+			}
1330
+		}
1331
+	}
1332
+
1333
+
1334
+	/**
1335
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1336
+	 * an array with properties for setting up usage of the joyride plugin
1337
+	 *
1338
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1339
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1340
+	 *         _set_page_config() comments
1341
+	 * @return void
1342
+	 * @throws InvalidArgumentException
1343
+	 * @throws InvalidDataTypeException
1344
+	 * @throws InvalidInterfaceException
1345
+	 */
1346
+	protected function _add_help_tour()
1347
+	{
1348
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1349
+		// $tours = array();
1350
+		// $this->_help_tour = array();
1351
+		// // exit early if help tours are turned off globally
1352
+		// if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1353
+		//     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1354
+		// ) {
1355
+		//     return;
1356
+		// }
1357
+		// // loop through _page_config to find any help_tour defined
1358
+		// foreach ($this->_page_config as $route => $config) {
1359
+		//     // we're only going to set things up for this route
1360
+		//     if ($route !== $this->_req_action) {
1361
+		//         continue;
1362
+		//     }
1363
+		//     if (isset($config['help_tour'])) {
1364
+		//         foreach ($config['help_tour'] as $tour) {
1365
+		//             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1366
+		//             // let's see if we can get that file...
1367
+		//             // if not its possible this is a decaf route not set in caffeinated
1368
+		//             // so lets try and get the caffeinated equivalent
1369
+		//             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1370
+		//                                                      . basename($this->_get_dir())
1371
+		//                                                      . '/help_tours/'
1372
+		//                                                      . $tour
1373
+		//                                                      . '.class.php' : $file_path;
1374
+		//             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1375
+		//             if (! is_readable($file_path)) {
1376
+		//                 EE_Error::add_error(
1377
+		//                     sprintf(
1378
+		//                         esc_html__(
1379
+		//                             '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',
1380
+		//                             'event_espresso'
1381
+		//                         ),
1382
+		//                         $file_path,
1383
+		//                         $tour
1384
+		//                     ),
1385
+		//                     __FILE__,
1386
+		//                     __FUNCTION__,
1387
+		//                     __LINE__
1388
+		//                 );
1389
+		//                 return;
1390
+		//             }
1391
+		//             require_once $file_path;
1392
+		//             if (! class_exists($tour)) {
1393
+		//                 $error_msg[] = sprintf(
1394
+		//                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1395
+		//                     $tour
1396
+		//                 );
1397
+		//                 $error_msg[] = $error_msg[0] . "\r\n"
1398
+		//                                . sprintf(
1399
+		//                                    esc_html__(
1400
+		//                                        '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.',
1401
+		//                                        'event_espresso'
1402
+		//                                    ),
1403
+		//                                    $tour,
1404
+		//                                    '<br />',
1405
+		//                                    $tour,
1406
+		//                                    $this->_req_action,
1407
+		//                                    get_class($this)
1408
+		//                                );
1409
+		//                 throw new EE_Error(implode('||', $error_msg));
1410
+		//             }
1411
+		//             $tour_obj = new $tour($this->_is_caf);
1412
+		//             $tours[] = $tour_obj;
1413
+		//             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1414
+		//         }
1415
+		//         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1416
+		//         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1417
+		//         $tours[] = $end_stop_tour;
1418
+		//         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1419
+		//     }
1420
+		// }
1421
+		//
1422
+		// if (! empty($tours)) {
1423
+		//     $this->_help_tour['tours'] = $tours;
1424
+		// }
1425
+		// // that's it!  Now that the $_help_tours property is set (or not)
1426
+		// // the scripts and html should be taken care of automatically.
1427
+		//
1428
+		// /**
1429
+		//  * Allow extending the help tours variable.
1430
+		//  *
1431
+		//  * @param Array $_help_tour The array containing all help tour information to be displayed.
1432
+		//  */
1433
+		// $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1434
+	}
1435
+
1436
+
1437
+	/**
1438
+	 * This simply sets up any qtips that have been defined in the page config
1439
+	 *
1440
+	 * @return void
1441
+	 */
1442
+	protected function _add_qtips()
1443
+	{
1444
+		if (isset($this->_route_config['qtips'])) {
1445
+			$qtips = (array) $this->_route_config['qtips'];
1446
+			// load qtip loader
1447
+			$path = [
1448
+				$this->_get_dir() . '/qtips/',
1449
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1450
+			];
1451
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1452
+		}
1453
+	}
1454
+
1455
+
1456
+	/**
1457
+	 * _set_nav_tabs
1458
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1459
+	 * wish to add additional tabs or modify accordingly.
1460
+	 *
1461
+	 * @return void
1462
+	 * @throws InvalidArgumentException
1463
+	 * @throws InvalidInterfaceException
1464
+	 * @throws InvalidDataTypeException
1465
+	 */
1466
+	protected function _set_nav_tabs()
1467
+	{
1468
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1469
+		$i = 0;
1470
+		foreach ($this->_page_config as $slug => $config) {
1471
+			if (! is_array($config) || empty($config['nav'])) {
1472
+				continue;
1473
+			}
1474
+			// no nav tab for this config
1475
+			// check for persistent flag
1476
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1477
+				// nav tab is only to appear when route requested.
1478
+				continue;
1479
+			}
1480
+			if (! $this->check_user_access($slug, true)) {
1481
+				// no nav tab because current user does not have access.
1482
+				continue;
1483
+			}
1484
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1485
+			$this->_nav_tabs[ $slug ] = [
1486
+				'url'       => isset($config['nav']['url'])
1487
+					? $config['nav']['url']
1488
+					: self::add_query_args_and_nonce(
1489
+						['action' => $slug],
1490
+						$this->_admin_base_url
1491
+					),
1492
+				'link_text' => isset($config['nav']['label'])
1493
+					? $config['nav']['label']
1494
+					: ucwords(
1495
+						str_replace('_', ' ', $slug)
1496
+					),
1497
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1498
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1499
+			];
1500
+			$i++;
1501
+		}
1502
+		// if $this->_nav_tabs is empty then lets set the default
1503
+		if (empty($this->_nav_tabs)) {
1504
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1505
+				'url'       => $this->_admin_base_url,
1506
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1507
+				'css_class' => 'nav-tab-active',
1508
+				'order'     => 10,
1509
+			];
1510
+		}
1511
+		// now let's sort the tabs according to order
1512
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1513
+	}
1514
+
1515
+
1516
+	/**
1517
+	 * _set_current_labels
1518
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1519
+	 * property array
1520
+	 *
1521
+	 * @return void
1522
+	 */
1523
+	private function _set_current_labels()
1524
+	{
1525
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1526
+			foreach ($this->_route_config['labels'] as $label => $text) {
1527
+				if (is_array($text)) {
1528
+					foreach ($text as $sublabel => $subtext) {
1529
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1530
+					}
1531
+				} else {
1532
+					$this->_labels[ $label ] = $text;
1533
+				}
1534
+			}
1535
+		}
1536
+	}
1537
+
1538
+
1539
+	/**
1540
+	 *        verifies user access for this admin page
1541
+	 *
1542
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1543
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1544
+	 *                               return false if verify fail.
1545
+	 * @return bool
1546
+	 * @throws InvalidArgumentException
1547
+	 * @throws InvalidDataTypeException
1548
+	 * @throws InvalidInterfaceException
1549
+	 */
1550
+	public function check_user_access($route_to_check = '', $verify_only = false)
1551
+	{
1552
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1553
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1554
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1555
+						  && is_array(
1556
+							  $this->_page_routes[ $route_to_check ]
1557
+						  )
1558
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1559
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1560
+		if (empty($capability) && empty($route_to_check)) {
1561
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1562
+				: $this->_route['capability'];
1563
+		} else {
1564
+			$capability = empty($capability) ? 'manage_options' : $capability;
1565
+		}
1566
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1567
+		if (! defined('DOING_AJAX')
1568
+			&& (
1569
+				! function_exists('is_admin')
1570
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1571
+					$capability,
1572
+					$this->page_slug
1573
+					. '_'
1574
+					. $route_to_check,
1575
+					$id
1576
+				)
1577
+			)
1578
+		) {
1579
+			if ($verify_only) {
1580
+				return false;
1581
+			}
1582
+			if (is_user_logged_in()) {
1583
+				wp_die(__('You do not have access to this route.', 'event_espresso'));
1584
+			} else {
1585
+				return false;
1586
+			}
1587
+		}
1588
+		return true;
1589
+	}
1590
+
1591
+
1592
+	/**
1593
+	 * admin_init_global
1594
+	 * This runs all the code that we want executed within the WP admin_init hook.
1595
+	 * This method executes for ALL EE Admin pages.
1596
+	 *
1597
+	 * @return void
1598
+	 */
1599
+	public function admin_init_global()
1600
+	{
1601
+	}
1602
+
1603
+
1604
+	/**
1605
+	 * wp_loaded_global
1606
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1607
+	 * EE_Admin page and will execute on every EE Admin Page load
1608
+	 *
1609
+	 * @return void
1610
+	 */
1611
+	public function wp_loaded()
1612
+	{
1613
+	}
1614
+
1615
+
1616
+	/**
1617
+	 * admin_notices
1618
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1619
+	 * ALL EE_Admin pages.
1620
+	 *
1621
+	 * @return void
1622
+	 */
1623
+	public function admin_notices_global()
1624
+	{
1625
+		$this->_display_no_javascript_warning();
1626
+		$this->_display_espresso_notices();
1627
+	}
1628
+
1629
+
1630
+	public function network_admin_notices_global()
1631
+	{
1632
+		$this->_display_no_javascript_warning();
1633
+		$this->_display_espresso_notices();
1634
+	}
1635
+
1636
+
1637
+	/**
1638
+	 * admin_footer_scripts_global
1639
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1640
+	 * will apply on ALL EE_Admin pages.
1641
+	 *
1642
+	 * @return void
1643
+	 */
1644
+	public function admin_footer_scripts_global()
1645
+	{
1646
+		$this->_add_admin_page_ajax_loading_img();
1647
+		$this->_add_admin_page_overlay();
1648
+		// if metaboxes are present we need to add the nonce field
1649
+		if (isset($this->_route_config['metaboxes'])
1650
+			|| isset($this->_route_config['list_table'])
1651
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1652
+		) {
1653
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1654
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1655
+		}
1656
+	}
1657
+
1658
+
1659
+	/**
1660
+	 * admin_footer_global
1661
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1662
+	 * ALL EE_Admin Pages.
1663
+	 *
1664
+	 * @return void
1665
+	 */
1666
+	public function admin_footer_global()
1667
+	{
1668
+		// dialog container for dialog helper
1669
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1670
+		$d_cont .= '<div class="ee-notices"></div>';
1671
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1672
+		$d_cont .= '</div>';
1673
+		echo $d_cont;
1674
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1675
+		// help tour stuff?
1676
+		// if (isset($this->_help_tour[ $this->_req_action ])) {
1677
+		//     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1678
+		// }
1679
+		// current set timezone for timezone js
1680
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1681
+	}
1682
+
1683
+
1684
+	/**
1685
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1686
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1687
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1688
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1689
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1690
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1691
+	 * for the
1692
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1693
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1694
+	 *    'help_trigger_id' => array(
1695
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1696
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1697
+	 *    )
1698
+	 * );
1699
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1700
+	 *
1701
+	 * @param array $help_array
1702
+	 * @param bool  $display
1703
+	 * @return string content
1704
+	 * @throws DomainException
1705
+	 * @throws EE_Error
1706
+	 */
1707
+	protected function _set_help_popup_content($help_array = [], $display = false)
1708
+	{
1709
+		$content    = '';
1710
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1711
+		// loop through the array and setup content
1712
+		foreach ($help_array as $trigger => $help) {
1713
+			// make sure the array is setup properly
1714
+			if (! isset($help['title']) || ! isset($help['content'])) {
1715
+				throw new EE_Error(
1716
+					esc_html__(
1717
+						'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',
1718
+						'event_espresso'
1719
+					)
1720
+				);
1721
+			}
1722
+			// we're good so let'd setup the template vars and then assign parsed template content to our content.
1723
+			$template_args = [
1724
+				'help_popup_id'      => $trigger,
1725
+				'help_popup_title'   => $help['title'],
1726
+				'help_popup_content' => $help['content'],
1727
+			];
1728
+			$content       .= EEH_Template::display_template(
1729
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1730
+				$template_args,
1731
+				true
1732
+			);
1733
+		}
1734
+		if ($display) {
1735
+			echo $content;
1736
+			return '';
1737
+		}
1738
+		return $content;
1739
+	}
1740
+
1741
+
1742
+	/**
1743
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1744
+	 *
1745
+	 * @return array properly formatted array for help popup content
1746
+	 * @throws EE_Error
1747
+	 */
1748
+	private function _get_help_content()
1749
+	{
1750
+		// what is the method we're looking for?
1751
+		$method_name = '_help_popup_content_' . $this->_req_action;
1752
+		// if method doesn't exist let's get out.
1753
+		if (! method_exists($this, $method_name)) {
1754
+			return [];
1755
+		}
1756
+		// k we're good to go let's retrieve the help array
1757
+		$help_array = call_user_func([$this, $method_name]);
1758
+		// make sure we've got an array!
1759
+		if (! is_array($help_array)) {
1760
+			throw new EE_Error(
1761
+				esc_html__(
1762
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1763
+					'event_espresso'
1764
+				)
1765
+			);
1766
+		}
1767
+		return $help_array;
1768
+	}
1769
+
1770
+
1771
+	/**
1772
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1773
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1774
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1775
+	 *
1776
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1777
+	 * @param boolean $display    if false then we return the trigger string
1778
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1779
+	 * @return string
1780
+	 * @throws DomainException
1781
+	 * @throws EE_Error
1782
+	 */
1783
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1784
+	{
1785
+		if (defined('DOING_AJAX')) {
1786
+			return '';
1787
+		}
1788
+		// 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
1789
+		$help_array   = $this->_get_help_content();
1790
+		$help_content = '';
1791
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1792
+			$help_array[ $trigger_id ] = [
1793
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1794
+				'content' => esc_html__(
1795
+					'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.)',
1796
+					'event_espresso'
1797
+				),
1798
+			];
1799
+			$help_content              = $this->_set_help_popup_content($help_array, false);
1800
+		}
1801
+		// let's setup the trigger
1802
+		$content = '<a class="ee-dialog" href="?height='
1803
+				   . $dimensions[0]
1804
+				   . '&width='
1805
+				   . $dimensions[1]
1806
+				   . '&inlineId='
1807
+				   . $trigger_id
1808
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1809
+		$content .= $help_content;
1810
+		if ($display) {
1811
+			echo $content;
1812
+			return '';
1813
+		}
1814
+		return $content;
1815
+	}
1816
+
1817
+
1818
+	/**
1819
+	 * _add_global_screen_options
1820
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1821
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1822
+	 *
1823
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1824
+	 *         see also WP_Screen object documents...
1825
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1826
+	 * @abstract
1827
+	 * @return void
1828
+	 */
1829
+	private function _add_global_screen_options()
1830
+	{
1831
+	}
1832
+
1833
+
1834
+	/**
1835
+	 * _add_global_feature_pointers
1836
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1837
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1838
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1839
+	 *
1840
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1841
+	 *         extended) also see:
1842
+	 * @link   http://eamann.com/tech/wordpress-portland/
1843
+	 * @abstract
1844
+	 * @return void
1845
+	 */
1846
+	private function _add_global_feature_pointers()
1847
+	{
1848
+	}
1849
+
1850
+
1851
+	/**
1852
+	 * load_global_scripts_styles
1853
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1854
+	 *
1855
+	 * @return void
1856
+	 */
1857
+	public function load_global_scripts_styles()
1858
+	{
1859
+		/** STYLES **/
1860
+		// add debugging styles
1861
+		if (WP_DEBUG) {
1862
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1863
+		}
1864
+		// register all styles
1865
+		wp_register_style(
1866
+			'espresso-ui-theme',
1867
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1868
+			[],
1869
+			EVENT_ESPRESSO_VERSION
1870
+		);
1871
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1872
+		// helpers styles
1873
+		wp_register_style(
1874
+			'ee-text-links',
1875
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1876
+			[],
1877
+			EVENT_ESPRESSO_VERSION
1878
+		);
1879
+		/** SCRIPTS **/
1880
+		// register all scripts
1881
+		wp_register_script(
1882
+			'ee-dialog',
1883
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1884
+			['jquery', 'jquery-ui-draggable'],
1885
+			EVENT_ESPRESSO_VERSION,
1886
+			true
1887
+		);
1888
+		wp_register_script(
1889
+			'ee_admin_js',
1890
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1891
+			['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1892
+			EVENT_ESPRESSO_VERSION,
1893
+			true
1894
+		);
1895
+		wp_register_script(
1896
+			'jquery-ui-timepicker-addon',
1897
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1898
+			['jquery-ui-datepicker', 'jquery-ui-slider'],
1899
+			EVENT_ESPRESSO_VERSION,
1900
+			true
1901
+		);
1902
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1903
+		// if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1904
+		//     add_filter('FHEE_load_joyride', '__return_true');
1905
+		// }
1906
+		// script for sorting tables
1907
+		wp_register_script(
1908
+			'espresso_ajax_table_sorting',
1909
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1910
+			['ee_admin_js', 'jquery-ui-sortable'],
1911
+			EVENT_ESPRESSO_VERSION,
1912
+			true
1913
+		);
1914
+		// script for parsing uri's
1915
+		wp_register_script(
1916
+			'ee-parse-uri',
1917
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1918
+			[],
1919
+			EVENT_ESPRESSO_VERSION,
1920
+			true
1921
+		);
1922
+		// and parsing associative serialized form elements
1923
+		wp_register_script(
1924
+			'ee-serialize-full-array',
1925
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1926
+			['jquery'],
1927
+			EVENT_ESPRESSO_VERSION,
1928
+			true
1929
+		);
1930
+		// helpers scripts
1931
+		wp_register_script(
1932
+			'ee-text-links',
1933
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1934
+			['jquery'],
1935
+			EVENT_ESPRESSO_VERSION,
1936
+			true
1937
+		);
1938
+		wp_register_script(
1939
+			'ee-moment-core',
1940
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1941
+			[],
1942
+			EVENT_ESPRESSO_VERSION,
1943
+			true
1944
+		);
1945
+		wp_register_script(
1946
+			'ee-moment',
1947
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1948
+			['ee-moment-core'],
1949
+			EVENT_ESPRESSO_VERSION,
1950
+			true
1951
+		);
1952
+		wp_register_script(
1953
+			'ee-datepicker',
1954
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1955
+			['jquery-ui-timepicker-addon', 'ee-moment'],
1956
+			EVENT_ESPRESSO_VERSION,
1957
+			true
1958
+		);
1959
+		// google charts
1960
+		wp_register_script(
1961
+			'google-charts',
1962
+			'https://www.gstatic.com/charts/loader.js',
1963
+			[],
1964
+			EVENT_ESPRESSO_VERSION,
1965
+			false
1966
+		);
1967
+		// ENQUEUE ALL BASICS BY DEFAULT
1968
+		wp_enqueue_style('ee-admin-css');
1969
+		wp_enqueue_script('ee_admin_js');
1970
+		wp_enqueue_script('ee-accounting');
1971
+		wp_enqueue_script('jquery-validate');
1972
+		// taking care of metaboxes
1973
+		if (empty($this->_cpt_route)
1974
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1975
+		) {
1976
+			wp_enqueue_script('dashboard');
1977
+		}
1978
+		// LOCALIZED DATA
1979
+		// localize script for ajax lazy loading
1980
+		$lazy_loader_container_ids = apply_filters(
1981
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1982
+			['espresso_news_post_box_content']
1983
+		);
1984
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1985
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1986
+		// /**
1987
+		//  * help tour stuff
1988
+		//  */
1989
+		// if (! empty($this->_help_tour)) {
1990
+		//     // register the js for kicking things off
1991
+		//     wp_enqueue_script(
1992
+		//         'ee-help-tour',
1993
+		//         EE_ADMIN_URL . 'assets/ee-help-tour.js',
1994
+		//         array('jquery-joyride'),
1995
+		//         EVENT_ESPRESSO_VERSION,
1996
+		//         true
1997
+		//     );
1998
+		//     $tours = array();
1999
+		//     // setup tours for the js tour object
2000
+		//     foreach ($this->_help_tour['tours'] as $tour) {
2001
+		//         if ($tour instanceof EE_Help_Tour) {
2002
+		//             $tours[] = array(
2003
+		//                 'id'      => $tour->get_slug(),
2004
+		//                 'options' => $tour->get_options(),
2005
+		//             );
2006
+		//         }
2007
+		//     }
2008
+		//     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2009
+		//     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2010
+		// }
2011
+	}
2012
+
2013
+
2014
+	/**
2015
+	 *        admin_footer_scripts_eei18n_js_strings
2016
+	 *
2017
+	 * @return        void
2018
+	 */
2019
+	public function admin_footer_scripts_eei18n_js_strings()
2020
+	{
2021
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2022
+		EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2023
+			'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!!!',
2024
+			'event_espresso'
2025
+		);
2026
+		EE_Registry::$i18n_js_strings['January']        = esc_html__('January', 'event_espresso');
2027
+		EE_Registry::$i18n_js_strings['February']       = esc_html__('February', 'event_espresso');
2028
+		EE_Registry::$i18n_js_strings['March']          = esc_html__('March', 'event_espresso');
2029
+		EE_Registry::$i18n_js_strings['April']          = esc_html__('April', 'event_espresso');
2030
+		EE_Registry::$i18n_js_strings['May']            = esc_html__('May', 'event_espresso');
2031
+		EE_Registry::$i18n_js_strings['June']           = esc_html__('June', 'event_espresso');
2032
+		EE_Registry::$i18n_js_strings['July']           = esc_html__('July', 'event_espresso');
2033
+		EE_Registry::$i18n_js_strings['August']         = esc_html__('August', 'event_espresso');
2034
+		EE_Registry::$i18n_js_strings['September']      = esc_html__('September', 'event_espresso');
2035
+		EE_Registry::$i18n_js_strings['October']        = esc_html__('October', 'event_espresso');
2036
+		EE_Registry::$i18n_js_strings['November']       = esc_html__('November', 'event_espresso');
2037
+		EE_Registry::$i18n_js_strings['December']       = esc_html__('December', 'event_espresso');
2038
+		EE_Registry::$i18n_js_strings['Jan']            = esc_html__('Jan', 'event_espresso');
2039
+		EE_Registry::$i18n_js_strings['Feb']            = esc_html__('Feb', 'event_espresso');
2040
+		EE_Registry::$i18n_js_strings['Mar']            = esc_html__('Mar', 'event_espresso');
2041
+		EE_Registry::$i18n_js_strings['Apr']            = esc_html__('Apr', 'event_espresso');
2042
+		EE_Registry::$i18n_js_strings['May']            = esc_html__('May', 'event_espresso');
2043
+		EE_Registry::$i18n_js_strings['Jun']            = esc_html__('Jun', 'event_espresso');
2044
+		EE_Registry::$i18n_js_strings['Jul']            = esc_html__('Jul', 'event_espresso');
2045
+		EE_Registry::$i18n_js_strings['Aug']            = esc_html__('Aug', 'event_espresso');
2046
+		EE_Registry::$i18n_js_strings['Sep']            = esc_html__('Sep', 'event_espresso');
2047
+		EE_Registry::$i18n_js_strings['Oct']            = esc_html__('Oct', 'event_espresso');
2048
+		EE_Registry::$i18n_js_strings['Nov']            = esc_html__('Nov', 'event_espresso');
2049
+		EE_Registry::$i18n_js_strings['Dec']            = esc_html__('Dec', 'event_espresso');
2050
+		EE_Registry::$i18n_js_strings['Sunday']         = esc_html__('Sunday', 'event_espresso');
2051
+		EE_Registry::$i18n_js_strings['Monday']         = esc_html__('Monday', 'event_espresso');
2052
+		EE_Registry::$i18n_js_strings['Tuesday']        = esc_html__('Tuesday', 'event_espresso');
2053
+		EE_Registry::$i18n_js_strings['Wednesday']      = esc_html__('Wednesday', 'event_espresso');
2054
+		EE_Registry::$i18n_js_strings['Thursday']       = esc_html__('Thursday', 'event_espresso');
2055
+		EE_Registry::$i18n_js_strings['Friday']         = esc_html__('Friday', 'event_espresso');
2056
+		EE_Registry::$i18n_js_strings['Saturday']       = esc_html__('Saturday', 'event_espresso');
2057
+		EE_Registry::$i18n_js_strings['Sun']            = esc_html__('Sun', 'event_espresso');
2058
+		EE_Registry::$i18n_js_strings['Mon']            = esc_html__('Mon', 'event_espresso');
2059
+		EE_Registry::$i18n_js_strings['Tue']            = esc_html__('Tue', 'event_espresso');
2060
+		EE_Registry::$i18n_js_strings['Wed']            = esc_html__('Wed', 'event_espresso');
2061
+		EE_Registry::$i18n_js_strings['Thu']            = esc_html__('Thu', 'event_espresso');
2062
+		EE_Registry::$i18n_js_strings['Fri']            = esc_html__('Fri', 'event_espresso');
2063
+		EE_Registry::$i18n_js_strings['Sat']            = esc_html__('Sat', 'event_espresso');
2064
+	}
2065
+
2066
+
2067
+	/**
2068
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2069
+	 *
2070
+	 * @return        void
2071
+	 */
2072
+	public function add_xdebug_style()
2073
+	{
2074
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2075
+	}
2076
+
2077
+
2078
+	/************************/
2079
+	/** LIST TABLE METHODS **/
2080
+	/************************/
2081
+	/**
2082
+	 * this sets up the list table if the current view requires it.
2083
+	 *
2084
+	 * @return void
2085
+	 * @throws EE_Error
2086
+	 */
2087
+	protected function _set_list_table()
2088
+	{
2089
+		// first is this a list_table view?
2090
+		if (! isset($this->_route_config['list_table'])) {
2091
+			return;
2092
+		} //not a list_table view so get out.
2093
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2094
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2095
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2096
+			// user error msg
2097
+			$error_msg = esc_html__(
2098
+				'An error occurred. The requested list table views could not be found.',
2099
+				'event_espresso'
2100
+			);
2101
+			// developer error msg
2102
+			$error_msg .= '||'
2103
+						  . sprintf(
2104
+							  esc_html__(
2105
+								  '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.',
2106
+								  'event_espresso'
2107
+							  ),
2108
+							  $this->_req_action,
2109
+							  $list_table_view
2110
+						  );
2111
+			throw new EE_Error($error_msg);
2112
+		}
2113
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2114
+		$this->_views = apply_filters(
2115
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2116
+			$this->_views
2117
+		);
2118
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2119
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2120
+		$this->_set_list_table_view();
2121
+		$this->_set_list_table_object();
2122
+	}
2123
+
2124
+
2125
+	/**
2126
+	 * set current view for List Table
2127
+	 *
2128
+	 * @return void
2129
+	 */
2130
+	protected function _set_list_table_view()
2131
+	{
2132
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2133
+		$status = $this->request->getRequestParam('status', null, 'key');
2134
+		$this->_view = $status && array_key_exists($status, $this->_views)
2135
+			? $status
2136
+			: $this->_view;
2137
+	}
2138
+
2139
+
2140
+	/**
2141
+	 * _set_list_table_object
2142
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2143
+	 *
2144
+	 * @throws InvalidInterfaceException
2145
+	 * @throws InvalidArgumentException
2146
+	 * @throws InvalidDataTypeException
2147
+	 * @throws EE_Error
2148
+	 * @throws InvalidInterfaceException
2149
+	 */
2150
+	protected function _set_list_table_object()
2151
+	{
2152
+		if (isset($this->_route_config['list_table'])) {
2153
+			if (! class_exists($this->_route_config['list_table'])) {
2154
+				throw new EE_Error(
2155
+					sprintf(
2156
+						esc_html__(
2157
+							'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.',
2158
+							'event_espresso'
2159
+						),
2160
+						$this->_route_config['list_table'],
2161
+						get_class($this)
2162
+					)
2163
+				);
2164
+			}
2165
+			$this->_list_table_object = $this->loader->getShared(
2166
+				$this->_route_config['list_table'],
2167
+				[$this]
2168
+			);
2169
+		}
2170
+	}
2171
+
2172
+
2173
+	/**
2174
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2175
+	 *
2176
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2177
+	 *                                                    urls.  The array should be indexed by the view it is being
2178
+	 *                                                    added to.
2179
+	 * @return array
2180
+	 */
2181
+	public function get_list_table_view_RLs($extra_query_args = [])
2182
+	{
2183
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2184
+		if (empty($this->_views)) {
2185
+			$this->_views = [];
2186
+		}
2187
+		// cycle thru views
2188
+		foreach ($this->_views as $key => $view) {
2189
+			$query_args = [];
2190
+			// check for current view
2191
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2192
+			$query_args['action']                        = $this->_req_action;
2193
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2194
+			$query_args['status']                        = $view['slug'];
2195
+			// merge any other arguments sent in.
2196
+			if (isset($extra_query_args[ $view['slug'] ])) {
2197
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2198
+			}
2199
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2200
+		}
2201
+		return $this->_views;
2202
+	}
2203
+
2204
+
2205
+	/**
2206
+	 * _entries_per_page_dropdown
2207
+	 * generates a drop down box for selecting the number of visible rows in an admin page list table
2208
+	 *
2209
+	 * @param int $max_entries total number of rows in the table
2210
+	 * @return string
2211
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2212
+	 *         WP does it.
2213
+	 */
2214
+	protected function _entries_per_page_dropdown($max_entries = 0)
2215
+	{
2216
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2217
+		$values   = [10, 25, 50, 100];
2218
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2219
+		if ($max_entries) {
2220
+			$values[] = $max_entries;
2221
+			sort($values);
2222
+		}
2223
+		$entries_per_page_dropdown = '
2224 2224
 			<div id="entries-per-page-dv" class="alignleft actions">
2225 2225
 				<label class="hide-if-no-js">
2226 2226
 					Show
2227 2227
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2228
-        foreach ($values as $value) {
2229
-            if ($value < $max_entries) {
2230
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2231
-                $entries_per_page_dropdown .= '
2228
+		foreach ($values as $value) {
2229
+			if ($value < $max_entries) {
2230
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2231
+				$entries_per_page_dropdown .= '
2232 2232
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2233
-            }
2234
-        }
2235
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2236
-        $entries_per_page_dropdown .= '
2233
+			}
2234
+		}
2235
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2236
+		$entries_per_page_dropdown .= '
2237 2237
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2238
-        $entries_per_page_dropdown .= '
2238
+		$entries_per_page_dropdown .= '
2239 2239
 					</select>
2240 2240
 					entries
2241 2241
 				</label>
2242 2242
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2243 2243
 			</div>
2244 2244
 		';
2245
-        return $entries_per_page_dropdown;
2246
-    }
2247
-
2248
-
2249
-    /**
2250
-     *        _set_search_attributes
2251
-     *
2252
-     * @return        void
2253
-     */
2254
-    public function _set_search_attributes()
2255
-    {
2256
-        $this->_template_args['search']['btn_label'] = sprintf(
2257
-            esc_html__('Search %s', 'event_espresso'),
2258
-            empty($this->_search_btn_label) ? $this->page_label
2259
-                : $this->_search_btn_label
2260
-        );
2261
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2262
-    }
2263
-
2264
-
2265
-
2266
-    /*** END LIST TABLE METHODS **/
2267
-
2268
-
2269
-    /**
2270
-     * _add_registered_metaboxes
2271
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2272
-     *
2273
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2274
-     * @return void
2275
-     * @throws EE_Error
2276
-     */
2277
-    private function _add_registered_meta_boxes()
2278
-    {
2279
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2280
-        // we only add meta boxes if the page_route calls for it
2281
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2282
-            && is_array(
2283
-                $this->_route_config['metaboxes']
2284
-            )
2285
-        ) {
2286
-            // this simply loops through the callbacks provided
2287
-            // and checks if there is a corresponding callback registered by the child
2288
-            // if there is then we go ahead and process the metabox loader.
2289
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2290
-                // first check for Closures
2291
-                if ($metabox_callback instanceof Closure) {
2292
-                    $result = $metabox_callback();
2293
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2294
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2295
-                } else {
2296
-                    $result = call_user_func([$this, &$metabox_callback]);
2297
-                }
2298
-                if ($result === false) {
2299
-                    // user error msg
2300
-                    $error_msg = esc_html__(
2301
-                        'An error occurred. The  requested metabox could not be found.',
2302
-                        'event_espresso'
2303
-                    );
2304
-                    // developer error msg
2305
-                    $error_msg .= '||'
2306
-                                  . sprintf(
2307
-                                      esc_html__(
2308
-                                          '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.',
2309
-                                          'event_espresso'
2310
-                                      ),
2311
-                                      $metabox_callback
2312
-                                  );
2313
-                    throw new EE_Error($error_msg);
2314
-                }
2315
-            }
2316
-        }
2317
-    }
2318
-
2319
-
2320
-    /**
2321
-     * _add_screen_columns
2322
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2323
-     * the dynamic column template and we'll setup the column options for the page.
2324
-     *
2325
-     * @return void
2326
-     */
2327
-    private function _add_screen_columns()
2328
-    {
2329
-        if (is_array($this->_route_config)
2330
-            && isset($this->_route_config['columns'])
2331
-            && is_array($this->_route_config['columns'])
2332
-            && count($this->_route_config['columns']) === 2
2333
-        ) {
2334
-            add_screen_option(
2335
-                'layout_columns',
2336
-                [
2337
-                    'max'     => (int) $this->_route_config['columns'][0],
2338
-                    'default' => (int) $this->_route_config['columns'][1],
2339
-                ]
2340
-            );
2341
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2342
-            $screen_id                                           = $this->_current_screen->id;
2343
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2344
-            $total_columns                                       = ! empty($screen_columns)
2345
-                ? $screen_columns
2346
-                : $this->_route_config['columns'][1];
2347
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2348
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2349
-            $this->_template_args['screen']                      = $this->_current_screen;
2350
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2351
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2352
-            // finally if we don't have has_metaboxes set in the route config
2353
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2354
-            $this->_route_config['has_metaboxes'] = true;
2355
-        }
2356
-    }
2357
-
2358
-
2359
-
2360
-    /** GLOBALLY AVAILABLE METABOXES **/
2361
-
2362
-
2363
-    /**
2364
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2365
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2366
-     * these get loaded on.
2367
-     */
2368
-    private function _espresso_news_post_box()
2369
-    {
2370
-        $news_box_title = apply_filters(
2371
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2372
-            esc_html__('New @ Event Espresso', 'event_espresso')
2373
-        );
2374
-        add_meta_box(
2375
-            'espresso_news_post_box',
2376
-            $news_box_title,
2377
-            [
2378
-                $this,
2379
-                'espresso_news_post_box',
2380
-            ],
2381
-            $this->_wp_page_slug,
2382
-            'side'
2383
-        );
2384
-    }
2385
-
2386
-
2387
-    /**
2388
-     * Code for setting up espresso ratings request metabox.
2389
-     */
2390
-    protected function _espresso_ratings_request()
2391
-    {
2392
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2393
-            return;
2394
-        }
2395
-        $ratings_box_title = apply_filters(
2396
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2397
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2398
-        );
2399
-        add_meta_box(
2400
-            'espresso_ratings_request',
2401
-            $ratings_box_title,
2402
-            [
2403
-                $this,
2404
-                'espresso_ratings_request',
2405
-            ],
2406
-            $this->_wp_page_slug,
2407
-            'side'
2408
-        );
2409
-    }
2410
-
2411
-
2412
-    /**
2413
-     * Code for setting up espresso ratings request metabox content.
2414
-     *
2415
-     * @throws DomainException
2416
-     */
2417
-    public function espresso_ratings_request()
2418
-    {
2419
-        EEH_Template::display_template(
2420
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2421
-            []
2422
-        );
2423
-    }
2424
-
2425
-
2426
-    public static function cached_rss_display($rss_id, $url)
2427
-    {
2428
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2429
-                     . __('Loading&#8230;', 'event_espresso')
2430
-                     . '</p><p class="hide-if-js">'
2431
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2432
-                     . '</p>';
2433
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2434
-        $pre       .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2435
-        $post      = '</div>' . "\n";
2436
-        $cache_key = 'ee_rss_' . md5($rss_id);
2437
-        $output    = get_transient($cache_key);
2438
-        if ($output !== false) {
2439
-            echo $pre . $output . $post;
2440
-            return true;
2441
-        }
2442
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2443
-            echo $pre . $loading . $post;
2444
-            return false;
2445
-        }
2446
-        ob_start();
2447
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2448
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2449
-        return true;
2450
-    }
2451
-
2452
-
2453
-    public function espresso_news_post_box()
2454
-    {
2455
-        ?>
2245
+		return $entries_per_page_dropdown;
2246
+	}
2247
+
2248
+
2249
+	/**
2250
+	 *        _set_search_attributes
2251
+	 *
2252
+	 * @return        void
2253
+	 */
2254
+	public function _set_search_attributes()
2255
+	{
2256
+		$this->_template_args['search']['btn_label'] = sprintf(
2257
+			esc_html__('Search %s', 'event_espresso'),
2258
+			empty($this->_search_btn_label) ? $this->page_label
2259
+				: $this->_search_btn_label
2260
+		);
2261
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2262
+	}
2263
+
2264
+
2265
+
2266
+	/*** END LIST TABLE METHODS **/
2267
+
2268
+
2269
+	/**
2270
+	 * _add_registered_metaboxes
2271
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2272
+	 *
2273
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2274
+	 * @return void
2275
+	 * @throws EE_Error
2276
+	 */
2277
+	private function _add_registered_meta_boxes()
2278
+	{
2279
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2280
+		// we only add meta boxes if the page_route calls for it
2281
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2282
+			&& is_array(
2283
+				$this->_route_config['metaboxes']
2284
+			)
2285
+		) {
2286
+			// this simply loops through the callbacks provided
2287
+			// and checks if there is a corresponding callback registered by the child
2288
+			// if there is then we go ahead and process the metabox loader.
2289
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2290
+				// first check for Closures
2291
+				if ($metabox_callback instanceof Closure) {
2292
+					$result = $metabox_callback();
2293
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2294
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2295
+				} else {
2296
+					$result = call_user_func([$this, &$metabox_callback]);
2297
+				}
2298
+				if ($result === false) {
2299
+					// user error msg
2300
+					$error_msg = esc_html__(
2301
+						'An error occurred. The  requested metabox could not be found.',
2302
+						'event_espresso'
2303
+					);
2304
+					// developer error msg
2305
+					$error_msg .= '||'
2306
+								  . sprintf(
2307
+									  esc_html__(
2308
+										  '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.',
2309
+										  'event_espresso'
2310
+									  ),
2311
+									  $metabox_callback
2312
+								  );
2313
+					throw new EE_Error($error_msg);
2314
+				}
2315
+			}
2316
+		}
2317
+	}
2318
+
2319
+
2320
+	/**
2321
+	 * _add_screen_columns
2322
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2323
+	 * the dynamic column template and we'll setup the column options for the page.
2324
+	 *
2325
+	 * @return void
2326
+	 */
2327
+	private function _add_screen_columns()
2328
+	{
2329
+		if (is_array($this->_route_config)
2330
+			&& isset($this->_route_config['columns'])
2331
+			&& is_array($this->_route_config['columns'])
2332
+			&& count($this->_route_config['columns']) === 2
2333
+		) {
2334
+			add_screen_option(
2335
+				'layout_columns',
2336
+				[
2337
+					'max'     => (int) $this->_route_config['columns'][0],
2338
+					'default' => (int) $this->_route_config['columns'][1],
2339
+				]
2340
+			);
2341
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2342
+			$screen_id                                           = $this->_current_screen->id;
2343
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2344
+			$total_columns                                       = ! empty($screen_columns)
2345
+				? $screen_columns
2346
+				: $this->_route_config['columns'][1];
2347
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2348
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2349
+			$this->_template_args['screen']                      = $this->_current_screen;
2350
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2351
+																   . 'admin_details_metabox_column_wrapper.template.php';
2352
+			// finally if we don't have has_metaboxes set in the route config
2353
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2354
+			$this->_route_config['has_metaboxes'] = true;
2355
+		}
2356
+	}
2357
+
2358
+
2359
+
2360
+	/** GLOBALLY AVAILABLE METABOXES **/
2361
+
2362
+
2363
+	/**
2364
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2365
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2366
+	 * these get loaded on.
2367
+	 */
2368
+	private function _espresso_news_post_box()
2369
+	{
2370
+		$news_box_title = apply_filters(
2371
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2372
+			esc_html__('New @ Event Espresso', 'event_espresso')
2373
+		);
2374
+		add_meta_box(
2375
+			'espresso_news_post_box',
2376
+			$news_box_title,
2377
+			[
2378
+				$this,
2379
+				'espresso_news_post_box',
2380
+			],
2381
+			$this->_wp_page_slug,
2382
+			'side'
2383
+		);
2384
+	}
2385
+
2386
+
2387
+	/**
2388
+	 * Code for setting up espresso ratings request metabox.
2389
+	 */
2390
+	protected function _espresso_ratings_request()
2391
+	{
2392
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2393
+			return;
2394
+		}
2395
+		$ratings_box_title = apply_filters(
2396
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2397
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2398
+		);
2399
+		add_meta_box(
2400
+			'espresso_ratings_request',
2401
+			$ratings_box_title,
2402
+			[
2403
+				$this,
2404
+				'espresso_ratings_request',
2405
+			],
2406
+			$this->_wp_page_slug,
2407
+			'side'
2408
+		);
2409
+	}
2410
+
2411
+
2412
+	/**
2413
+	 * Code for setting up espresso ratings request metabox content.
2414
+	 *
2415
+	 * @throws DomainException
2416
+	 */
2417
+	public function espresso_ratings_request()
2418
+	{
2419
+		EEH_Template::display_template(
2420
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2421
+			[]
2422
+		);
2423
+	}
2424
+
2425
+
2426
+	public static function cached_rss_display($rss_id, $url)
2427
+	{
2428
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2429
+					 . __('Loading&#8230;', 'event_espresso')
2430
+					 . '</p><p class="hide-if-js">'
2431
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2432
+					 . '</p>';
2433
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2434
+		$pre       .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2435
+		$post      = '</div>' . "\n";
2436
+		$cache_key = 'ee_rss_' . md5($rss_id);
2437
+		$output    = get_transient($cache_key);
2438
+		if ($output !== false) {
2439
+			echo $pre . $output . $post;
2440
+			return true;
2441
+		}
2442
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2443
+			echo $pre . $loading . $post;
2444
+			return false;
2445
+		}
2446
+		ob_start();
2447
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2448
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2449
+		return true;
2450
+	}
2451
+
2452
+
2453
+	public function espresso_news_post_box()
2454
+	{
2455
+		?>
2456 2456
         <div class="padding">
2457 2457
             <div id="espresso_news_post_box_content" class="infolinks">
2458 2458
                 <?php
2459
-                // Get RSS Feed(s)
2460
-                self::cached_rss_display(
2461
-                    'espresso_news_post_box_content',
2462
-                    urlencode(
2463
-                        apply_filters(
2464
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2465
-                            'http://eventespresso.com/feed/'
2466
-                        )
2467
-                    )
2468
-                );
2469
-                ?>
2459
+				// Get RSS Feed(s)
2460
+				self::cached_rss_display(
2461
+					'espresso_news_post_box_content',
2462
+					urlencode(
2463
+						apply_filters(
2464
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2465
+							'http://eventespresso.com/feed/'
2466
+						)
2467
+					)
2468
+				);
2469
+				?>
2470 2470
             </div>
2471 2471
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2472 2472
         </div>
2473 2473
         <?php
2474
-    }
2475
-
2476
-
2477
-    private function _espresso_links_post_box()
2478
-    {
2479
-        // Hiding until we actually have content to put in here...
2480
-        // 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');
2481
-    }
2482
-
2483
-
2484
-    public function espresso_links_post_box()
2485
-    {
2486
-        // Hiding until we actually have content to put in here...
2487
-        // EEH_Template::display_template(
2488
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2489
-        // );
2490
-    }
2491
-
2492
-
2493
-    protected function _espresso_sponsors_post_box()
2494
-    {
2495
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2496
-            add_meta_box(
2497
-                'espresso_sponsors_post_box',
2498
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2499
-                [$this, 'espresso_sponsors_post_box'],
2500
-                $this->_wp_page_slug,
2501
-                'side'
2502
-            );
2503
-        }
2504
-    }
2505
-
2506
-
2507
-    public function espresso_sponsors_post_box()
2508
-    {
2509
-        EEH_Template::display_template(
2510
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2511
-        );
2512
-    }
2513
-
2514
-
2515
-    private function _publish_post_box()
2516
-    {
2517
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2518
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2519
-        // then we'll use that for the metabox label.
2520
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2521
-        if (! empty($this->_labels['publishbox'])) {
2522
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2523
-                : $this->_labels['publishbox'];
2524
-        } else {
2525
-            $box_label = esc_html__('Publish', 'event_espresso');
2526
-        }
2527
-        $box_label = apply_filters(
2528
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2529
-            $box_label,
2530
-            $this->_req_action,
2531
-            $this
2532
-        );
2533
-        add_meta_box(
2534
-            $meta_box_ref,
2535
-            $box_label,
2536
-            [$this, 'editor_overview'],
2537
-            $this->_current_screen->id,
2538
-            'side',
2539
-            'high'
2540
-        );
2541
-    }
2542
-
2543
-
2544
-    public function editor_overview()
2545
-    {
2546
-        // if we have extra content set let's add it in if not make sure its empty
2547
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2548
-            ? $this->_template_args['publish_box_extra_content']
2549
-            : '';
2550
-        echo EEH_Template::display_template(
2551
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2552
-            $this->_template_args,
2553
-            true
2554
-        );
2555
-    }
2556
-
2557
-
2558
-    /** end of globally available metaboxes section **/
2559
-
2560
-
2561
-    /**
2562
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2563
-     * protected method.
2564
-     *
2565
-     * @param string $name
2566
-     * @param int    $id
2567
-     * @param bool   $delete
2568
-     * @param string $save_close_redirect_URL
2569
-     * @param bool   $both_btns
2570
-     * @throws EE_Error
2571
-     * @throws InvalidArgumentException
2572
-     * @throws InvalidDataTypeException
2573
-     * @throws InvalidInterfaceException
2574
-     * @see   $this->_set_publish_post_box_vars for param details
2575
-     * @since 4.6.0
2576
-     */
2577
-    public function set_publish_post_box_vars(
2578
-        $name = '',
2579
-        $id = 0,
2580
-        $delete = false,
2581
-        $save_close_redirect_URL = '',
2582
-        $both_btns = true
2583
-    ) {
2584
-        $this->_set_publish_post_box_vars(
2585
-            $name,
2586
-            $id,
2587
-            $delete,
2588
-            $save_close_redirect_URL,
2589
-            $both_btns
2590
-        );
2591
-    }
2592
-
2593
-
2594
-    /**
2595
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2596
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2597
-     * save, and save and close buttons to work properly, then you will want to include a
2598
-     * values for the name and id arguments.
2599
-     *
2600
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2601
-     * @param int     $id                         id attached to the item published
2602
-     * @param string  $delete                     page route callback for the delete action
2603
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2604
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2605
-     *                                            the Save button
2606
-     * @throws EE_Error
2607
-     * @throws InvalidArgumentException
2608
-     * @throws InvalidDataTypeException
2609
-     * @throws InvalidInterfaceException
2610
-     * @todo  Add in validation for name/id arguments.
2611
-     */
2612
-    protected function _set_publish_post_box_vars(
2613
-        $name = '',
2614
-        $id = 0,
2615
-        $delete = '',
2616
-        $save_close_redirect_URL = '',
2617
-        $both_btns = true
2618
-    ) {
2619
-        // if Save & Close, use a custom redirect URL or default to the main page?
2620
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2621
-            ? $save_close_redirect_URL
2622
-            : $this->_admin_base_url;
2623
-        // create the Save & Close and Save buttons
2624
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2625
-        // if we have extra content set let's add it in if not make sure its empty
2626
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2627
-            ? $this->_template_args['publish_box_extra_content']
2628
-            : '';
2629
-        if ($delete && ! empty($id)) {
2630
-            // make sure we have a default if just true is sent.
2631
-            $delete           = ! empty($delete) ? $delete : 'delete';
2632
-            $delete_link_args = [$name => $id];
2633
-            $delete           = $this->get_action_link_or_button(
2634
-                $delete,
2635
-                $delete,
2636
-                $delete_link_args,
2637
-                'submitdelete deletion',
2638
-                '',
2639
-                false
2640
-            );
2641
-        }
2642
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2643
-        if (! empty($name) && ! empty($id)) {
2644
-            $hidden_field_arr[ $name ] = [
2645
-                'type'  => 'hidden',
2646
-                'value' => $id,
2647
-            ];
2648
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2649
-        } else {
2650
-            $hf = '';
2651
-        }
2652
-        // add hidden field
2653
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2654
-            ? $hf[ $name ]['field']
2655
-            : $hf;
2656
-    }
2657
-
2658
-
2659
-    /**
2660
-     * displays an error message to ppl who have javascript disabled
2661
-     *
2662
-     * @return void
2663
-     */
2664
-    private function _display_no_javascript_warning()
2665
-    {
2666
-        ?>
2474
+	}
2475
+
2476
+
2477
+	private function _espresso_links_post_box()
2478
+	{
2479
+		// Hiding until we actually have content to put in here...
2480
+		// 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');
2481
+	}
2482
+
2483
+
2484
+	public function espresso_links_post_box()
2485
+	{
2486
+		// Hiding until we actually have content to put in here...
2487
+		// EEH_Template::display_template(
2488
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2489
+		// );
2490
+	}
2491
+
2492
+
2493
+	protected function _espresso_sponsors_post_box()
2494
+	{
2495
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2496
+			add_meta_box(
2497
+				'espresso_sponsors_post_box',
2498
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2499
+				[$this, 'espresso_sponsors_post_box'],
2500
+				$this->_wp_page_slug,
2501
+				'side'
2502
+			);
2503
+		}
2504
+	}
2505
+
2506
+
2507
+	public function espresso_sponsors_post_box()
2508
+	{
2509
+		EEH_Template::display_template(
2510
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2511
+		);
2512
+	}
2513
+
2514
+
2515
+	private function _publish_post_box()
2516
+	{
2517
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2518
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2519
+		// then we'll use that for the metabox label.
2520
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2521
+		if (! empty($this->_labels['publishbox'])) {
2522
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2523
+				: $this->_labels['publishbox'];
2524
+		} else {
2525
+			$box_label = esc_html__('Publish', 'event_espresso');
2526
+		}
2527
+		$box_label = apply_filters(
2528
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2529
+			$box_label,
2530
+			$this->_req_action,
2531
+			$this
2532
+		);
2533
+		add_meta_box(
2534
+			$meta_box_ref,
2535
+			$box_label,
2536
+			[$this, 'editor_overview'],
2537
+			$this->_current_screen->id,
2538
+			'side',
2539
+			'high'
2540
+		);
2541
+	}
2542
+
2543
+
2544
+	public function editor_overview()
2545
+	{
2546
+		// if we have extra content set let's add it in if not make sure its empty
2547
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2548
+			? $this->_template_args['publish_box_extra_content']
2549
+			: '';
2550
+		echo EEH_Template::display_template(
2551
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2552
+			$this->_template_args,
2553
+			true
2554
+		);
2555
+	}
2556
+
2557
+
2558
+	/** end of globally available metaboxes section **/
2559
+
2560
+
2561
+	/**
2562
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2563
+	 * protected method.
2564
+	 *
2565
+	 * @param string $name
2566
+	 * @param int    $id
2567
+	 * @param bool   $delete
2568
+	 * @param string $save_close_redirect_URL
2569
+	 * @param bool   $both_btns
2570
+	 * @throws EE_Error
2571
+	 * @throws InvalidArgumentException
2572
+	 * @throws InvalidDataTypeException
2573
+	 * @throws InvalidInterfaceException
2574
+	 * @see   $this->_set_publish_post_box_vars for param details
2575
+	 * @since 4.6.0
2576
+	 */
2577
+	public function set_publish_post_box_vars(
2578
+		$name = '',
2579
+		$id = 0,
2580
+		$delete = false,
2581
+		$save_close_redirect_URL = '',
2582
+		$both_btns = true
2583
+	) {
2584
+		$this->_set_publish_post_box_vars(
2585
+			$name,
2586
+			$id,
2587
+			$delete,
2588
+			$save_close_redirect_URL,
2589
+			$both_btns
2590
+		);
2591
+	}
2592
+
2593
+
2594
+	/**
2595
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2596
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2597
+	 * save, and save and close buttons to work properly, then you will want to include a
2598
+	 * values for the name and id arguments.
2599
+	 *
2600
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2601
+	 * @param int     $id                         id attached to the item published
2602
+	 * @param string  $delete                     page route callback for the delete action
2603
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2604
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2605
+	 *                                            the Save button
2606
+	 * @throws EE_Error
2607
+	 * @throws InvalidArgumentException
2608
+	 * @throws InvalidDataTypeException
2609
+	 * @throws InvalidInterfaceException
2610
+	 * @todo  Add in validation for name/id arguments.
2611
+	 */
2612
+	protected function _set_publish_post_box_vars(
2613
+		$name = '',
2614
+		$id = 0,
2615
+		$delete = '',
2616
+		$save_close_redirect_URL = '',
2617
+		$both_btns = true
2618
+	) {
2619
+		// if Save & Close, use a custom redirect URL or default to the main page?
2620
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2621
+			? $save_close_redirect_URL
2622
+			: $this->_admin_base_url;
2623
+		// create the Save & Close and Save buttons
2624
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2625
+		// if we have extra content set let's add it in if not make sure its empty
2626
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2627
+			? $this->_template_args['publish_box_extra_content']
2628
+			: '';
2629
+		if ($delete && ! empty($id)) {
2630
+			// make sure we have a default if just true is sent.
2631
+			$delete           = ! empty($delete) ? $delete : 'delete';
2632
+			$delete_link_args = [$name => $id];
2633
+			$delete           = $this->get_action_link_or_button(
2634
+				$delete,
2635
+				$delete,
2636
+				$delete_link_args,
2637
+				'submitdelete deletion',
2638
+				'',
2639
+				false
2640
+			);
2641
+		}
2642
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2643
+		if (! empty($name) && ! empty($id)) {
2644
+			$hidden_field_arr[ $name ] = [
2645
+				'type'  => 'hidden',
2646
+				'value' => $id,
2647
+			];
2648
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2649
+		} else {
2650
+			$hf = '';
2651
+		}
2652
+		// add hidden field
2653
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2654
+			? $hf[ $name ]['field']
2655
+			: $hf;
2656
+	}
2657
+
2658
+
2659
+	/**
2660
+	 * displays an error message to ppl who have javascript disabled
2661
+	 *
2662
+	 * @return void
2663
+	 */
2664
+	private function _display_no_javascript_warning()
2665
+	{
2666
+		?>
2667 2667
         <noscript>
2668 2668
             <div id="no-js-message" class="error">
2669 2669
                 <p style="font-size:1.3em;">
2670 2670
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2671 2671
                     <?php esc_html_e(
2672
-                        '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.',
2673
-                        'event_espresso'
2674
-                    ); ?>
2672
+						'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.',
2673
+						'event_espresso'
2674
+					); ?>
2675 2675
                 </p>
2676 2676
             </div>
2677 2677
         </noscript>
2678 2678
         <?php
2679
-    }
2680
-
2681
-
2682
-    /**
2683
-     * displays espresso success and/or error notices
2684
-     *
2685
-     * @return void
2686
-     */
2687
-    private function _display_espresso_notices()
2688
-    {
2689
-        $notices = $this->_get_transient(true);
2690
-        echo stripslashes($notices);
2691
-    }
2692
-
2693
-
2694
-    /**
2695
-     * spinny things pacify the masses
2696
-     *
2697
-     * @return void
2698
-     */
2699
-    protected function _add_admin_page_ajax_loading_img()
2700
-    {
2701
-        ?>
2679
+	}
2680
+
2681
+
2682
+	/**
2683
+	 * displays espresso success and/or error notices
2684
+	 *
2685
+	 * @return void
2686
+	 */
2687
+	private function _display_espresso_notices()
2688
+	{
2689
+		$notices = $this->_get_transient(true);
2690
+		echo stripslashes($notices);
2691
+	}
2692
+
2693
+
2694
+	/**
2695
+	 * spinny things pacify the masses
2696
+	 *
2697
+	 * @return void
2698
+	 */
2699
+	protected function _add_admin_page_ajax_loading_img()
2700
+	{
2701
+		?>
2702 2702
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2703 2703
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2704
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2704
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2705 2705
         </div>
2706 2706
         <?php
2707
-    }
2707
+	}
2708 2708
 
2709 2709
 
2710
-    /**
2711
-     * add admin page overlay for modal boxes
2712
-     *
2713
-     * @return void
2714
-     */
2715
-    protected function _add_admin_page_overlay()
2716
-    {
2717
-        ?>
2710
+	/**
2711
+	 * add admin page overlay for modal boxes
2712
+	 *
2713
+	 * @return void
2714
+	 */
2715
+	protected function _add_admin_page_overlay()
2716
+	{
2717
+		?>
2718 2718
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2719 2719
         <?php
2720
-    }
2721
-
2722
-
2723
-    /**
2724
-     * facade for add_meta_box
2725
-     *
2726
-     * @param string  $action        where the metabox get's displayed
2727
-     * @param string  $title         Title of Metabox (output in metabox header)
2728
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2729
-     *                               instead of the one created in here.
2730
-     * @param array   $callback_args an array of args supplied for the metabox
2731
-     * @param string  $column        what metabox column
2732
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2733
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2734
-     *                               created but just set our own callback for wp's add_meta_box.
2735
-     * @throws DomainException
2736
-     */
2737
-    public function _add_admin_page_meta_box(
2738
-        $action,
2739
-        $title,
2740
-        $callback,
2741
-        $callback_args,
2742
-        $column = 'normal',
2743
-        $priority = 'high',
2744
-        $create_func = true
2745
-    ) {
2746
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2747
-        // 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.
2748
-        if (empty($callback_args) && $create_func) {
2749
-            $callback_args = [
2750
-                'template_path' => $this->_template_path,
2751
-                'template_args' => $this->_template_args,
2752
-            ];
2753
-        }
2754
-        // 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)
2755
-        $call_back_func = $create_func
2756
-            ? function ($post, $metabox) {
2757
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2758
-                echo EEH_Template::display_template(
2759
-                    $metabox['args']['template_path'],
2760
-                    $metabox['args']['template_args'],
2761
-                    true
2762
-                );
2763
-            }
2764
-            : $callback;
2765
-        add_meta_box(
2766
-            str_replace('_', '-', $action) . '-mbox',
2767
-            $title,
2768
-            $call_back_func,
2769
-            $this->_wp_page_slug,
2770
-            $column,
2771
-            $priority,
2772
-            $callback_args
2773
-        );
2774
-    }
2775
-
2776
-
2777
-    /**
2778
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2779
-     *
2780
-     * @throws DomainException
2781
-     * @throws EE_Error
2782
-     */
2783
-    public function display_admin_page_with_metabox_columns()
2784
-    {
2785
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2786
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2787
-            $this->_column_template_path,
2788
-            $this->_template_args,
2789
-            true
2790
-        );
2791
-        // the final wrapper
2792
-        $this->admin_page_wrapper();
2793
-    }
2794
-
2795
-
2796
-    /**
2797
-     * generates  HTML wrapper for an admin details page
2798
-     *
2799
-     * @return void
2800
-     * @throws EE_Error
2801
-     * @throws DomainException
2802
-     */
2803
-    public function display_admin_page_with_sidebar()
2804
-    {
2805
-        $this->_display_admin_page(true);
2806
-    }
2807
-
2808
-
2809
-    /**
2810
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2811
-     *
2812
-     * @return void
2813
-     * @throws EE_Error
2814
-     * @throws DomainException
2815
-     */
2816
-    public function display_admin_page_with_no_sidebar()
2817
-    {
2818
-        $this->_display_admin_page();
2819
-    }
2820
-
2821
-
2822
-    /**
2823
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2824
-     *
2825
-     * @return void
2826
-     * @throws EE_Error
2827
-     * @throws DomainException
2828
-     */
2829
-    public function display_about_admin_page()
2830
-    {
2831
-        $this->_display_admin_page(false, true);
2832
-    }
2833
-
2834
-
2835
-    /**
2836
-     * display_admin_page
2837
-     * contains the code for actually displaying an admin page
2838
-     *
2839
-     * @param boolean $sidebar true with sidebar, false without
2840
-     * @param boolean $about   use the about admin wrapper instead of the default.
2841
-     * @return void
2842
-     * @throws DomainException
2843
-     * @throws EE_Error
2844
-     */
2845
-    private function _display_admin_page($sidebar = false, $about = false)
2846
-    {
2847
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2848
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2849
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2850
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2851
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2852
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2853
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2854
-            ? 'poststuff'
2855
-            : 'espresso-default-admin';
2856
-        $template_path                                     = $sidebar
2857
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2858
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2859
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2860
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2861
-        }
2862
-        $template_path                                     = ! empty($this->_column_template_path)
2863
-            ? $this->_column_template_path : $template_path;
2864
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2865
-            ? $this->_template_args['admin_page_content']
2866
-            : '';
2867
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2868
-            ? $this->_template_args['before_admin_page_content']
2869
-            : '';
2870
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2871
-            ? $this->_template_args['after_admin_page_content']
2872
-            : '';
2873
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2874
-            $template_path,
2875
-            $this->_template_args,
2876
-            true
2877
-        );
2878
-        // the final template wrapper
2879
-        $this->admin_page_wrapper($about);
2880
-    }
2881
-
2882
-
2883
-    /**
2884
-     * This is used to display caf preview pages.
2885
-     *
2886
-     * @param string $utm_campaign_source what is the key used for google analytics link
2887
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2888
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2889
-     * @return void
2890
-     * @throws DomainException
2891
-     * @throws EE_Error
2892
-     * @throws InvalidArgumentException
2893
-     * @throws InvalidDataTypeException
2894
-     * @throws InvalidInterfaceException
2895
-     * @since 4.3.2
2896
-     */
2897
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2898
-    {
2899
-        // let's generate a default preview action button if there isn't one already present.
2900
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2901
-            'Upgrade to Event Espresso 4 Right Now',
2902
-            'event_espresso'
2903
-        );
2904
-        $buy_now_url                                   = add_query_arg(
2905
-            [
2906
-                'ee_ver'       => 'ee4',
2907
-                'utm_source'   => 'ee4_plugin_admin',
2908
-                'utm_medium'   => 'link',
2909
-                'utm_campaign' => $utm_campaign_source,
2910
-                'utm_content'  => 'buy_now_button',
2911
-            ],
2912
-            'http://eventespresso.com/pricing/'
2913
-        );
2914
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2915
-            ? $this->get_action_link_or_button(
2916
-                '',
2917
-                'buy_now',
2918
-                [],
2919
-                'button-primary button-large',
2920
-                $buy_now_url,
2921
-                true
2922
-            )
2923
-            : $this->_template_args['preview_action_button'];
2924
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2925
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2926
-            $this->_template_args,
2927
-            true
2928
-        );
2929
-        $this->_display_admin_page($display_sidebar);
2930
-    }
2931
-
2932
-
2933
-    /**
2934
-     * display_admin_list_table_page_with_sidebar
2935
-     * generates HTML wrapper for an admin_page with list_table
2936
-     *
2937
-     * @return void
2938
-     * @throws EE_Error
2939
-     * @throws DomainException
2940
-     */
2941
-    public function display_admin_list_table_page_with_sidebar()
2942
-    {
2943
-        $this->_display_admin_list_table_page(true);
2944
-    }
2945
-
2946
-
2947
-    /**
2948
-     * display_admin_list_table_page_with_no_sidebar
2949
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2950
-     *
2951
-     * @return void
2952
-     * @throws EE_Error
2953
-     * @throws DomainException
2954
-     */
2955
-    public function display_admin_list_table_page_with_no_sidebar()
2956
-    {
2957
-        $this->_display_admin_list_table_page();
2958
-    }
2959
-
2960
-
2961
-    /**
2962
-     * generates html wrapper for an admin_list_table page
2963
-     *
2964
-     * @param boolean $sidebar whether to display with sidebar or not.
2965
-     * @return void
2966
-     * @throws DomainException
2967
-     * @throws EE_Error
2968
-     */
2969
-    private function _display_admin_list_table_page($sidebar = false)
2970
-    {
2971
-        // setup search attributes
2972
-        $this->_set_search_attributes();
2973
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
2974
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2975
-        $this->_template_args['table_url']        = defined('DOING_AJAX')
2976
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2977
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2978
-        $this->_template_args['list_table']       = $this->_list_table_object;
2979
-        $this->_template_args['current_route']    = $this->_req_action;
2980
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2981
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2982
-        if (! empty($ajax_sorting_callback)) {
2983
-            $sortable_list_table_form_fields = wp_nonce_field(
2984
-                $ajax_sorting_callback . '_nonce',
2985
-                $ajax_sorting_callback . '_nonce',
2986
-                false,
2987
-                false
2988
-            );
2989
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2990
-                                                . $this->page_slug
2991
-                                                . '" />';
2992
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2993
-                                                . $ajax_sorting_callback
2994
-                                                . '" />';
2995
-        } else {
2996
-            $sortable_list_table_form_fields = '';
2997
-        }
2998
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2999
-        $hidden_form_fields                                      =
3000
-            isset($this->_template_args['list_table_hidden_fields'])
3001
-                ? $this->_template_args['list_table_hidden_fields']
3002
-                : '';
3003
-        $nonce_ref                                               = $this->_req_action . '_nonce';
3004
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
3005
-                                                                    . $nonce_ref
3006
-                                                                    . '" value="'
3007
-                                                                    . wp_create_nonce($nonce_ref)
3008
-                                                                    . '">';
3009
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3010
-        // display message about search results?
3011
-        $search = $this->request->getRequestParam('s');
3012
-        $this->_template_args['before_list_table'] .= ! empty($search)
3013
-            ? '<p class="ee-search-results">' . sprintf(
3014
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3015
-                trim($search, '%')
3016
-            ) . '</p>'
3017
-            : '';
3018
-        // filter before_list_table template arg
3019
-        $this->_template_args['before_list_table'] = apply_filters(
3020
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3021
-            $this->_template_args['before_list_table'],
3022
-            $this->page_slug,
3023
-            $this->request->requestParams(),
3024
-            $this->_req_action
3025
-        );
3026
-        // convert to array and filter again
3027
-        // arrays are easier to inject new items in a specific location,
3028
-        // but would not be backwards compatible, so we have to add a new filter
3029
-        $this->_template_args['before_list_table'] = implode(
3030
-            " \n",
3031
-            (array) apply_filters(
3032
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3033
-                (array) $this->_template_args['before_list_table'],
3034
-                $this->page_slug,
3035
-                $this->request->requestParams(),
3036
-                $this->_req_action
3037
-            )
3038
-        );
3039
-        // filter after_list_table template arg
3040
-        $this->_template_args['after_list_table'] = apply_filters(
3041
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3042
-            $this->_template_args['after_list_table'],
3043
-            $this->page_slug,
3044
-            $this->request->requestParams(),
3045
-            $this->_req_action
3046
-        );
3047
-        // convert to array and filter again
3048
-        // arrays are easier to inject new items in a specific location,
3049
-        // but would not be backwards compatible, so we have to add a new filter
3050
-        $this->_template_args['after_list_table']   = implode(
3051
-            " \n",
3052
-            (array) apply_filters(
3053
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3054
-                (array) $this->_template_args['after_list_table'],
3055
-                $this->page_slug,
3056
-                $this->request->requestParams(),
3057
-                $this->_req_action
3058
-            )
3059
-        );
3060
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3061
-            $template_path,
3062
-            $this->_template_args,
3063
-            true
3064
-        );
3065
-        // the final template wrapper
3066
-        if ($sidebar) {
3067
-            $this->display_admin_page_with_sidebar();
3068
-        } else {
3069
-            $this->display_admin_page_with_no_sidebar();
3070
-        }
3071
-    }
3072
-
3073
-
3074
-    /**
3075
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3076
-     * html string for the legend.
3077
-     * $items are expected in an array in the following format:
3078
-     * $legend_items = array(
3079
-     *        'item_id' => array(
3080
-     *            'icon' => 'http://url_to_icon_being_described.png',
3081
-     *            'desc' => esc_html__('localized description of item');
3082
-     *        )
3083
-     * );
3084
-     *
3085
-     * @param array $items see above for format of array
3086
-     * @return string html string of legend
3087
-     * @throws DomainException
3088
-     */
3089
-    protected function _display_legend($items)
3090
-    {
3091
-        $this->_template_args['items'] = apply_filters(
3092
-            'FHEE__EE_Admin_Page___display_legend__items',
3093
-            (array) $items,
3094
-            $this
3095
-        );
3096
-        return EEH_Template::display_template(
3097
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3098
-            $this->_template_args,
3099
-            true
3100
-        );
3101
-    }
3102
-
3103
-
3104
-    /**
3105
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3106
-     * The returned json object is created from an array in the following format:
3107
-     * array(
3108
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3109
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3110
-     *  'notices' => '', // - contains any EE_Error formatted notices
3111
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3112
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3113
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3114
-     *  that might be included in here)
3115
-     * )
3116
-     * The json object is populated by whatever is set in the $_template_args property.
3117
-     *
3118
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3119
-     *                                 instead of displayed.
3120
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3121
-     * @return void
3122
-     * @throws EE_Error
3123
-     */
3124
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
3125
-    {
3126
-        // make sure any EE_Error notices have been handled.
3127
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3128
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3129
-        unset($this->_template_args['data']);
3130
-        $json = [
3131
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3132
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3133
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3134
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3135
-            'notices'   => EE_Error::get_notices(),
3136
-            'content'   => isset($this->_template_args['admin_page_content'])
3137
-                ? $this->_template_args['admin_page_content'] : '',
3138
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3139
-            'isEEajax'  => true
3140
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3141
-        ];
3142
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3143
-        if (null === error_get_last() || ! headers_sent()) {
3144
-            header('Content-Type: application/json; charset=UTF-8');
3145
-        }
3146
-        echo wp_json_encode($json);
3147
-        exit();
3148
-    }
3149
-
3150
-
3151
-    /**
3152
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3153
-     *
3154
-     * @return void
3155
-     * @throws EE_Error
3156
-     */
3157
-    public function return_json()
3158
-    {
3159
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3160
-            $this->_return_json();
3161
-        } else {
3162
-            throw new EE_Error(
3163
-                sprintf(
3164
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3165
-                    __FUNCTION__
3166
-                )
3167
-            );
3168
-        }
3169
-    }
3170
-
3171
-
3172
-    /**
3173
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3174
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3175
-     *
3176
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3177
-     */
3178
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3179
-    {
3180
-        $this->_hook_obj = $hook_obj;
3181
-    }
3182
-
3183
-
3184
-    /**
3185
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3186
-     *
3187
-     * @param boolean $about whether to use the special about page wrapper or default.
3188
-     * @return void
3189
-     * @throws DomainException
3190
-     * @throws EE_Error
3191
-     */
3192
-    public function admin_page_wrapper($about = false)
3193
-    {
3194
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3195
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3196
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3197
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3198
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3199
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3200
-            isset($this->_template_args['before_admin_page_content'])
3201
-                ? $this->_template_args['before_admin_page_content']
3202
-                : ''
3203
-        );
3204
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3205
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3206
-            isset($this->_template_args['after_admin_page_content'])
3207
-                ? $this->_template_args['after_admin_page_content']
3208
-                : ''
3209
-        );
3210
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3211
-        // load settings page wrapper template
3212
-        $template_path = ! defined('DOING_AJAX')
3213
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3214
-            : EE_ADMIN_TEMPLATE
3215
-              . 'admin_wrapper_ajax.template.php';
3216
-        // about page?
3217
-        $template_path = $about
3218
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3219
-            : $template_path;
3220
-        if (defined('DOING_AJAX')) {
3221
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3222
-                $template_path,
3223
-                $this->_template_args,
3224
-                true
3225
-            );
3226
-            $this->_return_json();
3227
-        } else {
3228
-            EEH_Template::display_template($template_path, $this->_template_args);
3229
-        }
3230
-    }
3231
-
3232
-
3233
-    /**
3234
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3235
-     *
3236
-     * @return string html
3237
-     * @throws EE_Error
3238
-     */
3239
-    protected function _get_main_nav_tabs()
3240
-    {
3241
-        // let's generate the html using the EEH_Tabbed_Content helper.
3242
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3243
-        // (rather than setting in the page_routes array)
3244
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3245
-    }
3246
-
3247
-
3248
-    /**
3249
-     *        sort nav tabs
3250
-     *
3251
-     * @param $a
3252
-     * @param $b
3253
-     * @return int
3254
-     */
3255
-    private function _sort_nav_tabs($a, $b)
3256
-    {
3257
-        if ($a['order'] === $b['order']) {
3258
-            return 0;
3259
-        }
3260
-        return ($a['order'] < $b['order']) ? -1 : 1;
3261
-    }
3262
-
3263
-
3264
-    /**
3265
-     *    generates HTML for the forms used on admin pages
3266
-     *
3267
-     * @param array  $input_vars   - array of input field details
3268
-     * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3269
-     *                             use)
3270
-     * @param bool   $id
3271
-     * @return string
3272
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3273
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3274
-     */
3275
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3276
-    {
3277
-        $content = $generator === 'string'
3278
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3279
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3280
-        return $content;
3281
-    }
3282
-
3283
-
3284
-    /**
3285
-     * generates the "Save" and "Save & Close" buttons for edit forms
3286
-     *
3287
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3288
-     *                                   Close" button.
3289
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3290
-     *                                   'Save', [1] => 'save & close')
3291
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3292
-     *                                   via the "name" value in the button).  We can also use this to just dump
3293
-     *                                   default actions by submitting some other value.
3294
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3295
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3296
-     *                                   close (normal form handling).
3297
-     */
3298
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3299
-    {
3300
-        // make sure $text and $actions are in an array
3301
-        $text          = (array) $text;
3302
-        $actions       = (array) $actions;
3303
-        $referrer_url  = empty($referrer)
3304
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3305
-              . $this->request->getServerParam('REQUEST_URI')
3306
-              . '" />'
3307
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3308
-              . $referrer
3309
-              . '" />';
3310
-        $button_text   = ! empty($text)
3311
-            ? $text
3312
-            : [
3313
-                esc_html__('Save', 'event_espresso'),
3314
-                esc_html__('Save and Close', 'event_espresso'),
3315
-            ];
3316
-        $default_names = ['save', 'save_and_close'];
3317
-        // add in a hidden index for the current page (so save and close redirects properly)
3318
-        $this->_template_args['save_buttons'] = $referrer_url;
3319
-        foreach ($button_text as $key => $button) {
3320
-            $ref                                  = $default_names[ $key ];
3321
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3322
-                                                     . $ref
3323
-                                                     . '" value="'
3324
-                                                     . $button
3325
-                                                     . '" name="'
3326
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3327
-                                                     . '" id="'
3328
-                                                     . $this->_current_view . '_' . $ref
3329
-                                                     . '" />';
3330
-            if (! $both) {
3331
-                break;
3332
-            }
3333
-        }
3334
-    }
3335
-
3336
-
3337
-    /**
3338
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3339
-     *
3340
-     * @param string $route
3341
-     * @param array  $additional_hidden_fields
3342
-     * @see   $this->_set_add_edit_form_tags() for details on params
3343
-     * @since 4.6.0
3344
-     */
3345
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3346
-    {
3347
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3348
-    }
3349
-
3350
-
3351
-    /**
3352
-     * set form open and close tags on add/edit pages.
3353
-     *
3354
-     * @param string $route                    the route you want the form to direct to
3355
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3356
-     * @return void
3357
-     */
3358
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3359
-    {
3360
-        if (empty($route)) {
3361
-            $user_msg = esc_html__(
3362
-                'An error occurred. No action was set for this page\'s form.',
3363
-                'event_espresso'
3364
-            );
3365
-            $dev_msg  = $user_msg . "\n"
3366
-                        . sprintf(
3367
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3368
-                            __FUNCTION__,
3369
-                            __CLASS__
3370
-                        );
3371
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3372
-        }
3373
-        // open form
3374
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3375
-                                                             . $this->_admin_base_url
3376
-                                                             . '" id="'
3377
-                                                             . $route
3378
-                                                             . '_event_form" >';
3379
-        // add nonce
3380
-        $nonce                                             =
3381
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3382
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3383
-        // add REQUIRED form action
3384
-        $hidden_fields = [
3385
-            'action' => ['type' => 'hidden', 'value' => $route],
3386
-        ];
3387
-        // merge arrays
3388
-        $hidden_fields = is_array($additional_hidden_fields)
3389
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3390
-            : $hidden_fields;
3391
-        // generate form fields
3392
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3393
-        // add fields to form
3394
-        foreach ((array) $form_fields as $field_name => $form_field) {
3395
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3396
-        }
3397
-        // close form
3398
-        $this->_template_args['after_admin_page_content'] = '</form>';
3399
-    }
3400
-
3401
-
3402
-    /**
3403
-     * Public Wrapper for _redirect_after_action() method since its
3404
-     * discovered it would be useful for external code to have access.
3405
-     *
3406
-     * @param bool   $success
3407
-     * @param string $what
3408
-     * @param string $action_desc
3409
-     * @param array  $query_args
3410
-     * @param bool   $override_overwrite
3411
-     * @throws EE_Error
3412
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3413
-     * @since 4.5.0
3414
-     */
3415
-    public function redirect_after_action(
3416
-        $success = false,
3417
-        $what = 'item',
3418
-        $action_desc = 'processed',
3419
-        $query_args = [],
3420
-        $override_overwrite = false
3421
-    ) {
3422
-        $this->_redirect_after_action(
3423
-            $success,
3424
-            $what,
3425
-            $action_desc,
3426
-            $query_args,
3427
-            $override_overwrite
3428
-        );
3429
-    }
3430
-
3431
-
3432
-    /**
3433
-     * Helper method for merging existing request data with the returned redirect url.
3434
-     *
3435
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3436
-     * filters are still applied.
3437
-     *
3438
-     * @param array $new_route_data
3439
-     * @return array
3440
-     */
3441
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3442
-    {
3443
-        foreach ($this->request->requestParams() as $ref => $value) {
3444
-            // unset nonces
3445
-            if (strpos($ref, 'nonce') !== false) {
3446
-                $this->request->unSetRequestParam($ref);
3447
-                continue;
3448
-            }
3449
-            // urlencode values.
3450
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3451
-            $this->request->setRequestParam($ref, $value);
3452
-        }
3453
-        return array_merge($this->request->requestParams(), $new_route_data);
3454
-    }
3455
-
3456
-
3457
-    /**
3458
-     *    _redirect_after_action
3459
-     *
3460
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3461
-     * @param string $what               - what the action was performed on
3462
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3463
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3464
-     *                                   action is completed
3465
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3466
-     *                                   override this so that they show.
3467
-     * @return void
3468
-     * @throws EE_Error
3469
-     */
3470
-    protected function _redirect_after_action(
3471
-        $success = 0,
3472
-        $what = 'item',
3473
-        $action_desc = 'processed',
3474
-        $query_args = [],
3475
-        $override_overwrite = false
3476
-    ) {
3477
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3478
-        // class name for actions/filters.
3479
-        $classname = get_class($this);
3480
-        // set redirect url.
3481
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3482
-        // otherwise we go with whatever is set as the _admin_base_url
3483
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3484
-        $notices      = EE_Error::get_notices(false);
3485
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3486
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3487
-            EE_Error::overwrite_success();
3488
-        }
3489
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3490
-            // how many records affected ? more than one record ? or just one ?
3491
-            if ($success > 1) {
3492
-                // set plural msg
3493
-                EE_Error::add_success(
3494
-                    sprintf(
3495
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3496
-                        $what,
3497
-                        $action_desc
3498
-                    ),
3499
-                    __FILE__,
3500
-                    __FUNCTION__,
3501
-                    __LINE__
3502
-                );
3503
-            } elseif ($success === 1) {
3504
-                // set singular msg
3505
-                EE_Error::add_success(
3506
-                    sprintf(
3507
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3508
-                        $what,
3509
-                        $action_desc
3510
-                    ),
3511
-                    __FILE__,
3512
-                    __FUNCTION__,
3513
-                    __LINE__
3514
-                );
3515
-            }
3516
-        }
3517
-        // check that $query_args isn't something crazy
3518
-        if (! is_array($query_args)) {
3519
-            $query_args = [];
3520
-        }
3521
-        /**
3522
-         * Allow injecting actions before the query_args are modified for possible different
3523
-         * redirections on save and close actions
3524
-         *
3525
-         * @param array $query_args       The original query_args array coming into the
3526
-         *                                method.
3527
-         * @since 4.2.0
3528
-         */
3529
-        do_action(
3530
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3531
-            $query_args
3532
-        );
3533
-        // calculate where we're going (if we have a "save and close" button pushed)
3534
-
3535
-        if (
3536
-            $this->request->requestParamIsSet('save_and_close')
3537
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3538
-        ) {
3539
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3540
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3541
-            // regenerate query args array from referrer URL
3542
-            parse_str($parsed_url['query'], $query_args);
3543
-            // correct page and action will be in the query args now
3544
-            $redirect_url = admin_url('admin.php');
3545
-        }
3546
-        // merge any default query_args set in _default_route_query_args property
3547
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3548
-            $args_to_merge = [];
3549
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3550
-                // is there a wp_referer array in our _default_route_query_args property?
3551
-                if ($query_param === 'wp_referer') {
3552
-                    $query_value = (array) $query_value;
3553
-                    foreach ($query_value as $reference => $value) {
3554
-                        if (strpos($reference, 'nonce') !== false) {
3555
-                            continue;
3556
-                        }
3557
-                        // finally we will override any arguments in the referer with
3558
-                        // what might be set on the _default_route_query_args array.
3559
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3560
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3561
-                        } else {
3562
-                            $args_to_merge[ $reference ] = urlencode($value);
3563
-                        }
3564
-                    }
3565
-                    continue;
3566
-                }
3567
-                $args_to_merge[ $query_param ] = $query_value;
3568
-            }
3569
-            // now let's merge these arguments but override with what was specifically sent in to the
3570
-            // redirect.
3571
-            $query_args = array_merge($args_to_merge, $query_args);
3572
-        }
3573
-        $this->_process_notices($query_args);
3574
-        // generate redirect url
3575
-        // if redirecting to anything other than the main page, add a nonce
3576
-        if (isset($query_args['action'])) {
3577
-            // manually generate wp_nonce and merge that with the query vars
3578
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3579
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3580
-        }
3581
-        // we're adding some hooks and filters in here for processing any things just before redirects
3582
-        // (example: an admin page has done an insert or update and we want to run something after that).
3583
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3584
-        $redirect_url = apply_filters(
3585
-            'FHEE_redirect_' . $classname . $this->_req_action,
3586
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3587
-            $query_args
3588
-        );
3589
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3590
-        if (defined('DOING_AJAX')) {
3591
-            $default_data                    = [
3592
-                'close'        => true,
3593
-                'redirect_url' => $redirect_url,
3594
-                'where'        => 'main',
3595
-                'what'         => 'append',
3596
-            ];
3597
-            $this->_template_args['success'] = $success;
3598
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3599
-                $default_data,
3600
-                $this->_template_args['data']
3601
-            ) : $default_data;
3602
-            $this->_return_json();
3603
-        }
3604
-        wp_safe_redirect($redirect_url);
3605
-        exit();
3606
-    }
3607
-
3608
-
3609
-    /**
3610
-     * process any notices before redirecting (or returning ajax request)
3611
-     * This method sets the $this->_template_args['notices'] attribute;
3612
-     *
3613
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3614
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3615
-     *                                  page_routes haven't been defined yet.
3616
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3617
-     *                                  still save a transient for the notice.
3618
-     * @return void
3619
-     * @throws EE_Error
3620
-     */
3621
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3622
-    {
3623
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3624
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3625
-            $notices = EE_Error::get_notices(false);
3626
-            if (empty($this->_template_args['success'])) {
3627
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3628
-            }
3629
-            if (empty($this->_template_args['errors'])) {
3630
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3631
-            }
3632
-            if (empty($this->_template_args['attention'])) {
3633
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3634
-            }
3635
-        }
3636
-        $this->_template_args['notices'] = EE_Error::get_notices();
3637
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3638
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3639
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3640
-            $this->_add_transient(
3641
-                $route,
3642
-                $this->_template_args['notices'],
3643
-                true,
3644
-                $skip_route_verify
3645
-            );
3646
-        }
3647
-    }
3648
-
3649
-
3650
-    /**
3651
-     * get_action_link_or_button
3652
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3653
-     *
3654
-     * @param string $action        use this to indicate which action the url is generated with.
3655
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3656
-     *                              property.
3657
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3658
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3659
-     * @param string $base_url      If this is not provided
3660
-     *                              the _admin_base_url will be used as the default for the button base_url.
3661
-     *                              Otherwise this value will be used.
3662
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3663
-     * @return string
3664
-     * @throws InvalidArgumentException
3665
-     * @throws InvalidInterfaceException
3666
-     * @throws InvalidDataTypeException
3667
-     * @throws EE_Error
3668
-     */
3669
-    public function get_action_link_or_button(
3670
-        $action,
3671
-        $type = 'add',
3672
-        $extra_request = [],
3673
-        $class = 'button-primary',
3674
-        $base_url = '',
3675
-        $exclude_nonce = false
3676
-    ) {
3677
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3678
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3679
-            throw new EE_Error(
3680
-                sprintf(
3681
-                    esc_html__(
3682
-                        'There is no page route for given action for the button.  This action was given: %s',
3683
-                        'event_espresso'
3684
-                    ),
3685
-                    $action
3686
-                )
3687
-            );
3688
-        }
3689
-        if (! isset($this->_labels['buttons'][ $type ])) {
3690
-            throw new EE_Error(
3691
-                sprintf(
3692
-                    __(
3693
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3694
-                        'event_espresso'
3695
-                    ),
3696
-                    $type
3697
-                )
3698
-            );
3699
-        }
3700
-        // finally check user access for this button.
3701
-        $has_access = $this->check_user_access($action, true);
3702
-        if (! $has_access) {
3703
-            return '';
3704
-        }
3705
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3706
-        $query_args = [
3707
-            'action' => $action,
3708
-        ];
3709
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3710
-        if (! empty($extra_request)) {
3711
-            $query_args = array_merge($extra_request, $query_args);
3712
-        }
3713
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3714
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3715
-    }
3716
-
3717
-
3718
-    /**
3719
-     * _per_page_screen_option
3720
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3721
-     *
3722
-     * @return void
3723
-     * @throws InvalidArgumentException
3724
-     * @throws InvalidInterfaceException
3725
-     * @throws InvalidDataTypeException
3726
-     */
3727
-    protected function _per_page_screen_option()
3728
-    {
3729
-        $option = 'per_page';
3730
-        $args   = [
3731
-            'label'   => apply_filters(
3732
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3733
-                $this->_admin_page_title,
3734
-                $this
3735
-            ),
3736
-            'default' => (int) apply_filters(
3737
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3738
-                20
3739
-            ),
3740
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3741
-        ];
3742
-        // ONLY add the screen option if the user has access to it.
3743
-        if ($this->check_user_access($this->_current_view, true)) {
3744
-            add_screen_option($option, $args);
3745
-        }
3746
-    }
3747
-
3748
-
3749
-    /**
3750
-     * set_per_page_screen_option
3751
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3752
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3753
-     * admin_menu.
3754
-     *
3755
-     * @return void
3756
-     */
3757
-    private function _set_per_page_screen_options()
3758
-    {
3759
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3760
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3761
-            if (! $user = wp_get_current_user()) {
3762
-                return;
3763
-            }
3764
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3765
-            if (! $option) {
3766
-                return;
3767
-            }
3768
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3769
-            $map_option = $option;
3770
-            $option     = str_replace('-', '_', $option);
3771
-            switch ($map_option) {
3772
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3773
-                    $max_value = apply_filters(
3774
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3775
-                        999,
3776
-                        $this->_current_page,
3777
-                        $this->_current_view
3778
-                    );
3779
-                    if ($value < 1) {
3780
-                        return;
3781
-                    }
3782
-                    $value = min($value, $max_value);
3783
-                    break;
3784
-                default:
3785
-                    $value = apply_filters(
3786
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3787
-                        false,
3788
-                        $option,
3789
-                        $value
3790
-                    );
3791
-                    if (false === $value) {
3792
-                        return;
3793
-                    }
3794
-                    break;
3795
-            }
3796
-            update_user_meta($user->ID, $option, $value);
3797
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3798
-            exit;
3799
-        }
3800
-    }
3801
-
3802
-
3803
-    /**
3804
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3805
-     *
3806
-     * @param array $data array that will be assigned to template args.
3807
-     */
3808
-    public function set_template_args($data)
3809
-    {
3810
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3811
-    }
3812
-
3813
-
3814
-    /**
3815
-     * This makes available the WP transient system for temporarily moving data between routes
3816
-     *
3817
-     * @param string $route             the route that should receive the transient
3818
-     * @param array  $data              the data that gets sent
3819
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3820
-     *                                  normal route transient.
3821
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3822
-     *                                  when we are adding a transient before page_routes have been defined.
3823
-     * @return void
3824
-     * @throws EE_Error
3825
-     */
3826
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3827
-    {
3828
-        $user_id = get_current_user_id();
3829
-        if (! $skip_route_verify) {
3830
-            $this->_verify_route($route);
3831
-        }
3832
-        // now let's set the string for what kind of transient we're setting
3833
-        $transient = $notices
3834
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3835
-            : 'rte_tx_' . $route . '_' . $user_id;
3836
-        $data      = $notices ? ['notices' => $data] : $data;
3837
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3838
-        $existing = is_multisite() && is_network_admin()
3839
-            ? get_site_transient($transient)
3840
-            : get_transient($transient);
3841
-        if ($existing) {
3842
-            $data = array_merge((array) $data, (array) $existing);
3843
-        }
3844
-        if (is_multisite() && is_network_admin()) {
3845
-            set_site_transient($transient, $data, 8);
3846
-        } else {
3847
-            set_transient($transient, $data, 8);
3848
-        }
3849
-    }
3850
-
3851
-
3852
-    /**
3853
-     * this retrieves the temporary transient that has been set for moving data between routes.
3854
-     *
3855
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3856
-     * @param string $route
3857
-     * @return mixed data
3858
-     */
3859
-    protected function _get_transient($notices = false, $route = '')
3860
-    {
3861
-        $user_id   = get_current_user_id();
3862
-        $route     = ! $route ? $this->_req_action : $route;
3863
-        $transient = $notices
3864
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3865
-            : 'rte_tx_' . $route . '_' . $user_id;
3866
-        $data      = is_multisite() && is_network_admin()
3867
-            ? get_site_transient($transient)
3868
-            : get_transient($transient);
3869
-        // delete transient after retrieval (just in case it hasn't expired);
3870
-        if (is_multisite() && is_network_admin()) {
3871
-            delete_site_transient($transient);
3872
-        } else {
3873
-            delete_transient($transient);
3874
-        }
3875
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3876
-    }
3877
-
3878
-
3879
-    /**
3880
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3881
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3882
-     * default route callback on the EE_Admin page you want it run.)
3883
-     *
3884
-     * @return void
3885
-     */
3886
-    protected function _transient_garbage_collection()
3887
-    {
3888
-        global $wpdb;
3889
-        // retrieve all existing transients
3890
-        $query =
3891
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3892
-        if ($results = $wpdb->get_results($query)) {
3893
-            foreach ($results as $result) {
3894
-                $transient = str_replace('_transient_', '', $result->option_name);
3895
-                get_transient($transient);
3896
-                if (is_multisite() && is_network_admin()) {
3897
-                    get_site_transient($transient);
3898
-                }
3899
-            }
3900
-        }
3901
-    }
3902
-
3903
-
3904
-    /**
3905
-     * get_view
3906
-     *
3907
-     * @return string content of _view property
3908
-     */
3909
-    public function get_view()
3910
-    {
3911
-        return $this->_view;
3912
-    }
3913
-
3914
-
3915
-    /**
3916
-     * getter for the protected $_views property
3917
-     *
3918
-     * @return array
3919
-     */
3920
-    public function get_views()
3921
-    {
3922
-        return $this->_views;
3923
-    }
3924
-
3925
-
3926
-    /**
3927
-     * get_current_page
3928
-     *
3929
-     * @return string _current_page property value
3930
-     */
3931
-    public function get_current_page()
3932
-    {
3933
-        return $this->_current_page;
3934
-    }
3935
-
3936
-
3937
-    /**
3938
-     * get_current_view
3939
-     *
3940
-     * @return string _current_view property value
3941
-     */
3942
-    public function get_current_view()
3943
-    {
3944
-        return $this->_current_view;
3945
-    }
3946
-
3947
-
3948
-    /**
3949
-     * get_current_screen
3950
-     *
3951
-     * @return object The current WP_Screen object
3952
-     */
3953
-    public function get_current_screen()
3954
-    {
3955
-        return $this->_current_screen;
3956
-    }
3957
-
3958
-
3959
-    /**
3960
-     * get_current_page_view_url
3961
-     *
3962
-     * @return string This returns the url for the current_page_view.
3963
-     */
3964
-    public function get_current_page_view_url()
3965
-    {
3966
-        return $this->_current_page_view_url;
3967
-    }
3968
-
3969
-
3970
-    /**
3971
-     * just returns the _req_data property
3972
-     *
3973
-     * @return array
3974
-     */
3975
-    public function get_request_data()
3976
-    {
3977
-        return $this->request->requestParams();
3978
-    }
3979
-
3980
-
3981
-    /**
3982
-     * returns the _req_data protected property
3983
-     *
3984
-     * @return string
3985
-     */
3986
-    public function get_req_action()
3987
-    {
3988
-        return $this->_req_action;
3989
-    }
3990
-
3991
-
3992
-    /**
3993
-     * @return bool  value of $_is_caf property
3994
-     */
3995
-    public function is_caf()
3996
-    {
3997
-        return $this->_is_caf;
3998
-    }
3999
-
4000
-
4001
-    /**
4002
-     * @return mixed
4003
-     */
4004
-    public function default_espresso_metaboxes()
4005
-    {
4006
-        return $this->_default_espresso_metaboxes;
4007
-    }
4008
-
4009
-
4010
-    /**
4011
-     * @return mixed
4012
-     */
4013
-    public function admin_base_url()
4014
-    {
4015
-        return $this->_admin_base_url;
4016
-    }
4017
-
4018
-
4019
-    /**
4020
-     * @return mixed
4021
-     */
4022
-    public function wp_page_slug()
4023
-    {
4024
-        return $this->_wp_page_slug;
4025
-    }
4026
-
4027
-
4028
-    /**
4029
-     * updates  espresso configuration settings
4030
-     *
4031
-     * @param string                   $tab
4032
-     * @param EE_Config_Base|EE_Config $config
4033
-     * @param string                   $file file where error occurred
4034
-     * @param string                   $func function  where error occurred
4035
-     * @param string                   $line line no where error occurred
4036
-     * @return boolean
4037
-     */
4038
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4039
-    {
4040
-        // remove any options that are NOT going to be saved with the config settings.
4041
-        if (isset($config->core->ee_ueip_optin)) {
4042
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4043
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4044
-            update_option('ee_ueip_has_notified', true);
4045
-        }
4046
-        // and save it (note we're also doing the network save here)
4047
-        $net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4048
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4049
-        if ($config_saved && $net_saved) {
4050
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4051
-            return true;
4052
-        }
4053
-        EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4054
-        return false;
4055
-    }
4056
-
4057
-
4058
-    /**
4059
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4060
-     *
4061
-     * @return array
4062
-     */
4063
-    public function get_yes_no_values()
4064
-    {
4065
-        return $this->_yes_no_values;
4066
-    }
4067
-
4068
-
4069
-    protected function _get_dir()
4070
-    {
4071
-        $reflector = new ReflectionClass(get_class($this));
4072
-        return dirname($reflector->getFileName());
4073
-    }
4074
-
4075
-
4076
-    /**
4077
-     * A helper for getting a "next link".
4078
-     *
4079
-     * @param string $url   The url to link to
4080
-     * @param string $class The class to use.
4081
-     * @return string
4082
-     */
4083
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4084
-    {
4085
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4086
-    }
4087
-
4088
-
4089
-    /**
4090
-     * A helper for getting a "previous link".
4091
-     *
4092
-     * @param string $url   The url to link to
4093
-     * @param string $class The class to use.
4094
-     * @return string
4095
-     */
4096
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4097
-    {
4098
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4099
-    }
4100
-
4101
-
4102
-
4103
-
4104
-
4105
-
4106
-
4107
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4108
-
4109
-
4110
-    /**
4111
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4112
-     * 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
4113
-     * _req_data array.
4114
-     *
4115
-     * @return bool success/fail
4116
-     * @throws EE_Error
4117
-     * @throws InvalidArgumentException
4118
-     * @throws ReflectionException
4119
-     * @throws InvalidDataTypeException
4120
-     * @throws InvalidInterfaceException
4121
-     */
4122
-    protected function _process_resend_registration()
4123
-    {
4124
-        $this->_template_args['success'] = EED_Messages::process_resend($this->request->requestParams());
4125
-        do_action(
4126
-            'AHEE__EE_Admin_Page___process_resend_registration',
4127
-            $this->_template_args['success'],
4128
-            $this->request->requestParams()
4129
-        );
4130
-        return $this->_template_args['success'];
4131
-    }
4132
-
4133
-
4134
-    /**
4135
-     * This automatically processes any payment message notifications when manual payment has been applied.
4136
-     *
4137
-     * @param EE_Payment $payment
4138
-     * @return bool success/fail
4139
-     */
4140
-    protected function _process_payment_notification(EE_Payment $payment)
4141
-    {
4142
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4143
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4144
-        $this->_template_args['success'] = apply_filters(
4145
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4146
-            false,
4147
-            $payment
4148
-        );
4149
-        return $this->_template_args['success'];
4150
-    }
2720
+	}
2721
+
2722
+
2723
+	/**
2724
+	 * facade for add_meta_box
2725
+	 *
2726
+	 * @param string  $action        where the metabox get's displayed
2727
+	 * @param string  $title         Title of Metabox (output in metabox header)
2728
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2729
+	 *                               instead of the one created in here.
2730
+	 * @param array   $callback_args an array of args supplied for the metabox
2731
+	 * @param string  $column        what metabox column
2732
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2733
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2734
+	 *                               created but just set our own callback for wp's add_meta_box.
2735
+	 * @throws DomainException
2736
+	 */
2737
+	public function _add_admin_page_meta_box(
2738
+		$action,
2739
+		$title,
2740
+		$callback,
2741
+		$callback_args,
2742
+		$column = 'normal',
2743
+		$priority = 'high',
2744
+		$create_func = true
2745
+	) {
2746
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2747
+		// 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.
2748
+		if (empty($callback_args) && $create_func) {
2749
+			$callback_args = [
2750
+				'template_path' => $this->_template_path,
2751
+				'template_args' => $this->_template_args,
2752
+			];
2753
+		}
2754
+		// 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)
2755
+		$call_back_func = $create_func
2756
+			? function ($post, $metabox) {
2757
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2758
+				echo EEH_Template::display_template(
2759
+					$metabox['args']['template_path'],
2760
+					$metabox['args']['template_args'],
2761
+					true
2762
+				);
2763
+			}
2764
+			: $callback;
2765
+		add_meta_box(
2766
+			str_replace('_', '-', $action) . '-mbox',
2767
+			$title,
2768
+			$call_back_func,
2769
+			$this->_wp_page_slug,
2770
+			$column,
2771
+			$priority,
2772
+			$callback_args
2773
+		);
2774
+	}
2775
+
2776
+
2777
+	/**
2778
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2779
+	 *
2780
+	 * @throws DomainException
2781
+	 * @throws EE_Error
2782
+	 */
2783
+	public function display_admin_page_with_metabox_columns()
2784
+	{
2785
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2786
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2787
+			$this->_column_template_path,
2788
+			$this->_template_args,
2789
+			true
2790
+		);
2791
+		// the final wrapper
2792
+		$this->admin_page_wrapper();
2793
+	}
2794
+
2795
+
2796
+	/**
2797
+	 * generates  HTML wrapper for an admin details page
2798
+	 *
2799
+	 * @return void
2800
+	 * @throws EE_Error
2801
+	 * @throws DomainException
2802
+	 */
2803
+	public function display_admin_page_with_sidebar()
2804
+	{
2805
+		$this->_display_admin_page(true);
2806
+	}
2807
+
2808
+
2809
+	/**
2810
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2811
+	 *
2812
+	 * @return void
2813
+	 * @throws EE_Error
2814
+	 * @throws DomainException
2815
+	 */
2816
+	public function display_admin_page_with_no_sidebar()
2817
+	{
2818
+		$this->_display_admin_page();
2819
+	}
2820
+
2821
+
2822
+	/**
2823
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2824
+	 *
2825
+	 * @return void
2826
+	 * @throws EE_Error
2827
+	 * @throws DomainException
2828
+	 */
2829
+	public function display_about_admin_page()
2830
+	{
2831
+		$this->_display_admin_page(false, true);
2832
+	}
2833
+
2834
+
2835
+	/**
2836
+	 * display_admin_page
2837
+	 * contains the code for actually displaying an admin page
2838
+	 *
2839
+	 * @param boolean $sidebar true with sidebar, false without
2840
+	 * @param boolean $about   use the about admin wrapper instead of the default.
2841
+	 * @return void
2842
+	 * @throws DomainException
2843
+	 * @throws EE_Error
2844
+	 */
2845
+	private function _display_admin_page($sidebar = false, $about = false)
2846
+	{
2847
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2848
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2849
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2850
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2851
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2852
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2853
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2854
+			? 'poststuff'
2855
+			: 'espresso-default-admin';
2856
+		$template_path                                     = $sidebar
2857
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2858
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2859
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2860
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2861
+		}
2862
+		$template_path                                     = ! empty($this->_column_template_path)
2863
+			? $this->_column_template_path : $template_path;
2864
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2865
+			? $this->_template_args['admin_page_content']
2866
+			: '';
2867
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2868
+			? $this->_template_args['before_admin_page_content']
2869
+			: '';
2870
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2871
+			? $this->_template_args['after_admin_page_content']
2872
+			: '';
2873
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2874
+			$template_path,
2875
+			$this->_template_args,
2876
+			true
2877
+		);
2878
+		// the final template wrapper
2879
+		$this->admin_page_wrapper($about);
2880
+	}
2881
+
2882
+
2883
+	/**
2884
+	 * This is used to display caf preview pages.
2885
+	 *
2886
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2887
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2888
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2889
+	 * @return void
2890
+	 * @throws DomainException
2891
+	 * @throws EE_Error
2892
+	 * @throws InvalidArgumentException
2893
+	 * @throws InvalidDataTypeException
2894
+	 * @throws InvalidInterfaceException
2895
+	 * @since 4.3.2
2896
+	 */
2897
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2898
+	{
2899
+		// let's generate a default preview action button if there isn't one already present.
2900
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2901
+			'Upgrade to Event Espresso 4 Right Now',
2902
+			'event_espresso'
2903
+		);
2904
+		$buy_now_url                                   = add_query_arg(
2905
+			[
2906
+				'ee_ver'       => 'ee4',
2907
+				'utm_source'   => 'ee4_plugin_admin',
2908
+				'utm_medium'   => 'link',
2909
+				'utm_campaign' => $utm_campaign_source,
2910
+				'utm_content'  => 'buy_now_button',
2911
+			],
2912
+			'http://eventespresso.com/pricing/'
2913
+		);
2914
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2915
+			? $this->get_action_link_or_button(
2916
+				'',
2917
+				'buy_now',
2918
+				[],
2919
+				'button-primary button-large',
2920
+				$buy_now_url,
2921
+				true
2922
+			)
2923
+			: $this->_template_args['preview_action_button'];
2924
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2925
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2926
+			$this->_template_args,
2927
+			true
2928
+		);
2929
+		$this->_display_admin_page($display_sidebar);
2930
+	}
2931
+
2932
+
2933
+	/**
2934
+	 * display_admin_list_table_page_with_sidebar
2935
+	 * generates HTML wrapper for an admin_page with list_table
2936
+	 *
2937
+	 * @return void
2938
+	 * @throws EE_Error
2939
+	 * @throws DomainException
2940
+	 */
2941
+	public function display_admin_list_table_page_with_sidebar()
2942
+	{
2943
+		$this->_display_admin_list_table_page(true);
2944
+	}
2945
+
2946
+
2947
+	/**
2948
+	 * display_admin_list_table_page_with_no_sidebar
2949
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2950
+	 *
2951
+	 * @return void
2952
+	 * @throws EE_Error
2953
+	 * @throws DomainException
2954
+	 */
2955
+	public function display_admin_list_table_page_with_no_sidebar()
2956
+	{
2957
+		$this->_display_admin_list_table_page();
2958
+	}
2959
+
2960
+
2961
+	/**
2962
+	 * generates html wrapper for an admin_list_table page
2963
+	 *
2964
+	 * @param boolean $sidebar whether to display with sidebar or not.
2965
+	 * @return void
2966
+	 * @throws DomainException
2967
+	 * @throws EE_Error
2968
+	 */
2969
+	private function _display_admin_list_table_page($sidebar = false)
2970
+	{
2971
+		// setup search attributes
2972
+		$this->_set_search_attributes();
2973
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
2974
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2975
+		$this->_template_args['table_url']        = defined('DOING_AJAX')
2976
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2977
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2978
+		$this->_template_args['list_table']       = $this->_list_table_object;
2979
+		$this->_template_args['current_route']    = $this->_req_action;
2980
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2981
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2982
+		if (! empty($ajax_sorting_callback)) {
2983
+			$sortable_list_table_form_fields = wp_nonce_field(
2984
+				$ajax_sorting_callback . '_nonce',
2985
+				$ajax_sorting_callback . '_nonce',
2986
+				false,
2987
+				false
2988
+			);
2989
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2990
+												. $this->page_slug
2991
+												. '" />';
2992
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2993
+												. $ajax_sorting_callback
2994
+												. '" />';
2995
+		} else {
2996
+			$sortable_list_table_form_fields = '';
2997
+		}
2998
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2999
+		$hidden_form_fields                                      =
3000
+			isset($this->_template_args['list_table_hidden_fields'])
3001
+				? $this->_template_args['list_table_hidden_fields']
3002
+				: '';
3003
+		$nonce_ref                                               = $this->_req_action . '_nonce';
3004
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
3005
+																	. $nonce_ref
3006
+																	. '" value="'
3007
+																	. wp_create_nonce($nonce_ref)
3008
+																	. '">';
3009
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3010
+		// display message about search results?
3011
+		$search = $this->request->getRequestParam('s');
3012
+		$this->_template_args['before_list_table'] .= ! empty($search)
3013
+			? '<p class="ee-search-results">' . sprintf(
3014
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3015
+				trim($search, '%')
3016
+			) . '</p>'
3017
+			: '';
3018
+		// filter before_list_table template arg
3019
+		$this->_template_args['before_list_table'] = apply_filters(
3020
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3021
+			$this->_template_args['before_list_table'],
3022
+			$this->page_slug,
3023
+			$this->request->requestParams(),
3024
+			$this->_req_action
3025
+		);
3026
+		// convert to array and filter again
3027
+		// arrays are easier to inject new items in a specific location,
3028
+		// but would not be backwards compatible, so we have to add a new filter
3029
+		$this->_template_args['before_list_table'] = implode(
3030
+			" \n",
3031
+			(array) apply_filters(
3032
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3033
+				(array) $this->_template_args['before_list_table'],
3034
+				$this->page_slug,
3035
+				$this->request->requestParams(),
3036
+				$this->_req_action
3037
+			)
3038
+		);
3039
+		// filter after_list_table template arg
3040
+		$this->_template_args['after_list_table'] = apply_filters(
3041
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3042
+			$this->_template_args['after_list_table'],
3043
+			$this->page_slug,
3044
+			$this->request->requestParams(),
3045
+			$this->_req_action
3046
+		);
3047
+		// convert to array and filter again
3048
+		// arrays are easier to inject new items in a specific location,
3049
+		// but would not be backwards compatible, so we have to add a new filter
3050
+		$this->_template_args['after_list_table']   = implode(
3051
+			" \n",
3052
+			(array) apply_filters(
3053
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3054
+				(array) $this->_template_args['after_list_table'],
3055
+				$this->page_slug,
3056
+				$this->request->requestParams(),
3057
+				$this->_req_action
3058
+			)
3059
+		);
3060
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3061
+			$template_path,
3062
+			$this->_template_args,
3063
+			true
3064
+		);
3065
+		// the final template wrapper
3066
+		if ($sidebar) {
3067
+			$this->display_admin_page_with_sidebar();
3068
+		} else {
3069
+			$this->display_admin_page_with_no_sidebar();
3070
+		}
3071
+	}
3072
+
3073
+
3074
+	/**
3075
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3076
+	 * html string for the legend.
3077
+	 * $items are expected in an array in the following format:
3078
+	 * $legend_items = array(
3079
+	 *        'item_id' => array(
3080
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3081
+	 *            'desc' => esc_html__('localized description of item');
3082
+	 *        )
3083
+	 * );
3084
+	 *
3085
+	 * @param array $items see above for format of array
3086
+	 * @return string html string of legend
3087
+	 * @throws DomainException
3088
+	 */
3089
+	protected function _display_legend($items)
3090
+	{
3091
+		$this->_template_args['items'] = apply_filters(
3092
+			'FHEE__EE_Admin_Page___display_legend__items',
3093
+			(array) $items,
3094
+			$this
3095
+		);
3096
+		return EEH_Template::display_template(
3097
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3098
+			$this->_template_args,
3099
+			true
3100
+		);
3101
+	}
3102
+
3103
+
3104
+	/**
3105
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3106
+	 * The returned json object is created from an array in the following format:
3107
+	 * array(
3108
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3109
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3110
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3111
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3112
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3113
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3114
+	 *  that might be included in here)
3115
+	 * )
3116
+	 * The json object is populated by whatever is set in the $_template_args property.
3117
+	 *
3118
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3119
+	 *                                 instead of displayed.
3120
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3121
+	 * @return void
3122
+	 * @throws EE_Error
3123
+	 */
3124
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
3125
+	{
3126
+		// make sure any EE_Error notices have been handled.
3127
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3128
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3129
+		unset($this->_template_args['data']);
3130
+		$json = [
3131
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3132
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3133
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3134
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3135
+			'notices'   => EE_Error::get_notices(),
3136
+			'content'   => isset($this->_template_args['admin_page_content'])
3137
+				? $this->_template_args['admin_page_content'] : '',
3138
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3139
+			'isEEajax'  => true
3140
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3141
+		];
3142
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3143
+		if (null === error_get_last() || ! headers_sent()) {
3144
+			header('Content-Type: application/json; charset=UTF-8');
3145
+		}
3146
+		echo wp_json_encode($json);
3147
+		exit();
3148
+	}
3149
+
3150
+
3151
+	/**
3152
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3153
+	 *
3154
+	 * @return void
3155
+	 * @throws EE_Error
3156
+	 */
3157
+	public function return_json()
3158
+	{
3159
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3160
+			$this->_return_json();
3161
+		} else {
3162
+			throw new EE_Error(
3163
+				sprintf(
3164
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3165
+					__FUNCTION__
3166
+				)
3167
+			);
3168
+		}
3169
+	}
3170
+
3171
+
3172
+	/**
3173
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3174
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3175
+	 *
3176
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3177
+	 */
3178
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3179
+	{
3180
+		$this->_hook_obj = $hook_obj;
3181
+	}
3182
+
3183
+
3184
+	/**
3185
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3186
+	 *
3187
+	 * @param boolean $about whether to use the special about page wrapper or default.
3188
+	 * @return void
3189
+	 * @throws DomainException
3190
+	 * @throws EE_Error
3191
+	 */
3192
+	public function admin_page_wrapper($about = false)
3193
+	{
3194
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3195
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3196
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3197
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3198
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3199
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3200
+			isset($this->_template_args['before_admin_page_content'])
3201
+				? $this->_template_args['before_admin_page_content']
3202
+				: ''
3203
+		);
3204
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3205
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3206
+			isset($this->_template_args['after_admin_page_content'])
3207
+				? $this->_template_args['after_admin_page_content']
3208
+				: ''
3209
+		);
3210
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3211
+		// load settings page wrapper template
3212
+		$template_path = ! defined('DOING_AJAX')
3213
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3214
+			: EE_ADMIN_TEMPLATE
3215
+			  . 'admin_wrapper_ajax.template.php';
3216
+		// about page?
3217
+		$template_path = $about
3218
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3219
+			: $template_path;
3220
+		if (defined('DOING_AJAX')) {
3221
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3222
+				$template_path,
3223
+				$this->_template_args,
3224
+				true
3225
+			);
3226
+			$this->_return_json();
3227
+		} else {
3228
+			EEH_Template::display_template($template_path, $this->_template_args);
3229
+		}
3230
+	}
3231
+
3232
+
3233
+	/**
3234
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3235
+	 *
3236
+	 * @return string html
3237
+	 * @throws EE_Error
3238
+	 */
3239
+	protected function _get_main_nav_tabs()
3240
+	{
3241
+		// let's generate the html using the EEH_Tabbed_Content helper.
3242
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3243
+		// (rather than setting in the page_routes array)
3244
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3245
+	}
3246
+
3247
+
3248
+	/**
3249
+	 *        sort nav tabs
3250
+	 *
3251
+	 * @param $a
3252
+	 * @param $b
3253
+	 * @return int
3254
+	 */
3255
+	private function _sort_nav_tabs($a, $b)
3256
+	{
3257
+		if ($a['order'] === $b['order']) {
3258
+			return 0;
3259
+		}
3260
+		return ($a['order'] < $b['order']) ? -1 : 1;
3261
+	}
3262
+
3263
+
3264
+	/**
3265
+	 *    generates HTML for the forms used on admin pages
3266
+	 *
3267
+	 * @param array  $input_vars   - array of input field details
3268
+	 * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3269
+	 *                             use)
3270
+	 * @param bool   $id
3271
+	 * @return string
3272
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3273
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3274
+	 */
3275
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3276
+	{
3277
+		$content = $generator === 'string'
3278
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3279
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3280
+		return $content;
3281
+	}
3282
+
3283
+
3284
+	/**
3285
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3286
+	 *
3287
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3288
+	 *                                   Close" button.
3289
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3290
+	 *                                   'Save', [1] => 'save & close')
3291
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3292
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3293
+	 *                                   default actions by submitting some other value.
3294
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3295
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3296
+	 *                                   close (normal form handling).
3297
+	 */
3298
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3299
+	{
3300
+		// make sure $text and $actions are in an array
3301
+		$text          = (array) $text;
3302
+		$actions       = (array) $actions;
3303
+		$referrer_url  = empty($referrer)
3304
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3305
+			  . $this->request->getServerParam('REQUEST_URI')
3306
+			  . '" />'
3307
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3308
+			  . $referrer
3309
+			  . '" />';
3310
+		$button_text   = ! empty($text)
3311
+			? $text
3312
+			: [
3313
+				esc_html__('Save', 'event_espresso'),
3314
+				esc_html__('Save and Close', 'event_espresso'),
3315
+			];
3316
+		$default_names = ['save', 'save_and_close'];
3317
+		// add in a hidden index for the current page (so save and close redirects properly)
3318
+		$this->_template_args['save_buttons'] = $referrer_url;
3319
+		foreach ($button_text as $key => $button) {
3320
+			$ref                                  = $default_names[ $key ];
3321
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3322
+													 . $ref
3323
+													 . '" value="'
3324
+													 . $button
3325
+													 . '" name="'
3326
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3327
+													 . '" id="'
3328
+													 . $this->_current_view . '_' . $ref
3329
+													 . '" />';
3330
+			if (! $both) {
3331
+				break;
3332
+			}
3333
+		}
3334
+	}
3335
+
3336
+
3337
+	/**
3338
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3339
+	 *
3340
+	 * @param string $route
3341
+	 * @param array  $additional_hidden_fields
3342
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3343
+	 * @since 4.6.0
3344
+	 */
3345
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3346
+	{
3347
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3348
+	}
3349
+
3350
+
3351
+	/**
3352
+	 * set form open and close tags on add/edit pages.
3353
+	 *
3354
+	 * @param string $route                    the route you want the form to direct to
3355
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3356
+	 * @return void
3357
+	 */
3358
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3359
+	{
3360
+		if (empty($route)) {
3361
+			$user_msg = esc_html__(
3362
+				'An error occurred. No action was set for this page\'s form.',
3363
+				'event_espresso'
3364
+			);
3365
+			$dev_msg  = $user_msg . "\n"
3366
+						. sprintf(
3367
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3368
+							__FUNCTION__,
3369
+							__CLASS__
3370
+						);
3371
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3372
+		}
3373
+		// open form
3374
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3375
+															 . $this->_admin_base_url
3376
+															 . '" id="'
3377
+															 . $route
3378
+															 . '_event_form" >';
3379
+		// add nonce
3380
+		$nonce                                             =
3381
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3382
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3383
+		// add REQUIRED form action
3384
+		$hidden_fields = [
3385
+			'action' => ['type' => 'hidden', 'value' => $route],
3386
+		];
3387
+		// merge arrays
3388
+		$hidden_fields = is_array($additional_hidden_fields)
3389
+			? array_merge($hidden_fields, $additional_hidden_fields)
3390
+			: $hidden_fields;
3391
+		// generate form fields
3392
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3393
+		// add fields to form
3394
+		foreach ((array) $form_fields as $field_name => $form_field) {
3395
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3396
+		}
3397
+		// close form
3398
+		$this->_template_args['after_admin_page_content'] = '</form>';
3399
+	}
3400
+
3401
+
3402
+	/**
3403
+	 * Public Wrapper for _redirect_after_action() method since its
3404
+	 * discovered it would be useful for external code to have access.
3405
+	 *
3406
+	 * @param bool   $success
3407
+	 * @param string $what
3408
+	 * @param string $action_desc
3409
+	 * @param array  $query_args
3410
+	 * @param bool   $override_overwrite
3411
+	 * @throws EE_Error
3412
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3413
+	 * @since 4.5.0
3414
+	 */
3415
+	public function redirect_after_action(
3416
+		$success = false,
3417
+		$what = 'item',
3418
+		$action_desc = 'processed',
3419
+		$query_args = [],
3420
+		$override_overwrite = false
3421
+	) {
3422
+		$this->_redirect_after_action(
3423
+			$success,
3424
+			$what,
3425
+			$action_desc,
3426
+			$query_args,
3427
+			$override_overwrite
3428
+		);
3429
+	}
3430
+
3431
+
3432
+	/**
3433
+	 * Helper method for merging existing request data with the returned redirect url.
3434
+	 *
3435
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3436
+	 * filters are still applied.
3437
+	 *
3438
+	 * @param array $new_route_data
3439
+	 * @return array
3440
+	 */
3441
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3442
+	{
3443
+		foreach ($this->request->requestParams() as $ref => $value) {
3444
+			// unset nonces
3445
+			if (strpos($ref, 'nonce') !== false) {
3446
+				$this->request->unSetRequestParam($ref);
3447
+				continue;
3448
+			}
3449
+			// urlencode values.
3450
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3451
+			$this->request->setRequestParam($ref, $value);
3452
+		}
3453
+		return array_merge($this->request->requestParams(), $new_route_data);
3454
+	}
3455
+
3456
+
3457
+	/**
3458
+	 *    _redirect_after_action
3459
+	 *
3460
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3461
+	 * @param string $what               - what the action was performed on
3462
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3463
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3464
+	 *                                   action is completed
3465
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3466
+	 *                                   override this so that they show.
3467
+	 * @return void
3468
+	 * @throws EE_Error
3469
+	 */
3470
+	protected function _redirect_after_action(
3471
+		$success = 0,
3472
+		$what = 'item',
3473
+		$action_desc = 'processed',
3474
+		$query_args = [],
3475
+		$override_overwrite = false
3476
+	) {
3477
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3478
+		// class name for actions/filters.
3479
+		$classname = get_class($this);
3480
+		// set redirect url.
3481
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3482
+		// otherwise we go with whatever is set as the _admin_base_url
3483
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3484
+		$notices      = EE_Error::get_notices(false);
3485
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3486
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3487
+			EE_Error::overwrite_success();
3488
+		}
3489
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3490
+			// how many records affected ? more than one record ? or just one ?
3491
+			if ($success > 1) {
3492
+				// set plural msg
3493
+				EE_Error::add_success(
3494
+					sprintf(
3495
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3496
+						$what,
3497
+						$action_desc
3498
+					),
3499
+					__FILE__,
3500
+					__FUNCTION__,
3501
+					__LINE__
3502
+				);
3503
+			} elseif ($success === 1) {
3504
+				// set singular msg
3505
+				EE_Error::add_success(
3506
+					sprintf(
3507
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3508
+						$what,
3509
+						$action_desc
3510
+					),
3511
+					__FILE__,
3512
+					__FUNCTION__,
3513
+					__LINE__
3514
+				);
3515
+			}
3516
+		}
3517
+		// check that $query_args isn't something crazy
3518
+		if (! is_array($query_args)) {
3519
+			$query_args = [];
3520
+		}
3521
+		/**
3522
+		 * Allow injecting actions before the query_args are modified for possible different
3523
+		 * redirections on save and close actions
3524
+		 *
3525
+		 * @param array $query_args       The original query_args array coming into the
3526
+		 *                                method.
3527
+		 * @since 4.2.0
3528
+		 */
3529
+		do_action(
3530
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3531
+			$query_args
3532
+		);
3533
+		// calculate where we're going (if we have a "save and close" button pushed)
3534
+
3535
+		if (
3536
+			$this->request->requestParamIsSet('save_and_close')
3537
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3538
+		) {
3539
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3540
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3541
+			// regenerate query args array from referrer URL
3542
+			parse_str($parsed_url['query'], $query_args);
3543
+			// correct page and action will be in the query args now
3544
+			$redirect_url = admin_url('admin.php');
3545
+		}
3546
+		// merge any default query_args set in _default_route_query_args property
3547
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3548
+			$args_to_merge = [];
3549
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3550
+				// is there a wp_referer array in our _default_route_query_args property?
3551
+				if ($query_param === 'wp_referer') {
3552
+					$query_value = (array) $query_value;
3553
+					foreach ($query_value as $reference => $value) {
3554
+						if (strpos($reference, 'nonce') !== false) {
3555
+							continue;
3556
+						}
3557
+						// finally we will override any arguments in the referer with
3558
+						// what might be set on the _default_route_query_args array.
3559
+						if (isset($this->_default_route_query_args[ $reference ])) {
3560
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3561
+						} else {
3562
+							$args_to_merge[ $reference ] = urlencode($value);
3563
+						}
3564
+					}
3565
+					continue;
3566
+				}
3567
+				$args_to_merge[ $query_param ] = $query_value;
3568
+			}
3569
+			// now let's merge these arguments but override with what was specifically sent in to the
3570
+			// redirect.
3571
+			$query_args = array_merge($args_to_merge, $query_args);
3572
+		}
3573
+		$this->_process_notices($query_args);
3574
+		// generate redirect url
3575
+		// if redirecting to anything other than the main page, add a nonce
3576
+		if (isset($query_args['action'])) {
3577
+			// manually generate wp_nonce and merge that with the query vars
3578
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3579
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3580
+		}
3581
+		// we're adding some hooks and filters in here for processing any things just before redirects
3582
+		// (example: an admin page has done an insert or update and we want to run something after that).
3583
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3584
+		$redirect_url = apply_filters(
3585
+			'FHEE_redirect_' . $classname . $this->_req_action,
3586
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3587
+			$query_args
3588
+		);
3589
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3590
+		if (defined('DOING_AJAX')) {
3591
+			$default_data                    = [
3592
+				'close'        => true,
3593
+				'redirect_url' => $redirect_url,
3594
+				'where'        => 'main',
3595
+				'what'         => 'append',
3596
+			];
3597
+			$this->_template_args['success'] = $success;
3598
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3599
+				$default_data,
3600
+				$this->_template_args['data']
3601
+			) : $default_data;
3602
+			$this->_return_json();
3603
+		}
3604
+		wp_safe_redirect($redirect_url);
3605
+		exit();
3606
+	}
3607
+
3608
+
3609
+	/**
3610
+	 * process any notices before redirecting (or returning ajax request)
3611
+	 * This method sets the $this->_template_args['notices'] attribute;
3612
+	 *
3613
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3614
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3615
+	 *                                  page_routes haven't been defined yet.
3616
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3617
+	 *                                  still save a transient for the notice.
3618
+	 * @return void
3619
+	 * @throws EE_Error
3620
+	 */
3621
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3622
+	{
3623
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3624
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3625
+			$notices = EE_Error::get_notices(false);
3626
+			if (empty($this->_template_args['success'])) {
3627
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3628
+			}
3629
+			if (empty($this->_template_args['errors'])) {
3630
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3631
+			}
3632
+			if (empty($this->_template_args['attention'])) {
3633
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3634
+			}
3635
+		}
3636
+		$this->_template_args['notices'] = EE_Error::get_notices();
3637
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3638
+		if (! defined('DOING_AJAX') || $sticky_notices) {
3639
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3640
+			$this->_add_transient(
3641
+				$route,
3642
+				$this->_template_args['notices'],
3643
+				true,
3644
+				$skip_route_verify
3645
+			);
3646
+		}
3647
+	}
3648
+
3649
+
3650
+	/**
3651
+	 * get_action_link_or_button
3652
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3653
+	 *
3654
+	 * @param string $action        use this to indicate which action the url is generated with.
3655
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3656
+	 *                              property.
3657
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3658
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3659
+	 * @param string $base_url      If this is not provided
3660
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3661
+	 *                              Otherwise this value will be used.
3662
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3663
+	 * @return string
3664
+	 * @throws InvalidArgumentException
3665
+	 * @throws InvalidInterfaceException
3666
+	 * @throws InvalidDataTypeException
3667
+	 * @throws EE_Error
3668
+	 */
3669
+	public function get_action_link_or_button(
3670
+		$action,
3671
+		$type = 'add',
3672
+		$extra_request = [],
3673
+		$class = 'button-primary',
3674
+		$base_url = '',
3675
+		$exclude_nonce = false
3676
+	) {
3677
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3678
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3679
+			throw new EE_Error(
3680
+				sprintf(
3681
+					esc_html__(
3682
+						'There is no page route for given action for the button.  This action was given: %s',
3683
+						'event_espresso'
3684
+					),
3685
+					$action
3686
+				)
3687
+			);
3688
+		}
3689
+		if (! isset($this->_labels['buttons'][ $type ])) {
3690
+			throw new EE_Error(
3691
+				sprintf(
3692
+					__(
3693
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3694
+						'event_espresso'
3695
+					),
3696
+					$type
3697
+				)
3698
+			);
3699
+		}
3700
+		// finally check user access for this button.
3701
+		$has_access = $this->check_user_access($action, true);
3702
+		if (! $has_access) {
3703
+			return '';
3704
+		}
3705
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3706
+		$query_args = [
3707
+			'action' => $action,
3708
+		];
3709
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3710
+		if (! empty($extra_request)) {
3711
+			$query_args = array_merge($extra_request, $query_args);
3712
+		}
3713
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3714
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3715
+	}
3716
+
3717
+
3718
+	/**
3719
+	 * _per_page_screen_option
3720
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3721
+	 *
3722
+	 * @return void
3723
+	 * @throws InvalidArgumentException
3724
+	 * @throws InvalidInterfaceException
3725
+	 * @throws InvalidDataTypeException
3726
+	 */
3727
+	protected function _per_page_screen_option()
3728
+	{
3729
+		$option = 'per_page';
3730
+		$args   = [
3731
+			'label'   => apply_filters(
3732
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3733
+				$this->_admin_page_title,
3734
+				$this
3735
+			),
3736
+			'default' => (int) apply_filters(
3737
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3738
+				20
3739
+			),
3740
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3741
+		];
3742
+		// ONLY add the screen option if the user has access to it.
3743
+		if ($this->check_user_access($this->_current_view, true)) {
3744
+			add_screen_option($option, $args);
3745
+		}
3746
+	}
3747
+
3748
+
3749
+	/**
3750
+	 * set_per_page_screen_option
3751
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3752
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3753
+	 * admin_menu.
3754
+	 *
3755
+	 * @return void
3756
+	 */
3757
+	private function _set_per_page_screen_options()
3758
+	{
3759
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3760
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3761
+			if (! $user = wp_get_current_user()) {
3762
+				return;
3763
+			}
3764
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3765
+			if (! $option) {
3766
+				return;
3767
+			}
3768
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3769
+			$map_option = $option;
3770
+			$option     = str_replace('-', '_', $option);
3771
+			switch ($map_option) {
3772
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3773
+					$max_value = apply_filters(
3774
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3775
+						999,
3776
+						$this->_current_page,
3777
+						$this->_current_view
3778
+					);
3779
+					if ($value < 1) {
3780
+						return;
3781
+					}
3782
+					$value = min($value, $max_value);
3783
+					break;
3784
+				default:
3785
+					$value = apply_filters(
3786
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3787
+						false,
3788
+						$option,
3789
+						$value
3790
+					);
3791
+					if (false === $value) {
3792
+						return;
3793
+					}
3794
+					break;
3795
+			}
3796
+			update_user_meta($user->ID, $option, $value);
3797
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3798
+			exit;
3799
+		}
3800
+	}
3801
+
3802
+
3803
+	/**
3804
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3805
+	 *
3806
+	 * @param array $data array that will be assigned to template args.
3807
+	 */
3808
+	public function set_template_args($data)
3809
+	{
3810
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3811
+	}
3812
+
3813
+
3814
+	/**
3815
+	 * This makes available the WP transient system for temporarily moving data between routes
3816
+	 *
3817
+	 * @param string $route             the route that should receive the transient
3818
+	 * @param array  $data              the data that gets sent
3819
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3820
+	 *                                  normal route transient.
3821
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3822
+	 *                                  when we are adding a transient before page_routes have been defined.
3823
+	 * @return void
3824
+	 * @throws EE_Error
3825
+	 */
3826
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3827
+	{
3828
+		$user_id = get_current_user_id();
3829
+		if (! $skip_route_verify) {
3830
+			$this->_verify_route($route);
3831
+		}
3832
+		// now let's set the string for what kind of transient we're setting
3833
+		$transient = $notices
3834
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3835
+			: 'rte_tx_' . $route . '_' . $user_id;
3836
+		$data      = $notices ? ['notices' => $data] : $data;
3837
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3838
+		$existing = is_multisite() && is_network_admin()
3839
+			? get_site_transient($transient)
3840
+			: get_transient($transient);
3841
+		if ($existing) {
3842
+			$data = array_merge((array) $data, (array) $existing);
3843
+		}
3844
+		if (is_multisite() && is_network_admin()) {
3845
+			set_site_transient($transient, $data, 8);
3846
+		} else {
3847
+			set_transient($transient, $data, 8);
3848
+		}
3849
+	}
3850
+
3851
+
3852
+	/**
3853
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3854
+	 *
3855
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3856
+	 * @param string $route
3857
+	 * @return mixed data
3858
+	 */
3859
+	protected function _get_transient($notices = false, $route = '')
3860
+	{
3861
+		$user_id   = get_current_user_id();
3862
+		$route     = ! $route ? $this->_req_action : $route;
3863
+		$transient = $notices
3864
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3865
+			: 'rte_tx_' . $route . '_' . $user_id;
3866
+		$data      = is_multisite() && is_network_admin()
3867
+			? get_site_transient($transient)
3868
+			: get_transient($transient);
3869
+		// delete transient after retrieval (just in case it hasn't expired);
3870
+		if (is_multisite() && is_network_admin()) {
3871
+			delete_site_transient($transient);
3872
+		} else {
3873
+			delete_transient($transient);
3874
+		}
3875
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3876
+	}
3877
+
3878
+
3879
+	/**
3880
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3881
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3882
+	 * default route callback on the EE_Admin page you want it run.)
3883
+	 *
3884
+	 * @return void
3885
+	 */
3886
+	protected function _transient_garbage_collection()
3887
+	{
3888
+		global $wpdb;
3889
+		// retrieve all existing transients
3890
+		$query =
3891
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3892
+		if ($results = $wpdb->get_results($query)) {
3893
+			foreach ($results as $result) {
3894
+				$transient = str_replace('_transient_', '', $result->option_name);
3895
+				get_transient($transient);
3896
+				if (is_multisite() && is_network_admin()) {
3897
+					get_site_transient($transient);
3898
+				}
3899
+			}
3900
+		}
3901
+	}
3902
+
3903
+
3904
+	/**
3905
+	 * get_view
3906
+	 *
3907
+	 * @return string content of _view property
3908
+	 */
3909
+	public function get_view()
3910
+	{
3911
+		return $this->_view;
3912
+	}
3913
+
3914
+
3915
+	/**
3916
+	 * getter for the protected $_views property
3917
+	 *
3918
+	 * @return array
3919
+	 */
3920
+	public function get_views()
3921
+	{
3922
+		return $this->_views;
3923
+	}
3924
+
3925
+
3926
+	/**
3927
+	 * get_current_page
3928
+	 *
3929
+	 * @return string _current_page property value
3930
+	 */
3931
+	public function get_current_page()
3932
+	{
3933
+		return $this->_current_page;
3934
+	}
3935
+
3936
+
3937
+	/**
3938
+	 * get_current_view
3939
+	 *
3940
+	 * @return string _current_view property value
3941
+	 */
3942
+	public function get_current_view()
3943
+	{
3944
+		return $this->_current_view;
3945
+	}
3946
+
3947
+
3948
+	/**
3949
+	 * get_current_screen
3950
+	 *
3951
+	 * @return object The current WP_Screen object
3952
+	 */
3953
+	public function get_current_screen()
3954
+	{
3955
+		return $this->_current_screen;
3956
+	}
3957
+
3958
+
3959
+	/**
3960
+	 * get_current_page_view_url
3961
+	 *
3962
+	 * @return string This returns the url for the current_page_view.
3963
+	 */
3964
+	public function get_current_page_view_url()
3965
+	{
3966
+		return $this->_current_page_view_url;
3967
+	}
3968
+
3969
+
3970
+	/**
3971
+	 * just returns the _req_data property
3972
+	 *
3973
+	 * @return array
3974
+	 */
3975
+	public function get_request_data()
3976
+	{
3977
+		return $this->request->requestParams();
3978
+	}
3979
+
3980
+
3981
+	/**
3982
+	 * returns the _req_data protected property
3983
+	 *
3984
+	 * @return string
3985
+	 */
3986
+	public function get_req_action()
3987
+	{
3988
+		return $this->_req_action;
3989
+	}
3990
+
3991
+
3992
+	/**
3993
+	 * @return bool  value of $_is_caf property
3994
+	 */
3995
+	public function is_caf()
3996
+	{
3997
+		return $this->_is_caf;
3998
+	}
3999
+
4000
+
4001
+	/**
4002
+	 * @return mixed
4003
+	 */
4004
+	public function default_espresso_metaboxes()
4005
+	{
4006
+		return $this->_default_espresso_metaboxes;
4007
+	}
4008
+
4009
+
4010
+	/**
4011
+	 * @return mixed
4012
+	 */
4013
+	public function admin_base_url()
4014
+	{
4015
+		return $this->_admin_base_url;
4016
+	}
4017
+
4018
+
4019
+	/**
4020
+	 * @return mixed
4021
+	 */
4022
+	public function wp_page_slug()
4023
+	{
4024
+		return $this->_wp_page_slug;
4025
+	}
4026
+
4027
+
4028
+	/**
4029
+	 * updates  espresso configuration settings
4030
+	 *
4031
+	 * @param string                   $tab
4032
+	 * @param EE_Config_Base|EE_Config $config
4033
+	 * @param string                   $file file where error occurred
4034
+	 * @param string                   $func function  where error occurred
4035
+	 * @param string                   $line line no where error occurred
4036
+	 * @return boolean
4037
+	 */
4038
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4039
+	{
4040
+		// remove any options that are NOT going to be saved with the config settings.
4041
+		if (isset($config->core->ee_ueip_optin)) {
4042
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4043
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4044
+			update_option('ee_ueip_has_notified', true);
4045
+		}
4046
+		// and save it (note we're also doing the network save here)
4047
+		$net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4048
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4049
+		if ($config_saved && $net_saved) {
4050
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4051
+			return true;
4052
+		}
4053
+		EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4054
+		return false;
4055
+	}
4056
+
4057
+
4058
+	/**
4059
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4060
+	 *
4061
+	 * @return array
4062
+	 */
4063
+	public function get_yes_no_values()
4064
+	{
4065
+		return $this->_yes_no_values;
4066
+	}
4067
+
4068
+
4069
+	protected function _get_dir()
4070
+	{
4071
+		$reflector = new ReflectionClass(get_class($this));
4072
+		return dirname($reflector->getFileName());
4073
+	}
4074
+
4075
+
4076
+	/**
4077
+	 * A helper for getting a "next link".
4078
+	 *
4079
+	 * @param string $url   The url to link to
4080
+	 * @param string $class The class to use.
4081
+	 * @return string
4082
+	 */
4083
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4084
+	{
4085
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4086
+	}
4087
+
4088
+
4089
+	/**
4090
+	 * A helper for getting a "previous link".
4091
+	 *
4092
+	 * @param string $url   The url to link to
4093
+	 * @param string $class The class to use.
4094
+	 * @return string
4095
+	 */
4096
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4097
+	{
4098
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4099
+	}
4100
+
4101
+
4102
+
4103
+
4104
+
4105
+
4106
+
4107
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4108
+
4109
+
4110
+	/**
4111
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4112
+	 * 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
4113
+	 * _req_data array.
4114
+	 *
4115
+	 * @return bool success/fail
4116
+	 * @throws EE_Error
4117
+	 * @throws InvalidArgumentException
4118
+	 * @throws ReflectionException
4119
+	 * @throws InvalidDataTypeException
4120
+	 * @throws InvalidInterfaceException
4121
+	 */
4122
+	protected function _process_resend_registration()
4123
+	{
4124
+		$this->_template_args['success'] = EED_Messages::process_resend($this->request->requestParams());
4125
+		do_action(
4126
+			'AHEE__EE_Admin_Page___process_resend_registration',
4127
+			$this->_template_args['success'],
4128
+			$this->request->requestParams()
4129
+		);
4130
+		return $this->_template_args['success'];
4131
+	}
4132
+
4133
+
4134
+	/**
4135
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4136
+	 *
4137
+	 * @param EE_Payment $payment
4138
+	 * @return bool success/fail
4139
+	 */
4140
+	protected function _process_payment_notification(EE_Payment $payment)
4141
+	{
4142
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4143
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4144
+		$this->_template_args['success'] = apply_filters(
4145
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4146
+			false,
4147
+			$payment
4148
+		);
4149
+		return $this->_template_args['success'];
4150
+	}
4151 4151
 }
Please login to merge, or discard this patch.
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
         $ee_menu_slugs = (array) $ee_menu_slugs;
514 514
         if (
515 515
             ! defined('DOING_AJAX')
516
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
516
+            && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))
517 517
         ) {
518 518
             return;
519 519
         }
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
             ? $route
533 533
             : $req_action;
534 534
         $this->_current_view = $this->_req_action;
535
-        $this->_req_nonce    = $this->_req_action . '_nonce';
535
+        $this->_req_nonce    = $this->_req_action.'_nonce';
536 536
         $this->_define_page_props();
537 537
         $this->_current_page_view_url = add_query_arg(
538 538
             ['page' => $this->_current_page, 'action' => $this->_current_view],
@@ -570,21 +570,21 @@  discard block
 block discarded – undo
570 570
         }
571 571
         // filter routes and page_config so addons can add their stuff. Filtering done per class
572 572
         $this->_page_routes = apply_filters(
573
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
573
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
574 574
             $this->_page_routes,
575 575
             $this
576 576
         );
577 577
         $this->_page_config = apply_filters(
578
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
578
+            'FHEE__'.get_class($this).'__page_setup__page_config',
579 579
             $this->_page_config,
580 580
             $this
581 581
         );
582 582
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
583 583
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
584
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
584
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
585 585
             add_action(
586 586
                 'AHEE__EE_Admin_Page__route_admin_request',
587
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
587
+                [$this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view],
588 588
                 10,
589 589
                 2
590 590
             );
@@ -597,8 +597,8 @@  discard block
 block discarded – undo
597 597
             if ($this->_is_UI_request) {
598 598
                 // admin_init stuff - global, all views for this page class, specific view
599 599
                 add_action('admin_init', [$this, 'admin_init'], 10);
600
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
601
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
600
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
601
+                    add_action('admin_init', [$this, 'admin_init_'.$this->_current_view], 15);
602 602
                 }
603 603
             } else {
604 604
                 // hijack regular WP loading and route admin request immediately
@@ -618,12 +618,12 @@  discard block
 block discarded – undo
618 618
      */
619 619
     private function _do_other_page_hooks()
620 620
     {
621
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
621
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, []);
622 622
         foreach ($registered_pages as $page) {
623 623
             // now let's setup the file name and class that should be present
624 624
             $classname = str_replace('.class.php', '', $page);
625 625
             // autoloaders should take care of loading file
626
-            if (! class_exists($classname)) {
626
+            if ( ! class_exists($classname)) {
627 627
                 $error_msg[] = sprintf(
628 628
                     esc_html__(
629 629
                         'Something went wrong with loading the %s admin hooks page.',
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
                                    ),
641 641
                                    $page,
642 642
                                    '<br />',
643
-                                   '<strong>' . $classname . '</strong>'
643
+                                   '<strong>'.$classname.'</strong>'
644 644
                                );
645 645
                 throw new EE_Error(implode('||', $error_msg));
646 646
             }
@@ -683,13 +683,13 @@  discard block
 block discarded – undo
683 683
         // load admin_notices - global, page class, and view specific
684 684
         add_action('admin_notices', [$this, 'admin_notices_global'], 5);
685 685
         add_action('admin_notices', [$this, 'admin_notices'], 10);
686
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
687
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
686
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
687
+            add_action('admin_notices', [$this, 'admin_notices_'.$this->_current_view], 15);
688 688
         }
689 689
         // load network admin_notices - global, page class, and view specific
690 690
         add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
691
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
692
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
691
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
692
+            add_action('network_admin_notices', [$this, 'network_admin_notices_'.$this->_current_view]);
693 693
         }
694 694
         // this will save any per_page screen options if they are present
695 695
         $this->_set_per_page_screen_options();
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
     protected function _verify_routes()
812 812
     {
813 813
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
814
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
814
+        if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
815 815
             return false;
816 816
         }
817 817
         $this->_route = false;
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
                 $this->_admin_page_title
824 824
             );
825 825
             // developer error msg
826
-            $error_msg .= '||' . $error_msg
826
+            $error_msg .= '||'.$error_msg
827 827
                           . esc_html__(
828 828
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
829 829
                               'event_espresso'
@@ -832,9 +832,9 @@  discard block
 block discarded – undo
832 832
         }
833 833
         // and that the requested page route exists
834 834
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
835
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
836
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
837
-                ? $this->_page_config[ $this->_req_action ] : [];
835
+            $this->_route        = $this->_page_routes[$this->_req_action];
836
+            $this->_route_config = isset($this->_page_config[$this->_req_action])
837
+                ? $this->_page_config[$this->_req_action] : [];
838 838
         } else {
839 839
             // user error msg
840 840
             $error_msg = sprintf(
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
                 $this->_admin_page_title
846 846
             );
847 847
             // developer error msg
848
-            $error_msg .= '||' . $error_msg
848
+            $error_msg .= '||'.$error_msg
849 849
                           . sprintf(
850 850
                               esc_html__(
851 851
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
             throw new EE_Error($error_msg);
857 857
         }
858 858
         // and that a default route exists
859
-        if (! array_key_exists('default', $this->_page_routes)) {
859
+        if ( ! array_key_exists('default', $this->_page_routes)) {
860 860
             // user error msg
861 861
             $error_msg = sprintf(
862 862
                 esc_html__(
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
                 $this->_admin_page_title
867 867
             );
868 868
             // developer error msg
869
-            $error_msg .= '||' . $error_msg
869
+            $error_msg .= '||'.$error_msg
870 870
                           . esc_html__(
871 871
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
872 872
                               'event_espresso'
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
             $this->_admin_page_title
908 908
         );
909 909
         // developer error msg
910
-        $error_msg .= '||' . $error_msg
910
+        $error_msg .= '||'.$error_msg
911 911
                       . sprintf(
912 912
                           esc_html__(
913 913
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
     protected function _verify_nonce($nonce, $nonce_ref)
933 933
     {
934 934
         // verify nonce against expected value
935
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
935
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
936 936
             // these are not the droids you are looking for !!!
937 937
             $msg = sprintf(
938 938
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
                     __CLASS__
950 950
                 );
951 951
             }
952
-            if (! defined('DOING_AJAX')) {
952
+            if ( ! defined('DOING_AJAX')) {
953 953
                 wp_die($msg);
954 954
             }
955 955
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
      */
974 974
     protected function _route_admin_request()
975 975
     {
976
-        if (! $this->_is_UI_request) {
976
+        if ( ! $this->_is_UI_request) {
977 977
             $this->_verify_routes();
978 978
         }
979 979
         $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
         $error_msg = '';
994 994
         // action right before calling route
995 995
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
996
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
996
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
997 997
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
998 998
         }
999 999
         // right before calling the route, let's clean the _wp_http_referer
@@ -1004,7 +1004,7 @@  discard block
 block discarded – undo
1004 1004
                 wp_unslash($this->request->getServerParam('REQUEST_URI'))
1005 1005
             )
1006 1006
         );
1007
-        if (! empty($func)) {
1007
+        if ( ! empty($func)) {
1008 1008
             if (is_array($func)) {
1009 1009
                 list($class, $method) = $func;
1010 1010
             } elseif (strpos($func, '::') !== false) {
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
                 $class  = $this;
1014 1014
                 $method = $func;
1015 1015
             }
1016
-            if (! (is_object($class) && $class === $this)) {
1016
+            if ( ! (is_object($class) && $class === $this)) {
1017 1017
                 // send along this admin page object for access by addons.
1018 1018
                 $args['admin_page_object'] = $this;
1019 1019
             }
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
                     $method
1054 1054
                 );
1055 1055
             }
1056
-            if (! empty($error_msg)) {
1056
+            if ( ! empty($error_msg)) {
1057 1057
                 throw new EE_Error($error_msg);
1058 1058
             }
1059 1059
         }
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
                 if (strpos($key, 'nonce') !== false) {
1138 1138
                     continue;
1139 1139
                 }
1140
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1140
+                $args['wp_referer['.$key.']'] = $value;
1141 1141
             }
1142 1142
         }
1143 1143
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1177,8 +1177,8 @@  discard block
 block discarded – undo
1177 1177
     protected function _add_help_tabs()
1178 1178
     {
1179 1179
         $tour_buttons = '';
1180
-        if (isset($this->_page_config[ $this->_req_action ])) {
1181
-            $config = $this->_page_config[ $this->_req_action ];
1180
+        if (isset($this->_page_config[$this->_req_action])) {
1181
+            $config = $this->_page_config[$this->_req_action];
1182 1182
             // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1183 1183
             // is there a help tour for the current route?  if there is let's setup the tour buttons
1184 1184
             // if (isset($this->_help_tour[ $this->_req_action ])) {
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1202 1202
             if (is_array($config) && isset($config['help_sidebar'])) {
1203 1203
                 // check that the callback given is valid
1204
-                if (! method_exists($this, $config['help_sidebar'])) {
1204
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1205 1205
                     throw new EE_Error(
1206 1206
                         sprintf(
1207 1207
                             esc_html__(
@@ -1214,7 +1214,7 @@  discard block
 block discarded – undo
1214 1214
                     );
1215 1215
                 }
1216 1216
                 $content = apply_filters(
1217
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1217
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1218 1218
                     $this->{$config['help_sidebar']}()
1219 1219
                 );
1220 1220
                 $content .= $tour_buttons; // add help tour buttons.
@@ -1222,27 +1222,27 @@  discard block
 block discarded – undo
1222 1222
                 $this->_current_screen->set_help_sidebar($content);
1223 1223
             }
1224 1224
             // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1225
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1225
+            if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1226 1226
                 $this->_current_screen->set_help_sidebar($tour_buttons);
1227 1227
             }
1228 1228
             // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1229
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1229
+            if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1230 1230
                 $_ht['id']      = $this->page_slug;
1231 1231
                 $_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1232 1232
                 $_ht['content'] = '<p>'
1233 1233
                                   . esc_html__(
1234 1234
                                       'The buttons to the right allow you to start/restart any help tours available for this page',
1235 1235
                                       'event_espresso'
1236
-                                  ) . '</p>';
1236
+                                  ).'</p>';
1237 1237
                 $this->_current_screen->add_help_tab($_ht);
1238 1238
             }
1239
-            if (! isset($config['help_tabs'])) {
1239
+            if ( ! isset($config['help_tabs'])) {
1240 1240
                 return;
1241 1241
             } //no help tabs for this route
1242 1242
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1243 1243
                 // we're here so there ARE help tabs!
1244 1244
                 // make sure we've got what we need
1245
-                if (! isset($cfg['title'])) {
1245
+                if ( ! isset($cfg['title'])) {
1246 1246
                     throw new EE_Error(
1247 1247
                         esc_html__(
1248 1248
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
                         )
1251 1251
                     );
1252 1252
                 }
1253
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1253
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1254 1254
                     throw new EE_Error(
1255 1255
                         esc_html__(
1256 1256
                             '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',
@@ -1259,11 +1259,11 @@  discard block
 block discarded – undo
1259 1259
                     );
1260 1260
                 }
1261 1261
                 // first priority goes to content.
1262
-                if (! empty($cfg['content'])) {
1262
+                if ( ! empty($cfg['content'])) {
1263 1263
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1264 1264
                     // second priority goes to filename
1265
-                } elseif (! empty($cfg['filename'])) {
1266
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1265
+                } elseif ( ! empty($cfg['filename'])) {
1266
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1267 1267
                     // 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)
1268 1268
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1269 1269
                                                              . basename($this->_get_dir())
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
                                                              . $cfg['filename']
1272 1272
                                                              . '.help_tab.php' : $file_path;
1273 1273
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1274
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1274
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1275 1275
                         EE_Error::add_error(
1276 1276
                             sprintf(
1277 1277
                                 esc_html__(
@@ -1318,7 +1318,7 @@  discard block
 block discarded – undo
1318 1318
                     return;
1319 1319
                 }
1320 1320
                 // setup config array for help tab method
1321
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1321
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1322 1322
                 $_ht = [
1323 1323
                     'id'       => $id,
1324 1324
                     'title'    => $cfg['title'],
@@ -1445,8 +1445,8 @@  discard block
 block discarded – undo
1445 1445
             $qtips = (array) $this->_route_config['qtips'];
1446 1446
             // load qtip loader
1447 1447
             $path = [
1448
-                $this->_get_dir() . '/qtips/',
1449
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1448
+                $this->_get_dir().'/qtips/',
1449
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1450 1450
             ];
1451 1451
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1452 1452
         }
@@ -1468,7 +1468,7 @@  discard block
 block discarded – undo
1468 1468
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1469 1469
         $i = 0;
1470 1470
         foreach ($this->_page_config as $slug => $config) {
1471
-            if (! is_array($config) || empty($config['nav'])) {
1471
+            if ( ! is_array($config) || empty($config['nav'])) {
1472 1472
                 continue;
1473 1473
             }
1474 1474
             // no nav tab for this config
@@ -1477,12 +1477,12 @@  discard block
 block discarded – undo
1477 1477
                 // nav tab is only to appear when route requested.
1478 1478
                 continue;
1479 1479
             }
1480
-            if (! $this->check_user_access($slug, true)) {
1480
+            if ( ! $this->check_user_access($slug, true)) {
1481 1481
                 // no nav tab because current user does not have access.
1482 1482
                 continue;
1483 1483
             }
1484
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1485
-            $this->_nav_tabs[ $slug ] = [
1484
+            $css_class                = isset($config['css_class']) ? $config['css_class'].' ' : '';
1485
+            $this->_nav_tabs[$slug] = [
1486 1486
                 'url'       => isset($config['nav']['url'])
1487 1487
                     ? $config['nav']['url']
1488 1488
                     : self::add_query_args_and_nonce(
@@ -1494,14 +1494,14 @@  discard block
 block discarded – undo
1494 1494
                     : ucwords(
1495 1495
                         str_replace('_', ' ', $slug)
1496 1496
                     ),
1497
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1497
+                'css_class' => $this->_req_action === $slug ? $css_class.'nav-tab-active' : $css_class,
1498 1498
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1499 1499
             ];
1500 1500
             $i++;
1501 1501
         }
1502 1502
         // if $this->_nav_tabs is empty then lets set the default
1503 1503
         if (empty($this->_nav_tabs)) {
1504
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1504
+            $this->_nav_tabs[$this->_default_nav_tab_name] = [
1505 1505
                 'url'       => $this->_admin_base_url,
1506 1506
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1507 1507
                 'css_class' => 'nav-tab-active',
@@ -1526,10 +1526,10 @@  discard block
 block discarded – undo
1526 1526
             foreach ($this->_route_config['labels'] as $label => $text) {
1527 1527
                 if (is_array($text)) {
1528 1528
                     foreach ($text as $sublabel => $subtext) {
1529
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1529
+                        $this->_labels[$label][$sublabel] = $subtext;
1530 1530
                     }
1531 1531
                 } else {
1532
-                    $this->_labels[ $label ] = $text;
1532
+                    $this->_labels[$label] = $text;
1533 1533
                 }
1534 1534
             }
1535 1535
         }
@@ -1551,12 +1551,12 @@  discard block
 block discarded – undo
1551 1551
     {
1552 1552
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1553 1553
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1554
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1554
+        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1555 1555
                           && is_array(
1556
-                              $this->_page_routes[ $route_to_check ]
1556
+                              $this->_page_routes[$route_to_check]
1557 1557
                           )
1558
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1559
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1558
+                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1559
+            ? $this->_page_routes[$route_to_check]['capability'] : null;
1560 1560
         if (empty($capability) && empty($route_to_check)) {
1561 1561
             $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1562 1562
                 : $this->_route['capability'];
@@ -1564,7 +1564,7 @@  discard block
 block discarded – undo
1564 1564
             $capability = empty($capability) ? 'manage_options' : $capability;
1565 1565
         }
1566 1566
         $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1567
-        if (! defined('DOING_AJAX')
1567
+        if ( ! defined('DOING_AJAX')
1568 1568
             && (
1569 1569
                 ! function_exists('is_admin')
1570 1570
                 || ! EE_Registry::instance()->CAP->current_user_can(
@@ -1666,7 +1666,7 @@  discard block
 block discarded – undo
1666 1666
     public function admin_footer_global()
1667 1667
     {
1668 1668
         // dialog container for dialog helper
1669
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1669
+        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n";
1670 1670
         $d_cont .= '<div class="ee-notices"></div>';
1671 1671
         $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1672 1672
         $d_cont .= '</div>';
@@ -1677,7 +1677,7 @@  discard block
 block discarded – undo
1677 1677
         //     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1678 1678
         // }
1679 1679
         // current set timezone for timezone js
1680
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1680
+        echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>';
1681 1681
     }
1682 1682
 
1683 1683
 
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
         // loop through the array and setup content
1712 1712
         foreach ($help_array as $trigger => $help) {
1713 1713
             // make sure the array is setup properly
1714
-            if (! isset($help['title']) || ! isset($help['content'])) {
1714
+            if ( ! isset($help['title']) || ! isset($help['content'])) {
1715 1715
                 throw new EE_Error(
1716 1716
                     esc_html__(
1717 1717
                         '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',
@@ -1725,8 +1725,8 @@  discard block
 block discarded – undo
1725 1725
                 'help_popup_title'   => $help['title'],
1726 1726
                 'help_popup_content' => $help['content'],
1727 1727
             ];
1728
-            $content       .= EEH_Template::display_template(
1729
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1728
+            $content .= EEH_Template::display_template(
1729
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1730 1730
                 $template_args,
1731 1731
                 true
1732 1732
             );
@@ -1748,15 +1748,15 @@  discard block
 block discarded – undo
1748 1748
     private function _get_help_content()
1749 1749
     {
1750 1750
         // what is the method we're looking for?
1751
-        $method_name = '_help_popup_content_' . $this->_req_action;
1751
+        $method_name = '_help_popup_content_'.$this->_req_action;
1752 1752
         // if method doesn't exist let's get out.
1753
-        if (! method_exists($this, $method_name)) {
1753
+        if ( ! method_exists($this, $method_name)) {
1754 1754
             return [];
1755 1755
         }
1756 1756
         // k we're good to go let's retrieve the help array
1757 1757
         $help_array = call_user_func([$this, $method_name]);
1758 1758
         // make sure we've got an array!
1759
-        if (! is_array($help_array)) {
1759
+        if ( ! is_array($help_array)) {
1760 1760
             throw new EE_Error(
1761 1761
                 esc_html__(
1762 1762
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1788,15 +1788,15 @@  discard block
 block discarded – undo
1788 1788
         // 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
1789 1789
         $help_array   = $this->_get_help_content();
1790 1790
         $help_content = '';
1791
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1792
-            $help_array[ $trigger_id ] = [
1791
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1792
+            $help_array[$trigger_id] = [
1793 1793
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1794 1794
                 'content' => esc_html__(
1795 1795
                     '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.)',
1796 1796
                     'event_espresso'
1797 1797
                 ),
1798 1798
             ];
1799
-            $help_content              = $this->_set_help_popup_content($help_array, false);
1799
+            $help_content = $this->_set_help_popup_content($help_array, false);
1800 1800
         }
1801 1801
         // let's setup the trigger
1802 1802
         $content = '<a class="ee-dialog" href="?height='
@@ -1864,15 +1864,15 @@  discard block
 block discarded – undo
1864 1864
         // register all styles
1865 1865
         wp_register_style(
1866 1866
             'espresso-ui-theme',
1867
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1867
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1868 1868
             [],
1869 1869
             EVENT_ESPRESSO_VERSION
1870 1870
         );
1871
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1871
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1872 1872
         // helpers styles
1873 1873
         wp_register_style(
1874 1874
             'ee-text-links',
1875
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1875
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css',
1876 1876
             [],
1877 1877
             EVENT_ESPRESSO_VERSION
1878 1878
         );
@@ -1880,21 +1880,21 @@  discard block
 block discarded – undo
1880 1880
         // register all scripts
1881 1881
         wp_register_script(
1882 1882
             'ee-dialog',
1883
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1883
+            EE_ADMIN_URL.'assets/ee-dialog-helper.js',
1884 1884
             ['jquery', 'jquery-ui-draggable'],
1885 1885
             EVENT_ESPRESSO_VERSION,
1886 1886
             true
1887 1887
         );
1888 1888
         wp_register_script(
1889 1889
             'ee_admin_js',
1890
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1890
+            EE_ADMIN_URL.'assets/ee-admin-page.js',
1891 1891
             ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1892 1892
             EVENT_ESPRESSO_VERSION,
1893 1893
             true
1894 1894
         );
1895 1895
         wp_register_script(
1896 1896
             'jquery-ui-timepicker-addon',
1897
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1897
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js',
1898 1898
             ['jquery-ui-datepicker', 'jquery-ui-slider'],
1899 1899
             EVENT_ESPRESSO_VERSION,
1900 1900
             true
@@ -1906,7 +1906,7 @@  discard block
 block discarded – undo
1906 1906
         // script for sorting tables
1907 1907
         wp_register_script(
1908 1908
             'espresso_ajax_table_sorting',
1909
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1909
+            EE_ADMIN_URL.'assets/espresso_ajax_table_sorting.js',
1910 1910
             ['ee_admin_js', 'jquery-ui-sortable'],
1911 1911
             EVENT_ESPRESSO_VERSION,
1912 1912
             true
@@ -1914,7 +1914,7 @@  discard block
 block discarded – undo
1914 1914
         // script for parsing uri's
1915 1915
         wp_register_script(
1916 1916
             'ee-parse-uri',
1917
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1917
+            EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js',
1918 1918
             [],
1919 1919
             EVENT_ESPRESSO_VERSION,
1920 1920
             true
@@ -1922,7 +1922,7 @@  discard block
 block discarded – undo
1922 1922
         // and parsing associative serialized form elements
1923 1923
         wp_register_script(
1924 1924
             'ee-serialize-full-array',
1925
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1925
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js',
1926 1926
             ['jquery'],
1927 1927
             EVENT_ESPRESSO_VERSION,
1928 1928
             true
@@ -1930,28 +1930,28 @@  discard block
 block discarded – undo
1930 1930
         // helpers scripts
1931 1931
         wp_register_script(
1932 1932
             'ee-text-links',
1933
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1933
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js',
1934 1934
             ['jquery'],
1935 1935
             EVENT_ESPRESSO_VERSION,
1936 1936
             true
1937 1937
         );
1938 1938
         wp_register_script(
1939 1939
             'ee-moment-core',
1940
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1940
+            EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js',
1941 1941
             [],
1942 1942
             EVENT_ESPRESSO_VERSION,
1943 1943
             true
1944 1944
         );
1945 1945
         wp_register_script(
1946 1946
             'ee-moment',
1947
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1947
+            EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js',
1948 1948
             ['ee-moment-core'],
1949 1949
             EVENT_ESPRESSO_VERSION,
1950 1950
             true
1951 1951
         );
1952 1952
         wp_register_script(
1953 1953
             'ee-datepicker',
1954
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1954
+            EE_ADMIN_URL.'assets/ee-datepicker.js',
1955 1955
             ['jquery-ui-timepicker-addon', 'ee-moment'],
1956 1956
             EVENT_ESPRESSO_VERSION,
1957 1957
             true
@@ -2087,12 +2087,12 @@  discard block
 block discarded – undo
2087 2087
     protected function _set_list_table()
2088 2088
     {
2089 2089
         // first is this a list_table view?
2090
-        if (! isset($this->_route_config['list_table'])) {
2090
+        if ( ! isset($this->_route_config['list_table'])) {
2091 2091
             return;
2092 2092
         } //not a list_table view so get out.
2093 2093
         // list table functions are per view specific (because some admin pages might have more than one list table!)
2094
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2095
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2094
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
2095
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2096 2096
             // user error msg
2097 2097
             $error_msg = esc_html__(
2098 2098
                 'An error occurred. The requested list table views could not be found.',
@@ -2112,10 +2112,10 @@  discard block
 block discarded – undo
2112 2112
         }
2113 2113
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2114 2114
         $this->_views = apply_filters(
2115
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2115
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
2116 2116
             $this->_views
2117 2117
         );
2118
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2118
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
2119 2119
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2120 2120
         $this->_set_list_table_view();
2121 2121
         $this->_set_list_table_object();
@@ -2150,7 +2150,7 @@  discard block
 block discarded – undo
2150 2150
     protected function _set_list_table_object()
2151 2151
     {
2152 2152
         if (isset($this->_route_config['list_table'])) {
2153
-            if (! class_exists($this->_route_config['list_table'])) {
2153
+            if ( ! class_exists($this->_route_config['list_table'])) {
2154 2154
                 throw new EE_Error(
2155 2155
                     sprintf(
2156 2156
                         esc_html__(
@@ -2188,15 +2188,15 @@  discard block
 block discarded – undo
2188 2188
         foreach ($this->_views as $key => $view) {
2189 2189
             $query_args = [];
2190 2190
             // check for current view
2191
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2191
+            $this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2192 2192
             $query_args['action']                        = $this->_req_action;
2193
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2193
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2194 2194
             $query_args['status']                        = $view['slug'];
2195 2195
             // merge any other arguments sent in.
2196
-            if (isset($extra_query_args[ $view['slug'] ])) {
2197
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2196
+            if (isset($extra_query_args[$view['slug']])) {
2197
+                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2198 2198
             }
2199
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2199
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2200 2200
         }
2201 2201
         return $this->_views;
2202 2202
     }
@@ -2227,14 +2227,14 @@  discard block
 block discarded – undo
2227 2227
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2228 2228
         foreach ($values as $value) {
2229 2229
             if ($value < $max_entries) {
2230
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2230
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2231 2231
                 $entries_per_page_dropdown .= '
2232
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2232
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2233 2233
             }
2234 2234
         }
2235
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2235
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2236 2236
         $entries_per_page_dropdown .= '
2237
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2237
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2238 2238
         $entries_per_page_dropdown .= '
2239 2239
 					</select>
2240 2240
 					entries
@@ -2258,7 +2258,7 @@  discard block
 block discarded – undo
2258 2258
             empty($this->_search_btn_label) ? $this->page_label
2259 2259
                 : $this->_search_btn_label
2260 2260
         );
2261
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2261
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2262 2262
     }
2263 2263
 
2264 2264
 
@@ -2344,7 +2344,7 @@  discard block
 block discarded – undo
2344 2344
             $total_columns                                       = ! empty($screen_columns)
2345 2345
                 ? $screen_columns
2346 2346
                 : $this->_route_config['columns'][1];
2347
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2347
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2348 2348
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2349 2349
             $this->_template_args['screen']                      = $this->_current_screen;
2350 2350
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2389,7 +2389,7 @@  discard block
 block discarded – undo
2389 2389
      */
2390 2390
     protected function _espresso_ratings_request()
2391 2391
     {
2392
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2392
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2393 2393
             return;
2394 2394
         }
2395 2395
         $ratings_box_title = apply_filters(
@@ -2417,7 +2417,7 @@  discard block
 block discarded – undo
2417 2417
     public function espresso_ratings_request()
2418 2418
     {
2419 2419
         EEH_Template::display_template(
2420
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2420
+            EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php',
2421 2421
             []
2422 2422
         );
2423 2423
     }
@@ -2425,22 +2425,22 @@  discard block
 block discarded – undo
2425 2425
 
2426 2426
     public static function cached_rss_display($rss_id, $url)
2427 2427
     {
2428
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2428
+        $loading = '<p class="widget-loading hide-if-no-js">'
2429 2429
                      . __('Loading&#8230;', 'event_espresso')
2430 2430
                      . '</p><p class="hide-if-js">'
2431 2431
                      . esc_html__('This widget requires JavaScript.', 'event_espresso')
2432 2432
                      . '</p>';
2433
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2434
-        $pre       .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2435
-        $post      = '</div>' . "\n";
2436
-        $cache_key = 'ee_rss_' . md5($rss_id);
2433
+        $pre       = '<div class="espresso-rss-display">'."\n\t";
2434
+        $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>';
2435
+        $post      = '</div>'."\n";
2436
+        $cache_key = 'ee_rss_'.md5($rss_id);
2437 2437
         $output    = get_transient($cache_key);
2438 2438
         if ($output !== false) {
2439
-            echo $pre . $output . $post;
2439
+            echo $pre.$output.$post;
2440 2440
             return true;
2441 2441
         }
2442
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2443
-            echo $pre . $loading . $post;
2442
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2443
+            echo $pre.$loading.$post;
2444 2444
             return false;
2445 2445
         }
2446 2446
         ob_start();
@@ -2507,19 +2507,19 @@  discard block
 block discarded – undo
2507 2507
     public function espresso_sponsors_post_box()
2508 2508
     {
2509 2509
         EEH_Template::display_template(
2510
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2510
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2511 2511
         );
2512 2512
     }
2513 2513
 
2514 2514
 
2515 2515
     private function _publish_post_box()
2516 2516
     {
2517
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2517
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2518 2518
         // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2519 2519
         // then we'll use that for the metabox label.
2520 2520
         // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2521
-        if (! empty($this->_labels['publishbox'])) {
2522
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2521
+        if ( ! empty($this->_labels['publishbox'])) {
2522
+            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2523 2523
                 : $this->_labels['publishbox'];
2524 2524
         } else {
2525 2525
             $box_label = esc_html__('Publish', 'event_espresso');
@@ -2548,7 +2548,7 @@  discard block
 block discarded – undo
2548 2548
             ? $this->_template_args['publish_box_extra_content']
2549 2549
             : '';
2550 2550
         echo EEH_Template::display_template(
2551
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2551
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2552 2552
             $this->_template_args,
2553 2553
             true
2554 2554
         );
@@ -2640,18 +2640,18 @@  discard block
 block discarded – undo
2640 2640
             );
2641 2641
         }
2642 2642
         $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2643
-        if (! empty($name) && ! empty($id)) {
2644
-            $hidden_field_arr[ $name ] = [
2643
+        if ( ! empty($name) && ! empty($id)) {
2644
+            $hidden_field_arr[$name] = [
2645 2645
                 'type'  => 'hidden',
2646 2646
                 'value' => $id,
2647 2647
             ];
2648
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2648
+            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2649 2649
         } else {
2650 2650
             $hf = '';
2651 2651
         }
2652 2652
         // add hidden field
2653 2653
         $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2654
-            ? $hf[ $name ]['field']
2654
+            ? $hf[$name]['field']
2655 2655
             : $hf;
2656 2656
     }
2657 2657
 
@@ -2753,7 +2753,7 @@  discard block
 block discarded – undo
2753 2753
         }
2754 2754
         // 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)
2755 2755
         $call_back_func = $create_func
2756
-            ? function ($post, $metabox) {
2756
+            ? function($post, $metabox) {
2757 2757
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2758 2758
                 echo EEH_Template::display_template(
2759 2759
                     $metabox['args']['template_path'],
@@ -2763,7 +2763,7 @@  discard block
 block discarded – undo
2763 2763
             }
2764 2764
             : $callback;
2765 2765
         add_meta_box(
2766
-            str_replace('_', '-', $action) . '-mbox',
2766
+            str_replace('_', '-', $action).'-mbox',
2767 2767
             $title,
2768 2768
             $call_back_func,
2769 2769
             $this->_wp_page_slug,
@@ -2855,9 +2855,9 @@  discard block
 block discarded – undo
2855 2855
             : 'espresso-default-admin';
2856 2856
         $template_path                                     = $sidebar
2857 2857
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2858
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2858
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2859 2859
         if (defined('DOING_AJAX') && DOING_AJAX) {
2860
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2860
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2861 2861
         }
2862 2862
         $template_path                                     = ! empty($this->_column_template_path)
2863 2863
             ? $this->_column_template_path : $template_path;
@@ -2897,11 +2897,11 @@  discard block
 block discarded – undo
2897 2897
     public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2898 2898
     {
2899 2899
         // let's generate a default preview action button if there isn't one already present.
2900
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2900
+        $this->_labels['buttons']['buy_now'] = esc_html__(
2901 2901
             'Upgrade to Event Espresso 4 Right Now',
2902 2902
             'event_espresso'
2903 2903
         );
2904
-        $buy_now_url                                   = add_query_arg(
2904
+        $buy_now_url = add_query_arg(
2905 2905
             [
2906 2906
                 'ee_ver'       => 'ee4',
2907 2907
                 'utm_source'   => 'ee4_plugin_admin',
@@ -2921,8 +2921,8 @@  discard block
 block discarded – undo
2921 2921
                 true
2922 2922
             )
2923 2923
             : $this->_template_args['preview_action_button'];
2924
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2925
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2924
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2925
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2926 2926
             $this->_template_args,
2927 2927
             true
2928 2928
         );
@@ -2971,7 +2971,7 @@  discard block
 block discarded – undo
2971 2971
         // setup search attributes
2972 2972
         $this->_set_search_attributes();
2973 2973
         $this->_template_args['current_page']     = $this->_wp_page_slug;
2974
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2974
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2975 2975
         $this->_template_args['table_url']        = defined('DOING_AJAX')
2976 2976
             ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2977 2977
             : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
@@ -2979,10 +2979,10 @@  discard block
 block discarded – undo
2979 2979
         $this->_template_args['current_route']    = $this->_req_action;
2980 2980
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2981 2981
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2982
-        if (! empty($ajax_sorting_callback)) {
2982
+        if ( ! empty($ajax_sorting_callback)) {
2983 2983
             $sortable_list_table_form_fields = wp_nonce_field(
2984
-                $ajax_sorting_callback . '_nonce',
2985
-                $ajax_sorting_callback . '_nonce',
2984
+                $ajax_sorting_callback.'_nonce',
2985
+                $ajax_sorting_callback.'_nonce',
2986 2986
                 false,
2987 2987
                 false
2988 2988
             );
@@ -3000,20 +3000,20 @@  discard block
 block discarded – undo
3000 3000
             isset($this->_template_args['list_table_hidden_fields'])
3001 3001
                 ? $this->_template_args['list_table_hidden_fields']
3002 3002
                 : '';
3003
-        $nonce_ref                                               = $this->_req_action . '_nonce';
3004
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
3003
+        $nonce_ref = $this->_req_action.'_nonce';
3004
+        $hidden_form_fields .= '<input type="hidden" name="'
3005 3005
                                                                     . $nonce_ref
3006 3006
                                                                     . '" value="'
3007 3007
                                                                     . wp_create_nonce($nonce_ref)
3008 3008
                                                                     . '">';
3009
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3009
+        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3010 3010
         // display message about search results?
3011 3011
         $search = $this->request->getRequestParam('s');
3012 3012
         $this->_template_args['before_list_table'] .= ! empty($search)
3013
-            ? '<p class="ee-search-results">' . sprintf(
3013
+            ? '<p class="ee-search-results">'.sprintf(
3014 3014
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3015 3015
                 trim($search, '%')
3016
-            ) . '</p>'
3016
+            ).'</p>'
3017 3017
             : '';
3018 3018
         // filter before_list_table template arg
3019 3019
         $this->_template_args['before_list_table'] = apply_filters(
@@ -3047,7 +3047,7 @@  discard block
 block discarded – undo
3047 3047
         // convert to array and filter again
3048 3048
         // arrays are easier to inject new items in a specific location,
3049 3049
         // but would not be backwards compatible, so we have to add a new filter
3050
-        $this->_template_args['after_list_table']   = implode(
3050
+        $this->_template_args['after_list_table'] = implode(
3051 3051
             " \n",
3052 3052
             (array) apply_filters(
3053 3053
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
@@ -3094,7 +3094,7 @@  discard block
 block discarded – undo
3094 3094
             $this
3095 3095
         );
3096 3096
         return EEH_Template::display_template(
3097
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3097
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
3098 3098
             $this->_template_args,
3099 3099
             true
3100 3100
         );
@@ -3201,13 +3201,13 @@  discard block
 block discarded – undo
3201 3201
                 ? $this->_template_args['before_admin_page_content']
3202 3202
                 : ''
3203 3203
         );
3204
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3204
+        $this->_template_args['after_admin_page_content'] = apply_filters(
3205 3205
             "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3206 3206
             isset($this->_template_args['after_admin_page_content'])
3207 3207
                 ? $this->_template_args['after_admin_page_content']
3208 3208
                 : ''
3209 3209
         );
3210
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3210
+        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3211 3211
         // load settings page wrapper template
3212 3212
         $template_path = ! defined('DOING_AJAX')
3213 3213
             ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
@@ -3307,7 +3307,7 @@  discard block
 block discarded – undo
3307 3307
             : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3308 3308
               . $referrer
3309 3309
               . '" />';
3310
-        $button_text   = ! empty($text)
3310
+        $button_text = ! empty($text)
3311 3311
             ? $text
3312 3312
             : [
3313 3313
                 esc_html__('Save', 'event_espresso'),
@@ -3317,17 +3317,17 @@  discard block
 block discarded – undo
3317 3317
         // add in a hidden index for the current page (so save and close redirects properly)
3318 3318
         $this->_template_args['save_buttons'] = $referrer_url;
3319 3319
         foreach ($button_text as $key => $button) {
3320
-            $ref                                  = $default_names[ $key ];
3320
+            $ref = $default_names[$key];
3321 3321
             $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3322 3322
                                                      . $ref
3323 3323
                                                      . '" value="'
3324 3324
                                                      . $button
3325 3325
                                                      . '" name="'
3326
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3326
+                                                     . ( ! empty($actions) ? $actions[$key] : $ref)
3327 3327
                                                      . '" id="'
3328
-                                                     . $this->_current_view . '_' . $ref
3328
+                                                     . $this->_current_view.'_'.$ref
3329 3329
                                                      . '" />';
3330
-            if (! $both) {
3330
+            if ( ! $both) {
3331 3331
                 break;
3332 3332
             }
3333 3333
         }
@@ -3362,13 +3362,13 @@  discard block
 block discarded – undo
3362 3362
                 'An error occurred. No action was set for this page\'s form.',
3363 3363
                 'event_espresso'
3364 3364
             );
3365
-            $dev_msg  = $user_msg . "\n"
3365
+            $dev_msg = $user_msg."\n"
3366 3366
                         . sprintf(
3367 3367
                             esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3368 3368
                             __FUNCTION__,
3369 3369
                             __CLASS__
3370 3370
                         );
3371
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3371
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3372 3372
         }
3373 3373
         // open form
3374 3374
         $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
@@ -3377,9 +3377,9 @@  discard block
 block discarded – undo
3377 3377
                                                              . $route
3378 3378
                                                              . '_event_form" >';
3379 3379
         // add nonce
3380
-        $nonce                                             =
3381
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3382
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3380
+        $nonce =
3381
+            wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3382
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3383 3383
         // add REQUIRED form action
3384 3384
         $hidden_fields = [
3385 3385
             'action' => ['type' => 'hidden', 'value' => $route],
@@ -3392,7 +3392,7 @@  discard block
 block discarded – undo
3392 3392
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3393 3393
         // add fields to form
3394 3394
         foreach ((array) $form_fields as $field_name => $form_field) {
3395
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3395
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3396 3396
         }
3397 3397
         // close form
3398 3398
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3483,10 +3483,10 @@  discard block
 block discarded – undo
3483 3483
         $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3484 3484
         $notices      = EE_Error::get_notices(false);
3485 3485
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3486
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3486
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3487 3487
             EE_Error::overwrite_success();
3488 3488
         }
3489
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3489
+        if ( ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3490 3490
             // how many records affected ? more than one record ? or just one ?
3491 3491
             if ($success > 1) {
3492 3492
                 // set plural msg
@@ -3515,7 +3515,7 @@  discard block
 block discarded – undo
3515 3515
             }
3516 3516
         }
3517 3517
         // check that $query_args isn't something crazy
3518
-        if (! is_array($query_args)) {
3518
+        if ( ! is_array($query_args)) {
3519 3519
             $query_args = [];
3520 3520
         }
3521 3521
         /**
@@ -3544,7 +3544,7 @@  discard block
 block discarded – undo
3544 3544
             $redirect_url = admin_url('admin.php');
3545 3545
         }
3546 3546
         // merge any default query_args set in _default_route_query_args property
3547
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3547
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3548 3548
             $args_to_merge = [];
3549 3549
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3550 3550
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3556,15 +3556,15 @@  discard block
 block discarded – undo
3556 3556
                         }
3557 3557
                         // finally we will override any arguments in the referer with
3558 3558
                         // what might be set on the _default_route_query_args array.
3559
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3560
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3559
+                        if (isset($this->_default_route_query_args[$reference])) {
3560
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3561 3561
                         } else {
3562
-                            $args_to_merge[ $reference ] = urlencode($value);
3562
+                            $args_to_merge[$reference] = urlencode($value);
3563 3563
                         }
3564 3564
                     }
3565 3565
                     continue;
3566 3566
                 }
3567
-                $args_to_merge[ $query_param ] = $query_value;
3567
+                $args_to_merge[$query_param] = $query_value;
3568 3568
             }
3569 3569
             // now let's merge these arguments but override with what was specifically sent in to the
3570 3570
             // redirect.
@@ -3576,19 +3576,19 @@  discard block
 block discarded – undo
3576 3576
         if (isset($query_args['action'])) {
3577 3577
             // manually generate wp_nonce and merge that with the query vars
3578 3578
             // becuz the wp_nonce_url function wrecks havoc on some vars
3579
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3579
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3580 3580
         }
3581 3581
         // we're adding some hooks and filters in here for processing any things just before redirects
3582 3582
         // (example: an admin page has done an insert or update and we want to run something after that).
3583
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3583
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3584 3584
         $redirect_url = apply_filters(
3585
-            'FHEE_redirect_' . $classname . $this->_req_action,
3585
+            'FHEE_redirect_'.$classname.$this->_req_action,
3586 3586
             self::add_query_args_and_nonce($query_args, $redirect_url),
3587 3587
             $query_args
3588 3588
         );
3589 3589
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3590 3590
         if (defined('DOING_AJAX')) {
3591
-            $default_data                    = [
3591
+            $default_data = [
3592 3592
                 'close'        => true,
3593 3593
                 'redirect_url' => $redirect_url,
3594 3594
                 'where'        => 'main',
@@ -3635,7 +3635,7 @@  discard block
 block discarded – undo
3635 3635
         }
3636 3636
         $this->_template_args['notices'] = EE_Error::get_notices();
3637 3637
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3638
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3638
+        if ( ! defined('DOING_AJAX') || $sticky_notices) {
3639 3639
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3640 3640
             $this->_add_transient(
3641 3641
                 $route,
@@ -3675,7 +3675,7 @@  discard block
 block discarded – undo
3675 3675
         $exclude_nonce = false
3676 3676
     ) {
3677 3677
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3678
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3678
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3679 3679
             throw new EE_Error(
3680 3680
                 sprintf(
3681 3681
                     esc_html__(
@@ -3686,7 +3686,7 @@  discard block
 block discarded – undo
3686 3686
                 )
3687 3687
             );
3688 3688
         }
3689
-        if (! isset($this->_labels['buttons'][ $type ])) {
3689
+        if ( ! isset($this->_labels['buttons'][$type])) {
3690 3690
             throw new EE_Error(
3691 3691
                 sprintf(
3692 3692
                     __(
@@ -3699,7 +3699,7 @@  discard block
 block discarded – undo
3699 3699
         }
3700 3700
         // finally check user access for this button.
3701 3701
         $has_access = $this->check_user_access($action, true);
3702
-        if (! $has_access) {
3702
+        if ( ! $has_access) {
3703 3703
             return '';
3704 3704
         }
3705 3705
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3707,11 +3707,11 @@  discard block
 block discarded – undo
3707 3707
             'action' => $action,
3708 3708
         ];
3709 3709
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3710
-        if (! empty($extra_request)) {
3710
+        if ( ! empty($extra_request)) {
3711 3711
             $query_args = array_merge($extra_request, $query_args);
3712 3712
         }
3713 3713
         $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3714
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3714
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3715 3715
     }
3716 3716
 
3717 3717
 
@@ -3737,7 +3737,7 @@  discard block
 block discarded – undo
3737 3737
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3738 3738
                 20
3739 3739
             ),
3740
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3740
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3741 3741
         ];
3742 3742
         // ONLY add the screen option if the user has access to it.
3743 3743
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3758,18 +3758,18 @@  discard block
 block discarded – undo
3758 3758
     {
3759 3759
         if ($this->request->requestParamIsSet('wp_screen_options')) {
3760 3760
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3761
-            if (! $user = wp_get_current_user()) {
3761
+            if ( ! $user = wp_get_current_user()) {
3762 3762
                 return;
3763 3763
             }
3764 3764
             $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3765
-            if (! $option) {
3765
+            if ( ! $option) {
3766 3766
                 return;
3767 3767
             }
3768
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3768
+            $value = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3769 3769
             $map_option = $option;
3770 3770
             $option     = str_replace('-', '_', $option);
3771 3771
             switch ($map_option) {
3772
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3772
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3773 3773
                     $max_value = apply_filters(
3774 3774
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3775 3775
                         999,
@@ -3826,13 +3826,13 @@  discard block
 block discarded – undo
3826 3826
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3827 3827
     {
3828 3828
         $user_id = get_current_user_id();
3829
-        if (! $skip_route_verify) {
3829
+        if ( ! $skip_route_verify) {
3830 3830
             $this->_verify_route($route);
3831 3831
         }
3832 3832
         // now let's set the string for what kind of transient we're setting
3833 3833
         $transient = $notices
3834
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3835
-            : 'rte_tx_' . $route . '_' . $user_id;
3834
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3835
+            : 'rte_tx_'.$route.'_'.$user_id;
3836 3836
         $data      = $notices ? ['notices' => $data] : $data;
3837 3837
         // is there already a transient for this route?  If there is then let's ADD to that transient
3838 3838
         $existing = is_multisite() && is_network_admin()
@@ -3861,8 +3861,8 @@  discard block
 block discarded – undo
3861 3861
         $user_id   = get_current_user_id();
3862 3862
         $route     = ! $route ? $this->_req_action : $route;
3863 3863
         $transient = $notices
3864
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3865
-            : 'rte_tx_' . $route . '_' . $user_id;
3864
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3865
+            : 'rte_tx_'.$route.'_'.$user_id;
3866 3866
         $data      = is_multisite() && is_network_admin()
3867 3867
             ? get_site_transient($transient)
3868 3868
             : get_transient($transient);
@@ -4082,7 +4082,7 @@  discard block
 block discarded – undo
4082 4082
      */
4083 4083
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4084 4084
     {
4085
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4085
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4086 4086
     }
4087 4087
 
4088 4088
 
@@ -4095,7 +4095,7 @@  discard block
 block discarded – undo
4095 4095
      */
4096 4096
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4097 4097
     {
4098
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4098
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4099 4099
     }
4100 4100
 
4101 4101
 
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_CPT_Init.core.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -14,44 +14,44 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    public function do_initial_loads()
18
-    {
19
-        // we want to use the corresponding admin page object (but not route it!).
20
-        // To do this we just set _routing to false.
21
-        // That way this page object is being loaded on all pages to make sure we hook into admin properly.
22
-        // But note... we are ONLY doing this if the given page is NOT pages we WANT to load ;)
23
-        // This is important because we have hooks that help redirect custom post type saves
24
-        $page = $this->request->getRequestParam('page');
25
-        if ($page === '' || $page !== $this->_menu_map->menu_slug) {
26
-            $this->_routing = false;
27
-            $this->_initialize_admin_page();
28
-        } else {
29
-            // normal init loads
30
-            $this->_initialize_admin_page();
31
-            // added for 4.1 to completely disable autosave for our pages. This can be removed once we fully enable autosave functionality
32
-            remove_filter('wp_print_scripts', 'wp_just_in_time_script_localization');
33
-            add_filter('wp_print_scripts', array($this, 'wp_just_in_time_script_localization'), 100);
34
-            // end removal of autosave functionality.
35
-        }
36
-    }
17
+	public function do_initial_loads()
18
+	{
19
+		// we want to use the corresponding admin page object (but not route it!).
20
+		// To do this we just set _routing to false.
21
+		// That way this page object is being loaded on all pages to make sure we hook into admin properly.
22
+		// But note... we are ONLY doing this if the given page is NOT pages we WANT to load ;)
23
+		// This is important because we have hooks that help redirect custom post type saves
24
+		$page = $this->request->getRequestParam('page');
25
+		if ($page === '' || $page !== $this->_menu_map->menu_slug) {
26
+			$this->_routing = false;
27
+			$this->_initialize_admin_page();
28
+		} else {
29
+			// normal init loads
30
+			$this->_initialize_admin_page();
31
+			// added for 4.1 to completely disable autosave for our pages. This can be removed once we fully enable autosave functionality
32
+			remove_filter('wp_print_scripts', 'wp_just_in_time_script_localization');
33
+			add_filter('wp_print_scripts', array($this, 'wp_just_in_time_script_localization'), 100);
34
+			// end removal of autosave functionality.
35
+		}
36
+	}
37 37
 
38 38
 
39
-    public function wp_just_in_time_script_localization()
40
-    {
41
-        wp_localize_script(
42
-            'autosave',
43
-            'autosaveL10n',
44
-            array(
45
-                'autosaveInterval' => 172800,
46
-                'savingText'       => __('Saving Draft&#8230;', 'event_espresso'),
47
-                'saveAlert'        => __('The changes you made will be lost if you navigate away from this page.', 'event_espresso'),
48
-            )
49
-        );
50
-    }
39
+	public function wp_just_in_time_script_localization()
40
+	{
41
+		wp_localize_script(
42
+			'autosave',
43
+			'autosaveL10n',
44
+			array(
45
+				'autosaveInterval' => 172800,
46
+				'savingText'       => __('Saving Draft&#8230;', 'event_espresso'),
47
+				'saveAlert'        => __('The changes you made will be lost if you navigate away from this page.', 'event_espresso'),
48
+			)
49
+		);
50
+	}
51 51
 
52 52
 
53
-    public function adjust_post_lock_window($interval)
54
-    {
55
-        return 172800;
56
-    }
53
+	public function adjust_post_lock_window($interval)
54
+	{
55
+		return 172800;
56
+	}
57 57
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin.core.php 2 patches
Indentation   +1029 added lines, -1029 removed lines patch added patch discarded remove patch
@@ -20,492 +20,492 @@  discard block
 block discarded – undo
20 20
 final class EE_Admin implements InterminableInterface
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Admin $_instance
25
-     */
26
-    private static $_instance;
27
-
28
-    /**
29
-     * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
30
-     */
31
-    private $persistent_admin_notice_manager;
32
-
33
-    /**
34
-     * @var LoaderInterface
35
-     */
36
-    protected $loader;
37
-
38
-    /**
39
-     * @var RequestInterface
40
-     */
41
-    protected $request;
42
-
43
-
44
-    /**
45
-     * @param RequestInterface $request
46
-     * @singleton method used to instantiate class object
47
-     * @return EE_Admin
48
-     * @throws EE_Error
49
-     */
50
-    public static function instance(RequestInterface $request = null)
51
-    {
52
-        // check if class object is instantiated
53
-        if (! self::$_instance instanceof EE_Admin) {
54
-            self::$_instance = new self($request);
55
-        }
56
-        return self::$_instance;
57
-    }
58
-
59
-
60
-    /**
61
-     * @return EE_Admin
62
-     * @throws EE_Error
63
-     */
64
-    public static function reset()
65
-    {
66
-        self::$_instance = null;
67
-        $request         = LoaderFactory::getLoader()->getShared(RequestInterface::class);
68
-        return self::instance($request);
69
-    }
70
-
71
-
72
-    /**
73
-     * @param RequestInterface $request
74
-     * @throws EE_Error
75
-     * @throws InvalidDataTypeException
76
-     * @throws InvalidInterfaceException
77
-     * @throws InvalidArgumentException
78
-     */
79
-    protected function __construct(RequestInterface $request)
80
-    {
81
-        $this->request = $request;
82
-        // define global EE_Admin constants
83
-        $this->_define_all_constants();
84
-        // set autoloaders for our admin page classes based on included path information
85
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
86
-        // admin hooks
87
-        add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2);
88
-        add_action('AHEE__EE_System__initialize_last', [$this, 'init']);
89
-        add_action('AHEE__EE_Admin_Page__route_admin_request', [$this, 'route_admin_request'], 100, 2);
90
-        add_action('wp_loaded', [$this, 'wp_loaded'], 100);
91
-        add_action('admin_init', [$this, 'admin_init'], 100);
92
-        add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts'], 20);
93
-        add_action('admin_notices', [$this, 'display_admin_notices'], 10);
94
-        add_action('network_admin_notices', [$this, 'display_admin_notices'], 10);
95
-        add_filter('pre_update_option', [$this, 'check_for_invalid_datetime_formats'], 100, 2);
96
-        add_filter('admin_footer_text', [$this, 'espresso_admin_footer']);
97
-        add_action('load-plugins.php', [$this, 'hookIntoWpPluginsPage']);
98
-        add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2);
99
-        add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2);
100
-        // reset Environment config (we only do this on admin page loads);
101
-        EE_Registry::instance()->CFG->environment->recheck_values();
102
-        do_action('AHEE__EE_Admin__loaded');
103
-    }
104
-
105
-
106
-    /**
107
-     * _define_all_constants
108
-     * define constants that are set globally for all admin pages
109
-     *
110
-     * @return void
111
-     */
112
-    private function _define_all_constants()
113
-    {
114
-        if (! defined('EE_ADMIN_URL')) {
115
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
116
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
117
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/');
118
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
119
-            define('WP_AJAX_URL', admin_url('admin-ajax.php'));
120
-        }
121
-    }
122
-
123
-
124
-    /**
125
-     * filter_plugin_actions - adds links to the Plugins page listing
126
-     *
127
-     * @param array  $links
128
-     * @param string $plugin
129
-     * @return    array
130
-     */
131
-    public function filter_plugin_actions($links, $plugin)
132
-    {
133
-        // set $main_file in stone
134
-        static $main_file;
135
-        // if $main_file is not set yet
136
-        if (! $main_file) {
137
-            $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
138
-        }
139
-        if ($plugin === $main_file) {
140
-            // compare current plugin to this one
141
-            if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
142
-                $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
143
-                                    . ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
144
-                                    . esc_html__('Maintenance Mode Active', 'event_espresso')
145
-                                    . '</a>';
146
-                array_unshift($links, $maintenance_link);
147
-            } else {
148
-                $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
149
-                                     . esc_html__('Settings', 'event_espresso')
150
-                                     . '</a>';
151
-                $events_link       = '<a href="admin.php?page=espresso_events">'
152
-                                     . esc_html__('Events', 'event_espresso')
153
-                                     . '</a>';
154
-                // add before other links
155
-                array_unshift($links, $org_settings_link, $events_link);
156
-            }
157
-        }
158
-        return $links;
159
-    }
160
-
161
-
162
-    /**
163
-     * @deprecated $VID:$
164
-     */
165
-    public function get_request()
166
-    {
167
-    }
168
-
169
-
170
-    /**
171
-     * hide_admin_pages_except_maintenance_mode
172
-     *
173
-     * @param array $admin_page_folder_names
174
-     * @return array
175
-     */
176
-    public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = [])
177
-    {
178
-        return [
179
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance/',
180
-            'about'       => EE_ADMIN_PAGES . 'about/',
181
-            'support'     => EE_ADMIN_PAGES . 'support/',
182
-        ];
183
-    }
184
-
185
-
186
-    /**
187
-     * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
188
-     * EE_Front_Controller's init phases have run
189
-     *
190
-     * @return void
191
-     * @throws EE_Error
192
-     * @throws InvalidArgumentException
193
-     * @throws InvalidDataTypeException
194
-     * @throws InvalidInterfaceException
195
-     * @throws ReflectionException
196
-     * @throws ServiceNotFoundException
197
-     */
198
-    public function init()
199
-    {
200
-        // only enable most of the EE_Admin IF we're not in full maintenance mode
201
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
202
-            $this->initModelsReady();
203
-        }
204
-        // run the admin page factory but ONLY if we are doing an ee admin ajax request
205
-        if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
206
-            try {
207
-                // this loads the controller for the admin pages which will setup routing etc
208
-                EE_Registry::instance()->load_core('Admin_Page_Loader');
209
-            } catch (EE_Error $e) {
210
-                $e->get_error();
211
-            }
212
-        }
213
-        add_filter('content_save_pre', [$this, 'its_eSpresso'], 10, 1);
214
-        // make sure our CPTs and custom taxonomy metaboxes get shown for first time users
215
-        add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10);
216
-        add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10);
217
-        // exclude EE critical pages from all nav menus and wp_list_pages
218
-        add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu'], 10);
219
-    }
220
-
221
-
222
-    /**
223
-     * Gets the loader (and if it wasn't previously set, sets it)
224
-     *
225
-     * @return LoaderInterface
226
-     * @throws InvalidArgumentException
227
-     * @throws InvalidDataTypeException
228
-     * @throws InvalidInterfaceException
229
-     */
230
-    protected function getLoader()
231
-    {
232
-        if (! $this->loader instanceof LoaderInterface) {
233
-            $this->loader = LoaderFactory::getLoader();
234
-        }
235
-        return $this->loader;
236
-    }
237
-
238
-
239
-    /**
240
-     * Method that's fired on admin requests (including admin ajax) but only when the models are usable
241
-     * (ie, the site isn't in maintenance mode)
242
-     *
243
-     * @return void
244
-     * @throws EE_Error
245
-     * @since 4.9.63.p
246
-     */
247
-    protected function initModelsReady()
248
-    {
249
-        // ok so we want to enable the entire admin
250
-        $this->persistent_admin_notice_manager = $this->getLoader()->getShared(
251
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
252
-        );
253
-        /** @var RequestInterface $request */
254
-        $request = $this->getLoader()->getShared(RequestInterface::class);
255
-        $this->persistent_admin_notice_manager->setReturnUrl(
256
-            EE_Admin_Page::add_query_args_and_nonce(
257
-                [
258
-                    'page'   => $request->getRequestParam('page'),
259
-                    'action' => $request->getRequestParam('action'),
260
-                ],
261
-                EE_ADMIN_URL
262
-            )
263
-        );
264
-        $this->maybeSetDatetimeWarningNotice();
265
-        // at a glance dashboard widget
266
-        add_filter('dashboard_glance_items', [$this, 'dashboard_glance_items'], 10);
267
-        // filter for get_edit_post_link used on comments for custom post types
268
-        add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 2);
269
-    }
270
-
271
-
272
-    /**
273
-     *    get_persistent_admin_notices
274
-     *
275
-     * @access    public
276
-     * @return void
277
-     * @throws EE_Error
278
-     * @throws InvalidArgumentException
279
-     * @throws InvalidDataTypeException
280
-     * @throws InvalidInterfaceException
281
-     */
282
-    public function maybeSetDatetimeWarningNotice()
283
-    {
284
-        // add dismissible notice for datetime changes.  Only valid if site does not have a timezone_string set.
285
-        // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
286
-        // with this.  But after enough time (indeterminate at this point) we can just remove this notice.
287
-        // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
288
-        if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
289
-            && ! get_option('timezone_string')
290
-            && EEM_Event::instance()->count() > 0
291
-        ) {
292
-            new PersistentAdminNotice(
293
-                'datetime_fix_notice',
294
-                sprintf(
295
-                    esc_html__(
296
-                        '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
297
-                        'event_espresso'
298
-                    ),
299
-                    '<strong>',
300
-                    '</strong>',
301
-                    '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
302
-                    '</a>',
303
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
304
-                        [
305
-                            'page'   => 'espresso_maintenance_settings',
306
-                            'action' => 'datetime_tools',
307
-                        ],
308
-                        admin_url('admin.php')
309
-                    ) . '">'
310
-                ),
311
-                false,
312
-                'manage_options',
313
-                'datetime_fix_persistent_notice'
314
-            );
315
-        }
316
-    }
317
-
318
-
319
-    /**
320
-     * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
321
-     * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
322
-     * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
323
-     * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
324
-     * normal property on the post_type object.  It's found ONLY in this particular context.
325
-     *
326
-     * @param WP_Post $post_type WP post type object
327
-     * @return WP_Post
328
-     * @throws InvalidArgumentException
329
-     * @throws InvalidDataTypeException
330
-     * @throws InvalidInterfaceException
331
-     */
332
-    public function remove_pages_from_nav_menu($post_type)
333
-    {
334
-        // if this isn't the "pages" post type let's get out
335
-        if ($post_type->name !== 'page') {
336
-            return $post_type;
337
-        }
338
-        $critical_pages            = EE_Registry::instance()->CFG->core->get_critical_pages_array();
339
-        $post_type->_default_query = [
340
-            'post__not_in' => $critical_pages,
341
-        ];
342
-        return $post_type;
343
-    }
344
-
345
-
346
-    /**
347
-     * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
348
-     * metaboxes get shown as well
349
-     *
350
-     * @return void
351
-     */
352
-    public function enable_hidden_ee_nav_menu_metaboxes()
353
-    {
354
-        global $wp_meta_boxes, $pagenow;
355
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
356
-            return;
357
-        }
358
-        $user = wp_get_current_user();
359
-        // has this been done yet?
360
-        if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
361
-            return;
362
-        }
363
-
364
-        $hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
365
-        $initial_meta_boxes = apply_filters(
366
-            'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
367
-            [
368
-                'nav-menu-theme-locations',
369
-                'add-page',
370
-                'add-custom-links',
371
-                'add-category',
372
-                'add-espresso_events',
373
-                'add-espresso_venues',
374
-                'add-espresso_event_categories',
375
-                'add-espresso_venue_categories',
376
-                'add-post-type-post',
377
-                'add-post-type-page',
378
-            ]
379
-        );
380
-
381
-        if (is_array($hidden_meta_boxes)) {
382
-            foreach ($hidden_meta_boxes as $key => $meta_box_id) {
383
-                if (in_array($meta_box_id, $initial_meta_boxes, true)) {
384
-                    unset($hidden_meta_boxes[ $key ]);
385
-                }
386
-            }
387
-        }
388
-        update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
389
-        update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
390
-    }
391
-
392
-
393
-    /**
394
-     * This method simply registers custom nav menu boxes for "nav_menus.php route"
395
-     * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
396
-     *
397
-     * @return void
398
-     * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
399
-     *         addons etc.
400
-     */
401
-    public function register_custom_nav_menu_boxes()
402
-    {
403
-        add_meta_box(
404
-            'add-extra-nav-menu-pages',
405
-            esc_html__('Event Espresso Pages', 'event_espresso'),
406
-            [$this, 'ee_cpt_archive_pages'],
407
-            'nav-menus',
408
-            'side',
409
-            'core'
410
-        );
411
-    }
412
-
413
-
414
-    /**
415
-     * Use this to edit the post link for our cpts so that the edit link points to the correct page.
416
-     *
417
-     * @param string $link the original link generated by wp
418
-     * @param int    $id   post id
419
-     * @return string  the (maybe) modified link
420
-     * @since   4.3.0
421
-     */
422
-    public function modify_edit_post_link($link, $id)
423
-    {
424
-        if (! $post = get_post($id)) {
425
-            return $link;
426
-        }
427
-        if ($post->post_type === 'espresso_attendees') {
428
-            $query_args = [
429
-                'action' => 'edit_attendee',
430
-                'post'   => $id,
431
-            ];
432
-            return EEH_URL::add_query_args_and_nonce(
433
-                $query_args,
434
-                admin_url('admin.php?page=espresso_registrations')
435
-            );
436
-        }
437
-        return $link;
438
-    }
439
-
440
-
441
-    public function ee_cpt_archive_pages()
442
-    {
443
-        global $nav_menu_selected_id;
444
-        $db_fields    = false;
445
-        $walker       = new Walker_Nav_Menu_Checklist($db_fields);
446
-        $current_tab  = 'event-archives';
447
-        $removed_args = [
448
-            'action',
449
-            'customlink-tab',
450
-            'edit-menu-item',
451
-            'menu-item',
452
-            'page-tab',
453
-            '_wpnonce',
454
-        ];
455
-        ?>
23
+	/**
24
+	 * @var EE_Admin $_instance
25
+	 */
26
+	private static $_instance;
27
+
28
+	/**
29
+	 * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
30
+	 */
31
+	private $persistent_admin_notice_manager;
32
+
33
+	/**
34
+	 * @var LoaderInterface
35
+	 */
36
+	protected $loader;
37
+
38
+	/**
39
+	 * @var RequestInterface
40
+	 */
41
+	protected $request;
42
+
43
+
44
+	/**
45
+	 * @param RequestInterface $request
46
+	 * @singleton method used to instantiate class object
47
+	 * @return EE_Admin
48
+	 * @throws EE_Error
49
+	 */
50
+	public static function instance(RequestInterface $request = null)
51
+	{
52
+		// check if class object is instantiated
53
+		if (! self::$_instance instanceof EE_Admin) {
54
+			self::$_instance = new self($request);
55
+		}
56
+		return self::$_instance;
57
+	}
58
+
59
+
60
+	/**
61
+	 * @return EE_Admin
62
+	 * @throws EE_Error
63
+	 */
64
+	public static function reset()
65
+	{
66
+		self::$_instance = null;
67
+		$request         = LoaderFactory::getLoader()->getShared(RequestInterface::class);
68
+		return self::instance($request);
69
+	}
70
+
71
+
72
+	/**
73
+	 * @param RequestInterface $request
74
+	 * @throws EE_Error
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws InvalidInterfaceException
77
+	 * @throws InvalidArgumentException
78
+	 */
79
+	protected function __construct(RequestInterface $request)
80
+	{
81
+		$this->request = $request;
82
+		// define global EE_Admin constants
83
+		$this->_define_all_constants();
84
+		// set autoloaders for our admin page classes based on included path information
85
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
86
+		// admin hooks
87
+		add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2);
88
+		add_action('AHEE__EE_System__initialize_last', [$this, 'init']);
89
+		add_action('AHEE__EE_Admin_Page__route_admin_request', [$this, 'route_admin_request'], 100, 2);
90
+		add_action('wp_loaded', [$this, 'wp_loaded'], 100);
91
+		add_action('admin_init', [$this, 'admin_init'], 100);
92
+		add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts'], 20);
93
+		add_action('admin_notices', [$this, 'display_admin_notices'], 10);
94
+		add_action('network_admin_notices', [$this, 'display_admin_notices'], 10);
95
+		add_filter('pre_update_option', [$this, 'check_for_invalid_datetime_formats'], 100, 2);
96
+		add_filter('admin_footer_text', [$this, 'espresso_admin_footer']);
97
+		add_action('load-plugins.php', [$this, 'hookIntoWpPluginsPage']);
98
+		add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2);
99
+		add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2);
100
+		// reset Environment config (we only do this on admin page loads);
101
+		EE_Registry::instance()->CFG->environment->recheck_values();
102
+		do_action('AHEE__EE_Admin__loaded');
103
+	}
104
+
105
+
106
+	/**
107
+	 * _define_all_constants
108
+	 * define constants that are set globally for all admin pages
109
+	 *
110
+	 * @return void
111
+	 */
112
+	private function _define_all_constants()
113
+	{
114
+		if (! defined('EE_ADMIN_URL')) {
115
+			define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
116
+			define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
117
+			define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/');
118
+			define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
119
+			define('WP_AJAX_URL', admin_url('admin-ajax.php'));
120
+		}
121
+	}
122
+
123
+
124
+	/**
125
+	 * filter_plugin_actions - adds links to the Plugins page listing
126
+	 *
127
+	 * @param array  $links
128
+	 * @param string $plugin
129
+	 * @return    array
130
+	 */
131
+	public function filter_plugin_actions($links, $plugin)
132
+	{
133
+		// set $main_file in stone
134
+		static $main_file;
135
+		// if $main_file is not set yet
136
+		if (! $main_file) {
137
+			$main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
138
+		}
139
+		if ($plugin === $main_file) {
140
+			// compare current plugin to this one
141
+			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
142
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
143
+									. ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
144
+									. esc_html__('Maintenance Mode Active', 'event_espresso')
145
+									. '</a>';
146
+				array_unshift($links, $maintenance_link);
147
+			} else {
148
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
149
+									 . esc_html__('Settings', 'event_espresso')
150
+									 . '</a>';
151
+				$events_link       = '<a href="admin.php?page=espresso_events">'
152
+									 . esc_html__('Events', 'event_espresso')
153
+									 . '</a>';
154
+				// add before other links
155
+				array_unshift($links, $org_settings_link, $events_link);
156
+			}
157
+		}
158
+		return $links;
159
+	}
160
+
161
+
162
+	/**
163
+	 * @deprecated $VID:$
164
+	 */
165
+	public function get_request()
166
+	{
167
+	}
168
+
169
+
170
+	/**
171
+	 * hide_admin_pages_except_maintenance_mode
172
+	 *
173
+	 * @param array $admin_page_folder_names
174
+	 * @return array
175
+	 */
176
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = [])
177
+	{
178
+		return [
179
+			'maintenance' => EE_ADMIN_PAGES . 'maintenance/',
180
+			'about'       => EE_ADMIN_PAGES . 'about/',
181
+			'support'     => EE_ADMIN_PAGES . 'support/',
182
+		];
183
+	}
184
+
185
+
186
+	/**
187
+	 * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
188
+	 * EE_Front_Controller's init phases have run
189
+	 *
190
+	 * @return void
191
+	 * @throws EE_Error
192
+	 * @throws InvalidArgumentException
193
+	 * @throws InvalidDataTypeException
194
+	 * @throws InvalidInterfaceException
195
+	 * @throws ReflectionException
196
+	 * @throws ServiceNotFoundException
197
+	 */
198
+	public function init()
199
+	{
200
+		// only enable most of the EE_Admin IF we're not in full maintenance mode
201
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
202
+			$this->initModelsReady();
203
+		}
204
+		// run the admin page factory but ONLY if we are doing an ee admin ajax request
205
+		if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
206
+			try {
207
+				// this loads the controller for the admin pages which will setup routing etc
208
+				EE_Registry::instance()->load_core('Admin_Page_Loader');
209
+			} catch (EE_Error $e) {
210
+				$e->get_error();
211
+			}
212
+		}
213
+		add_filter('content_save_pre', [$this, 'its_eSpresso'], 10, 1);
214
+		// make sure our CPTs and custom taxonomy metaboxes get shown for first time users
215
+		add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10);
216
+		add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10);
217
+		// exclude EE critical pages from all nav menus and wp_list_pages
218
+		add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu'], 10);
219
+	}
220
+
221
+
222
+	/**
223
+	 * Gets the loader (and if it wasn't previously set, sets it)
224
+	 *
225
+	 * @return LoaderInterface
226
+	 * @throws InvalidArgumentException
227
+	 * @throws InvalidDataTypeException
228
+	 * @throws InvalidInterfaceException
229
+	 */
230
+	protected function getLoader()
231
+	{
232
+		if (! $this->loader instanceof LoaderInterface) {
233
+			$this->loader = LoaderFactory::getLoader();
234
+		}
235
+		return $this->loader;
236
+	}
237
+
238
+
239
+	/**
240
+	 * Method that's fired on admin requests (including admin ajax) but only when the models are usable
241
+	 * (ie, the site isn't in maintenance mode)
242
+	 *
243
+	 * @return void
244
+	 * @throws EE_Error
245
+	 * @since 4.9.63.p
246
+	 */
247
+	protected function initModelsReady()
248
+	{
249
+		// ok so we want to enable the entire admin
250
+		$this->persistent_admin_notice_manager = $this->getLoader()->getShared(
251
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
252
+		);
253
+		/** @var RequestInterface $request */
254
+		$request = $this->getLoader()->getShared(RequestInterface::class);
255
+		$this->persistent_admin_notice_manager->setReturnUrl(
256
+			EE_Admin_Page::add_query_args_and_nonce(
257
+				[
258
+					'page'   => $request->getRequestParam('page'),
259
+					'action' => $request->getRequestParam('action'),
260
+				],
261
+				EE_ADMIN_URL
262
+			)
263
+		);
264
+		$this->maybeSetDatetimeWarningNotice();
265
+		// at a glance dashboard widget
266
+		add_filter('dashboard_glance_items', [$this, 'dashboard_glance_items'], 10);
267
+		// filter for get_edit_post_link used on comments for custom post types
268
+		add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 2);
269
+	}
270
+
271
+
272
+	/**
273
+	 *    get_persistent_admin_notices
274
+	 *
275
+	 * @access    public
276
+	 * @return void
277
+	 * @throws EE_Error
278
+	 * @throws InvalidArgumentException
279
+	 * @throws InvalidDataTypeException
280
+	 * @throws InvalidInterfaceException
281
+	 */
282
+	public function maybeSetDatetimeWarningNotice()
283
+	{
284
+		// add dismissible notice for datetime changes.  Only valid if site does not have a timezone_string set.
285
+		// @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
286
+		// with this.  But after enough time (indeterminate at this point) we can just remove this notice.
287
+		// this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
288
+		if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
289
+			&& ! get_option('timezone_string')
290
+			&& EEM_Event::instance()->count() > 0
291
+		) {
292
+			new PersistentAdminNotice(
293
+				'datetime_fix_notice',
294
+				sprintf(
295
+					esc_html__(
296
+						'%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
297
+						'event_espresso'
298
+					),
299
+					'<strong>',
300
+					'</strong>',
301
+					'<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
302
+					'</a>',
303
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
304
+						[
305
+							'page'   => 'espresso_maintenance_settings',
306
+							'action' => 'datetime_tools',
307
+						],
308
+						admin_url('admin.php')
309
+					) . '">'
310
+				),
311
+				false,
312
+				'manage_options',
313
+				'datetime_fix_persistent_notice'
314
+			);
315
+		}
316
+	}
317
+
318
+
319
+	/**
320
+	 * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
321
+	 * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
322
+	 * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
323
+	 * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
324
+	 * normal property on the post_type object.  It's found ONLY in this particular context.
325
+	 *
326
+	 * @param WP_Post $post_type WP post type object
327
+	 * @return WP_Post
328
+	 * @throws InvalidArgumentException
329
+	 * @throws InvalidDataTypeException
330
+	 * @throws InvalidInterfaceException
331
+	 */
332
+	public function remove_pages_from_nav_menu($post_type)
333
+	{
334
+		// if this isn't the "pages" post type let's get out
335
+		if ($post_type->name !== 'page') {
336
+			return $post_type;
337
+		}
338
+		$critical_pages            = EE_Registry::instance()->CFG->core->get_critical_pages_array();
339
+		$post_type->_default_query = [
340
+			'post__not_in' => $critical_pages,
341
+		];
342
+		return $post_type;
343
+	}
344
+
345
+
346
+	/**
347
+	 * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
348
+	 * metaboxes get shown as well
349
+	 *
350
+	 * @return void
351
+	 */
352
+	public function enable_hidden_ee_nav_menu_metaboxes()
353
+	{
354
+		global $wp_meta_boxes, $pagenow;
355
+		if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
356
+			return;
357
+		}
358
+		$user = wp_get_current_user();
359
+		// has this been done yet?
360
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
361
+			return;
362
+		}
363
+
364
+		$hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
365
+		$initial_meta_boxes = apply_filters(
366
+			'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
367
+			[
368
+				'nav-menu-theme-locations',
369
+				'add-page',
370
+				'add-custom-links',
371
+				'add-category',
372
+				'add-espresso_events',
373
+				'add-espresso_venues',
374
+				'add-espresso_event_categories',
375
+				'add-espresso_venue_categories',
376
+				'add-post-type-post',
377
+				'add-post-type-page',
378
+			]
379
+		);
380
+
381
+		if (is_array($hidden_meta_boxes)) {
382
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
383
+				if (in_array($meta_box_id, $initial_meta_boxes, true)) {
384
+					unset($hidden_meta_boxes[ $key ]);
385
+				}
386
+			}
387
+		}
388
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
389
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
390
+	}
391
+
392
+
393
+	/**
394
+	 * This method simply registers custom nav menu boxes for "nav_menus.php route"
395
+	 * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
396
+	 *
397
+	 * @return void
398
+	 * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
399
+	 *         addons etc.
400
+	 */
401
+	public function register_custom_nav_menu_boxes()
402
+	{
403
+		add_meta_box(
404
+			'add-extra-nav-menu-pages',
405
+			esc_html__('Event Espresso Pages', 'event_espresso'),
406
+			[$this, 'ee_cpt_archive_pages'],
407
+			'nav-menus',
408
+			'side',
409
+			'core'
410
+		);
411
+	}
412
+
413
+
414
+	/**
415
+	 * Use this to edit the post link for our cpts so that the edit link points to the correct page.
416
+	 *
417
+	 * @param string $link the original link generated by wp
418
+	 * @param int    $id   post id
419
+	 * @return string  the (maybe) modified link
420
+	 * @since   4.3.0
421
+	 */
422
+	public function modify_edit_post_link($link, $id)
423
+	{
424
+		if (! $post = get_post($id)) {
425
+			return $link;
426
+		}
427
+		if ($post->post_type === 'espresso_attendees') {
428
+			$query_args = [
429
+				'action' => 'edit_attendee',
430
+				'post'   => $id,
431
+			];
432
+			return EEH_URL::add_query_args_and_nonce(
433
+				$query_args,
434
+				admin_url('admin.php?page=espresso_registrations')
435
+			);
436
+		}
437
+		return $link;
438
+	}
439
+
440
+
441
+	public function ee_cpt_archive_pages()
442
+	{
443
+		global $nav_menu_selected_id;
444
+		$db_fields    = false;
445
+		$walker       = new Walker_Nav_Menu_Checklist($db_fields);
446
+		$current_tab  = 'event-archives';
447
+		$removed_args = [
448
+			'action',
449
+			'customlink-tab',
450
+			'edit-menu-item',
451
+			'menu-item',
452
+			'page-tab',
453
+			'_wpnonce',
454
+		];
455
+		?>
456 456
         <div id="posttype-extra-nav-menu-pages" class="posttypediv">
457 457
             <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs">
458 458
                 <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>>
459 459
                     <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives"
460 460
                        href="<?php
461
-                       if ($nav_menu_selected_id) {
462
-                           echo esc_url(
463
-                               add_query_arg(
464
-                                   'extra-nav-menu-pages-tab',
465
-                                   'event-archives',
466
-                                   remove_query_arg($removed_args)
467
-                               )
468
-                           );
469
-                       }
470
-                       ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
461
+					   if ($nav_menu_selected_id) {
462
+						   echo esc_url(
463
+							   add_query_arg(
464
+								   'extra-nav-menu-pages-tab',
465
+								   'event-archives',
466
+								   remove_query_arg($removed_args)
467
+							   )
468
+						   );
469
+					   }
470
+					   ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives">
471 471
                         <?php esc_html_e('Event Archive Pages', 'event_espresso'); ?>
472 472
                     </a>
473 473
                 </li>
474 474
             </ul><!-- .posttype-tabs -->
475 475
 
476 476
             <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php
477
-            echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
478
-            ?>">
477
+			echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive');
478
+			?>">
479 479
                 <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear">
480 480
                     <?php
481
-                    $pages          = $this->_get_extra_nav_menu_pages_items();
482
-                    $args['walker'] = $walker;
483
-                    echo walk_nav_menu_tree(
484
-                        array_map(
485
-                            [$this, '_setup_extra_nav_menu_pages_items'],
486
-                            $pages
487
-                        ),
488
-                        0,
489
-                        (object) $args
490
-                    );
491
-                    ?>
481
+					$pages          = $this->_get_extra_nav_menu_pages_items();
482
+					$args['walker'] = $walker;
483
+					echo walk_nav_menu_tree(
484
+						array_map(
485
+							[$this, '_setup_extra_nav_menu_pages_items'],
486
+							$pages
487
+						),
488
+						0,
489
+						(object) $args
490
+					);
491
+					?>
492 492
                 </ul>
493 493
             </div><!-- /.tabs-panel -->
494 494
 
495 495
             <p class="button-controls">
496 496
                 <span class="list-controls">
497 497
                     <a href="<?php
498
-                    echo esc_url(
499
-                        add_query_arg(
500
-                            [
501
-                                'extra-nav-menu-pages-tab' => 'event-archives',
502
-                                'selectall'                => 1,
503
-                            ],
504
-                            remove_query_arg($removed_args)
505
-                        )
506
-                    );
507
-                    ?>#posttype-extra-nav-menu-pages" class="select-all"><?php esc_html_e('Select All',
508
-                                                                                          'event_espresso'); ?></a>
498
+					echo esc_url(
499
+						add_query_arg(
500
+							[
501
+								'extra-nav-menu-pages-tab' => 'event-archives',
502
+								'selectall'                => 1,
503
+							],
504
+							remove_query_arg($removed_args)
505
+						)
506
+					);
507
+					?>#posttype-extra-nav-menu-pages" class="select-all"><?php esc_html_e('Select All',
508
+																						  'event_espresso'); ?></a>
509 509
                 </span>
510 510
                 <span class="add-to-menu">
511 511
                     <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?>
@@ -518,566 +518,566 @@  discard block
 block discarded – undo
518 518
 
519 519
         </div><!-- /.posttypediv -->
520 520
         <?php
521
-    }
522
-
523
-
524
-    /**
525
-     * Returns an array of event archive nav items.
526
-     *
527
-     * @return array
528
-     * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
529
-     *        method we use for getting the extra nav menu items
530
-     */
531
-    private function _get_extra_nav_menu_pages_items()
532
-    {
533
-        $menuitems[] = [
534
-            'title'       => esc_html__('Event List', 'event_espresso'),
535
-            'url'         => get_post_type_archive_link('espresso_events'),
536
-            'description' => esc_html__('Archive page for all events.', 'event_espresso'),
537
-        ];
538
-        return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
539
-    }
540
-
541
-
542
-    /**
543
-     * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
544
-     * the properties and converts it to the menu item object.
545
-     *
546
-     * @param $menu_item_values
547
-     * @return stdClass
548
-     * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
549
-     */
550
-    private function _setup_extra_nav_menu_pages_items($menu_item_values)
551
-    {
552
-        $menu_item = new stdClass();
553
-        $keys      = [
554
-            'ID'               => 0,
555
-            'db_id'            => 0,
556
-            'menu_item_parent' => 0,
557
-            'object_id'        => -1,
558
-            'post_parent'      => 0,
559
-            'type'             => 'custom',
560
-            'object'           => '',
561
-            'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
562
-            'title'            => '',
563
-            'url'              => '',
564
-            'target'           => '',
565
-            'attr_title'       => '',
566
-            'description'      => '',
567
-            'classes'          => [],
568
-            'xfn'              => '',
569
-        ];
570
-
571
-        foreach ($keys as $key => $value) {
572
-            $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
573
-        }
574
-        return $menu_item;
575
-    }
576
-
577
-
578
-    /**
579
-     * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
580
-     * EE_Admin_Page route is called.
581
-     *
582
-     * @return void
583
-     */
584
-    public function route_admin_request()
585
-    {
586
-    }
587
-
588
-
589
-    /**
590
-     * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
591
-     *
592
-     * @return void
593
-     */
594
-    public function wp_loaded()
595
-    {
596
-    }
597
-
598
-
599
-    /**
600
-     * admin_init
601
-     *
602
-     * @return void
603
-     * @throws InvalidArgumentException
604
-     * @throws InvalidDataTypeException
605
-     * @throws InvalidInterfaceException
606
-     */
607
-    public function admin_init()
608
-    {
609
-        /**
610
-         * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
611
-         * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
612
-         * - check if doing post processing.
613
-         * - check if doing post processing of one of EE CPTs
614
-         * - instantiate the corresponding EE CPT model for the post_type being processed.
615
-         */
616
-        $action    = $this->request->getRequestParam('action');
617
-        $post_type = $this->request->getRequestParam('post_type');
618
-        if ($post_type && $action === 'editpost') {
619
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
620
-            $custom_post_types = $this->getLoader()->getShared(
621
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
622
-            );
623
-            $custom_post_types->getCustomPostTypeModels($post_type);
624
-        }
625
-
626
-
627
-        /**
628
-         * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
629
-         * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
630
-         * Pages" tab in the EE General Settings Admin page.
631
-         * This is for user-proofing.
632
-         */
633
-        add_filter('wp_dropdown_pages', [$this, 'modify_dropdown_pages']);
634
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
635
-            $this->adminInitModelsReady();
636
-        }
637
-    }
638
-
639
-
640
-    /**
641
-     * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode)
642
-     */
643
-    protected function adminInitModelsReady()
644
-    {
645
-        if (function_exists('wp_add_privacy_policy_content')) {
646
-            $this->getLoader()->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager');
647
-        }
648
-    }
649
-
650
-
651
-    /**
652
-     * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
653
-     *
654
-     * @param string $output Current output.
655
-     * @return string
656
-     * @throws InvalidArgumentException
657
-     * @throws InvalidDataTypeException
658
-     * @throws InvalidInterfaceException
659
-     */
660
-    public function modify_dropdown_pages($output)
661
-    {
662
-        // get critical pages
663
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
664
-
665
-        // split current output by line break for easier parsing.
666
-        $split_output = explode("\n", $output);
667
-
668
-        // loop through to remove any critical pages from the array.
669
-        foreach ($critical_pages as $page_id) {
670
-            $needle = 'value="' . $page_id . '"';
671
-            foreach ($split_output as $key => $haystack) {
672
-                if (strpos($haystack, $needle) !== false) {
673
-                    unset($split_output[ $key ]);
674
-                }
675
-            }
676
-        }
677
-        // replace output with the new contents
678
-        return implode("\n", $split_output);
679
-    }
680
-
681
-
682
-    /**
683
-     * enqueue all admin scripts that need loaded for admin pages
684
-     *
685
-     * @return void
686
-     */
687
-    public function enqueue_admin_scripts()
688
-    {
689
-        // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
690
-        // Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
691
-        // calls.
692
-        wp_enqueue_script(
693
-            'ee-inject-wp',
694
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
695
-            ['jquery'],
696
-            EVENT_ESPRESSO_VERSION,
697
-            true
698
-        );
699
-        // register cookie script for future dependencies
700
-        wp_register_script(
701
-            'jquery-cookie',
702
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
703
-            ['jquery'],
704
-            '2.1',
705
-            true
706
-        );
707
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
708
-        // joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
709
-        // via: add_filter('FHEE_load_joyride', '__return_true' );
710
-        // if (apply_filters('FHEE_load_joyride', false)) {
711
-        //     // joyride style
712
-        //     wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
713
-        //     wp_register_style(
714
-        //         'ee-joyride-css',
715
-        //         EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
716
-        //         array('joyride-css'),
717
-        //         EVENT_ESPRESSO_VERSION
718
-        //     );
719
-        //     wp_register_script(
720
-        //         'joyride-modernizr',
721
-        //         EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
722
-        //         array(),
723
-        //         '2.1',
724
-        //         true
725
-        //     );
726
-        //     // joyride JS
727
-        //     wp_register_script(
728
-        //         'jquery-joyride',
729
-        //         EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
730
-        //         array('jquery-cookie', 'joyride-modernizr'),
731
-        //         '2.1',
732
-        //         true
733
-        //     );
734
-        //     // wanna go for a joyride?
735
-        //     wp_enqueue_style('ee-joyride-css');
736
-        //     wp_enqueue_script('jquery-joyride');
737
-        // }
738
-    }
739
-
740
-
741
-    /**
742
-     * display_admin_notices
743
-     *
744
-     * @return void
745
-     */
746
-    public function display_admin_notices()
747
-    {
748
-        echo EE_Error::get_notices();
749
-    }
750
-
751
-
752
-    /**
753
-     * @param array $elements
754
-     * @return array
755
-     * @throws EE_Error
756
-     * @throws InvalidArgumentException
757
-     * @throws InvalidDataTypeException
758
-     * @throws InvalidInterfaceException
759
-     */
760
-    public function dashboard_glance_items($elements)
761
-    {
762
-        $elements                        = is_array($elements) ? $elements : [$elements];
763
-        $events                          = EEM_Event::instance()->count();
764
-        $items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
765
-            ['page' => 'espresso_events'],
766
-            admin_url('admin.php')
767
-        );
768
-        $items['events']['text']         = sprintf(
769
-            esc_html(
770
-                _n('%s Event', '%s Events', $events, 'event_espresso')
771
-            ),
772
-            number_format_i18n($events)
773
-        );
774
-        $items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
775
-        $registrations                   = EEM_Registration::instance()->count(
776
-            [
777
-                [
778
-                    'STS_ID' => ['!=', EEM_Registration::status_id_incomplete],
779
-                ],
780
-            ]
781
-        );
782
-        $items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
783
-            ['page' => 'espresso_registrations'],
784
-            admin_url('admin.php')
785
-        );
786
-        $items['registrations']['text']  = sprintf(
787
-            esc_html(
788
-                _n('%s Registration', '%s Registrations', $registrations, 'event_espresso')
789
-            ),
790
-            number_format_i18n($registrations)
791
-        );
792
-        $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
793
-
794
-        $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
795
-
796
-        foreach ($items as $type => $item_properties) {
797
-            $elements[] = sprintf(
798
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
799
-                $item_properties['url'],
800
-                $item_properties['title'],
801
-                $item_properties['text']
802
-            );
803
-        }
804
-        return $elements;
805
-    }
806
-
807
-
808
-    /**
809
-     * check_for_invalid_datetime_formats
810
-     * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
811
-     * their selected format can be parsed by PHP
812
-     *
813
-     * @param    $value
814
-     * @param    $option
815
-     * @return    string
816
-     */
817
-    public function check_for_invalid_datetime_formats($value, $option)
818
-    {
819
-        // check for date_format or time_format
820
-        switch ($option) {
821
-            case 'date_format':
822
-                $date_time_format = $value . ' ' . get_option('time_format');
823
-                break;
824
-            case 'time_format':
825
-                $date_time_format = get_option('date_format') . ' ' . $value;
826
-                break;
827
-            default:
828
-                $date_time_format = false;
829
-        }
830
-        // do we have a date_time format to check ?
831
-        if ($date_time_format) {
832
-            $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
833
-
834
-            if (is_array($error_msg)) {
835
-                $msg = '<p>'
836
-                       . sprintf(
837
-                           esc_html__(
838
-                               'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
839
-                               'event_espresso'
840
-                           ),
841
-                           date($date_time_format),
842
-                           $date_time_format
843
-                       )
844
-                       . '</p><p><ul>';
845
-
846
-
847
-                foreach ($error_msg as $error) {
848
-                    $msg .= '<li>' . $error . '</li>';
849
-                }
850
-
851
-                $msg .= '</ul></p><p>'
852
-                        . sprintf(
853
-                            esc_html__(
854
-                                '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
855
-                                'event_espresso'
856
-                            ),
857
-                            '<span style="color:#D54E21;">',
858
-                            '</span>'
859
-                        )
860
-                        . '</p>';
861
-
862
-                // trigger WP settings error
863
-                add_settings_error(
864
-                    'date_format',
865
-                    'date_format',
866
-                    $msg
867
-                );
868
-
869
-                // set format to something valid
870
-                switch ($option) {
871
-                    case 'date_format':
872
-                        $value = 'F j, Y';
873
-                        break;
874
-                    case 'time_format':
875
-                        $value = 'g:i a';
876
-                        break;
877
-                }
878
-            }
879
-        }
880
-        return $value;
881
-    }
882
-
883
-
884
-    /**
885
-     * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
886
-     *
887
-     * @param $content
888
-     * @return    string
889
-     */
890
-    public function its_eSpresso($content)
891
-    {
892
-        return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
893
-    }
894
-
895
-
896
-    /**
897
-     * espresso_admin_footer
898
-     *
899
-     * @return    string
900
-     */
901
-    public function espresso_admin_footer()
902
-    {
903
-        return EEH_Template::powered_by_event_espresso('aln-cntr', '', ['utm_content' => 'admin_footer']);
904
-    }
905
-
906
-
907
-    /**
908
-     * static method for registering ee admin page.
909
-     * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
910
-     *
911
-     * @param       $page_basename
912
-     * @param       $page_path
913
-     * @param array $config
914
-     * @return void
915
-     * @throws EE_Error
916
-     * @see        EE_Register_Admin_Page::register()
917
-     * @since      4.3.0
918
-     * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
919
-     */
920
-    public static function register_ee_admin_page($page_basename, $page_path, $config = [])
921
-    {
922
-        EE_Error::doing_it_wrong(
923
-            __METHOD__,
924
-            sprintf(
925
-                esc_html__(
926
-                    'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
927
-                    'event_espresso'
928
-                ),
929
-                $page_basename
930
-            ),
931
-            '4.3'
932
-        );
933
-        if (class_exists('EE_Register_Admin_Page')) {
934
-            $config['page_path'] = $page_path;
935
-        }
936
-        EE_Register_Admin_Page::register($page_basename, $config);
937
-    }
938
-
939
-
940
-    /**
941
-     * @param int     $post_ID
942
-     * @param WP_Post $post
943
-     * @return void
944
-     * @deprecated 4.8.41
945
-     */
946
-    public static function parse_post_content_on_save($post_ID, $post)
947
-    {
948
-        EE_Error::doing_it_wrong(
949
-            __METHOD__,
950
-            esc_html__('Usage is deprecated', 'event_espresso'),
951
-            '4.8.41'
952
-        );
953
-    }
954
-
955
-
956
-    /**
957
-     * @param  $option
958
-     * @param  $old_value
959
-     * @param  $value
960
-     * @return void
961
-     * @deprecated 4.8.41
962
-     */
963
-    public function reset_page_for_posts_on_change($option, $old_value, $value)
964
-    {
965
-        EE_Error::doing_it_wrong(
966
-            __METHOD__,
967
-            esc_html__('Usage is deprecated', 'event_espresso'),
968
-            '4.8.41'
969
-        );
970
-    }
971
-
972
-
973
-    /**
974
-     * @return void
975
-     * @deprecated 4.9.27
976
-     */
977
-    public function get_persistent_admin_notices()
978
-    {
979
-        EE_Error::doing_it_wrong(
980
-            __METHOD__,
981
-            sprintf(
982
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
983
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
984
-            ),
985
-            '4.9.27'
986
-        );
987
-    }
988
-
989
-
990
-    /**
991
-     * @throws InvalidInterfaceException
992
-     * @throws InvalidDataTypeException
993
-     * @throws DomainException
994
-     * @deprecated 4.9.27
995
-     */
996
-    public function dismiss_ee_nag_notice_callback()
997
-    {
998
-        EE_Error::doing_it_wrong(
999
-            __METHOD__,
1000
-            sprintf(
1001
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1002
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1003
-            ),
1004
-            '4.9.27'
1005
-        );
1006
-        $this->persistent_admin_notice_manager->dismissNotice();
1007
-    }
1008
-
1009
-
1010
-    /**
1011
-     * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
1012
-     *
1013
-     * @throws InvalidArgumentException
1014
-     * @throws InvalidDataTypeException
1015
-     * @throws InvalidInterfaceException
1016
-     */
1017
-    public function hookIntoWpPluginsPage()
1018
-    {
1019
-        $this->getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal');
1020
-        $this->getLoader()
1021
-             ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
1022
-             ->decafUpsells();
1023
-    }
1024
-
1025
-
1026
-    /**
1027
-     * Hooks into the "post states" filter in a wp post type list table.
1028
-     *
1029
-     * @param array   $post_states
1030
-     * @param WP_Post $post
1031
-     * @return array
1032
-     * @throws InvalidArgumentException
1033
-     * @throws InvalidDataTypeException
1034
-     * @throws InvalidInterfaceException
1035
-     */
1036
-    public function displayStateForCriticalPages($post_states, $post)
1037
-    {
1038
-        $post_states = (array) $post_states;
1039
-        if (! $post instanceof WP_Post || $post->post_type !== 'page') {
1040
-            return $post_states;
1041
-        }
1042
-        /** @var EE_Core_Config $config */
1043
-        $config = $this->getLoader()->getShared('EE_Config')->core;
1044
-        if (in_array($post->ID, $config->get_critical_pages_array(), true)) {
1045
-            $post_states[] = sprintf(
1046
-            /* Translators: Using company name - Event Espresso Critical Page */
1047
-                esc_html__('%s Critical Page', 'event_espresso'),
1048
-                'Event Espresso'
1049
-            );
1050
-        }
1051
-        return $post_states;
1052
-    }
1053
-
1054
-
1055
-    /**
1056
-     * Show documentation links on the plugins page
1057
-     *
1058
-     * @param mixed $meta Plugin Row Meta
1059
-     * @param mixed $file Plugin Base file
1060
-     * @return array
1061
-     */
1062
-    public function addLinksToPluginRowMeta($meta, $file)
1063
-    {
1064
-        if (EE_PLUGIN_BASENAME === $file) {
1065
-            $row_meta = [
1066
-                'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"'
1067
-                          . ' aria-label="'
1068
-                          . esc_attr__('View Event Espresso documentation', 'event_espresso')
1069
-                          . '">'
1070
-                          . esc_html__('Docs', 'event_espresso')
1071
-                          . '</a>',
1072
-                'api'  => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"'
1073
-                          . ' aria-label="'
1074
-                          . esc_attr__('View Event Espresso API docs', 'event_espresso')
1075
-                          . '">'
1076
-                          . esc_html__('API docs', 'event_espresso')
1077
-                          . '</a>',
1078
-            ];
1079
-            return array_merge($meta, $row_meta);
1080
-        }
1081
-        return (array) $meta;
1082
-    }
521
+	}
522
+
523
+
524
+	/**
525
+	 * Returns an array of event archive nav items.
526
+	 *
527
+	 * @return array
528
+	 * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
529
+	 *        method we use for getting the extra nav menu items
530
+	 */
531
+	private function _get_extra_nav_menu_pages_items()
532
+	{
533
+		$menuitems[] = [
534
+			'title'       => esc_html__('Event List', 'event_espresso'),
535
+			'url'         => get_post_type_archive_link('espresso_events'),
536
+			'description' => esc_html__('Archive page for all events.', 'event_espresso'),
537
+		];
538
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
539
+	}
540
+
541
+
542
+	/**
543
+	 * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
544
+	 * the properties and converts it to the menu item object.
545
+	 *
546
+	 * @param $menu_item_values
547
+	 * @return stdClass
548
+	 * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
549
+	 */
550
+	private function _setup_extra_nav_menu_pages_items($menu_item_values)
551
+	{
552
+		$menu_item = new stdClass();
553
+		$keys      = [
554
+			'ID'               => 0,
555
+			'db_id'            => 0,
556
+			'menu_item_parent' => 0,
557
+			'object_id'        => -1,
558
+			'post_parent'      => 0,
559
+			'type'             => 'custom',
560
+			'object'           => '',
561
+			'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
562
+			'title'            => '',
563
+			'url'              => '',
564
+			'target'           => '',
565
+			'attr_title'       => '',
566
+			'description'      => '',
567
+			'classes'          => [],
568
+			'xfn'              => '',
569
+		];
570
+
571
+		foreach ($keys as $key => $value) {
572
+			$menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
573
+		}
574
+		return $menu_item;
575
+	}
576
+
577
+
578
+	/**
579
+	 * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
580
+	 * EE_Admin_Page route is called.
581
+	 *
582
+	 * @return void
583
+	 */
584
+	public function route_admin_request()
585
+	{
586
+	}
587
+
588
+
589
+	/**
590
+	 * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
591
+	 *
592
+	 * @return void
593
+	 */
594
+	public function wp_loaded()
595
+	{
596
+	}
597
+
598
+
599
+	/**
600
+	 * admin_init
601
+	 *
602
+	 * @return void
603
+	 * @throws InvalidArgumentException
604
+	 * @throws InvalidDataTypeException
605
+	 * @throws InvalidInterfaceException
606
+	 */
607
+	public function admin_init()
608
+	{
609
+		/**
610
+		 * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
611
+		 * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
612
+		 * - check if doing post processing.
613
+		 * - check if doing post processing of one of EE CPTs
614
+		 * - instantiate the corresponding EE CPT model for the post_type being processed.
615
+		 */
616
+		$action    = $this->request->getRequestParam('action');
617
+		$post_type = $this->request->getRequestParam('post_type');
618
+		if ($post_type && $action === 'editpost') {
619
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
620
+			$custom_post_types = $this->getLoader()->getShared(
621
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
622
+			);
623
+			$custom_post_types->getCustomPostTypeModels($post_type);
624
+		}
625
+
626
+
627
+		/**
628
+		 * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
629
+		 * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
630
+		 * Pages" tab in the EE General Settings Admin page.
631
+		 * This is for user-proofing.
632
+		 */
633
+		add_filter('wp_dropdown_pages', [$this, 'modify_dropdown_pages']);
634
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
635
+			$this->adminInitModelsReady();
636
+		}
637
+	}
638
+
639
+
640
+	/**
641
+	 * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode)
642
+	 */
643
+	protected function adminInitModelsReady()
644
+	{
645
+		if (function_exists('wp_add_privacy_policy_content')) {
646
+			$this->getLoader()->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager');
647
+		}
648
+	}
649
+
650
+
651
+	/**
652
+	 * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
653
+	 *
654
+	 * @param string $output Current output.
655
+	 * @return string
656
+	 * @throws InvalidArgumentException
657
+	 * @throws InvalidDataTypeException
658
+	 * @throws InvalidInterfaceException
659
+	 */
660
+	public function modify_dropdown_pages($output)
661
+	{
662
+		// get critical pages
663
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
664
+
665
+		// split current output by line break for easier parsing.
666
+		$split_output = explode("\n", $output);
667
+
668
+		// loop through to remove any critical pages from the array.
669
+		foreach ($critical_pages as $page_id) {
670
+			$needle = 'value="' . $page_id . '"';
671
+			foreach ($split_output as $key => $haystack) {
672
+				if (strpos($haystack, $needle) !== false) {
673
+					unset($split_output[ $key ]);
674
+				}
675
+			}
676
+		}
677
+		// replace output with the new contents
678
+		return implode("\n", $split_output);
679
+	}
680
+
681
+
682
+	/**
683
+	 * enqueue all admin scripts that need loaded for admin pages
684
+	 *
685
+	 * @return void
686
+	 */
687
+	public function enqueue_admin_scripts()
688
+	{
689
+		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
690
+		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
691
+		// calls.
692
+		wp_enqueue_script(
693
+			'ee-inject-wp',
694
+			EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
695
+			['jquery'],
696
+			EVENT_ESPRESSO_VERSION,
697
+			true
698
+		);
699
+		// register cookie script for future dependencies
700
+		wp_register_script(
701
+			'jquery-cookie',
702
+			EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
703
+			['jquery'],
704
+			'2.1',
705
+			true
706
+		);
707
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
708
+		// joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
709
+		// via: add_filter('FHEE_load_joyride', '__return_true' );
710
+		// if (apply_filters('FHEE_load_joyride', false)) {
711
+		//     // joyride style
712
+		//     wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
713
+		//     wp_register_style(
714
+		//         'ee-joyride-css',
715
+		//         EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
716
+		//         array('joyride-css'),
717
+		//         EVENT_ESPRESSO_VERSION
718
+		//     );
719
+		//     wp_register_script(
720
+		//         'joyride-modernizr',
721
+		//         EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
722
+		//         array(),
723
+		//         '2.1',
724
+		//         true
725
+		//     );
726
+		//     // joyride JS
727
+		//     wp_register_script(
728
+		//         'jquery-joyride',
729
+		//         EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
730
+		//         array('jquery-cookie', 'joyride-modernizr'),
731
+		//         '2.1',
732
+		//         true
733
+		//     );
734
+		//     // wanna go for a joyride?
735
+		//     wp_enqueue_style('ee-joyride-css');
736
+		//     wp_enqueue_script('jquery-joyride');
737
+		// }
738
+	}
739
+
740
+
741
+	/**
742
+	 * display_admin_notices
743
+	 *
744
+	 * @return void
745
+	 */
746
+	public function display_admin_notices()
747
+	{
748
+		echo EE_Error::get_notices();
749
+	}
750
+
751
+
752
+	/**
753
+	 * @param array $elements
754
+	 * @return array
755
+	 * @throws EE_Error
756
+	 * @throws InvalidArgumentException
757
+	 * @throws InvalidDataTypeException
758
+	 * @throws InvalidInterfaceException
759
+	 */
760
+	public function dashboard_glance_items($elements)
761
+	{
762
+		$elements                        = is_array($elements) ? $elements : [$elements];
763
+		$events                          = EEM_Event::instance()->count();
764
+		$items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
765
+			['page' => 'espresso_events'],
766
+			admin_url('admin.php')
767
+		);
768
+		$items['events']['text']         = sprintf(
769
+			esc_html(
770
+				_n('%s Event', '%s Events', $events, 'event_espresso')
771
+			),
772
+			number_format_i18n($events)
773
+		);
774
+		$items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
775
+		$registrations                   = EEM_Registration::instance()->count(
776
+			[
777
+				[
778
+					'STS_ID' => ['!=', EEM_Registration::status_id_incomplete],
779
+				],
780
+			]
781
+		);
782
+		$items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
783
+			['page' => 'espresso_registrations'],
784
+			admin_url('admin.php')
785
+		);
786
+		$items['registrations']['text']  = sprintf(
787
+			esc_html(
788
+				_n('%s Registration', '%s Registrations', $registrations, 'event_espresso')
789
+			),
790
+			number_format_i18n($registrations)
791
+		);
792
+		$items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
793
+
794
+		$items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
795
+
796
+		foreach ($items as $type => $item_properties) {
797
+			$elements[] = sprintf(
798
+				'<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
799
+				$item_properties['url'],
800
+				$item_properties['title'],
801
+				$item_properties['text']
802
+			);
803
+		}
804
+		return $elements;
805
+	}
806
+
807
+
808
+	/**
809
+	 * check_for_invalid_datetime_formats
810
+	 * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
811
+	 * their selected format can be parsed by PHP
812
+	 *
813
+	 * @param    $value
814
+	 * @param    $option
815
+	 * @return    string
816
+	 */
817
+	public function check_for_invalid_datetime_formats($value, $option)
818
+	{
819
+		// check for date_format or time_format
820
+		switch ($option) {
821
+			case 'date_format':
822
+				$date_time_format = $value . ' ' . get_option('time_format');
823
+				break;
824
+			case 'time_format':
825
+				$date_time_format = get_option('date_format') . ' ' . $value;
826
+				break;
827
+			default:
828
+				$date_time_format = false;
829
+		}
830
+		// do we have a date_time format to check ?
831
+		if ($date_time_format) {
832
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
833
+
834
+			if (is_array($error_msg)) {
835
+				$msg = '<p>'
836
+					   . sprintf(
837
+						   esc_html__(
838
+							   'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
839
+							   'event_espresso'
840
+						   ),
841
+						   date($date_time_format),
842
+						   $date_time_format
843
+					   )
844
+					   . '</p><p><ul>';
845
+
846
+
847
+				foreach ($error_msg as $error) {
848
+					$msg .= '<li>' . $error . '</li>';
849
+				}
850
+
851
+				$msg .= '</ul></p><p>'
852
+						. sprintf(
853
+							esc_html__(
854
+								'%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
855
+								'event_espresso'
856
+							),
857
+							'<span style="color:#D54E21;">',
858
+							'</span>'
859
+						)
860
+						. '</p>';
861
+
862
+				// trigger WP settings error
863
+				add_settings_error(
864
+					'date_format',
865
+					'date_format',
866
+					$msg
867
+				);
868
+
869
+				// set format to something valid
870
+				switch ($option) {
871
+					case 'date_format':
872
+						$value = 'F j, Y';
873
+						break;
874
+					case 'time_format':
875
+						$value = 'g:i a';
876
+						break;
877
+				}
878
+			}
879
+		}
880
+		return $value;
881
+	}
882
+
883
+
884
+	/**
885
+	 * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
886
+	 *
887
+	 * @param $content
888
+	 * @return    string
889
+	 */
890
+	public function its_eSpresso($content)
891
+	{
892
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
893
+	}
894
+
895
+
896
+	/**
897
+	 * espresso_admin_footer
898
+	 *
899
+	 * @return    string
900
+	 */
901
+	public function espresso_admin_footer()
902
+	{
903
+		return EEH_Template::powered_by_event_espresso('aln-cntr', '', ['utm_content' => 'admin_footer']);
904
+	}
905
+
906
+
907
+	/**
908
+	 * static method for registering ee admin page.
909
+	 * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
910
+	 *
911
+	 * @param       $page_basename
912
+	 * @param       $page_path
913
+	 * @param array $config
914
+	 * @return void
915
+	 * @throws EE_Error
916
+	 * @see        EE_Register_Admin_Page::register()
917
+	 * @since      4.3.0
918
+	 * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
919
+	 */
920
+	public static function register_ee_admin_page($page_basename, $page_path, $config = [])
921
+	{
922
+		EE_Error::doing_it_wrong(
923
+			__METHOD__,
924
+			sprintf(
925
+				esc_html__(
926
+					'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
927
+					'event_espresso'
928
+				),
929
+				$page_basename
930
+			),
931
+			'4.3'
932
+		);
933
+		if (class_exists('EE_Register_Admin_Page')) {
934
+			$config['page_path'] = $page_path;
935
+		}
936
+		EE_Register_Admin_Page::register($page_basename, $config);
937
+	}
938
+
939
+
940
+	/**
941
+	 * @param int     $post_ID
942
+	 * @param WP_Post $post
943
+	 * @return void
944
+	 * @deprecated 4.8.41
945
+	 */
946
+	public static function parse_post_content_on_save($post_ID, $post)
947
+	{
948
+		EE_Error::doing_it_wrong(
949
+			__METHOD__,
950
+			esc_html__('Usage is deprecated', 'event_espresso'),
951
+			'4.8.41'
952
+		);
953
+	}
954
+
955
+
956
+	/**
957
+	 * @param  $option
958
+	 * @param  $old_value
959
+	 * @param  $value
960
+	 * @return void
961
+	 * @deprecated 4.8.41
962
+	 */
963
+	public function reset_page_for_posts_on_change($option, $old_value, $value)
964
+	{
965
+		EE_Error::doing_it_wrong(
966
+			__METHOD__,
967
+			esc_html__('Usage is deprecated', 'event_espresso'),
968
+			'4.8.41'
969
+		);
970
+	}
971
+
972
+
973
+	/**
974
+	 * @return void
975
+	 * @deprecated 4.9.27
976
+	 */
977
+	public function get_persistent_admin_notices()
978
+	{
979
+		EE_Error::doing_it_wrong(
980
+			__METHOD__,
981
+			sprintf(
982
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
983
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
984
+			),
985
+			'4.9.27'
986
+		);
987
+	}
988
+
989
+
990
+	/**
991
+	 * @throws InvalidInterfaceException
992
+	 * @throws InvalidDataTypeException
993
+	 * @throws DomainException
994
+	 * @deprecated 4.9.27
995
+	 */
996
+	public function dismiss_ee_nag_notice_callback()
997
+	{
998
+		EE_Error::doing_it_wrong(
999
+			__METHOD__,
1000
+			sprintf(
1001
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1002
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1003
+			),
1004
+			'4.9.27'
1005
+		);
1006
+		$this->persistent_admin_notice_manager->dismissNotice();
1007
+	}
1008
+
1009
+
1010
+	/**
1011
+	 * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
1012
+	 *
1013
+	 * @throws InvalidArgumentException
1014
+	 * @throws InvalidDataTypeException
1015
+	 * @throws InvalidInterfaceException
1016
+	 */
1017
+	public function hookIntoWpPluginsPage()
1018
+	{
1019
+		$this->getLoader()->getShared('EventEspresso\core\domain\services\admin\ExitModal');
1020
+		$this->getLoader()
1021
+			 ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
1022
+			 ->decafUpsells();
1023
+	}
1024
+
1025
+
1026
+	/**
1027
+	 * Hooks into the "post states" filter in a wp post type list table.
1028
+	 *
1029
+	 * @param array   $post_states
1030
+	 * @param WP_Post $post
1031
+	 * @return array
1032
+	 * @throws InvalidArgumentException
1033
+	 * @throws InvalidDataTypeException
1034
+	 * @throws InvalidInterfaceException
1035
+	 */
1036
+	public function displayStateForCriticalPages($post_states, $post)
1037
+	{
1038
+		$post_states = (array) $post_states;
1039
+		if (! $post instanceof WP_Post || $post->post_type !== 'page') {
1040
+			return $post_states;
1041
+		}
1042
+		/** @var EE_Core_Config $config */
1043
+		$config = $this->getLoader()->getShared('EE_Config')->core;
1044
+		if (in_array($post->ID, $config->get_critical_pages_array(), true)) {
1045
+			$post_states[] = sprintf(
1046
+			/* Translators: Using company name - Event Espresso Critical Page */
1047
+				esc_html__('%s Critical Page', 'event_espresso'),
1048
+				'Event Espresso'
1049
+			);
1050
+		}
1051
+		return $post_states;
1052
+	}
1053
+
1054
+
1055
+	/**
1056
+	 * Show documentation links on the plugins page
1057
+	 *
1058
+	 * @param mixed $meta Plugin Row Meta
1059
+	 * @param mixed $file Plugin Base file
1060
+	 * @return array
1061
+	 */
1062
+	public function addLinksToPluginRowMeta($meta, $file)
1063
+	{
1064
+		if (EE_PLUGIN_BASENAME === $file) {
1065
+			$row_meta = [
1066
+				'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"'
1067
+						  . ' aria-label="'
1068
+						  . esc_attr__('View Event Espresso documentation', 'event_espresso')
1069
+						  . '">'
1070
+						  . esc_html__('Docs', 'event_espresso')
1071
+						  . '</a>',
1072
+				'api'  => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"'
1073
+						  . ' aria-label="'
1074
+						  . esc_attr__('View Event Espresso API docs', 'event_espresso')
1075
+						  . '">'
1076
+						  . esc_html__('API docs', 'event_espresso')
1077
+						  . '</a>',
1078
+			];
1079
+			return array_merge($meta, $row_meta);
1080
+		}
1081
+		return (array) $meta;
1082
+	}
1083 1083
 }
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public static function instance(RequestInterface $request = null)
51 51
     {
52 52
         // check if class object is instantiated
53
-        if (! self::$_instance instanceof EE_Admin) {
53
+        if ( ! self::$_instance instanceof EE_Admin) {
54 54
             self::$_instance = new self($request);
55 55
         }
56 56
         return self::$_instance;
@@ -111,11 +111,11 @@  discard block
 block discarded – undo
111 111
      */
112 112
     private function _define_all_constants()
113 113
     {
114
-        if (! defined('EE_ADMIN_URL')) {
115
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
116
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
117
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/');
118
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
114
+        if ( ! defined('EE_ADMIN_URL')) {
115
+            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/');
116
+            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/');
117
+            define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates/');
118
+            define('WP_ADMIN_PATH', ABSPATH.'wp-admin/');
119 119
             define('WP_AJAX_URL', admin_url('admin-ajax.php'));
120 120
         }
121 121
     }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
         // set $main_file in stone
134 134
         static $main_file;
135 135
         // if $main_file is not set yet
136
-        if (! $main_file) {
136
+        if ( ! $main_file) {
137 137
             $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE);
138 138
         }
139 139
         if ($plugin === $main_file) {
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
     public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = [])
177 177
     {
178 178
         return [
179
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance/',
180
-            'about'       => EE_ADMIN_PAGES . 'about/',
181
-            'support'     => EE_ADMIN_PAGES . 'support/',
179
+            'maintenance' => EE_ADMIN_PAGES.'maintenance/',
180
+            'about'       => EE_ADMIN_PAGES.'about/',
181
+            'support'     => EE_ADMIN_PAGES.'support/',
182 182
         ];
183 183
     }
184 184
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             $this->initModelsReady();
203 203
         }
204 204
         // run the admin page factory but ONLY if we are doing an ee admin ajax request
205
-        if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
205
+        if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) {
206 206
             try {
207 207
                 // this loads the controller for the admin pages which will setup routing etc
208 208
                 EE_Registry::instance()->load_core('Admin_Page_Loader');
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
      */
230 230
     protected function getLoader()
231 231
     {
232
-        if (! $this->loader instanceof LoaderInterface) {
232
+        if ( ! $this->loader instanceof LoaderInterface) {
233 233
             $this->loader = LoaderFactory::getLoader();
234 234
         }
235 235
         return $this->loader;
@@ -300,13 +300,13 @@  discard block
 block discarded – undo
300 300
                     '</strong>',
301 301
                     '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
302 302
                     '</a>',
303
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
303
+                    '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
304 304
                         [
305 305
                             'page'   => 'espresso_maintenance_settings',
306 306
                             'action' => 'datetime_tools',
307 307
                         ],
308 308
                         admin_url('admin.php')
309
-                    ) . '">'
309
+                    ).'">'
310 310
                 ),
311 311
                 false,
312 312
                 'manage_options',
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
     public function enable_hidden_ee_nav_menu_metaboxes()
353 353
     {
354 354
         global $wp_meta_boxes, $pagenow;
355
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
355
+        if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
356 356
             return;
357 357
         }
358 358
         $user = wp_get_current_user();
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
         if (is_array($hidden_meta_boxes)) {
382 382
             foreach ($hidden_meta_boxes as $key => $meta_box_id) {
383 383
                 if (in_array($meta_box_id, $initial_meta_boxes, true)) {
384
-                    unset($hidden_meta_boxes[ $key ]);
384
+                    unset($hidden_meta_boxes[$key]);
385 385
                 }
386 386
             }
387 387
         }
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
      */
422 422
     public function modify_edit_post_link($link, $id)
423 423
     {
424
-        if (! $post = get_post($id)) {
424
+        if ( ! $post = get_post($id)) {
425 425
             return $link;
426 426
         }
427 427
         if ($post->post_type === 'espresso_attendees') {
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
         ];
570 570
 
571 571
         foreach ($keys as $key => $value) {
572
-            $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
572
+            $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
573 573
         }
574 574
         return $menu_item;
575 575
     }
@@ -667,10 +667,10 @@  discard block
 block discarded – undo
667 667
 
668 668
         // loop through to remove any critical pages from the array.
669 669
         foreach ($critical_pages as $page_id) {
670
-            $needle = 'value="' . $page_id . '"';
670
+            $needle = 'value="'.$page_id.'"';
671 671
             foreach ($split_output as $key => $haystack) {
672 672
                 if (strpos($haystack, $needle) !== false) {
673
-                    unset($split_output[ $key ]);
673
+                    unset($split_output[$key]);
674 674
                 }
675 675
             }
676 676
         }
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
         // calls.
692 692
         wp_enqueue_script(
693 693
             'ee-inject-wp',
694
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
694
+            EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js',
695 695
             ['jquery'],
696 696
             EVENT_ESPRESSO_VERSION,
697 697
             true
@@ -699,7 +699,7 @@  discard block
 block discarded – undo
699 699
         // register cookie script for future dependencies
700 700
         wp_register_script(
701 701
             'jquery-cookie',
702
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
702
+            EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js',
703 703
             ['jquery'],
704 704
             '2.1',
705 705
             true
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
             ['page' => 'espresso_events'],
766 766
             admin_url('admin.php')
767 767
         );
768
-        $items['events']['text']         = sprintf(
768
+        $items['events']['text'] = sprintf(
769 769
             esc_html(
770 770
                 _n('%s Event', '%s Events', $events, 'event_espresso')
771 771
             ),
@@ -779,11 +779,11 @@  discard block
 block discarded – undo
779 779
                 ],
780 780
             ]
781 781
         );
782
-        $items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
782
+        $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(
783 783
             ['page' => 'espresso_registrations'],
784 784
             admin_url('admin.php')
785 785
         );
786
-        $items['registrations']['text']  = sprintf(
786
+        $items['registrations']['text'] = sprintf(
787 787
             esc_html(
788 788
                 _n('%s Registration', '%s Registrations', $registrations, 'event_espresso')
789 789
             ),
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 
796 796
         foreach ($items as $type => $item_properties) {
797 797
             $elements[] = sprintf(
798
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
798
+                '<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>',
799 799
                 $item_properties['url'],
800 800
                 $item_properties['title'],
801 801
                 $item_properties['text']
@@ -819,10 +819,10 @@  discard block
 block discarded – undo
819 819
         // check for date_format or time_format
820 820
         switch ($option) {
821 821
             case 'date_format':
822
-                $date_time_format = $value . ' ' . get_option('time_format');
822
+                $date_time_format = $value.' '.get_option('time_format');
823 823
                 break;
824 824
             case 'time_format':
825
-                $date_time_format = get_option('date_format') . ' ' . $value;
825
+                $date_time_format = get_option('date_format').' '.$value;
826 826
                 break;
827 827
             default:
828 828
                 $date_time_format = false;
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
 
846 846
 
847 847
                 foreach ($error_msg as $error) {
848
-                    $msg .= '<li>' . $error . '</li>';
848
+                    $msg .= '<li>'.$error.'</li>';
849 849
                 }
850 850
 
851 851
                 $msg .= '</ul></p><p>'
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
     public function displayStateForCriticalPages($post_states, $post)
1037 1037
     {
1038 1038
         $post_states = (array) $post_states;
1039
-        if (! $post instanceof WP_Post || $post->post_type !== 'page') {
1039
+        if ( ! $post instanceof WP_Post || $post->post_type !== 'page') {
1040 1040
             return $post_states;
1041 1041
         }
1042 1042
         /** @var EE_Core_Config $config */
Please login to merge, or discard this patch.
core/admin/EE_Admin_Hooks.core.php 2 patches
Indentation   +722 added lines, -722 removed lines patch added patch discarded remove patch
@@ -15,726 +15,726 @@
 block discarded – undo
15 15
 {
16 16
 
17 17
 
18
-    /**
19
-     * we're just going to use this to hold the name of the caller class (child class name)
20
-     *
21
-     * @var string
22
-     */
23
-    public $caller;
24
-
25
-
26
-    /**
27
-     * this is just a flag set automatically to indicate whether we've got an extended hook class running (i.e.
28
-     * espresso_events_Registration_Form_Hooks_Extend extends espresso_events_Registration_Form_Hooks).  This flag is
29
-     * used later to make sure we require the needed files.
30
-     *
31
-     * @var bool
32
-     */
33
-    protected $_extend;
34
-
35
-
36
-    /**
37
-     * child classes MUST set this property so that the page object can be loaded correctly
38
-     *
39
-     * @var string
40
-     */
41
-    protected $_name;
42
-
43
-
44
-    /**
45
-     * This is set by child classes and is an associative array of ajax hooks in the format:
46
-     * array(
47
-     *    'ajax_action_ref' => 'executing_method'; //must be public
48
-     * )
49
-     *
50
-     * @var array
51
-     */
52
-    protected $_ajax_func;
53
-
54
-
55
-    /**
56
-     * This is an array of methods that get executed on a page routes admin_init hook. Use the following format:
57
-     * array(
58
-     *    'page_route' => 'executing_method' //must be public
59
-     * )
60
-     *
61
-     * @var array
62
-     */
63
-    protected $_init_func;
64
-
65
-
66
-    /**
67
-     * This is an array of methods that output metabox content for the given page route.  Use the following format:
68
-     * array(
69
-     *    0 => array(
70
-     *        'page_route' => 'string_for_page_route', //must correspond to a page route in the class being connected
71
-     *        with (i.e. "edit_event") If this is in an array then the same params below will be used but the metabox
72
-     *        will be added to each route.
73
-     *        'func' =>  'executing_method',  //must be public (i.e. public function executing_method($post,
74
-     *        $callback_args){} ).  Note if you include callback args in the array then you need to declare them in the
75
-     *        method arguments.
76
-     *        'id' => 'identifier_for_metabox', //so it can be removed by addons (optional, class will set it
77
-     *        automatically)
78
-     *        'priority' => 'default', //default 'default' (optional)
79
-     *        'label' => __('Localized Title', 'event_espresso'),
80
-     *        'context' => 'advanced' //advanced is default (optional),
81
-     *    'callback_args' => array() //any callback args to include (optional)
82
-     * )
83
-     * Why are we indexing numerically?  Because it's possible there may be more than one metabox per page_route.
84
-     *
85
-     * @var array
86
-     */
87
-    protected $_metaboxes;
88
-
89
-
90
-    /**
91
-     * This is an array of values that indicate any metaboxes we want removed from a given page route.  Usually this is
92
-     * used when caffeinated functionality is replacing decaffeinated functionality.  Use the following format for the
93
-     * array: array(
94
-     *    0 => array(
95
-     *        'page_route' => 'string_for_page_route' //can be string or array of strings that match a page_route(s)
96
-     *        that are in the class being connected with (i.e. 'edit', or 'create_new').
97
-     *        'id' => 'identifier_for_metabox', //what the id is of the metabox being removed
98
-     *        'context' => 'normal', //the context for the metabox being removed (has to match)
99
-     *        'screen' => 'screen_id', //(optional), if not included then this class will attempt to remove the metabox
100
-     *        using the currently loaded screen object->id  however, there may be cases where you have to specify the
101
-     *        id for the screen the metabox is on.
102
-     *    )
103
-     * )
104
-     *
105
-     * @var array
106
-     */
107
-    protected $_remove_metaboxes;
108
-
109
-
110
-    /**
111
-     * This parent class takes care of loading the scripts and styles if the child class has set the properties for
112
-     * them in the following format.  Note, the first array index ('register') is for defining all the registers.  The
113
-     * second array index is for indicating what routes each script/style loads on. array(
114
-     * 'registers' => array(
115
-     *        'script_ref' => array( // if more than one script is to be loaded its best to use the 'dependency'
116
-     *        argument to link scripts together.
117
-     *            'type' => 'js' // 'js' or 'css' (defaults to js).  This tells us what type of wp_function to use
118
-     *            'url' => 'http://urltoscript.css.js',
119
-     *            'depends' => array('jquery'), //an array of dependencies for the scripts. REMEMBER, if a script has
120
-     *            already been registered elsewhere in the system.  You can just use the depends array to make sure it
121
-     *            gets loaded before the one you are setting here.
122
-     *            'footer' => TRUE //defaults to true (styles don't use this parameter)
123
-     *        ),
124
-     *    'enqueues' => array( //this time each key corresponds to the script ref followed by an array of page routes
125
-     *    the script gets enqueued on.
126
-     *        'script_ref' => array('route_one', 'route_two')
127
-     *    ),
128
-     *    'localize' => array( //this allows you to set a localize object.  Indicate which script the object is being
129
-     *    attached to and then include an array indexed by the name of the object and the array of key/value pairs for
130
-     *    the object.
131
-     *        'scrip_ref' => array(
132
-     *            'NAME_OF_JS_OBJECT' => array(
133
-     *                'translate_ref' => __('localized_string', 'event_espresso'),
134
-     *                'some_data' => 5
135
-     *            )
136
-     *        )
137
-     *    )
138
-     * )
139
-     *
140
-     * @var array
141
-     */
142
-    protected $_scripts_styles;
143
-
144
-
145
-    /**
146
-     * This is a property that will contain the current route.
147
-     *
148
-     * @var string;
149
-     */
150
-    protected $_current_route;
151
-
152
-
153
-    /**
154
-     * this optional property can be set by child classes to override the priority for the automatic action/filter hook
155
-     * loading in the `_load_routed_hooks()` method.  Please follow this format: array(
156
-     *    'wp_hook_reference' => 1
157
-     *    )
158
-     * )
159
-     *
160
-     * @var array
161
-     */
162
-    protected $_wp_action_filters_priority;
163
-
164
-
165
-    /**
166
-     * This just holds a merged array of the request vars
167
-     *
168
-     * @var array
169
-     */
170
-    protected $_req_data;
171
-
172
-
173
-    /**
174
-     * This just holds an instance of the page object for this hook
175
-     *
176
-     * @var EE_Admin_Page
177
-     */
178
-    protected $_page_object;
179
-
180
-
181
-    /**
182
-     * This holds the EE_Admin_Page object from the calling admin page that this object hooks into.
183
-     *
184
-     * @var EE_Admin_Page|EE_Admin_Page_CPT
185
-     */
186
-    protected $_adminpage_obj;
187
-
188
-
189
-    /**
190
-     * Holds EE_Registry object
191
-     *
192
-     * @var EE_Registry
193
-     */
194
-    protected $EE = null;
195
-
196
-    /**
197
-     * @var RequestInterface
198
-     */
199
-    protected $request;
200
-
201
-    /**
202
-     * constructor
203
-     *
204
-     * @param EE_Admin_Page $admin_page
205
-     * @throws EE_Error
206
-     */
207
-    public function __construct(EE_Admin_Page $admin_page)
208
-    {
209
-        $this->_adminpage_obj = $admin_page;
210
-        $this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
211
-        $this->_req_data = $this->request->requestParams();
212
-        $this->_set_defaults();
213
-        $this->_set_hooks_properties();
214
-        // first let's verify we're on the right page
215
-        if (! isset($this->_req_data['page']) || $this->_req_data['page'] !== $this->_adminpage_obj->page_slug) {
216
-            return;
217
-        }
218
-        //get out nothing more to be done here.
219
-        // allow for extends to modify properties
220
-        if (method_exists($this, '_extend_properties')) {
221
-            $this->_extend_properties();
222
-        }
223
-        $this->_set_page_object();
224
-        $this->_init_hooks();
225
-        $this->_load_custom_methods();
226
-        $this->_load_routed_hooks();
227
-        add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
228
-        add_action('admin_enqueue_scripts', array($this, 'add_metaboxes'), 20);
229
-        add_action('admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15);
230
-        $this->_ajax_hooks();
231
-    }
232
-
233
-
234
-    /**
235
-     * used by child classes to set the following properties:
236
-     * $_ajax_func (optional)
237
-     * $_init_func (optional)
238
-     * $_metaboxes (optional)
239
-     * $_scripts (optional)
240
-     * $_styles (optional)
241
-     * $_name (required)
242
-     * Also in this method will be registered any scripts or styles loaded on the targeted page (as indicated in the
243
-     * _scripts/_styles properties) Also children should place in this method any filters/actions that have to happen
244
-     * really early on page load (just after admin_init) if they want to have them registered for handling early.
245
-     *
246
-     * @access protected
247
-     * @abstract
248
-     * @return void
249
-     */
250
-    abstract protected function _set_hooks_properties();
251
-
252
-
253
-    /**
254
-     * The hooks for enqueue_scripts and enqueue_styles will be run in here.  Child classes need to define their
255
-     * scripts and styles in the relevant $_scripts and $_styles properties.  Child classes must have also already
256
-     * registered the scripts and styles using wp_register_script and wp_register_style functions.
257
-     *
258
-     * @access public
259
-     * @return void
260
-     */
261
-    public function enqueue_scripts_styles()
262
-    {
263
-
264
-        if (! empty($this->_scripts_styles)) {
265
-            // first let's do all the registrations
266
-            if (! isset($this->_scripts_styles['registers'])) {
267
-                $msg[] = __(
268
-                    'There is no "registers" index in the <code>$this->_scripts_styles</code> property.',
269
-                    'event_espresso'
270
-                );
271
-                $msg[] = sprintf(
272
-                    __(
273
-                        'Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child',
274
-                        'event_espresso'
275
-                    ),
276
-                    '<strong>' . $this->caller . '</strong>'
277
-                );
278
-                throw new EE_Error(implode('||', $msg));
279
-            }
280
-            foreach ($this->_scripts_styles['registers'] as $ref => $details) {
281
-                $defaults = array(
282
-                    'type'    => 'js',
283
-                    'url'     => '',
284
-                    'depends' => array(),
285
-                    'version' => EVENT_ESPRESSO_VERSION,
286
-                    'footer'  => true,
287
-                );
288
-                $details = wp_parse_args($details, $defaults);
289
-                extract($details);
290
-                // let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do
291
-                $this->_scripts_styles['registers'][ $ref ]['type'] = $type;
292
-                // let's make sure we're not missing any REQUIRED parameters
293
-                if (empty($url)) {
294
-                    $msg[] = sprintf(
295
-                        __('Missing the url for the requested %s', 'event_espresso'),
296
-                        $type == 'js' ? 'script' : 'stylesheet'
297
-                    );
298
-                    $msg[] = sprintf(
299
-                        __(
300
-                            'Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref',
301
-                            'event_espresso'
302
-                        ),
303
-                        '<strong>' . $this->caller . '</strong>',
304
-                        $ref
305
-                    );
306
-                    throw new EE_Error(implode('||', $msg));
307
-                }
308
-                // made it here so let's do the appropriate registration
309
-                $type == 'js'
310
-                    ? wp_register_script($ref, $url, $depends, $version, $footer)
311
-                    : wp_register_style(
312
-                        $ref,
313
-                        $url,
314
-                        $depends,
315
-                        $version
316
-                    );
317
-            }
318
-            // k now lets do the enqueues
319
-            if (! isset($this->_scripts_styles['enqueues'])) {
320
-                return;
321
-            }  //not sure if we should throw an error here or not.
322
-
323
-            foreach ($this->_scripts_styles['enqueues'] as $ref => $routes) {
324
-                // make sure $routes is an array
325
-                $routes = (array) $routes;
326
-                if (in_array($this->_current_route, $routes)) {
327
-                    $this->_scripts_styles['registers'][ $ref ]['type'] == 'js' ? wp_enqueue_script($ref)
328
-                        : wp_enqueue_style($ref);
329
-                    // if we have a localization for the script let's do that too.
330
-                    if (isset($this->_scripts_styles['localize'][ $ref ])) {
331
-                        foreach ($this->_scripts_styles['localize'][ $ref ] as $object_name => $indexes) {
332
-                            wp_localize_script(
333
-                                $ref,
334
-                                $object_name,
335
-                                $this->_scripts_styles['localize'][ $ref ][ $object_name ]
336
-                            );
337
-                        }
338
-                    }
339
-                }
340
-            }
341
-            // let's do the deregisters
342
-            if (! isset($this->_scripts_styles['deregisters'])) {
343
-                return;
344
-            }
345
-            foreach ($this->_scripts_styles['deregisters'] as $ref => $details) {
346
-                $defaults = array(
347
-                    'type' => 'js',
348
-                );
349
-                $details = wp_parse_args($details, $defaults);
350
-                extract($details);
351
-                $type == 'js' ? wp_deregister_script($ref) : wp_deregister_style($ref);
352
-            }
353
-        }
354
-    }
355
-
356
-
357
-    /**
358
-     * just set the defaults for the hooks properties.
359
-     *
360
-     * @access private
361
-     * @return void
362
-     */
363
-    private function _set_defaults()
364
-    {
365
-        $this->_ajax_func = $this->_init_func = $this->_metaboxes = $this->_scripts = $this->_styles = $this->_wp_action_filters_priority = array();
366
-        $this->_current_route = $this->getCurrentRoute();
367
-        $this->caller = get_class($this);
368
-        $this->_extend = stripos($this->caller, 'Extend') ? true : false;
369
-    }
370
-
371
-
372
-    /**
373
-     * A helper for determining the current route.
374
-     * @return string
375
-     */
376
-    private function getCurrentRoute()
377
-    {
378
-        $action = $this->request->getRequestParam('action');
379
-        // list tables do something else with 'action' for bulk actions.
380
-        $action = $action !== '-1' && $action !== ''  ? $action : 'default';
381
-        $route = $this->request->getRequestParam('route');
382
-        // we set a 'route' variable in some cases where action is being used by something else.
383
-        return $action === 'default' && $route !== '' ? $route : $action;
384
-    }
385
-
386
-
387
-    /**
388
-     * this sets the _page_object property
389
-     *
390
-     * @access protected
391
-     * @return void
392
-     * @throws EE_Error
393
-     */
394
-    protected function _set_page_object()
395
-    {
396
-        // first make sure $this->_name is set
397
-        if (empty($this->_name)) {
398
-            $msg[] = __('We can\'t load the page object', 'event_espresso');
399
-            $msg[] = sprintf(
400
-                __("This is because the %s child class has not set the '_name' property", 'event_espresso'),
401
-                $this->caller
402
-            );
403
-            throw new EE_Error(implode('||', $msg));
404
-        }
405
-        $class_name = str_replace('_', ' ', $this->_name); // take the_message -> the message
406
-        $class_name = str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page'; // take the message -> The_Message
407
-        // first default file (if exists)
408
-        $decaf_file = EE_ADMIN_PAGES . $this->_name . '/' . $class_name . '.core.php';
409
-        if (is_readable($decaf_file)) {
410
-            require_once($decaf_file);
411
-        }
412
-        // now we have to do require for extended file (if needed)
413
-        if ($this->_extend) {
414
-            require_once(EE_CORE_CAF_ADMIN_EXTEND . $this->_name . '/Extend_' . $class_name . '.core.php');
415
-        }
416
-        // if we've got an extended class we use that!
417
-        $class_name = $this->_extend ? 'Extend_' . $class_name : $class_name;
418
-        // let's make sure the class exists
419
-        if (! class_exists($class_name)) {
420
-            $msg[] = __('We can\'t load the page object', 'event_espresso');
421
-            $msg[] = sprintf(
422
-                __(
423
-                    'The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class',
424
-                    'event_espresso'
425
-                ),
426
-                $class_name
427
-            );
428
-            throw new EE_Error(implode('||', $msg));
429
-        }
430
-        LoaderFactory::getLoader()->getShared($class_name);
431
-    }
432
-
433
-
434
-    /**
435
-     * Child "hook" classes can declare any methods that they want executed when a specific page route is loaded.  The
436
-     * advantage of this is when doing things like running our own db interactions on saves etc.  Remember that
437
-     * $this->_req_data (all the _POST and _GET data) is available to your methods.
438
-     *
439
-     * @access private
440
-     * @return void
441
-     */
442
-    private function _load_custom_methods()
443
-    {
444
-        /**
445
-         * method cannot be named 'default' (@see http://us3.php
446
-         * .net/manual/en/reserved.keywords.php) so need to
447
-         * handle routes that are "default"
448
-         *
449
-         * @since 4.3.0
450
-         */
451
-        $method_callback = $this->_current_route == 'default' ? 'default_callback' : $this->_current_route;
452
-        // these run before the Admin_Page route executes.
453
-        if (method_exists($this, $method_callback)) {
454
-            call_user_func(array($this, $method_callback));
455
-        }
456
-        // these run via the _redirect_after_action method in EE_Admin_Page which usually happens after non_UI methods in EE_Admin_Page classes.  There are two redirect actions, the first fires before $query_args might be manipulated by "save and close" actions and the seond fires right before the actual redirect happens.
457
-        // first the actions
458
-        // note that these action hooks will have the $query_args value available.
459
-        $admin_class_name = get_class($this->_adminpage_obj);
460
-        if (method_exists($this, '_redirect_action_early_' . $this->_current_route)) {
461
-            add_action(
462
-                'AHEE__'
463
-                . $admin_class_name
464
-                . '___redirect_after_action__before_redirect_modification_'
465
-                . $this->_current_route,
466
-                array($this, '_redirect_action_early_' . $this->_current_route),
467
-                10
468
-            );
469
-        }
470
-        if (method_exists($this, '_redirect_action_' . $this->_current_route)) {
471
-            add_action(
472
-                'AHEE_redirect_' . $admin_class_name . $this->_current_route,
473
-                array($this, '_redirect_action_' . $this->_current_route),
474
-                10
475
-            );
476
-        }
477
-        // let's hook into the _redirect itself and allow for changing where the user goes after redirect.  This will have $query_args and $redirect_url available.
478
-        if (method_exists($this, '_redirect_filter_' . $this->_current_route)) {
479
-            add_filter(
480
-                'FHEE_redirect_' . $admin_class_name . $this->_current_route,
481
-                array($this, '_redirect_filter_' . $this->_current_route),
482
-                10,
483
-                2
484
-            );
485
-        }
486
-    }
487
-
488
-
489
-    /**
490
-     * This method will search for a corresponding method with a name matching the route and the wp_hook to run.  This
491
-     * allows child hook classes to target hooking into a specific wp action or filter hook ONLY on a certain route.
492
-     * just remember, methods MUST be public Future hooks should be added in here to be access by child classes.
493
-     *
494
-     * @return void
495
-     */
496
-    private function _load_routed_hooks()
497
-    {
498
-
499
-        // this array provides the hook action names that will be referenced.  Key is the action. Value is an array with the type (action or filter) and the number of parameters for the hook.  We'll default all priorities for automatic hooks to 10.
500
-        $hook_filter_array = array(
501
-            'admin_footer'                                                                            => array(
502
-                'type'     => 'action',
503
-                'argnum'   => 1,
504
-                'priority' => 10,
505
-            ),
506
-            'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array(
507
-                'type'     => 'filter',
508
-                'argnum'   => 1,
509
-                'priority' => 10,
510
-            ),
511
-            'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug                               => array(
512
-                'type'     => 'filter',
513
-                'argnum'   => 1,
514
-                'priority' => 10,
515
-            ),
516
-            'FHEE_list_table_views'                                                                   => array(
517
-                'type'     => 'filter',
518
-                'argnum'   => 1,
519
-                'priority' => 10,
520
-            ),
521
-            'AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes'                              => array(
522
-                'type'     => 'action',
523
-                'argnum'   => 1,
524
-                'priority' => 10,
525
-            ),
526
-        );
527
-        foreach ($hook_filter_array as $hook => $args) {
528
-            if (method_exists($this, $this->_current_route . '_' . $hook)) {
529
-                if (isset($this->_wp_action_filters_priority[ $hook ])) {
530
-                    $args['priority'] = $this->_wp_action_filters_priority[ $hook ];
531
-                }
532
-                if ($args['type'] == 'action') {
533
-                    add_action(
534
-                        $hook,
535
-                        array($this, $this->_current_route . '_' . $hook),
536
-                        $args['priority'],
537
-                        $args['argnum']
538
-                    );
539
-                } else {
540
-                    add_filter(
541
-                        $hook,
542
-                        array($this, $this->_current_route . '_' . $hook),
543
-                        $args['priority'],
544
-                        $args['argnum']
545
-                    );
546
-                }
547
-            }
548
-        }
549
-    }
550
-
551
-
552
-    /**
553
-     * Loop throught the $_ajax_func array and add_actions for the array.
554
-     *
555
-     * @return void
556
-     */
557
-    private function _ajax_hooks()
558
-    {
559
-
560
-        if (empty($this->_ajax_func)) {
561
-            return;
562
-        } //get out there's nothing to take care of.
563
-        foreach ($this->_ajax_func as $action => $method) {
564
-            // make sure method exists
565
-            if (! method_exists($this, $method)) {
566
-                $msg[] = __(
567
-                    'There is no corresponding method for the hook labeled in the _ajax_func array',
568
-                    'event_espresso'
569
-                ) . '<br />';
570
-                $msg[] = sprintf(
571
-                    __(
572
-                        'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
573
-                        'event_espresso'
574
-                    ),
575
-                    $method,
576
-                    $this->caller
577
-                );
578
-                throw new EE_Error(implode('||', $msg));
579
-            }
580
-            add_action('wp_ajax_' . $action, array($this, $method));
581
-        }
582
-    }
583
-
584
-
585
-    /**
586
-     * Loop throught the $_init_func array and add_actions for the array.
587
-     *
588
-     * @return void
589
-     */
590
-    protected function _init_hooks()
591
-    {
592
-        if (empty($this->_init_func)) {
593
-            return;
594
-        }
595
-        //get out there's nothing to take care of.
596
-        // We need to determine what page_route we are on!
597
-        foreach ($this->_init_func as $route => $method) {
598
-            // make sure method exists
599
-            if (! method_exists($this, $method)) {
600
-                $msg[] = __(
601
-                    'There is no corresponding method for the hook labeled in the _init_func array',
602
-                    'event_espresso'
603
-                ) . '<br />';
604
-                $msg[] = sprintf(
605
-                    __(
606
-                        'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
607
-                        'event_espresso'
608
-                    ),
609
-                    $method,
610
-                    $this->caller
611
-                );
612
-                throw new EE_Error(implode('||', $msg));
613
-            }
614
-            if ($route == $this->_current_route) {
615
-                add_action('admin_init', array($this, $method));
616
-            }
617
-        }
618
-    }
619
-
620
-
621
-    /**
622
-     * Loop through the _metaboxes property and add_metaboxes accordingly
623
-     * //todo we could eventually make this a config component class (i.e. new EE_Metabox);
624
-     *
625
-     * @access public
626
-     * @return void
627
-     */
628
-    public function add_metaboxes()
629
-    {
630
-        if (empty($this->_metaboxes)) {
631
-            return;
632
-        } //get out we don't have any metaboxes to set for this connection
633
-        $this->_handle_metabox_array($this->_metaboxes);
634
-    }
635
-
636
-
637
-    private function _handle_metabox_array($boxes, $add = true)
638
-    {
639
-
640
-        foreach ($boxes as $box) {
641
-            if (! isset($box['page_route'])) {
642
-                continue;
643
-            } //we dont' have a valid array
644
-            // let's make sure $box['page_route'] is an array so the "foreach" will work.
645
-            $box['page_route'] = (array) $box['page_route'];
646
-            foreach ($box['page_route'] as $route) {
647
-                if ($route != $this->_current_route) {
648
-                    continue;
649
-                } //get out we only add metaboxes for set route.
650
-                if ($add) {
651
-                    $this->_add_metabox($box);
652
-                } else {
653
-                    $this->_remove_metabox($box);
654
-                }
655
-            }
656
-        }
657
-    }
658
-
659
-
660
-    /**
661
-     * Loop through the _remove_metaboxes property and remove metaboxes accordingly.
662
-     *
663
-     * @access public
664
-     * @return void
665
-     */
666
-    public function remove_metaboxes()
667
-    {
668
-
669
-        if (empty($this->_remove_metaboxes)) {
670
-            return;
671
-        } //get out there are no metaboxes to remove
672
-        $this->_handle_metabox_array($this->_remove_metaboxes, false);
673
-    }
674
-
675
-
676
-    /**
677
-     * This just handles adding a metabox
678
-     *
679
-     * @access private
680
-     * @param array $args an array of args that have been set for this metabox by the child class
681
-     */
682
-    private function _add_metabox($args)
683
-    {
684
-        $current_screen = get_current_screen();
685
-        $screen_id = is_object($current_screen) ? $current_screen->id : null;
686
-        $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
687
-        // set defaults
688
-        $defaults = array(
689
-            'func'          => $func,
690
-            'id'            => $this->caller . '_' . $func . '_metabox',
691
-            'priority'      => 'default',
692
-            'label'         => $this->caller,
693
-            'context'       => 'advanced',
694
-            'callback_args' => array(),
695
-            'page'          => isset($args['page']) ? $args['page'] : $screen_id,
696
-        );
697
-        $args = wp_parse_args($args, $defaults);
698
-        extract($args);
699
-        // make sure method exists
700
-        if (! method_exists($this, $func)) {
701
-            $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />';
702
-            $msg[] = sprintf(
703
-                __(
704
-                    'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
705
-                    'event_espresso'
706
-                ),
707
-                $func,
708
-                $this->caller
709
-            );
710
-            throw new EE_Error(implode('||', $msg));
711
-        }
712
-        // everything checks out so lets add the metabox
713
-        add_meta_box($id, $label, array($this, $func), $page, $context, $priority, $callback_args);
714
-    }
715
-
716
-
717
-    private function _remove_metabox($args)
718
-    {
719
-        $current_screen = get_current_screen();
720
-        $screen_id = is_object($current_screen) ? $current_screen->id : null;
721
-        $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
722
-        // set defaults
723
-        $defaults = array(
724
-            'id'      => isset($args['id'])
725
-                ? $args['id']
726
-                : $this->_current_route
727
-                  . '_'
728
-                  . $this->caller
729
-                  . '_'
730
-                  . $func
731
-                  . '_metabox',
732
-            'context' => 'default',
733
-            'screen'  => isset($args['screen']) ? $args['screen'] : $screen_id,
734
-        );
735
-        $args = wp_parse_args($args, $defaults);
736
-        extract($args);
737
-        // everything checks out so lets remove the box!
738
-        remove_meta_box($id, $screen, $context);
739
-    }
18
+	/**
19
+	 * we're just going to use this to hold the name of the caller class (child class name)
20
+	 *
21
+	 * @var string
22
+	 */
23
+	public $caller;
24
+
25
+
26
+	/**
27
+	 * this is just a flag set automatically to indicate whether we've got an extended hook class running (i.e.
28
+	 * espresso_events_Registration_Form_Hooks_Extend extends espresso_events_Registration_Form_Hooks).  This flag is
29
+	 * used later to make sure we require the needed files.
30
+	 *
31
+	 * @var bool
32
+	 */
33
+	protected $_extend;
34
+
35
+
36
+	/**
37
+	 * child classes MUST set this property so that the page object can be loaded correctly
38
+	 *
39
+	 * @var string
40
+	 */
41
+	protected $_name;
42
+
43
+
44
+	/**
45
+	 * This is set by child classes and is an associative array of ajax hooks in the format:
46
+	 * array(
47
+	 *    'ajax_action_ref' => 'executing_method'; //must be public
48
+	 * )
49
+	 *
50
+	 * @var array
51
+	 */
52
+	protected $_ajax_func;
53
+
54
+
55
+	/**
56
+	 * This is an array of methods that get executed on a page routes admin_init hook. Use the following format:
57
+	 * array(
58
+	 *    'page_route' => 'executing_method' //must be public
59
+	 * )
60
+	 *
61
+	 * @var array
62
+	 */
63
+	protected $_init_func;
64
+
65
+
66
+	/**
67
+	 * This is an array of methods that output metabox content for the given page route.  Use the following format:
68
+	 * array(
69
+	 *    0 => array(
70
+	 *        'page_route' => 'string_for_page_route', //must correspond to a page route in the class being connected
71
+	 *        with (i.e. "edit_event") If this is in an array then the same params below will be used but the metabox
72
+	 *        will be added to each route.
73
+	 *        'func' =>  'executing_method',  //must be public (i.e. public function executing_method($post,
74
+	 *        $callback_args){} ).  Note if you include callback args in the array then you need to declare them in the
75
+	 *        method arguments.
76
+	 *        'id' => 'identifier_for_metabox', //so it can be removed by addons (optional, class will set it
77
+	 *        automatically)
78
+	 *        'priority' => 'default', //default 'default' (optional)
79
+	 *        'label' => __('Localized Title', 'event_espresso'),
80
+	 *        'context' => 'advanced' //advanced is default (optional),
81
+	 *    'callback_args' => array() //any callback args to include (optional)
82
+	 * )
83
+	 * Why are we indexing numerically?  Because it's possible there may be more than one metabox per page_route.
84
+	 *
85
+	 * @var array
86
+	 */
87
+	protected $_metaboxes;
88
+
89
+
90
+	/**
91
+	 * This is an array of values that indicate any metaboxes we want removed from a given page route.  Usually this is
92
+	 * used when caffeinated functionality is replacing decaffeinated functionality.  Use the following format for the
93
+	 * array: array(
94
+	 *    0 => array(
95
+	 *        'page_route' => 'string_for_page_route' //can be string or array of strings that match a page_route(s)
96
+	 *        that are in the class being connected with (i.e. 'edit', or 'create_new').
97
+	 *        'id' => 'identifier_for_metabox', //what the id is of the metabox being removed
98
+	 *        'context' => 'normal', //the context for the metabox being removed (has to match)
99
+	 *        'screen' => 'screen_id', //(optional), if not included then this class will attempt to remove the metabox
100
+	 *        using the currently loaded screen object->id  however, there may be cases where you have to specify the
101
+	 *        id for the screen the metabox is on.
102
+	 *    )
103
+	 * )
104
+	 *
105
+	 * @var array
106
+	 */
107
+	protected $_remove_metaboxes;
108
+
109
+
110
+	/**
111
+	 * This parent class takes care of loading the scripts and styles if the child class has set the properties for
112
+	 * them in the following format.  Note, the first array index ('register') is for defining all the registers.  The
113
+	 * second array index is for indicating what routes each script/style loads on. array(
114
+	 * 'registers' => array(
115
+	 *        'script_ref' => array( // if more than one script is to be loaded its best to use the 'dependency'
116
+	 *        argument to link scripts together.
117
+	 *            'type' => 'js' // 'js' or 'css' (defaults to js).  This tells us what type of wp_function to use
118
+	 *            'url' => 'http://urltoscript.css.js',
119
+	 *            'depends' => array('jquery'), //an array of dependencies for the scripts. REMEMBER, if a script has
120
+	 *            already been registered elsewhere in the system.  You can just use the depends array to make sure it
121
+	 *            gets loaded before the one you are setting here.
122
+	 *            'footer' => TRUE //defaults to true (styles don't use this parameter)
123
+	 *        ),
124
+	 *    'enqueues' => array( //this time each key corresponds to the script ref followed by an array of page routes
125
+	 *    the script gets enqueued on.
126
+	 *        'script_ref' => array('route_one', 'route_two')
127
+	 *    ),
128
+	 *    'localize' => array( //this allows you to set a localize object.  Indicate which script the object is being
129
+	 *    attached to and then include an array indexed by the name of the object and the array of key/value pairs for
130
+	 *    the object.
131
+	 *        'scrip_ref' => array(
132
+	 *            'NAME_OF_JS_OBJECT' => array(
133
+	 *                'translate_ref' => __('localized_string', 'event_espresso'),
134
+	 *                'some_data' => 5
135
+	 *            )
136
+	 *        )
137
+	 *    )
138
+	 * )
139
+	 *
140
+	 * @var array
141
+	 */
142
+	protected $_scripts_styles;
143
+
144
+
145
+	/**
146
+	 * This is a property that will contain the current route.
147
+	 *
148
+	 * @var string;
149
+	 */
150
+	protected $_current_route;
151
+
152
+
153
+	/**
154
+	 * this optional property can be set by child classes to override the priority for the automatic action/filter hook
155
+	 * loading in the `_load_routed_hooks()` method.  Please follow this format: array(
156
+	 *    'wp_hook_reference' => 1
157
+	 *    )
158
+	 * )
159
+	 *
160
+	 * @var array
161
+	 */
162
+	protected $_wp_action_filters_priority;
163
+
164
+
165
+	/**
166
+	 * This just holds a merged array of the request vars
167
+	 *
168
+	 * @var array
169
+	 */
170
+	protected $_req_data;
171
+
172
+
173
+	/**
174
+	 * This just holds an instance of the page object for this hook
175
+	 *
176
+	 * @var EE_Admin_Page
177
+	 */
178
+	protected $_page_object;
179
+
180
+
181
+	/**
182
+	 * This holds the EE_Admin_Page object from the calling admin page that this object hooks into.
183
+	 *
184
+	 * @var EE_Admin_Page|EE_Admin_Page_CPT
185
+	 */
186
+	protected $_adminpage_obj;
187
+
188
+
189
+	/**
190
+	 * Holds EE_Registry object
191
+	 *
192
+	 * @var EE_Registry
193
+	 */
194
+	protected $EE = null;
195
+
196
+	/**
197
+	 * @var RequestInterface
198
+	 */
199
+	protected $request;
200
+
201
+	/**
202
+	 * constructor
203
+	 *
204
+	 * @param EE_Admin_Page $admin_page
205
+	 * @throws EE_Error
206
+	 */
207
+	public function __construct(EE_Admin_Page $admin_page)
208
+	{
209
+		$this->_adminpage_obj = $admin_page;
210
+		$this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
211
+		$this->_req_data = $this->request->requestParams();
212
+		$this->_set_defaults();
213
+		$this->_set_hooks_properties();
214
+		// first let's verify we're on the right page
215
+		if (! isset($this->_req_data['page']) || $this->_req_data['page'] !== $this->_adminpage_obj->page_slug) {
216
+			return;
217
+		}
218
+		//get out nothing more to be done here.
219
+		// allow for extends to modify properties
220
+		if (method_exists($this, '_extend_properties')) {
221
+			$this->_extend_properties();
222
+		}
223
+		$this->_set_page_object();
224
+		$this->_init_hooks();
225
+		$this->_load_custom_methods();
226
+		$this->_load_routed_hooks();
227
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
228
+		add_action('admin_enqueue_scripts', array($this, 'add_metaboxes'), 20);
229
+		add_action('admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15);
230
+		$this->_ajax_hooks();
231
+	}
232
+
233
+
234
+	/**
235
+	 * used by child classes to set the following properties:
236
+	 * $_ajax_func (optional)
237
+	 * $_init_func (optional)
238
+	 * $_metaboxes (optional)
239
+	 * $_scripts (optional)
240
+	 * $_styles (optional)
241
+	 * $_name (required)
242
+	 * Also in this method will be registered any scripts or styles loaded on the targeted page (as indicated in the
243
+	 * _scripts/_styles properties) Also children should place in this method any filters/actions that have to happen
244
+	 * really early on page load (just after admin_init) if they want to have them registered for handling early.
245
+	 *
246
+	 * @access protected
247
+	 * @abstract
248
+	 * @return void
249
+	 */
250
+	abstract protected function _set_hooks_properties();
251
+
252
+
253
+	/**
254
+	 * The hooks for enqueue_scripts and enqueue_styles will be run in here.  Child classes need to define their
255
+	 * scripts and styles in the relevant $_scripts and $_styles properties.  Child classes must have also already
256
+	 * registered the scripts and styles using wp_register_script and wp_register_style functions.
257
+	 *
258
+	 * @access public
259
+	 * @return void
260
+	 */
261
+	public function enqueue_scripts_styles()
262
+	{
263
+
264
+		if (! empty($this->_scripts_styles)) {
265
+			// first let's do all the registrations
266
+			if (! isset($this->_scripts_styles['registers'])) {
267
+				$msg[] = __(
268
+					'There is no "registers" index in the <code>$this->_scripts_styles</code> property.',
269
+					'event_espresso'
270
+				);
271
+				$msg[] = sprintf(
272
+					__(
273
+						'Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child',
274
+						'event_espresso'
275
+					),
276
+					'<strong>' . $this->caller . '</strong>'
277
+				);
278
+				throw new EE_Error(implode('||', $msg));
279
+			}
280
+			foreach ($this->_scripts_styles['registers'] as $ref => $details) {
281
+				$defaults = array(
282
+					'type'    => 'js',
283
+					'url'     => '',
284
+					'depends' => array(),
285
+					'version' => EVENT_ESPRESSO_VERSION,
286
+					'footer'  => true,
287
+				);
288
+				$details = wp_parse_args($details, $defaults);
289
+				extract($details);
290
+				// let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do
291
+				$this->_scripts_styles['registers'][ $ref ]['type'] = $type;
292
+				// let's make sure we're not missing any REQUIRED parameters
293
+				if (empty($url)) {
294
+					$msg[] = sprintf(
295
+						__('Missing the url for the requested %s', 'event_espresso'),
296
+						$type == 'js' ? 'script' : 'stylesheet'
297
+					);
298
+					$msg[] = sprintf(
299
+						__(
300
+							'Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref',
301
+							'event_espresso'
302
+						),
303
+						'<strong>' . $this->caller . '</strong>',
304
+						$ref
305
+					);
306
+					throw new EE_Error(implode('||', $msg));
307
+				}
308
+				// made it here so let's do the appropriate registration
309
+				$type == 'js'
310
+					? wp_register_script($ref, $url, $depends, $version, $footer)
311
+					: wp_register_style(
312
+						$ref,
313
+						$url,
314
+						$depends,
315
+						$version
316
+					);
317
+			}
318
+			// k now lets do the enqueues
319
+			if (! isset($this->_scripts_styles['enqueues'])) {
320
+				return;
321
+			}  //not sure if we should throw an error here or not.
322
+
323
+			foreach ($this->_scripts_styles['enqueues'] as $ref => $routes) {
324
+				// make sure $routes is an array
325
+				$routes = (array) $routes;
326
+				if (in_array($this->_current_route, $routes)) {
327
+					$this->_scripts_styles['registers'][ $ref ]['type'] == 'js' ? wp_enqueue_script($ref)
328
+						: wp_enqueue_style($ref);
329
+					// if we have a localization for the script let's do that too.
330
+					if (isset($this->_scripts_styles['localize'][ $ref ])) {
331
+						foreach ($this->_scripts_styles['localize'][ $ref ] as $object_name => $indexes) {
332
+							wp_localize_script(
333
+								$ref,
334
+								$object_name,
335
+								$this->_scripts_styles['localize'][ $ref ][ $object_name ]
336
+							);
337
+						}
338
+					}
339
+				}
340
+			}
341
+			// let's do the deregisters
342
+			if (! isset($this->_scripts_styles['deregisters'])) {
343
+				return;
344
+			}
345
+			foreach ($this->_scripts_styles['deregisters'] as $ref => $details) {
346
+				$defaults = array(
347
+					'type' => 'js',
348
+				);
349
+				$details = wp_parse_args($details, $defaults);
350
+				extract($details);
351
+				$type == 'js' ? wp_deregister_script($ref) : wp_deregister_style($ref);
352
+			}
353
+		}
354
+	}
355
+
356
+
357
+	/**
358
+	 * just set the defaults for the hooks properties.
359
+	 *
360
+	 * @access private
361
+	 * @return void
362
+	 */
363
+	private function _set_defaults()
364
+	{
365
+		$this->_ajax_func = $this->_init_func = $this->_metaboxes = $this->_scripts = $this->_styles = $this->_wp_action_filters_priority = array();
366
+		$this->_current_route = $this->getCurrentRoute();
367
+		$this->caller = get_class($this);
368
+		$this->_extend = stripos($this->caller, 'Extend') ? true : false;
369
+	}
370
+
371
+
372
+	/**
373
+	 * A helper for determining the current route.
374
+	 * @return string
375
+	 */
376
+	private function getCurrentRoute()
377
+	{
378
+		$action = $this->request->getRequestParam('action');
379
+		// list tables do something else with 'action' for bulk actions.
380
+		$action = $action !== '-1' && $action !== ''  ? $action : 'default';
381
+		$route = $this->request->getRequestParam('route');
382
+		// we set a 'route' variable in some cases where action is being used by something else.
383
+		return $action === 'default' && $route !== '' ? $route : $action;
384
+	}
385
+
386
+
387
+	/**
388
+	 * this sets the _page_object property
389
+	 *
390
+	 * @access protected
391
+	 * @return void
392
+	 * @throws EE_Error
393
+	 */
394
+	protected function _set_page_object()
395
+	{
396
+		// first make sure $this->_name is set
397
+		if (empty($this->_name)) {
398
+			$msg[] = __('We can\'t load the page object', 'event_espresso');
399
+			$msg[] = sprintf(
400
+				__("This is because the %s child class has not set the '_name' property", 'event_espresso'),
401
+				$this->caller
402
+			);
403
+			throw new EE_Error(implode('||', $msg));
404
+		}
405
+		$class_name = str_replace('_', ' ', $this->_name); // take the_message -> the message
406
+		$class_name = str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page'; // take the message -> The_Message
407
+		// first default file (if exists)
408
+		$decaf_file = EE_ADMIN_PAGES . $this->_name . '/' . $class_name . '.core.php';
409
+		if (is_readable($decaf_file)) {
410
+			require_once($decaf_file);
411
+		}
412
+		// now we have to do require for extended file (if needed)
413
+		if ($this->_extend) {
414
+			require_once(EE_CORE_CAF_ADMIN_EXTEND . $this->_name . '/Extend_' . $class_name . '.core.php');
415
+		}
416
+		// if we've got an extended class we use that!
417
+		$class_name = $this->_extend ? 'Extend_' . $class_name : $class_name;
418
+		// let's make sure the class exists
419
+		if (! class_exists($class_name)) {
420
+			$msg[] = __('We can\'t load the page object', 'event_espresso');
421
+			$msg[] = sprintf(
422
+				__(
423
+					'The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class',
424
+					'event_espresso'
425
+				),
426
+				$class_name
427
+			);
428
+			throw new EE_Error(implode('||', $msg));
429
+		}
430
+		LoaderFactory::getLoader()->getShared($class_name);
431
+	}
432
+
433
+
434
+	/**
435
+	 * Child "hook" classes can declare any methods that they want executed when a specific page route is loaded.  The
436
+	 * advantage of this is when doing things like running our own db interactions on saves etc.  Remember that
437
+	 * $this->_req_data (all the _POST and _GET data) is available to your methods.
438
+	 *
439
+	 * @access private
440
+	 * @return void
441
+	 */
442
+	private function _load_custom_methods()
443
+	{
444
+		/**
445
+		 * method cannot be named 'default' (@see http://us3.php
446
+		 * .net/manual/en/reserved.keywords.php) so need to
447
+		 * handle routes that are "default"
448
+		 *
449
+		 * @since 4.3.0
450
+		 */
451
+		$method_callback = $this->_current_route == 'default' ? 'default_callback' : $this->_current_route;
452
+		// these run before the Admin_Page route executes.
453
+		if (method_exists($this, $method_callback)) {
454
+			call_user_func(array($this, $method_callback));
455
+		}
456
+		// these run via the _redirect_after_action method in EE_Admin_Page which usually happens after non_UI methods in EE_Admin_Page classes.  There are two redirect actions, the first fires before $query_args might be manipulated by "save and close" actions and the seond fires right before the actual redirect happens.
457
+		// first the actions
458
+		// note that these action hooks will have the $query_args value available.
459
+		$admin_class_name = get_class($this->_adminpage_obj);
460
+		if (method_exists($this, '_redirect_action_early_' . $this->_current_route)) {
461
+			add_action(
462
+				'AHEE__'
463
+				. $admin_class_name
464
+				. '___redirect_after_action__before_redirect_modification_'
465
+				. $this->_current_route,
466
+				array($this, '_redirect_action_early_' . $this->_current_route),
467
+				10
468
+			);
469
+		}
470
+		if (method_exists($this, '_redirect_action_' . $this->_current_route)) {
471
+			add_action(
472
+				'AHEE_redirect_' . $admin_class_name . $this->_current_route,
473
+				array($this, '_redirect_action_' . $this->_current_route),
474
+				10
475
+			);
476
+		}
477
+		// let's hook into the _redirect itself and allow for changing where the user goes after redirect.  This will have $query_args and $redirect_url available.
478
+		if (method_exists($this, '_redirect_filter_' . $this->_current_route)) {
479
+			add_filter(
480
+				'FHEE_redirect_' . $admin_class_name . $this->_current_route,
481
+				array($this, '_redirect_filter_' . $this->_current_route),
482
+				10,
483
+				2
484
+			);
485
+		}
486
+	}
487
+
488
+
489
+	/**
490
+	 * This method will search for a corresponding method with a name matching the route and the wp_hook to run.  This
491
+	 * allows child hook classes to target hooking into a specific wp action or filter hook ONLY on a certain route.
492
+	 * just remember, methods MUST be public Future hooks should be added in here to be access by child classes.
493
+	 *
494
+	 * @return void
495
+	 */
496
+	private function _load_routed_hooks()
497
+	{
498
+
499
+		// this array provides the hook action names that will be referenced.  Key is the action. Value is an array with the type (action or filter) and the number of parameters for the hook.  We'll default all priorities for automatic hooks to 10.
500
+		$hook_filter_array = array(
501
+			'admin_footer'                                                                            => array(
502
+				'type'     => 'action',
503
+				'argnum'   => 1,
504
+				'priority' => 10,
505
+			),
506
+			'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array(
507
+				'type'     => 'filter',
508
+				'argnum'   => 1,
509
+				'priority' => 10,
510
+			),
511
+			'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug                               => array(
512
+				'type'     => 'filter',
513
+				'argnum'   => 1,
514
+				'priority' => 10,
515
+			),
516
+			'FHEE_list_table_views'                                                                   => array(
517
+				'type'     => 'filter',
518
+				'argnum'   => 1,
519
+				'priority' => 10,
520
+			),
521
+			'AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes'                              => array(
522
+				'type'     => 'action',
523
+				'argnum'   => 1,
524
+				'priority' => 10,
525
+			),
526
+		);
527
+		foreach ($hook_filter_array as $hook => $args) {
528
+			if (method_exists($this, $this->_current_route . '_' . $hook)) {
529
+				if (isset($this->_wp_action_filters_priority[ $hook ])) {
530
+					$args['priority'] = $this->_wp_action_filters_priority[ $hook ];
531
+				}
532
+				if ($args['type'] == 'action') {
533
+					add_action(
534
+						$hook,
535
+						array($this, $this->_current_route . '_' . $hook),
536
+						$args['priority'],
537
+						$args['argnum']
538
+					);
539
+				} else {
540
+					add_filter(
541
+						$hook,
542
+						array($this, $this->_current_route . '_' . $hook),
543
+						$args['priority'],
544
+						$args['argnum']
545
+					);
546
+				}
547
+			}
548
+		}
549
+	}
550
+
551
+
552
+	/**
553
+	 * Loop throught the $_ajax_func array and add_actions for the array.
554
+	 *
555
+	 * @return void
556
+	 */
557
+	private function _ajax_hooks()
558
+	{
559
+
560
+		if (empty($this->_ajax_func)) {
561
+			return;
562
+		} //get out there's nothing to take care of.
563
+		foreach ($this->_ajax_func as $action => $method) {
564
+			// make sure method exists
565
+			if (! method_exists($this, $method)) {
566
+				$msg[] = __(
567
+					'There is no corresponding method for the hook labeled in the _ajax_func array',
568
+					'event_espresso'
569
+				) . '<br />';
570
+				$msg[] = sprintf(
571
+					__(
572
+						'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
573
+						'event_espresso'
574
+					),
575
+					$method,
576
+					$this->caller
577
+				);
578
+				throw new EE_Error(implode('||', $msg));
579
+			}
580
+			add_action('wp_ajax_' . $action, array($this, $method));
581
+		}
582
+	}
583
+
584
+
585
+	/**
586
+	 * Loop throught the $_init_func array and add_actions for the array.
587
+	 *
588
+	 * @return void
589
+	 */
590
+	protected function _init_hooks()
591
+	{
592
+		if (empty($this->_init_func)) {
593
+			return;
594
+		}
595
+		//get out there's nothing to take care of.
596
+		// We need to determine what page_route we are on!
597
+		foreach ($this->_init_func as $route => $method) {
598
+			// make sure method exists
599
+			if (! method_exists($this, $method)) {
600
+				$msg[] = __(
601
+					'There is no corresponding method for the hook labeled in the _init_func array',
602
+					'event_espresso'
603
+				) . '<br />';
604
+				$msg[] = sprintf(
605
+					__(
606
+						'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
607
+						'event_espresso'
608
+					),
609
+					$method,
610
+					$this->caller
611
+				);
612
+				throw new EE_Error(implode('||', $msg));
613
+			}
614
+			if ($route == $this->_current_route) {
615
+				add_action('admin_init', array($this, $method));
616
+			}
617
+		}
618
+	}
619
+
620
+
621
+	/**
622
+	 * Loop through the _metaboxes property and add_metaboxes accordingly
623
+	 * //todo we could eventually make this a config component class (i.e. new EE_Metabox);
624
+	 *
625
+	 * @access public
626
+	 * @return void
627
+	 */
628
+	public function add_metaboxes()
629
+	{
630
+		if (empty($this->_metaboxes)) {
631
+			return;
632
+		} //get out we don't have any metaboxes to set for this connection
633
+		$this->_handle_metabox_array($this->_metaboxes);
634
+	}
635
+
636
+
637
+	private function _handle_metabox_array($boxes, $add = true)
638
+	{
639
+
640
+		foreach ($boxes as $box) {
641
+			if (! isset($box['page_route'])) {
642
+				continue;
643
+			} //we dont' have a valid array
644
+			// let's make sure $box['page_route'] is an array so the "foreach" will work.
645
+			$box['page_route'] = (array) $box['page_route'];
646
+			foreach ($box['page_route'] as $route) {
647
+				if ($route != $this->_current_route) {
648
+					continue;
649
+				} //get out we only add metaboxes for set route.
650
+				if ($add) {
651
+					$this->_add_metabox($box);
652
+				} else {
653
+					$this->_remove_metabox($box);
654
+				}
655
+			}
656
+		}
657
+	}
658
+
659
+
660
+	/**
661
+	 * Loop through the _remove_metaboxes property and remove metaboxes accordingly.
662
+	 *
663
+	 * @access public
664
+	 * @return void
665
+	 */
666
+	public function remove_metaboxes()
667
+	{
668
+
669
+		if (empty($this->_remove_metaboxes)) {
670
+			return;
671
+		} //get out there are no metaboxes to remove
672
+		$this->_handle_metabox_array($this->_remove_metaboxes, false);
673
+	}
674
+
675
+
676
+	/**
677
+	 * This just handles adding a metabox
678
+	 *
679
+	 * @access private
680
+	 * @param array $args an array of args that have been set for this metabox by the child class
681
+	 */
682
+	private function _add_metabox($args)
683
+	{
684
+		$current_screen = get_current_screen();
685
+		$screen_id = is_object($current_screen) ? $current_screen->id : null;
686
+		$func = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
687
+		// set defaults
688
+		$defaults = array(
689
+			'func'          => $func,
690
+			'id'            => $this->caller . '_' . $func . '_metabox',
691
+			'priority'      => 'default',
692
+			'label'         => $this->caller,
693
+			'context'       => 'advanced',
694
+			'callback_args' => array(),
695
+			'page'          => isset($args['page']) ? $args['page'] : $screen_id,
696
+		);
697
+		$args = wp_parse_args($args, $defaults);
698
+		extract($args);
699
+		// make sure method exists
700
+		if (! method_exists($this, $func)) {
701
+			$msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />';
702
+			$msg[] = sprintf(
703
+				__(
704
+					'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
705
+					'event_espresso'
706
+				),
707
+				$func,
708
+				$this->caller
709
+			);
710
+			throw new EE_Error(implode('||', $msg));
711
+		}
712
+		// everything checks out so lets add the metabox
713
+		add_meta_box($id, $label, array($this, $func), $page, $context, $priority, $callback_args);
714
+	}
715
+
716
+
717
+	private function _remove_metabox($args)
718
+	{
719
+		$current_screen = get_current_screen();
720
+		$screen_id = is_object($current_screen) ? $current_screen->id : null;
721
+		$func = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
722
+		// set defaults
723
+		$defaults = array(
724
+			'id'      => isset($args['id'])
725
+				? $args['id']
726
+				: $this->_current_route
727
+				  . '_'
728
+				  . $this->caller
729
+				  . '_'
730
+				  . $func
731
+				  . '_metabox',
732
+			'context' => 'default',
733
+			'screen'  => isset($args['screen']) ? $args['screen'] : $screen_id,
734
+		);
735
+		$args = wp_parse_args($args, $defaults);
736
+		extract($args);
737
+		// everything checks out so lets remove the box!
738
+		remove_meta_box($id, $screen, $context);
739
+	}
740 740
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
         $this->_set_defaults();
213 213
         $this->_set_hooks_properties();
214 214
         // first let's verify we're on the right page
215
-        if (! isset($this->_req_data['page']) || $this->_req_data['page'] !== $this->_adminpage_obj->page_slug) {
215
+        if ( ! isset($this->_req_data['page']) || $this->_req_data['page'] !== $this->_adminpage_obj->page_slug) {
216 216
             return;
217 217
         }
218 218
         //get out nothing more to be done here.
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
     public function enqueue_scripts_styles()
262 262
     {
263 263
 
264
-        if (! empty($this->_scripts_styles)) {
264
+        if ( ! empty($this->_scripts_styles)) {
265 265
             // first let's do all the registrations
266
-            if (! isset($this->_scripts_styles['registers'])) {
266
+            if ( ! isset($this->_scripts_styles['registers'])) {
267 267
                 $msg[] = __(
268 268
                     'There is no "registers" index in the <code>$this->_scripts_styles</code> property.',
269 269
                     'event_espresso'
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
                         'Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child',
274 274
                         'event_espresso'
275 275
                     ),
276
-                    '<strong>' . $this->caller . '</strong>'
276
+                    '<strong>'.$this->caller.'</strong>'
277 277
                 );
278 278
                 throw new EE_Error(implode('||', $msg));
279 279
             }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
                 $details = wp_parse_args($details, $defaults);
289 289
                 extract($details);
290 290
                 // let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do
291
-                $this->_scripts_styles['registers'][ $ref ]['type'] = $type;
291
+                $this->_scripts_styles['registers'][$ref]['type'] = $type;
292 292
                 // let's make sure we're not missing any REQUIRED parameters
293 293
                 if (empty($url)) {
294 294
                     $msg[] = sprintf(
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
                             'Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref',
301 301
                             'event_espresso'
302 302
                         ),
303
-                        '<strong>' . $this->caller . '</strong>',
303
+                        '<strong>'.$this->caller.'</strong>',
304 304
                         $ref
305 305
                     );
306 306
                     throw new EE_Error(implode('||', $msg));
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
                     );
317 317
             }
318 318
             // k now lets do the enqueues
319
-            if (! isset($this->_scripts_styles['enqueues'])) {
319
+            if ( ! isset($this->_scripts_styles['enqueues'])) {
320 320
                 return;
321 321
             }  //not sure if we should throw an error here or not.
322 322
 
@@ -324,22 +324,22 @@  discard block
 block discarded – undo
324 324
                 // make sure $routes is an array
325 325
                 $routes = (array) $routes;
326 326
                 if (in_array($this->_current_route, $routes)) {
327
-                    $this->_scripts_styles['registers'][ $ref ]['type'] == 'js' ? wp_enqueue_script($ref)
327
+                    $this->_scripts_styles['registers'][$ref]['type'] == 'js' ? wp_enqueue_script($ref)
328 328
                         : wp_enqueue_style($ref);
329 329
                     // if we have a localization for the script let's do that too.
330
-                    if (isset($this->_scripts_styles['localize'][ $ref ])) {
331
-                        foreach ($this->_scripts_styles['localize'][ $ref ] as $object_name => $indexes) {
330
+                    if (isset($this->_scripts_styles['localize'][$ref])) {
331
+                        foreach ($this->_scripts_styles['localize'][$ref] as $object_name => $indexes) {
332 332
                             wp_localize_script(
333 333
                                 $ref,
334 334
                                 $object_name,
335
-                                $this->_scripts_styles['localize'][ $ref ][ $object_name ]
335
+                                $this->_scripts_styles['localize'][$ref][$object_name]
336 336
                             );
337 337
                         }
338 338
                     }
339 339
                 }
340 340
             }
341 341
             // let's do the deregisters
342
-            if (! isset($this->_scripts_styles['deregisters'])) {
342
+            if ( ! isset($this->_scripts_styles['deregisters'])) {
343 343
                 return;
344 344
             }
345 345
             foreach ($this->_scripts_styles['deregisters'] as $ref => $details) {
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
     {
378 378
         $action = $this->request->getRequestParam('action');
379 379
         // list tables do something else with 'action' for bulk actions.
380
-        $action = $action !== '-1' && $action !== ''  ? $action : 'default';
380
+        $action = $action !== '-1' && $action !== '' ? $action : 'default';
381 381
         $route = $this->request->getRequestParam('route');
382 382
         // we set a 'route' variable in some cases where action is being used by something else.
383 383
         return $action === 'default' && $route !== '' ? $route : $action;
@@ -403,20 +403,20 @@  discard block
 block discarded – undo
403 403
             throw new EE_Error(implode('||', $msg));
404 404
         }
405 405
         $class_name = str_replace('_', ' ', $this->_name); // take the_message -> the message
406
-        $class_name = str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page'; // take the message -> The_Message
406
+        $class_name = str_replace(' ', '_', ucwords($class_name)).'_Admin_Page'; // take the message -> The_Message
407 407
         // first default file (if exists)
408
-        $decaf_file = EE_ADMIN_PAGES . $this->_name . '/' . $class_name . '.core.php';
408
+        $decaf_file = EE_ADMIN_PAGES.$this->_name.'/'.$class_name.'.core.php';
409 409
         if (is_readable($decaf_file)) {
410 410
             require_once($decaf_file);
411 411
         }
412 412
         // now we have to do require for extended file (if needed)
413 413
         if ($this->_extend) {
414
-            require_once(EE_CORE_CAF_ADMIN_EXTEND . $this->_name . '/Extend_' . $class_name . '.core.php');
414
+            require_once(EE_CORE_CAF_ADMIN_EXTEND.$this->_name.'/Extend_'.$class_name.'.core.php');
415 415
         }
416 416
         // if we've got an extended class we use that!
417
-        $class_name = $this->_extend ? 'Extend_' . $class_name : $class_name;
417
+        $class_name = $this->_extend ? 'Extend_'.$class_name : $class_name;
418 418
         // let's make sure the class exists
419
-        if (! class_exists($class_name)) {
419
+        if ( ! class_exists($class_name)) {
420 420
             $msg[] = __('We can\'t load the page object', 'event_espresso');
421 421
             $msg[] = sprintf(
422 422
                 __(
@@ -457,28 +457,28 @@  discard block
 block discarded – undo
457 457
         // first the actions
458 458
         // note that these action hooks will have the $query_args value available.
459 459
         $admin_class_name = get_class($this->_adminpage_obj);
460
-        if (method_exists($this, '_redirect_action_early_' . $this->_current_route)) {
460
+        if (method_exists($this, '_redirect_action_early_'.$this->_current_route)) {
461 461
             add_action(
462 462
                 'AHEE__'
463 463
                 . $admin_class_name
464 464
                 . '___redirect_after_action__before_redirect_modification_'
465 465
                 . $this->_current_route,
466
-                array($this, '_redirect_action_early_' . $this->_current_route),
466
+                array($this, '_redirect_action_early_'.$this->_current_route),
467 467
                 10
468 468
             );
469 469
         }
470
-        if (method_exists($this, '_redirect_action_' . $this->_current_route)) {
470
+        if (method_exists($this, '_redirect_action_'.$this->_current_route)) {
471 471
             add_action(
472
-                'AHEE_redirect_' . $admin_class_name . $this->_current_route,
473
-                array($this, '_redirect_action_' . $this->_current_route),
472
+                'AHEE_redirect_'.$admin_class_name.$this->_current_route,
473
+                array($this, '_redirect_action_'.$this->_current_route),
474 474
                 10
475 475
             );
476 476
         }
477 477
         // let's hook into the _redirect itself and allow for changing where the user goes after redirect.  This will have $query_args and $redirect_url available.
478
-        if (method_exists($this, '_redirect_filter_' . $this->_current_route)) {
478
+        if (method_exists($this, '_redirect_filter_'.$this->_current_route)) {
479 479
             add_filter(
480
-                'FHEE_redirect_' . $admin_class_name . $this->_current_route,
481
-                array($this, '_redirect_filter_' . $this->_current_route),
480
+                'FHEE_redirect_'.$admin_class_name.$this->_current_route,
481
+                array($this, '_redirect_filter_'.$this->_current_route),
482 482
                 10,
483 483
                 2
484 484
             );
@@ -503,12 +503,12 @@  discard block
 block discarded – undo
503 503
                 'argnum'   => 1,
504 504
                 'priority' => 10,
505 505
             ),
506
-            'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array(
506
+            'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug.'_'.$this->_current_route => array(
507 507
                 'type'     => 'filter',
508 508
                 'argnum'   => 1,
509 509
                 'priority' => 10,
510 510
             ),
511
-            'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug                               => array(
511
+            'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug                               => array(
512 512
                 'type'     => 'filter',
513 513
                 'argnum'   => 1,
514 514
                 'priority' => 10,
@@ -525,21 +525,21 @@  discard block
 block discarded – undo
525 525
             ),
526 526
         );
527 527
         foreach ($hook_filter_array as $hook => $args) {
528
-            if (method_exists($this, $this->_current_route . '_' . $hook)) {
529
-                if (isset($this->_wp_action_filters_priority[ $hook ])) {
530
-                    $args['priority'] = $this->_wp_action_filters_priority[ $hook ];
528
+            if (method_exists($this, $this->_current_route.'_'.$hook)) {
529
+                if (isset($this->_wp_action_filters_priority[$hook])) {
530
+                    $args['priority'] = $this->_wp_action_filters_priority[$hook];
531 531
                 }
532 532
                 if ($args['type'] == 'action') {
533 533
                     add_action(
534 534
                         $hook,
535
-                        array($this, $this->_current_route . '_' . $hook),
535
+                        array($this, $this->_current_route.'_'.$hook),
536 536
                         $args['priority'],
537 537
                         $args['argnum']
538 538
                     );
539 539
                 } else {
540 540
                     add_filter(
541 541
                         $hook,
542
-                        array($this, $this->_current_route . '_' . $hook),
542
+                        array($this, $this->_current_route.'_'.$hook),
543 543
                         $args['priority'],
544 544
                         $args['argnum']
545 545
                     );
@@ -562,11 +562,11 @@  discard block
 block discarded – undo
562 562
         } //get out there's nothing to take care of.
563 563
         foreach ($this->_ajax_func as $action => $method) {
564 564
             // make sure method exists
565
-            if (! method_exists($this, $method)) {
565
+            if ( ! method_exists($this, $method)) {
566 566
                 $msg[] = __(
567 567
                     'There is no corresponding method for the hook labeled in the _ajax_func array',
568 568
                     'event_espresso'
569
-                ) . '<br />';
569
+                ).'<br />';
570 570
                 $msg[] = sprintf(
571 571
                     __(
572 572
                         'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
                 );
578 578
                 throw new EE_Error(implode('||', $msg));
579 579
             }
580
-            add_action('wp_ajax_' . $action, array($this, $method));
580
+            add_action('wp_ajax_'.$action, array($this, $method));
581 581
         }
582 582
     }
583 583
 
@@ -596,11 +596,11 @@  discard block
 block discarded – undo
596 596
         // We need to determine what page_route we are on!
597 597
         foreach ($this->_init_func as $route => $method) {
598 598
             // make sure method exists
599
-            if (! method_exists($this, $method)) {
599
+            if ( ! method_exists($this, $method)) {
600 600
                 $msg[] = __(
601 601
                     'There is no corresponding method for the hook labeled in the _init_func array',
602 602
                     'event_espresso'
603
-                ) . '<br />';
603
+                ).'<br />';
604 604
                 $msg[] = sprintf(
605 605
                     __(
606 606
                         'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
     {
639 639
 
640 640
         foreach ($boxes as $box) {
641
-            if (! isset($box['page_route'])) {
641
+            if ( ! isset($box['page_route'])) {
642 642
                 continue;
643 643
             } //we dont' have a valid array
644 644
             // let's make sure $box['page_route'] is an array so the "foreach" will work.
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
         // set defaults
688 688
         $defaults = array(
689 689
             'func'          => $func,
690
-            'id'            => $this->caller . '_' . $func . '_metabox',
690
+            'id'            => $this->caller.'_'.$func.'_metabox',
691 691
             'priority'      => 'default',
692 692
             'label'         => $this->caller,
693 693
             'context'       => 'advanced',
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
         $args = wp_parse_args($args, $defaults);
698 698
         extract($args);
699 699
         // make sure method exists
700
-        if (! method_exists($this, $func)) {
701
-            $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />';
700
+        if ( ! method_exists($this, $func)) {
701
+            $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso').'<br />';
702 702
             $msg[] = sprintf(
703 703
                 __(
704 704
                     'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_Init.core.php 2 patches
Indentation   +426 added lines, -426 removed lines patch added patch discarded remove patch
@@ -16,430 +16,430 @@
 block discarded – undo
16 16
 abstract class EE_Admin_Page_Init extends EE_Base
17 17
 {
18 18
 
19
-    // identity properties (set in _set_defaults and _set_init_properties)
20
-    public $label;
21
-
22
-    /**
23
-     * Menu map has a capability.  However, this allows admin pages to have separate capability requirements for menus
24
-     * and accessing pages.  If capability is NOT set, then it defaults to the menu_map capability.
25
-     *
26
-     * @var string
27
-     */
28
-    public $capability;
29
-
30
-
31
-    /**
32
-     * This holds the menu map object for this admin page.
33
-     *
34
-     * @var EE_Admin_Page_Menu_Map
35
-     */
36
-    protected $_menu_map;
37
-
38
-    /**
39
-     * deprecated
40
-     */
41
-    public $menu_label;
42
-    public $menu_slug;
43
-
44
-
45
-    // set in _set_defaults
46
-    protected $_folder_name;
47
-    protected $_folder_path;
48
-    protected $_file_name;
49
-    public $hook_file;
50
-    protected $_wp_page_slug;
51
-    protected $_routing;
52
-
53
-
54
-    // will hold page object.
55
-    protected $_loaded_page_object;
56
-
57
-
58
-    // for caf
59
-    protected $_files_hooked;
60
-    protected $_hook_paths;
61
-
62
-    // load_page?
63
-    private $_load_page;
64
-
65
-    /**
66
-     * @var RequestInterface
67
-     */
68
-    protected $request;
69
-
70
-
71
-    /**
72
-     * @Constructor
73
-     * @access public
74
-     * @return void
75
-     */
76
-    public function __construct()
77
-    {
78
-        $this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
79
-        // set global defaults
80
-        $this->_set_defaults();
81
-        // set properties that are always available with objects.
82
-        $this->_set_init_properties();
83
-        // global styles/scripts across all wp admin pages
84
-        add_action('admin_enqueue_scripts', array($this, 'load_wp_global_scripts_styles'), 5);
85
-        // load initial stuff.
86
-        $this->_set_file_and_folder_name();
87
-        $this->_set_menu_map();
88
-        if (empty($this->_menu_map) || is_array($this->_menu_map)) {
89
-            EE_Error::doing_it_wrong(
90
-                get_class($this) . '::$_menu_map',
91
-                sprintf(
92
-                    __(
93
-                        'The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core.  Please see Admin_Page_Init class examples in core for the new way of setting this property up.',
94
-                        'event_espresso'
95
-                    ),
96
-                    get_class($this)
97
-                ),
98
-                '4.4.0'
99
-            );
100
-            return;
101
-        }
102
-        // set default capability
103
-        $this->_set_capability();
104
-    }
105
-
106
-
107
-    /**
108
-     * _set_init_properties
109
-     * Child classes use to set the following properties:
110
-     * $label
111
-     *
112
-     * @abstract
113
-     * @access protected
114
-     * @return void
115
-     */
116
-    abstract protected function _set_init_properties();
117
-
118
-
119
-    /**
120
-     * _set_menu_map is a function that child classes use to set the menu_map property (which should be an instance of
121
-     * EE_Admin_Page_Menu_Map.  Their menu can either be EE_Admin_Page_Main_Menu or EE_Admin_Page_Sub_Menu.
122
-     *
123
-     * @since 4.4.0
124
-     * @ return void.
125
-     */
126
-    protected function _set_menu_map()
127
-    {
128
-        return array();
129
-    }
130
-
131
-
132
-    /**
133
-     * returns the menu map for this admin page
134
-     *
135
-     * @since 4.4.0
136
-     * @return EE_Admin_Page_Menu_Map
137
-     */
138
-    public function get_menu_map()
139
-    {
140
-        return $this->_menu_map;
141
-    }
142
-
143
-
144
-    /**
145
-     * This loads scripts and styles for the EE_Admin system
146
-     * that must be available on ALL WP admin pages (i.e. EE_menu items)
147
-     *
148
-     * @return void
149
-     */
150
-    public function load_wp_global_scripts_styles()
151
-    {
152
-        wp_register_style(
153
-            'espresso_menu',
154
-            EE_ADMIN_URL . 'assets/admin-menu-styles.css',
155
-            array('dashicons'),
156
-            EVENT_ESPRESSO_VERSION
157
-        );
158
-        wp_enqueue_style('espresso_menu');
159
-    }
160
-
161
-
162
-    /**
163
-     * this sets default properties (might be overridden in _set_init_properties);
164
-     *
165
-     * @access private
166
-     * @return  void
167
-     */
168
-    private function _set_defaults()
169
-    {
170
-        $this->_file_name = $this->_folder_name = $this->_wp_page_slug = $this->capability = null;
171
-        $this->_routing = true;
172
-        $this->_load_page = false;
173
-        $this->_files_hooked = $this->_hook_paths = array();
174
-        // menu_map
175
-        $this->_menu_map = $this->get_menu_map();
176
-    }
177
-
178
-
179
-    protected function _set_capability()
180
-    {
181
-        $capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability;
182
-        $this->capability = apply_filters('FHEE_' . $this->_menu_map->menu_slug . '_capability', $capability);
183
-    }
184
-
185
-
186
-    /**
187
-     * initialize_admin_page
188
-     * This method is what executes the loading of the specific page class for the given dir_name as called by the
189
-     * EE_Admin_Init class.
190
-     *
191
-     * @access  public
192
-     * @uses    _initialize_admin_page()
193
-     * @param  string $dir_name directory name for specific admin_page being loaded.
194
-     * @return void
195
-     */
196
-    public function initialize_admin_page()
197
-    {
198
-        // let's check user access first
199
-        $this->_check_user_access();
200
-        if (! is_object($this->_loaded_page_object)) {
201
-            return;
202
-        }
203
-        $this->_loaded_page_object->route_admin_request();
204
-        return;
205
-    }
206
-
207
-
208
-    public function set_page_dependencies($wp_page_slug)
209
-    {
210
-        if (! $this->_load_page) {
211
-            return;
212
-        }
213
-        if (! is_object($this->_loaded_page_object)) {
214
-            $msg[] = __(
215
-                'We can\'t load the page because we\'re missing a valid page object that tells us what to load',
216
-                'event_espresso'
217
-            );
218
-            $msg[] = $msg[0] . "\r\n"
219
-                     . sprintf(
220
-                         __(
221
-                             'The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory',
222
-                             'event_espresso'
223
-                         ),
224
-                         $this->_file_name,
225
-                         $this->_file_name,
226
-                         $this->_folder_path . $this->_file_name,
227
-                         $this->_menu_map->menu_slug
228
-                     );
229
-            throw new EE_Error(implode('||', $msg));
230
-        }
231
-        $this->_loaded_page_object->set_wp_page_slug($wp_page_slug);
232
-        $page_hook = 'load-' . $wp_page_slug;
233
-        // hook into page load hook so all page specific stuff get's loaded.
234
-        if (! empty($wp_page_slug)) {
235
-            add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies'));
236
-        }
237
-    }
238
-
239
-
240
-    /**
241
-     * This executes the intial page loads for EE_Admin pages to take care of any ajax or other code needing to run
242
-     * before the load-page... hook. Note, the page loads are happening around the wp_init hook.
243
-     *
244
-     * @return void
245
-     */
246
-    public function do_initial_loads()
247
-    {
248
-        // no loading or initializing if menu map is setup incorrectly.
249
-        if (empty($this->_menu_map) || is_array($this->_menu_map)) {
250
-            return;
251
-        }
252
-        $this->_initialize_admin_page();
253
-    }
254
-
255
-
256
-    /**
257
-     * all we're doing here is setting the $_file_name property for later use.
258
-     *
259
-     * @access private
260
-     * @return void
261
-     */
262
-    private function _set_file_and_folder_name()
263
-    {
264
-        $bt = debug_backtrace();
265
-        // for more reliable determination of folder name
266
-        // we're using this to get the actual folder name of the CALLING class (i.e. the child class that extends this).  Why?  Because $this->menu_slug may be different than the folder name (to avoid conflicts with other plugins)
267
-        $class = get_class($this);
268
-        foreach ($bt as $index => $values) {
269
-            if (isset($values['class']) && $values['class'] == $class) {
270
-                $file_index = $index - 1;
271
-                $this->_folder_name = basename(dirname($bt[ $file_index ]['file']));
272
-                if (! empty($this->_folder_name)) {
273
-                    break;
274
-                }
275
-            }
276
-        }
277
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
278
-        $this->_file_name = preg_replace('/^ee/', 'EE', $this->_folder_name);
279
-        $this->_file_name = ucwords(str_replace('_', ' ', $this->_file_name));
280
-        $this->_file_name = str_replace(' ', '_', $this->_file_name);
281
-    }
282
-
283
-
284
-    /**
285
-     * This automatically checks if we have a hook class in the loaded child directory.  If we DO then we will register
286
-     * it with the appropriate pages.  That way all we have to do is make sure the file is named correctly and
287
-     * "dropped" in. Example: if we wanted to set this up for Messages hooking into Events then we would do:
288
-     * events_Messages_Hooks.class.php
289
-     *
290
-     * @param bool $extend This indicates whether we're checking the extend directory for any register_hooks
291
-     *                     files/classes
292
-     * @return array
293
-     */
294
-    public function register_hooks($extend = false)
295
-    {
296
-
297
-        // get a list of files in the directory that have the "Hook" in their name an
298
-        // if this is an extended check (i.e. caf is active) then we will scan the caffeinated/extend directory first and any hook files that are found will be have their reference added to the $_files_hook array property.  Then, we make sure that when we loop through the core decaf directories to find hook files that we skip over any hooks files that have already been set by caf.
299
-        if ($extend) {
300
-            $hook_files_glob_path = apply_filters(
301
-                'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend',
302
-                EE_CORE_CAF_ADMIN_EXTEND
303
-                . $this->_folder_name
304
-                . '/*'
305
-                . $this->_file_name
306
-                . '_Hooks_Extend.class.php'
307
-            );
308
-            $this->_hook_paths = $this->_register_hook_files($hook_files_glob_path, $extend);
309
-        }
310
-        // loop through decaf folders
311
-        $hook_files_glob_path = apply_filters(
312
-            'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path',
313
-            $this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php'
314
-        );
315
-        $this->_hook_paths = array_merge(
316
-            $this->_register_hook_files($hook_files_glob_path),
317
-            $this->_hook_paths
318
-        );  // making sure any extended hook paths are later in the array than the core hook paths!
319
-        return $this->_hook_paths;
320
-    }
321
-
322
-
323
-    protected function _register_hook_files($hook_files_glob_path, $extend = false)
324
-    {
325
-        $hook_paths = array();
326
-        if ($hook_files = glob($hook_files_glob_path)) {
327
-            if (empty($hook_files)) {
328
-                return array();
329
-            }
330
-            foreach ($hook_files as $file) {
331
-                // lets get the linked admin.
332
-                $hook_file = $extend ? str_replace(EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . '/', '', $file)
333
-                    : str_replace($this->_folder_path, '', $file);
334
-                $replace = $extend
335
-                    ? '_' . $this->_file_name . '_Hooks_Extend.class.php'
336
-                    : '_'
337
-                      . $this->_file_name
338
-                      . '_Hooks.class.php';
339
-                $rel_admin = str_replace($replace, '', $hook_file);
340
-                $rel_admin = strtolower($rel_admin);
341
-                $hook_paths[] = $file;
342
-                // make sure we haven't already got a hook setup for this page path
343
-                if (in_array($rel_admin, $this->_files_hooked)) {
344
-                    continue;
345
-                }
346
-                $this->hook_file = $hook_file;
347
-                $rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin;
348
-                $filter = add_filter($rel_admin_hook, array($this, 'load_admin_hook'));
349
-                $this->_files_hooked[] = $rel_admin;
350
-            }
351
-        }
352
-        return $hook_paths;
353
-    }
354
-
355
-
356
-    public function load_admin_hook($registered_pages)
357
-    {
358
-        $this->hook_file;
359
-        $hook_file = (array) $this->hook_file;
360
-        return array_merge($hook_file, $registered_pages);
361
-    }
362
-
363
-
364
-    /**
365
-     * _initialize_admin_page
366
-     *
367
-     * @see  initialize_admin_page() for info
368
-     */
369
-    protected function _initialize_admin_page()
370
-    {
371
-        // JUST CHECK WE'RE ON RIGHT PAGE.
372
-        $page = $this->request->getRequestParam('page');
373
-        if ($page === '' || $page !== $this->_menu_map->menu_slug && $this->_routing) {
374
-            return;
375
-        } //not on the right page so let's get out.
376
-        $this->_load_page = true;
377
-
378
-        // we don't need to do a page_request check here because it's only called via WP menu system.
379
-        $admin_page = $this->_file_name . '_Admin_Page';
380
-        $hook_suffix = $this->_menu_map->menu_slug . '_' . $admin_page;
381
-        $admin_page = apply_filters(
382
-            "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$hook_suffix}",
383
-            $admin_page
384
-        );
385
-        // define requested admin page class name then load the file and instantiate
386
-        $path_to_file = str_replace(array('\\', '/'), '/', $this->_folder_path . $admin_page . '.core.php');
387
-        $path_to_file = apply_filters(
388
-            "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}",
389
-            $path_to_file
390
-        );// so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page
391
-        if (is_readable($path_to_file)) {
392
-            // This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place
393
-            do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization');
394
-            do_action(
395
-                'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_' . $this->_menu_map->menu_slug
396
-            );
397
-            require_once($path_to_file);
398
-            $a = new ReflectionClass($admin_page);
399
-            $this->_loaded_page_object = $a->newInstance($this->_routing);
400
-        }
401
-        do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization');
402
-        do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_' . $this->_menu_map->menu_slug);
403
-    }
404
-
405
-
406
-    public function get_admin_page_name()
407
-    {
408
-        return $this->_file_name . '_Admin_Page';
409
-    }
410
-
411
-
412
-    /**
413
-     * @return mixed
414
-     */
415
-    public function loaded_page_object()
416
-    {
417
-        return $this->_loaded_page_object;
418
-    }
419
-
420
-
421
-    // public function set_autoloaders($className)
422
-    // {
423
-    //     $dir_ref = array(
424
-    //         $this->_folder_path => array('core', 'class'),
425
-    //     );
426
-    //     EEH_Autoloader::try_autoload($dir_ref, $className);
427
-    // }
428
-    /**
429
-     * _check_user_access
430
-     * verifies user access for this admin page.  If no user access is available then let's gracefully exit with a
431
-     * WordPress die message.
432
-     *
433
-     * @return bool|die true if pass (or admin) wp_die if fail
434
-     */
435
-    private function _check_user_access()
436
-    {
437
-        if (! EE_Registry::instance()->CAP->current_user_can(
438
-            $this->_menu_map->capability,
439
-            $this->_menu_map->menu_slug
440
-        )) {
441
-            wp_die(__('You don\'t have access to this page.', 'event_espresso'), '', array('back_link' => true));
442
-        }
443
-        return true;
444
-    }
19
+	// identity properties (set in _set_defaults and _set_init_properties)
20
+	public $label;
21
+
22
+	/**
23
+	 * Menu map has a capability.  However, this allows admin pages to have separate capability requirements for menus
24
+	 * and accessing pages.  If capability is NOT set, then it defaults to the menu_map capability.
25
+	 *
26
+	 * @var string
27
+	 */
28
+	public $capability;
29
+
30
+
31
+	/**
32
+	 * This holds the menu map object for this admin page.
33
+	 *
34
+	 * @var EE_Admin_Page_Menu_Map
35
+	 */
36
+	protected $_menu_map;
37
+
38
+	/**
39
+	 * deprecated
40
+	 */
41
+	public $menu_label;
42
+	public $menu_slug;
43
+
44
+
45
+	// set in _set_defaults
46
+	protected $_folder_name;
47
+	protected $_folder_path;
48
+	protected $_file_name;
49
+	public $hook_file;
50
+	protected $_wp_page_slug;
51
+	protected $_routing;
52
+
53
+
54
+	// will hold page object.
55
+	protected $_loaded_page_object;
56
+
57
+
58
+	// for caf
59
+	protected $_files_hooked;
60
+	protected $_hook_paths;
61
+
62
+	// load_page?
63
+	private $_load_page;
64
+
65
+	/**
66
+	 * @var RequestInterface
67
+	 */
68
+	protected $request;
69
+
70
+
71
+	/**
72
+	 * @Constructor
73
+	 * @access public
74
+	 * @return void
75
+	 */
76
+	public function __construct()
77
+	{
78
+		$this->request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
79
+		// set global defaults
80
+		$this->_set_defaults();
81
+		// set properties that are always available with objects.
82
+		$this->_set_init_properties();
83
+		// global styles/scripts across all wp admin pages
84
+		add_action('admin_enqueue_scripts', array($this, 'load_wp_global_scripts_styles'), 5);
85
+		// load initial stuff.
86
+		$this->_set_file_and_folder_name();
87
+		$this->_set_menu_map();
88
+		if (empty($this->_menu_map) || is_array($this->_menu_map)) {
89
+			EE_Error::doing_it_wrong(
90
+				get_class($this) . '::$_menu_map',
91
+				sprintf(
92
+					__(
93
+						'The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core.  Please see Admin_Page_Init class examples in core for the new way of setting this property up.',
94
+						'event_espresso'
95
+					),
96
+					get_class($this)
97
+				),
98
+				'4.4.0'
99
+			);
100
+			return;
101
+		}
102
+		// set default capability
103
+		$this->_set_capability();
104
+	}
105
+
106
+
107
+	/**
108
+	 * _set_init_properties
109
+	 * Child classes use to set the following properties:
110
+	 * $label
111
+	 *
112
+	 * @abstract
113
+	 * @access protected
114
+	 * @return void
115
+	 */
116
+	abstract protected function _set_init_properties();
117
+
118
+
119
+	/**
120
+	 * _set_menu_map is a function that child classes use to set the menu_map property (which should be an instance of
121
+	 * EE_Admin_Page_Menu_Map.  Their menu can either be EE_Admin_Page_Main_Menu or EE_Admin_Page_Sub_Menu.
122
+	 *
123
+	 * @since 4.4.0
124
+	 * @ return void.
125
+	 */
126
+	protected function _set_menu_map()
127
+	{
128
+		return array();
129
+	}
130
+
131
+
132
+	/**
133
+	 * returns the menu map for this admin page
134
+	 *
135
+	 * @since 4.4.0
136
+	 * @return EE_Admin_Page_Menu_Map
137
+	 */
138
+	public function get_menu_map()
139
+	{
140
+		return $this->_menu_map;
141
+	}
142
+
143
+
144
+	/**
145
+	 * This loads scripts and styles for the EE_Admin system
146
+	 * that must be available on ALL WP admin pages (i.e. EE_menu items)
147
+	 *
148
+	 * @return void
149
+	 */
150
+	public function load_wp_global_scripts_styles()
151
+	{
152
+		wp_register_style(
153
+			'espresso_menu',
154
+			EE_ADMIN_URL . 'assets/admin-menu-styles.css',
155
+			array('dashicons'),
156
+			EVENT_ESPRESSO_VERSION
157
+		);
158
+		wp_enqueue_style('espresso_menu');
159
+	}
160
+
161
+
162
+	/**
163
+	 * this sets default properties (might be overridden in _set_init_properties);
164
+	 *
165
+	 * @access private
166
+	 * @return  void
167
+	 */
168
+	private function _set_defaults()
169
+	{
170
+		$this->_file_name = $this->_folder_name = $this->_wp_page_slug = $this->capability = null;
171
+		$this->_routing = true;
172
+		$this->_load_page = false;
173
+		$this->_files_hooked = $this->_hook_paths = array();
174
+		// menu_map
175
+		$this->_menu_map = $this->get_menu_map();
176
+	}
177
+
178
+
179
+	protected function _set_capability()
180
+	{
181
+		$capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability;
182
+		$this->capability = apply_filters('FHEE_' . $this->_menu_map->menu_slug . '_capability', $capability);
183
+	}
184
+
185
+
186
+	/**
187
+	 * initialize_admin_page
188
+	 * This method is what executes the loading of the specific page class for the given dir_name as called by the
189
+	 * EE_Admin_Init class.
190
+	 *
191
+	 * @access  public
192
+	 * @uses    _initialize_admin_page()
193
+	 * @param  string $dir_name directory name for specific admin_page being loaded.
194
+	 * @return void
195
+	 */
196
+	public function initialize_admin_page()
197
+	{
198
+		// let's check user access first
199
+		$this->_check_user_access();
200
+		if (! is_object($this->_loaded_page_object)) {
201
+			return;
202
+		}
203
+		$this->_loaded_page_object->route_admin_request();
204
+		return;
205
+	}
206
+
207
+
208
+	public function set_page_dependencies($wp_page_slug)
209
+	{
210
+		if (! $this->_load_page) {
211
+			return;
212
+		}
213
+		if (! is_object($this->_loaded_page_object)) {
214
+			$msg[] = __(
215
+				'We can\'t load the page because we\'re missing a valid page object that tells us what to load',
216
+				'event_espresso'
217
+			);
218
+			$msg[] = $msg[0] . "\r\n"
219
+					 . sprintf(
220
+						 __(
221
+							 'The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory',
222
+							 'event_espresso'
223
+						 ),
224
+						 $this->_file_name,
225
+						 $this->_file_name,
226
+						 $this->_folder_path . $this->_file_name,
227
+						 $this->_menu_map->menu_slug
228
+					 );
229
+			throw new EE_Error(implode('||', $msg));
230
+		}
231
+		$this->_loaded_page_object->set_wp_page_slug($wp_page_slug);
232
+		$page_hook = 'load-' . $wp_page_slug;
233
+		// hook into page load hook so all page specific stuff get's loaded.
234
+		if (! empty($wp_page_slug)) {
235
+			add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies'));
236
+		}
237
+	}
238
+
239
+
240
+	/**
241
+	 * This executes the intial page loads for EE_Admin pages to take care of any ajax or other code needing to run
242
+	 * before the load-page... hook. Note, the page loads are happening around the wp_init hook.
243
+	 *
244
+	 * @return void
245
+	 */
246
+	public function do_initial_loads()
247
+	{
248
+		// no loading or initializing if menu map is setup incorrectly.
249
+		if (empty($this->_menu_map) || is_array($this->_menu_map)) {
250
+			return;
251
+		}
252
+		$this->_initialize_admin_page();
253
+	}
254
+
255
+
256
+	/**
257
+	 * all we're doing here is setting the $_file_name property for later use.
258
+	 *
259
+	 * @access private
260
+	 * @return void
261
+	 */
262
+	private function _set_file_and_folder_name()
263
+	{
264
+		$bt = debug_backtrace();
265
+		// for more reliable determination of folder name
266
+		// we're using this to get the actual folder name of the CALLING class (i.e. the child class that extends this).  Why?  Because $this->menu_slug may be different than the folder name (to avoid conflicts with other plugins)
267
+		$class = get_class($this);
268
+		foreach ($bt as $index => $values) {
269
+			if (isset($values['class']) && $values['class'] == $class) {
270
+				$file_index = $index - 1;
271
+				$this->_folder_name = basename(dirname($bt[ $file_index ]['file']));
272
+				if (! empty($this->_folder_name)) {
273
+					break;
274
+				}
275
+			}
276
+		}
277
+		$this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
278
+		$this->_file_name = preg_replace('/^ee/', 'EE', $this->_folder_name);
279
+		$this->_file_name = ucwords(str_replace('_', ' ', $this->_file_name));
280
+		$this->_file_name = str_replace(' ', '_', $this->_file_name);
281
+	}
282
+
283
+
284
+	/**
285
+	 * This automatically checks if we have a hook class in the loaded child directory.  If we DO then we will register
286
+	 * it with the appropriate pages.  That way all we have to do is make sure the file is named correctly and
287
+	 * "dropped" in. Example: if we wanted to set this up for Messages hooking into Events then we would do:
288
+	 * events_Messages_Hooks.class.php
289
+	 *
290
+	 * @param bool $extend This indicates whether we're checking the extend directory for any register_hooks
291
+	 *                     files/classes
292
+	 * @return array
293
+	 */
294
+	public function register_hooks($extend = false)
295
+	{
296
+
297
+		// get a list of files in the directory that have the "Hook" in their name an
298
+		// if this is an extended check (i.e. caf is active) then we will scan the caffeinated/extend directory first and any hook files that are found will be have their reference added to the $_files_hook array property.  Then, we make sure that when we loop through the core decaf directories to find hook files that we skip over any hooks files that have already been set by caf.
299
+		if ($extend) {
300
+			$hook_files_glob_path = apply_filters(
301
+				'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend',
302
+				EE_CORE_CAF_ADMIN_EXTEND
303
+				. $this->_folder_name
304
+				. '/*'
305
+				. $this->_file_name
306
+				. '_Hooks_Extend.class.php'
307
+			);
308
+			$this->_hook_paths = $this->_register_hook_files($hook_files_glob_path, $extend);
309
+		}
310
+		// loop through decaf folders
311
+		$hook_files_glob_path = apply_filters(
312
+			'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path',
313
+			$this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php'
314
+		);
315
+		$this->_hook_paths = array_merge(
316
+			$this->_register_hook_files($hook_files_glob_path),
317
+			$this->_hook_paths
318
+		);  // making sure any extended hook paths are later in the array than the core hook paths!
319
+		return $this->_hook_paths;
320
+	}
321
+
322
+
323
+	protected function _register_hook_files($hook_files_glob_path, $extend = false)
324
+	{
325
+		$hook_paths = array();
326
+		if ($hook_files = glob($hook_files_glob_path)) {
327
+			if (empty($hook_files)) {
328
+				return array();
329
+			}
330
+			foreach ($hook_files as $file) {
331
+				// lets get the linked admin.
332
+				$hook_file = $extend ? str_replace(EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . '/', '', $file)
333
+					: str_replace($this->_folder_path, '', $file);
334
+				$replace = $extend
335
+					? '_' . $this->_file_name . '_Hooks_Extend.class.php'
336
+					: '_'
337
+					  . $this->_file_name
338
+					  . '_Hooks.class.php';
339
+				$rel_admin = str_replace($replace, '', $hook_file);
340
+				$rel_admin = strtolower($rel_admin);
341
+				$hook_paths[] = $file;
342
+				// make sure we haven't already got a hook setup for this page path
343
+				if (in_array($rel_admin, $this->_files_hooked)) {
344
+					continue;
345
+				}
346
+				$this->hook_file = $hook_file;
347
+				$rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin;
348
+				$filter = add_filter($rel_admin_hook, array($this, 'load_admin_hook'));
349
+				$this->_files_hooked[] = $rel_admin;
350
+			}
351
+		}
352
+		return $hook_paths;
353
+	}
354
+
355
+
356
+	public function load_admin_hook($registered_pages)
357
+	{
358
+		$this->hook_file;
359
+		$hook_file = (array) $this->hook_file;
360
+		return array_merge($hook_file, $registered_pages);
361
+	}
362
+
363
+
364
+	/**
365
+	 * _initialize_admin_page
366
+	 *
367
+	 * @see  initialize_admin_page() for info
368
+	 */
369
+	protected function _initialize_admin_page()
370
+	{
371
+		// JUST CHECK WE'RE ON RIGHT PAGE.
372
+		$page = $this->request->getRequestParam('page');
373
+		if ($page === '' || $page !== $this->_menu_map->menu_slug && $this->_routing) {
374
+			return;
375
+		} //not on the right page so let's get out.
376
+		$this->_load_page = true;
377
+
378
+		// we don't need to do a page_request check here because it's only called via WP menu system.
379
+		$admin_page = $this->_file_name . '_Admin_Page';
380
+		$hook_suffix = $this->_menu_map->menu_slug . '_' . $admin_page;
381
+		$admin_page = apply_filters(
382
+			"FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$hook_suffix}",
383
+			$admin_page
384
+		);
385
+		// define requested admin page class name then load the file and instantiate
386
+		$path_to_file = str_replace(array('\\', '/'), '/', $this->_folder_path . $admin_page . '.core.php');
387
+		$path_to_file = apply_filters(
388
+			"FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}",
389
+			$path_to_file
390
+		);// so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page
391
+		if (is_readable($path_to_file)) {
392
+			// This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place
393
+			do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization');
394
+			do_action(
395
+				'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_' . $this->_menu_map->menu_slug
396
+			);
397
+			require_once($path_to_file);
398
+			$a = new ReflectionClass($admin_page);
399
+			$this->_loaded_page_object = $a->newInstance($this->_routing);
400
+		}
401
+		do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization');
402
+		do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_' . $this->_menu_map->menu_slug);
403
+	}
404
+
405
+
406
+	public function get_admin_page_name()
407
+	{
408
+		return $this->_file_name . '_Admin_Page';
409
+	}
410
+
411
+
412
+	/**
413
+	 * @return mixed
414
+	 */
415
+	public function loaded_page_object()
416
+	{
417
+		return $this->_loaded_page_object;
418
+	}
419
+
420
+
421
+	// public function set_autoloaders($className)
422
+	// {
423
+	//     $dir_ref = array(
424
+	//         $this->_folder_path => array('core', 'class'),
425
+	//     );
426
+	//     EEH_Autoloader::try_autoload($dir_ref, $className);
427
+	// }
428
+	/**
429
+	 * _check_user_access
430
+	 * verifies user access for this admin page.  If no user access is available then let's gracefully exit with a
431
+	 * WordPress die message.
432
+	 *
433
+	 * @return bool|die true if pass (or admin) wp_die if fail
434
+	 */
435
+	private function _check_user_access()
436
+	{
437
+		if (! EE_Registry::instance()->CAP->current_user_can(
438
+			$this->_menu_map->capability,
439
+			$this->_menu_map->menu_slug
440
+		)) {
441
+			wp_die(__('You don\'t have access to this page.', 'event_espresso'), '', array('back_link' => true));
442
+		}
443
+		return true;
444
+	}
445 445
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
         $this->_set_menu_map();
88 88
         if (empty($this->_menu_map) || is_array($this->_menu_map)) {
89 89
             EE_Error::doing_it_wrong(
90
-                get_class($this) . '::$_menu_map',
90
+                get_class($this).'::$_menu_map',
91 91
                 sprintf(
92 92
                     __(
93 93
                         'The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core.  Please see Admin_Page_Init class examples in core for the new way of setting this property up.',
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     {
152 152
         wp_register_style(
153 153
             'espresso_menu',
154
-            EE_ADMIN_URL . 'assets/admin-menu-styles.css',
154
+            EE_ADMIN_URL.'assets/admin-menu-styles.css',
155 155
             array('dashicons'),
156 156
             EVENT_ESPRESSO_VERSION
157 157
         );
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     protected function _set_capability()
180 180
     {
181 181
         $capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability;
182
-        $this->capability = apply_filters('FHEE_' . $this->_menu_map->menu_slug . '_capability', $capability);
182
+        $this->capability = apply_filters('FHEE_'.$this->_menu_map->menu_slug.'_capability', $capability);
183 183
     }
184 184
 
185 185
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     {
198 198
         // let's check user access first
199 199
         $this->_check_user_access();
200
-        if (! is_object($this->_loaded_page_object)) {
200
+        if ( ! is_object($this->_loaded_page_object)) {
201 201
             return;
202 202
         }
203 203
         $this->_loaded_page_object->route_admin_request();
@@ -207,15 +207,15 @@  discard block
 block discarded – undo
207 207
 
208 208
     public function set_page_dependencies($wp_page_slug)
209 209
     {
210
-        if (! $this->_load_page) {
210
+        if ( ! $this->_load_page) {
211 211
             return;
212 212
         }
213
-        if (! is_object($this->_loaded_page_object)) {
213
+        if ( ! is_object($this->_loaded_page_object)) {
214 214
             $msg[] = __(
215 215
                 'We can\'t load the page because we\'re missing a valid page object that tells us what to load',
216 216
                 'event_espresso'
217 217
             );
218
-            $msg[] = $msg[0] . "\r\n"
218
+            $msg[] = $msg[0]."\r\n"
219 219
                      . sprintf(
220 220
                          __(
221 221
                              'The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory',
@@ -223,15 +223,15 @@  discard block
 block discarded – undo
223 223
                          ),
224 224
                          $this->_file_name,
225 225
                          $this->_file_name,
226
-                         $this->_folder_path . $this->_file_name,
226
+                         $this->_folder_path.$this->_file_name,
227 227
                          $this->_menu_map->menu_slug
228 228
                      );
229 229
             throw new EE_Error(implode('||', $msg));
230 230
         }
231 231
         $this->_loaded_page_object->set_wp_page_slug($wp_page_slug);
232
-        $page_hook = 'load-' . $wp_page_slug;
232
+        $page_hook = 'load-'.$wp_page_slug;
233 233
         // hook into page load hook so all page specific stuff get's loaded.
234
-        if (! empty($wp_page_slug)) {
234
+        if ( ! empty($wp_page_slug)) {
235 235
             add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies'));
236 236
         }
237 237
     }
@@ -268,13 +268,13 @@  discard block
 block discarded – undo
268 268
         foreach ($bt as $index => $values) {
269 269
             if (isset($values['class']) && $values['class'] == $class) {
270 270
                 $file_index = $index - 1;
271
-                $this->_folder_name = basename(dirname($bt[ $file_index ]['file']));
272
-                if (! empty($this->_folder_name)) {
271
+                $this->_folder_name = basename(dirname($bt[$file_index]['file']));
272
+                if ( ! empty($this->_folder_name)) {
273 273
                     break;
274 274
                 }
275 275
             }
276 276
         }
277
-        $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/';
277
+        $this->_folder_path = EE_ADMIN_PAGES.$this->_folder_name.'/';
278 278
         $this->_file_name = preg_replace('/^ee/', 'EE', $this->_folder_name);
279 279
         $this->_file_name = ucwords(str_replace('_', ' ', $this->_file_name));
280 280
         $this->_file_name = str_replace(' ', '_', $this->_file_name);
@@ -310,12 +310,12 @@  discard block
 block discarded – undo
310 310
         // loop through decaf folders
311 311
         $hook_files_glob_path = apply_filters(
312 312
             'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path',
313
-            $this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php'
313
+            $this->_folder_path.'*'.$this->_file_name.'_Hooks.class.php'
314 314
         );
315 315
         $this->_hook_paths = array_merge(
316 316
             $this->_register_hook_files($hook_files_glob_path),
317 317
             $this->_hook_paths
318
-        );  // making sure any extended hook paths are later in the array than the core hook paths!
318
+        ); // making sure any extended hook paths are later in the array than the core hook paths!
319 319
         return $this->_hook_paths;
320 320
     }
321 321
 
@@ -329,10 +329,10 @@  discard block
 block discarded – undo
329 329
             }
330 330
             foreach ($hook_files as $file) {
331 331
                 // lets get the linked admin.
332
-                $hook_file = $extend ? str_replace(EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . '/', '', $file)
332
+                $hook_file = $extend ? str_replace(EE_CORE_CAF_ADMIN_EXTEND.$this->_folder_name.'/', '', $file)
333 333
                     : str_replace($this->_folder_path, '', $file);
334 334
                 $replace = $extend
335
-                    ? '_' . $this->_file_name . '_Hooks_Extend.class.php'
335
+                    ? '_'.$this->_file_name.'_Hooks_Extend.class.php'
336 336
                     : '_'
337 337
                       . $this->_file_name
338 338
                       . '_Hooks.class.php';
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
                     continue;
345 345
                 }
346 346
                 $this->hook_file = $hook_file;
347
-                $rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin;
347
+                $rel_admin_hook = 'FHEE_do_other_page_hooks_'.$rel_admin;
348 348
                 $filter = add_filter($rel_admin_hook, array($this, 'load_admin_hook'));
349 349
                 $this->_files_hooked[] = $rel_admin;
350 350
             }
@@ -376,36 +376,36 @@  discard block
 block discarded – undo
376 376
         $this->_load_page = true;
377 377
 
378 378
         // we don't need to do a page_request check here because it's only called via WP menu system.
379
-        $admin_page = $this->_file_name . '_Admin_Page';
380
-        $hook_suffix = $this->_menu_map->menu_slug . '_' . $admin_page;
379
+        $admin_page = $this->_file_name.'_Admin_Page';
380
+        $hook_suffix = $this->_menu_map->menu_slug.'_'.$admin_page;
381 381
         $admin_page = apply_filters(
382 382
             "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$hook_suffix}",
383 383
             $admin_page
384 384
         );
385 385
         // define requested admin page class name then load the file and instantiate
386
-        $path_to_file = str_replace(array('\\', '/'), '/', $this->_folder_path . $admin_page . '.core.php');
386
+        $path_to_file = str_replace(array('\\', '/'), '/', $this->_folder_path.$admin_page.'.core.php');
387 387
         $path_to_file = apply_filters(
388 388
             "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}",
389 389
             $path_to_file
390
-        );// so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page
390
+        ); // so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page
391 391
         if (is_readable($path_to_file)) {
392 392
             // This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place
393 393
             do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization');
394 394
             do_action(
395
-                'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_' . $this->_menu_map->menu_slug
395
+                'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_'.$this->_menu_map->menu_slug
396 396
             );
397 397
             require_once($path_to_file);
398 398
             $a = new ReflectionClass($admin_page);
399 399
             $this->_loaded_page_object = $a->newInstance($this->_routing);
400 400
         }
401 401
         do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization');
402
-        do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_' . $this->_menu_map->menu_slug);
402
+        do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_'.$this->_menu_map->menu_slug);
403 403
     }
404 404
 
405 405
 
406 406
     public function get_admin_page_name()
407 407
     {
408
-        return $this->_file_name . '_Admin_Page';
408
+        return $this->_file_name.'_Admin_Page';
409 409
     }
410 410
 
411 411
 
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
      */
435 435
     private function _check_user_access()
436 436
     {
437
-        if (! EE_Registry::instance()->CAP->current_user_can(
437
+        if ( ! EE_Registry::instance()->CAP->current_user_can(
438 438
             $this->_menu_map->capability,
439 439
             $this->_menu_map->menu_slug
440 440
         )) {
Please login to merge, or discard this patch.