Completed
Branch BUG/reg-status-change-recursio... (2db0c9)
by
unknown
20:03 queued 10:32
created
core/EE_System.core.php 1 patch
Indentation   +1292 added lines, -1292 removed lines patch added patch discarded remove patch
@@ -27,1296 +27,1296 @@
 block discarded – undo
27 27
 final class EE_System implements ResettableInterface
28 28
 {
29 29
 
30
-    /**
31
-     * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
32
-     * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
33
-     */
34
-    const req_type_normal = 0;
35
-
36
-    /**
37
-     * Indicates this is a brand new installation of EE so we should install
38
-     * tables and default data etc
39
-     */
40
-    const req_type_new_activation = 1;
41
-
42
-    /**
43
-     * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
44
-     * and we just exited maintenance mode). We MUST check the database is setup properly
45
-     * and that default data is setup too
46
-     */
47
-    const req_type_reactivation = 2;
48
-
49
-    /**
50
-     * indicates that EE has been upgraded since its previous request.
51
-     * We may have data migration scripts to call and will want to trigger maintenance mode
52
-     */
53
-    const req_type_upgrade = 3;
54
-
55
-    /**
56
-     * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
57
-     */
58
-    const req_type_downgrade = 4;
59
-
60
-    /**
61
-     * @deprecated since version 4.6.0.dev.006
62
-     * Now whenever a new_activation is detected the request type is still just
63
-     * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
64
-     * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
65
-     * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
66
-     * (Specifically, when the migration manager indicates migrations are finished
67
-     * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
68
-     */
69
-    const req_type_activation_but_not_installed = 5;
70
-
71
-    /**
72
-     * option prefix for recording the activation history (like core's "espresso_db_update") of addons
73
-     */
74
-    const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
75
-
76
-    /**
77
-     * @var EE_System $_instance
78
-     */
79
-    private static $_instance;
80
-
81
-    /**
82
-     * @var EE_Registry $registry
83
-     */
84
-    private $registry;
85
-
86
-    /**
87
-     * @var LoaderInterface $loader
88
-     */
89
-    private $loader;
90
-
91
-    /**
92
-     * @var EE_Capabilities $capabilities
93
-     */
94
-    private $capabilities;
95
-
96
-    /**
97
-     * @var RequestInterface $request
98
-     */
99
-    private $request;
100
-
101
-    /**
102
-     * @var EE_Maintenance_Mode $maintenance_mode
103
-     */
104
-    private $maintenance_mode;
105
-
106
-    /**
107
-     * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
108
-     * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
109
-     *
110
-     * @var int $_req_type
111
-     */
112
-    private $_req_type;
113
-
114
-    /**
115
-     * Whether or not there was a non-micro version change in EE core version during this request
116
-     *
117
-     * @var boolean $_major_version_change
118
-     */
119
-    private $_major_version_change = false;
120
-
121
-    /**
122
-     * A Context DTO dedicated solely to identifying the current request type.
123
-     *
124
-     * @var RequestTypeContextCheckerInterface $request_type
125
-     */
126
-    private $request_type;
127
-
128
-
129
-    /**
130
-     * @singleton method used to instantiate class object
131
-     * @param EE_Registry|null         $registry
132
-     * @param LoaderInterface|null     $loader
133
-     * @param RequestInterface|null    $request
134
-     * @param EE_Maintenance_Mode|null $maintenance_mode
135
-     * @return EE_System
136
-     */
137
-    public static function instance(
138
-        EE_Registry $registry = null,
139
-        LoaderInterface $loader = null,
140
-        RequestInterface $request = null,
141
-        EE_Maintenance_Mode $maintenance_mode = null
142
-    ) {
143
-        // check if class object is instantiated
144
-        if (! self::$_instance instanceof EE_System) {
145
-            self::$_instance = new self($registry, $loader, $request, $maintenance_mode);
146
-        }
147
-        return self::$_instance;
148
-    }
149
-
150
-
151
-    /**
152
-     * resets the instance and returns it
153
-     *
154
-     * @return EE_System
155
-     */
156
-    public static function reset()
157
-    {
158
-        self::$_instance->_req_type = null;
159
-        // make sure none of the old hooks are left hanging around
160
-        remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
161
-        // we need to reset the migration manager in order for it to detect DMSs properly
162
-        EE_Data_Migration_Manager::reset();
163
-        self::instance()->detect_activations_or_upgrades();
164
-        self::instance()->perform_activations_upgrades_and_migrations();
165
-        return self::instance();
166
-    }
167
-
168
-
169
-    /**
170
-     * sets hooks for running rest of system
171
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
172
-     * starting EE Addons from any other point may lead to problems
173
-     *
174
-     * @param EE_Registry         $registry
175
-     * @param LoaderInterface     $loader
176
-     * @param RequestInterface    $request
177
-     * @param EE_Maintenance_Mode $maintenance_mode
178
-     */
179
-    private function __construct(
180
-        EE_Registry $registry,
181
-        LoaderInterface $loader,
182
-        RequestInterface $request,
183
-        EE_Maintenance_Mode $maintenance_mode
184
-    ) {
185
-        $this->registry = $registry;
186
-        $this->loader = $loader;
187
-        $this->request = $request;
188
-        $this->maintenance_mode = $maintenance_mode;
189
-        do_action('AHEE__EE_System__construct__begin', $this);
190
-        add_action(
191
-            'AHEE__EE_Bootstrap__load_espresso_addons',
192
-            array($this, 'loadCapabilities'),
193
-            5
194
-        );
195
-        add_action(
196
-            'AHEE__EE_Bootstrap__load_espresso_addons',
197
-            array($this, 'loadCommandBus'),
198
-            7
199
-        );
200
-        add_action(
201
-            'AHEE__EE_Bootstrap__load_espresso_addons',
202
-            array($this, 'loadPluginApi'),
203
-            9
204
-        );
205
-        // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
206
-        add_action(
207
-            'AHEE__EE_Bootstrap__load_espresso_addons',
208
-            array($this, 'load_espresso_addons')
209
-        );
210
-        // when an ee addon is activated, we want to call the core hook(s) again
211
-        // because the newly-activated addon didn't get a chance to run at all
212
-        add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
213
-        // detect whether install or upgrade
214
-        add_action(
215
-            'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
216
-            array($this, 'detect_activations_or_upgrades'),
217
-            3
218
-        );
219
-        // load EE_Config, EE_Textdomain, etc
220
-        add_action(
221
-            'AHEE__EE_Bootstrap__load_core_configuration',
222
-            array($this, 'load_core_configuration'),
223
-            5
224
-        );
225
-        // load specifications for matching routes to current request
226
-        add_action(
227
-            'AHEE__EE_Bootstrap__load_core_configuration',
228
-            array($this, 'loadRouteMatchSpecifications')
229
-        );
230
-        // load EE_Config, EE_Textdomain, etc
231
-        add_action(
232
-            'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
233
-            array($this, 'register_shortcodes_modules_and_widgets'),
234
-            7
235
-        );
236
-        // you wanna get going? I wanna get going... let's get going!
237
-        add_action(
238
-            'AHEE__EE_Bootstrap__brew_espresso',
239
-            array($this, 'brew_espresso'),
240
-            9
241
-        );
242
-        // other housekeeping
243
-        // exclude EE critical pages from wp_list_pages
244
-        add_filter(
245
-            'wp_list_pages_excludes',
246
-            array($this, 'remove_pages_from_wp_list_pages'),
247
-            10
248
-        );
249
-        // ALL EE Addons should use the following hook point to attach their initial setup too
250
-        // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
251
-        do_action('AHEE__EE_System__construct__complete', $this);
252
-    }
253
-
254
-
255
-    /**
256
-     * load and setup EE_Capabilities
257
-     *
258
-     * @return void
259
-     * @throws EE_Error
260
-     */
261
-    public function loadCapabilities()
262
-    {
263
-        $this->capabilities = $this->loader->getShared('EE_Capabilities');
264
-        add_action(
265
-            'AHEE__EE_Capabilities__init_caps__before_initialization',
266
-            function () {
267
-                LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
268
-            }
269
-        );
270
-    }
271
-
272
-
273
-    /**
274
-     * create and cache the CommandBus, and also add middleware
275
-     * The CapChecker middleware requires the use of EE_Capabilities
276
-     * which is why we need to load the CommandBus after Caps are set up
277
-     *
278
-     * @return void
279
-     * @throws EE_Error
280
-     */
281
-    public function loadCommandBus()
282
-    {
283
-        $this->loader->getShared(
284
-            'CommandBusInterface',
285
-            array(
286
-                null,
287
-                apply_filters(
288
-                    'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
289
-                    array(
290
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
291
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
292
-                    )
293
-                ),
294
-            )
295
-        );
296
-    }
297
-
298
-
299
-    /**
300
-     * @return void
301
-     * @throws EE_Error
302
-     */
303
-    public function loadPluginApi()
304
-    {
305
-        // set autoloaders for all of the classes implementing EEI_Plugin_API
306
-        // which provide helpers for EE plugin authors to more easily register certain components with EE.
307
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
308
-        $this->loader->getShared('EE_Request_Handler');
309
-    }
310
-
311
-
312
-    /**
313
-     * @param string $addon_name
314
-     * @param string $version_constant
315
-     * @param string $min_version_required
316
-     * @param string $load_callback
317
-     * @param string $plugin_file_constant
318
-     * @return void
319
-     */
320
-    private function deactivateIncompatibleAddon(
321
-        $addon_name,
322
-        $version_constant,
323
-        $min_version_required,
324
-        $load_callback,
325
-        $plugin_file_constant
326
-    ) {
327
-        if (! defined($version_constant)) {
328
-            return;
329
-        }
330
-        $addon_version = constant($version_constant);
331
-        if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
332
-            remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
333
-            if (! function_exists('deactivate_plugins')) {
334
-                require_once ABSPATH . 'wp-admin/includes/plugin.php';
335
-            }
336
-            deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
337
-            unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
338
-            EE_Error::add_error(
339
-                sprintf(
340
-                    esc_html__(
341
-                        'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.',
342
-                        'event_espresso'
343
-                    ),
344
-                    $addon_name,
345
-                    $min_version_required
346
-                ),
347
-                __FILE__,
348
-                __FUNCTION__ . "({$addon_name})",
349
-                __LINE__
350
-            );
351
-            EE_Error::get_notices(false, true);
352
-        }
353
-    }
354
-
355
-
356
-    /**
357
-     * load_espresso_addons
358
-     * allow addons to load first so that they can set hooks for running DMS's, etc
359
-     * this is hooked into both:
360
-     *    'AHEE__EE_Bootstrap__load_core_configuration'
361
-     *        which runs during the WP 'plugins_loaded' action at priority 5
362
-     *    and the WP 'activate_plugin' hook point
363
-     *
364
-     * @access public
365
-     * @return void
366
-     */
367
-    public function load_espresso_addons()
368
-    {
369
-        $this->deactivateIncompatibleAddon(
370
-            'Wait Lists',
371
-            'EE_WAIT_LISTS_VERSION',
372
-            '1.0.0.beta.074',
373
-            'load_espresso_wait_lists',
374
-            'EE_WAIT_LISTS_PLUGIN_FILE'
375
-        );
376
-        $this->deactivateIncompatibleAddon(
377
-            'Automated Upcoming Event Notifications',
378
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
379
-            '1.0.0.beta.091',
380
-            'load_espresso_automated_upcoming_event_notification',
381
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
382
-        );
383
-        do_action('AHEE__EE_System__load_espresso_addons');
384
-        // if the WP API basic auth plugin isn't already loaded, load it now.
385
-        // We want it for mobile apps. Just include the entire plugin
386
-        // also, don't load the basic auth when a plugin is getting activated, because
387
-        // it could be the basic auth plugin, and it doesn't check if its methods are already defined
388
-        // and causes a fatal error
389
-        if ($this->request->getRequestParam('activate') !== 'true'
390
-            && ! function_exists('json_basic_auth_handler')
391
-            && ! function_exists('json_basic_auth_error')
392
-            && ! in_array(
393
-                $this->request->getRequestParam('action'),
394
-                array('activate', 'activate-selected'),
395
-                true
396
-            )
397
-        ) {
398
-            include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
399
-        }
400
-        do_action('AHEE__EE_System__load_espresso_addons__complete');
401
-    }
402
-
403
-
404
-    /**
405
-     * detect_activations_or_upgrades
406
-     * Checks for activation or upgrade of core first;
407
-     * then also checks if any registered addons have been activated or upgraded
408
-     * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
409
-     * which runs during the WP 'plugins_loaded' action at priority 3
410
-     *
411
-     * @access public
412
-     * @return void
413
-     */
414
-    public function detect_activations_or_upgrades()
415
-    {
416
-        // first off: let's make sure to handle core
417
-        $this->detect_if_activation_or_upgrade();
418
-        foreach ($this->registry->addons as $addon) {
419
-            if ($addon instanceof EE_Addon) {
420
-                // detect teh request type for that addon
421
-                $addon->detect_activation_or_upgrade();
422
-            }
423
-        }
424
-    }
425
-
426
-
427
-    /**
428
-     * detect_if_activation_or_upgrade
429
-     * Takes care of detecting whether this is a brand new install or code upgrade,
430
-     * and either setting up the DB or setting up maintenance mode etc.
431
-     *
432
-     * @access public
433
-     * @return void
434
-     */
435
-    public function detect_if_activation_or_upgrade()
436
-    {
437
-        do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
438
-        // check if db has been updated, or if its a brand-new installation
439
-        $espresso_db_update = $this->fix_espresso_db_upgrade_option();
440
-        $request_type = $this->detect_req_type($espresso_db_update);
441
-        // EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
442
-        switch ($request_type) {
443
-            case EE_System::req_type_new_activation:
444
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
445
-                $this->_handle_core_version_change($espresso_db_update);
446
-                break;
447
-            case EE_System::req_type_reactivation:
448
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
449
-                $this->_handle_core_version_change($espresso_db_update);
450
-                break;
451
-            case EE_System::req_type_upgrade:
452
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
453
-                // migrations may be required now that we've upgraded
454
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
455
-                $this->_handle_core_version_change($espresso_db_update);
456
-                break;
457
-            case EE_System::req_type_downgrade:
458
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
459
-                // its possible migrations are no longer required
460
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
461
-                $this->_handle_core_version_change($espresso_db_update);
462
-                break;
463
-            case EE_System::req_type_normal:
464
-            default:
465
-                break;
466
-        }
467
-        do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
468
-    }
469
-
470
-
471
-    /**
472
-     * Updates the list of installed versions and sets hooks for
473
-     * initializing the database later during the request
474
-     *
475
-     * @param array $espresso_db_update
476
-     */
477
-    private function _handle_core_version_change($espresso_db_update)
478
-    {
479
-        $this->update_list_of_installed_versions($espresso_db_update);
480
-        // get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
481
-        add_action(
482
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
483
-            array($this, 'initialize_db_if_no_migrations_required')
484
-        );
485
-    }
486
-
487
-
488
-    /**
489
-     * standardizes the wp option 'espresso_db_upgrade' which actually stores
490
-     * information about what versions of EE have been installed and activated,
491
-     * NOT necessarily the state of the database
492
-     *
493
-     * @param mixed $espresso_db_update           the value of the WordPress option.
494
-     *                                            If not supplied, fetches it from the options table
495
-     * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
496
-     */
497
-    private function fix_espresso_db_upgrade_option($espresso_db_update = null)
498
-    {
499
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
500
-        if (! $espresso_db_update) {
501
-            $espresso_db_update = get_option('espresso_db_update');
502
-        }
503
-        // check that option is an array
504
-        if (! is_array($espresso_db_update)) {
505
-            // if option is FALSE, then it never existed
506
-            if ($espresso_db_update === false) {
507
-                // make $espresso_db_update an array and save option with autoload OFF
508
-                $espresso_db_update = array();
509
-                add_option('espresso_db_update', $espresso_db_update, '', 'no');
510
-            } else {
511
-                // option is NOT FALSE but also is NOT an array, so make it an array and save it
512
-                $espresso_db_update = array($espresso_db_update => array());
513
-                update_option('espresso_db_update', $espresso_db_update);
514
-            }
515
-        } else {
516
-            $corrected_db_update = array();
517
-            // if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
518
-            foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
519
-                if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
520
-                    // the key is an int, and the value IS NOT an array
521
-                    // so it must be numerically-indexed, where values are versions installed...
522
-                    // fix it!
523
-                    $version_string = $should_be_array;
524
-                    $corrected_db_update[ $version_string ] = array('unknown-date');
525
-                } else {
526
-                    // ok it checks out
527
-                    $corrected_db_update[ $should_be_version_string ] = $should_be_array;
528
-                }
529
-            }
530
-            $espresso_db_update = $corrected_db_update;
531
-            update_option('espresso_db_update', $espresso_db_update);
532
-        }
533
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
534
-        return $espresso_db_update;
535
-    }
536
-
537
-
538
-    /**
539
-     * Does the traditional work of setting up the plugin's database and adding default data.
540
-     * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
541
-     * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
542
-     * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
543
-     * so that it will be done when migrations are finished
544
-     *
545
-     * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
546
-     * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
547
-     *                                       This is a resource-intensive job
548
-     *                                       so we prefer to only do it when necessary
549
-     * @return void
550
-     * @throws EE_Error
551
-     */
552
-    public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
553
-    {
554
-        $request_type = $this->detect_req_type();
555
-        // only initialize system if we're not in maintenance mode.
556
-        if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
557
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
558
-            $rewrite_rules = $this->loader->getShared(
559
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
560
-            );
561
-            $rewrite_rules->flush();
562
-            if ($verify_schema) {
563
-                EEH_Activation::initialize_db_and_folders();
564
-            }
565
-            EEH_Activation::initialize_db_content();
566
-            EEH_Activation::system_initialization();
567
-            if ($initialize_addons_too) {
568
-                $this->initialize_addons();
569
-            }
570
-        } else {
571
-            EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
572
-        }
573
-        if ($request_type === EE_System::req_type_new_activation
574
-            || $request_type === EE_System::req_type_reactivation
575
-            || (
576
-                $request_type === EE_System::req_type_upgrade
577
-                && $this->is_major_version_change()
578
-            )
579
-        ) {
580
-            add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
581
-        }
582
-    }
583
-
584
-
585
-    /**
586
-     * Initializes the db for all registered addons
587
-     *
588
-     * @throws EE_Error
589
-     */
590
-    public function initialize_addons()
591
-    {
592
-        // foreach registered addon, make sure its db is up-to-date too
593
-        foreach ($this->registry->addons as $addon) {
594
-            if ($addon instanceof EE_Addon) {
595
-                $addon->initialize_db_if_no_migrations_required();
596
-            }
597
-        }
598
-    }
599
-
600
-
601
-    /**
602
-     * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
603
-     *
604
-     * @param    array  $version_history
605
-     * @param    string $current_version_to_add version to be added to the version history
606
-     * @return    boolean success as to whether or not this option was changed
607
-     */
608
-    public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
609
-    {
610
-        if (! $version_history) {
611
-            $version_history = $this->fix_espresso_db_upgrade_option($version_history);
612
-        }
613
-        if ($current_version_to_add === null) {
614
-            $current_version_to_add = espresso_version();
615
-        }
616
-        $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
617
-        // re-save
618
-        return update_option('espresso_db_update', $version_history);
619
-    }
620
-
621
-
622
-    /**
623
-     * Detects if the current version indicated in the has existed in the list of
624
-     * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
625
-     *
626
-     * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
627
-     *                                  If not supplied, fetches it from the options table.
628
-     *                                  Also, caches its result so later parts of the code can also know whether
629
-     *                                  there's been an update or not. This way we can add the current version to
630
-     *                                  espresso_db_update, but still know if this is a new install or not
631
-     * @return int one of the constants on EE_System::req_type_
632
-     */
633
-    public function detect_req_type($espresso_db_update = null)
634
-    {
635
-        if ($this->_req_type === null) {
636
-            $espresso_db_update = ! empty($espresso_db_update)
637
-                ? $espresso_db_update
638
-                : $this->fix_espresso_db_upgrade_option();
639
-            $this->_req_type = EE_System::detect_req_type_given_activation_history(
640
-                $espresso_db_update,
641
-                'ee_espresso_activation',
642
-                espresso_version()
643
-            );
644
-            $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
645
-            $this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal);
646
-        }
647
-        return $this->_req_type;
648
-    }
649
-
650
-
651
-    /**
652
-     * Returns whether or not there was a non-micro version change (ie, change in either
653
-     * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
654
-     * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
655
-     *
656
-     * @param $activation_history
657
-     * @return bool
658
-     */
659
-    private function _detect_major_version_change($activation_history)
660
-    {
661
-        $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
662
-        $previous_version_parts = explode('.', $previous_version);
663
-        $current_version_parts = explode('.', espresso_version());
664
-        return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
665
-               && ($previous_version_parts[0] !== $current_version_parts[0]
666
-                   || $previous_version_parts[1] !== $current_version_parts[1]
667
-               );
668
-    }
669
-
670
-
671
-    /**
672
-     * Returns true if either the major or minor version of EE changed during this request.
673
-     * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001
674
-     *
675
-     * @return bool
676
-     */
677
-    public function is_major_version_change()
678
-    {
679
-        return $this->_major_version_change;
680
-    }
681
-
682
-
683
-    /**
684
-     * Determines the request type for any ee addon, given three piece of info: the current array of activation
685
-     * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
686
-     * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
687
-     * just activated to (for core that will always be espresso_version())
688
-     *
689
-     * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
690
-     *                                                 ee plugin. for core that's 'espresso_db_update'
691
-     * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
692
-     *                                                 indicate that this plugin was just activated
693
-     * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
694
-     *                                                 espresso_version())
695
-     * @return int one of the constants on EE_System::req_type_*
696
-     */
697
-    public static function detect_req_type_given_activation_history(
698
-        $activation_history_for_addon,
699
-        $activation_indicator_option_name,
700
-        $version_to_upgrade_to
701
-    ) {
702
-        $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
703
-        if ($activation_history_for_addon) {
704
-            // it exists, so this isn't a completely new install
705
-            // check if this version already in that list of previously installed versions
706
-            if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) {
707
-                // it a version we haven't seen before
708
-                if ($version_is_higher === 1) {
709
-                    $req_type = EE_System::req_type_upgrade;
710
-                } else {
711
-                    $req_type = EE_System::req_type_downgrade;
712
-                }
713
-                delete_option($activation_indicator_option_name);
714
-            } else {
715
-                // its not an update. maybe a reactivation?
716
-                if (get_option($activation_indicator_option_name, false)) {
717
-                    if ($version_is_higher === -1) {
718
-                        $req_type = EE_System::req_type_downgrade;
719
-                    } elseif ($version_is_higher === 0) {
720
-                        // we've seen this version before, but it's an activation. must be a reactivation
721
-                        $req_type = EE_System::req_type_reactivation;
722
-                    } else {// $version_is_higher === 1
723
-                        $req_type = EE_System::req_type_upgrade;
724
-                    }
725
-                    delete_option($activation_indicator_option_name);
726
-                } else {
727
-                    // we've seen this version before and the activation indicate doesn't show it was just activated
728
-                    if ($version_is_higher === -1) {
729
-                        $req_type = EE_System::req_type_downgrade;
730
-                    } elseif ($version_is_higher === 0) {
731
-                        // we've seen this version before and it's not an activation. its normal request
732
-                        $req_type = EE_System::req_type_normal;
733
-                    } else {// $version_is_higher === 1
734
-                        $req_type = EE_System::req_type_upgrade;
735
-                    }
736
-                }
737
-            }
738
-        } else {
739
-            // brand new install
740
-            $req_type = EE_System::req_type_new_activation;
741
-            delete_option($activation_indicator_option_name);
742
-        }
743
-        return $req_type;
744
-    }
745
-
746
-
747
-    /**
748
-     * Detects if the $version_to_upgrade_to is higher than the most recent version in
749
-     * the $activation_history_for_addon
750
-     *
751
-     * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
752
-     *                                             sometimes containing 'unknown-date'
753
-     * @param string $version_to_upgrade_to        (current version)
754
-     * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
755
-     *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
756
-     *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
757
-     *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
758
-     */
759
-    private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
760
-    {
761
-        // find the most recently-activated version
762
-        $most_recently_active_version =
763
-            EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
764
-        return version_compare($version_to_upgrade_to, $most_recently_active_version);
765
-    }
766
-
767
-
768
-    /**
769
-     * Gets the most recently active version listed in the activation history,
770
-     * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
771
-     *
772
-     * @param array $activation_history  (keys are versions, values are arrays of times activated,
773
-     *                                   sometimes containing 'unknown-date'
774
-     * @return string
775
-     */
776
-    private static function _get_most_recently_active_version_from_activation_history($activation_history)
777
-    {
778
-        $most_recently_active_version_activation = '1970-01-01 00:00:00';
779
-        $most_recently_active_version = '0.0.0.dev.000';
780
-        if (is_array($activation_history)) {
781
-            foreach ($activation_history as $version => $times_activated) {
782
-                // check there is a record of when this version was activated. Otherwise,
783
-                // mark it as unknown
784
-                if (! $times_activated) {
785
-                    $times_activated = array('unknown-date');
786
-                }
787
-                if (is_string($times_activated)) {
788
-                    $times_activated = array($times_activated);
789
-                }
790
-                foreach ($times_activated as $an_activation) {
791
-                    if ($an_activation !== 'unknown-date'
792
-                        && $an_activation
793
-                           > $most_recently_active_version_activation) {
794
-                        $most_recently_active_version = $version;
795
-                        $most_recently_active_version_activation = $an_activation === 'unknown-date'
796
-                            ? '1970-01-01 00:00:00'
797
-                            : $an_activation;
798
-                    }
799
-                }
800
-            }
801
-        }
802
-        return $most_recently_active_version;
803
-    }
804
-
805
-
806
-    /**
807
-     * This redirects to the about EE page after activation
808
-     *
809
-     * @return void
810
-     */
811
-    public function redirect_to_about_ee()
812
-    {
813
-        $notices = EE_Error::get_notices(false);
814
-        // if current user is an admin and it's not an ajax or rest request
815
-        if (! isset($notices['errors'])
816
-            && $this->request->isAdmin()
817
-            && apply_filters(
818
-                'FHEE__EE_System__redirect_to_about_ee__do_redirect',
819
-                $this->capabilities->current_user_can('manage_options', 'espresso_about_default')
820
-            )
821
-        ) {
822
-            $query_params = array('page' => 'espresso_about');
823
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
824
-                $query_params['new_activation'] = true;
825
-            }
826
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
827
-                $query_params['reactivation'] = true;
828
-            }
829
-            $url = add_query_arg($query_params, admin_url('admin.php'));
830
-            wp_safe_redirect($url);
831
-            exit();
832
-        }
833
-    }
834
-
835
-
836
-    /**
837
-     * load_core_configuration
838
-     * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
839
-     * which runs during the WP 'plugins_loaded' action at priority 5
840
-     *
841
-     * @return void
842
-     * @throws ReflectionException
843
-     * @throws Exception
844
-     */
845
-    public function load_core_configuration()
846
-    {
847
-        do_action('AHEE__EE_System__load_core_configuration__begin', $this);
848
-        $this->loader->getShared('EE_Load_Textdomain');
849
-        // load textdomain
850
-        EE_Load_Textdomain::load_textdomain();
851
-        // load and setup EE_Config and EE_Network_Config
852
-        $config = $this->loader->getShared('EE_Config');
853
-        $this->loader->getShared('EE_Network_Config');
854
-        // setup autoloaders
855
-        // enable logging?
856
-        if ($config->admin->use_full_logging) {
857
-            $this->loader->getShared('EE_Log');
858
-        }
859
-        // check for activation errors
860
-        $activation_errors = get_option('ee_plugin_activation_errors', false);
861
-        if ($activation_errors) {
862
-            EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
863
-            update_option('ee_plugin_activation_errors', false);
864
-        }
865
-        // get model names
866
-        $this->_parse_model_names();
867
-        // load caf stuff a chance to play during the activation process too.
868
-        $this->_maybe_brew_regular();
869
-        // configure custom post type definitions
870
-        $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions');
871
-        $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions');
872
-        do_action('AHEE__EE_System__load_core_configuration__complete', $this);
873
-    }
874
-
875
-
876
-    /**
877
-     * cycles through all of the models/*.model.php files, and assembles an array of model names
878
-     *
879
-     * @return void
880
-     * @throws ReflectionException
881
-     */
882
-    private function _parse_model_names()
883
-    {
884
-        // get all the files in the EE_MODELS folder that end in .model.php
885
-        $models = glob(EE_MODELS . '*.model.php');
886
-        $model_names = array();
887
-        $non_abstract_db_models = array();
888
-        foreach ($models as $model) {
889
-            // get model classname
890
-            $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
891
-            $short_name = str_replace('EEM_', '', $classname);
892
-            $reflectionClass = new ReflectionClass($classname);
893
-            if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
894
-                $non_abstract_db_models[ $short_name ] = $classname;
895
-            }
896
-            $model_names[ $short_name ] = $classname;
897
-        }
898
-        $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
899
-        $this->registry->non_abstract_db_models = apply_filters(
900
-            'FHEE__EE_System__parse_implemented_model_names',
901
-            $non_abstract_db_models
902
-        );
903
-    }
904
-
905
-
906
-    /**
907
-     * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
908
-     * that need to be setup before our EE_System launches.
909
-     *
910
-     * @return void
911
-     * @throws DomainException
912
-     * @throws InvalidArgumentException
913
-     * @throws InvalidDataTypeException
914
-     * @throws InvalidInterfaceException
915
-     * @throws InvalidClassException
916
-     * @throws InvalidFilePathException
917
-     */
918
-    private function _maybe_brew_regular()
919
-    {
920
-        /** @var Domain $domain */
921
-        $domain = DomainFactory::getShared(
922
-            new FullyQualifiedName(
923
-                'EventEspresso\core\domain\Domain'
924
-            ),
925
-            array(
926
-                new FilePath(EVENT_ESPRESSO_MAIN_FILE),
927
-                Version::fromString(espresso_version()),
928
-            )
929
-        );
930
-        if ($domain->isCaffeinated()) {
931
-            require_once EE_CAFF_PATH . 'brewing_regular.php';
932
-        }
933
-    }
934
-
935
-
936
-    /**
937
-     * @since $VID:$
938
-     * @throws Exception
939
-     */
940
-    public function loadRouteMatchSpecifications()
941
-    {
942
-        try {
943
-            $this->loader->getShared(
944
-                'EventEspresso\core\services\route_match\RouteMatchSpecificationManager'
945
-            );
946
-        } catch (Exception $exception) {
947
-            new ExceptionStackTraceDisplay($exception);
948
-        }
949
-        do_action('AHEE__EE_System__loadRouteMatchSpecifications');
950
-    }
951
-
952
-
953
-    /**
954
-     * register_shortcodes_modules_and_widgets
955
-     * generate lists of shortcodes and modules, then verify paths and classes
956
-     * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
957
-     * which runs during the WP 'plugins_loaded' action at priority 7
958
-     *
959
-     * @access public
960
-     * @return void
961
-     * @throws Exception
962
-     */
963
-    public function register_shortcodes_modules_and_widgets()
964
-    {
965
-        if ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isAjax()) {
966
-            try {
967
-                // load, register, and add shortcodes the new way
968
-                $this->loader->getShared(
969
-                    'EventEspresso\core\services\shortcodes\ShortcodesManager',
970
-                    array(
971
-                        // and the old way, but we'll put it under control of the new system
972
-                        EE_Config::getLegacyShortcodesManager(),
973
-                    )
974
-                );
975
-            } catch (Exception $exception) {
976
-                new ExceptionStackTraceDisplay($exception);
977
-            }
978
-        }
979
-        do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
980
-        // check for addons using old hook point
981
-        if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
982
-            $this->_incompatible_addon_error();
983
-        }
984
-    }
985
-
986
-
987
-    /**
988
-     * _incompatible_addon_error
989
-     *
990
-     * @access public
991
-     * @return void
992
-     */
993
-    private function _incompatible_addon_error()
994
-    {
995
-        // get array of classes hooking into here
996
-        $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
997
-            'AHEE__EE_System__register_shortcodes_modules_and_addons'
998
-        );
999
-        if (! empty($class_names)) {
1000
-            $msg = __(
1001
-                'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
1002
-                'event_espresso'
1003
-            );
1004
-            $msg .= '<ul>';
1005
-            foreach ($class_names as $class_name) {
1006
-                $msg .= '<li><b>Event Espresso - '
1007
-                        . str_replace(
1008
-                            array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'),
1009
-                            '',
1010
-                            $class_name
1011
-                        ) . '</b></li>';
1012
-            }
1013
-            $msg .= '</ul>';
1014
-            $msg .= __(
1015
-                'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
1016
-                'event_espresso'
1017
-            );
1018
-            // save list of incompatible addons to wp-options for later use
1019
-            add_option('ee_incompatible_addons', $class_names, '', 'no');
1020
-            if (is_admin()) {
1021
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1022
-            }
1023
-        }
1024
-    }
1025
-
1026
-
1027
-    /**
1028
-     * brew_espresso
1029
-     * begins the process of setting hooks for initializing EE in the correct order
1030
-     * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1031
-     * which runs during the WP 'plugins_loaded' action at priority 9
1032
-     *
1033
-     * @return void
1034
-     */
1035
-    public function brew_espresso()
1036
-    {
1037
-        do_action('AHEE__EE_System__brew_espresso__begin', $this);
1038
-        // load some final core systems
1039
-        add_action('init', array($this, 'set_hooks_for_core'), 1);
1040
-        add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1041
-        add_action('init', array($this, 'load_CPTs_and_session'), 5);
1042
-        add_action('init', array($this, 'load_controllers'), 7);
1043
-        add_action('init', array($this, 'core_loaded_and_ready'), 9);
1044
-        add_action('init', array($this, 'initialize'), 10);
1045
-        add_action('init', array($this, 'initialize_last'), 100);
1046
-        if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
1047
-            // pew pew pew
1048
-            $this->loader->getShared('EventEspresso\core\services\licensing\LicenseService');
1049
-            do_action('AHEE__EE_System__brew_espresso__after_pue_init');
1050
-        }
1051
-        do_action('AHEE__EE_System__brew_espresso__complete', $this);
1052
-    }
1053
-
1054
-
1055
-    /**
1056
-     *    set_hooks_for_core
1057
-     *
1058
-     * @access public
1059
-     * @return    void
1060
-     * @throws EE_Error
1061
-     */
1062
-    public function set_hooks_for_core()
1063
-    {
1064
-        $this->_deactivate_incompatible_addons();
1065
-        do_action('AHEE__EE_System__set_hooks_for_core');
1066
-        $this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan');
1067
-        // caps need to be initialized on every request so that capability maps are set.
1068
-        // @see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1069
-        $this->registry->CAP->init_caps();
1070
-    }
1071
-
1072
-
1073
-    /**
1074
-     * Using the information gathered in EE_System::_incompatible_addon_error,
1075
-     * deactivates any addons considered incompatible with the current version of EE
1076
-     */
1077
-    private function _deactivate_incompatible_addons()
1078
-    {
1079
-        $incompatible_addons = get_option('ee_incompatible_addons', array());
1080
-        if (! empty($incompatible_addons)) {
1081
-            $active_plugins = get_option('active_plugins', array());
1082
-            foreach ($active_plugins as $active_plugin) {
1083
-                foreach ($incompatible_addons as $incompatible_addon) {
1084
-                    if (strpos($active_plugin, $incompatible_addon) !== false) {
1085
-                        unset($_GET['activate']);
1086
-                        espresso_deactivate_plugin($active_plugin);
1087
-                    }
1088
-                }
1089
-            }
1090
-        }
1091
-    }
1092
-
1093
-
1094
-    /**
1095
-     *    perform_activations_upgrades_and_migrations
1096
-     *
1097
-     * @access public
1098
-     * @return    void
1099
-     */
1100
-    public function perform_activations_upgrades_and_migrations()
1101
-    {
1102
-        do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1103
-    }
1104
-
1105
-
1106
-    /**
1107
-     * @return void
1108
-     * @throws DomainException
1109
-     */
1110
-    public function load_CPTs_and_session()
1111
-    {
1112
-        do_action('AHEE__EE_System__load_CPTs_and_session__start');
1113
-        /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies $register_custom_taxonomies */
1114
-        $register_custom_taxonomies = $this->loader->getShared(
1115
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'
1116
-        );
1117
-        $register_custom_taxonomies->registerCustomTaxonomies();
1118
-        /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */
1119
-        $register_custom_post_types = $this->loader->getShared(
1120
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'
1121
-        );
1122
-        $register_custom_post_types->registerCustomPostTypes();
1123
-        /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms */
1124
-        $register_custom_taxonomy_terms = $this->loader->getShared(
1125
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms'
1126
-        );
1127
-        $register_custom_taxonomy_terms->registerCustomTaxonomyTerms();
1128
-        // load legacy Custom Post Types and Taxonomies
1129
-        $this->loader->getShared('EE_Register_CPTs');
1130
-        do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1131
-    }
1132
-
1133
-
1134
-    /**
1135
-     * load_controllers
1136
-     * this is the best place to load any additional controllers that needs access to EE core.
1137
-     * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1138
-     * time
1139
-     *
1140
-     * @access public
1141
-     * @return void
1142
-     */
1143
-    public function load_controllers()
1144
-    {
1145
-        do_action('AHEE__EE_System__load_controllers__start');
1146
-        // let's get it started
1147
-        if (! $this->maintenance_mode->level()
1148
-            && ($this->request->isFrontend() || $this->request->isFrontAjax())
1149
-        ) {
1150
-            do_action('AHEE__EE_System__load_controllers__load_front_controllers');
1151
-            $this->loader->getShared('EE_Front_Controller');
1152
-        } elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) {
1153
-            do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1154
-            $this->loader->getShared('EE_Admin');
1155
-        }
1156
-        do_action('AHEE__EE_System__load_controllers__complete');
1157
-    }
1158
-
1159
-
1160
-    /**
1161
-     * core_loaded_and_ready
1162
-     * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1163
-     *
1164
-     * @access public
1165
-     * @return void
1166
-     * @throws Exception
1167
-     */
1168
-    public function core_loaded_and_ready()
1169
-    {
1170
-        if ($this->request->isAdmin()
1171
-            || $this->request->isFrontend()
1172
-            || $this->request->isIframe()
1173
-            || $this->request->isWordPressApi()
1174
-        ) {
1175
-            try {
1176
-                $this->loader->getShared('EventEspresso\core\services\assets\Registry');
1177
-                $this->loader->getShared('EventEspresso\core\domain\services\assets\CoreAssetManager');
1178
-                if (function_exists('register_block_type')) {
1179
-                    $this->loader->getShared(
1180
-                        'EventEspresso\core\services\editor\BlockRegistrationManager'
1181
-                    );
1182
-                }
1183
-            } catch (Exception $exception) {
1184
-                new ExceptionStackTraceDisplay($exception);
1185
-            }
1186
-        }
1187
-        if ($this->request->isAdmin()
1188
-            || $this->request->isEeAjax()
1189
-            || $this->request->isFrontend()
1190
-        ) {
1191
-            $this->loader->getShared('EE_Session');
1192
-        }
1193
-        // integrate WP_Query with the EE models
1194
-        $this->loader->getShared('EE_CPT_Strategy');
1195
-        do_action('AHEE__EE_System__core_loaded_and_ready');
1196
-        // always load template tags, because it's faster than checking if it's a front-end request, and many page
1197
-        // builders require these even on the front-end
1198
-        require_once EE_PUBLIC . 'template_tags.php';
1199
-        do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1200
-    }
1201
-
1202
-
1203
-    /**
1204
-     * initialize
1205
-     * this is the best place to begin initializing client code
1206
-     *
1207
-     * @access public
1208
-     * @return void
1209
-     */
1210
-    public function initialize()
1211
-    {
1212
-        do_action('AHEE__EE_System__initialize');
1213
-    }
1214
-
1215
-
1216
-    /**
1217
-     * initialize_last
1218
-     * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1219
-     * initialize has done so
1220
-     *
1221
-     * @access public
1222
-     * @return void
1223
-     */
1224
-    public function initialize_last()
1225
-    {
1226
-        do_action('AHEE__EE_System__initialize_last');
1227
-        /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
1228
-        $rewrite_rules = $this->loader->getShared(
1229
-            'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
1230
-        );
1231
-        $rewrite_rules->flushRewriteRules();
1232
-        add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1233
-        if (($this->request->isAjax() || $this->request->isAdmin())
1234
-            && $this->maintenance_mode->models_can_query()) {
1235
-            $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager');
1236
-            $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager');
1237
-        }
1238
-    }
1239
-
1240
-
1241
-    /**
1242
-     * @return void
1243
-     * @throws EE_Error
1244
-     */
1245
-    public function addEspressoToolbar()
1246
-    {
1247
-        $this->loader->getShared(
1248
-            'EventEspresso\core\domain\services\admin\AdminToolBar',
1249
-            array($this->registry->CAP)
1250
-        );
1251
-    }
1252
-
1253
-
1254
-    /**
1255
-     * do_not_cache
1256
-     * sets no cache headers and defines no cache constants for WP plugins
1257
-     *
1258
-     * @access public
1259
-     * @return void
1260
-     */
1261
-    public static function do_not_cache()
1262
-    {
1263
-        // set no cache constants
1264
-        if (! defined('DONOTCACHEPAGE')) {
1265
-            define('DONOTCACHEPAGE', true);
1266
-        }
1267
-        if (! defined('DONOTCACHCEOBJECT')) {
1268
-            define('DONOTCACHCEOBJECT', true);
1269
-        }
1270
-        if (! defined('DONOTCACHEDB')) {
1271
-            define('DONOTCACHEDB', true);
1272
-        }
1273
-        // add no cache headers
1274
-        add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1275
-        // plus a little extra for nginx and Google Chrome
1276
-        add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1277
-        // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1278
-        remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1279
-    }
1280
-
1281
-
1282
-    /**
1283
-     *    extra_nocache_headers
1284
-     *
1285
-     * @access    public
1286
-     * @param $headers
1287
-     * @return    array
1288
-     */
1289
-    public static function extra_nocache_headers($headers)
1290
-    {
1291
-        // for NGINX
1292
-        $headers['X-Accel-Expires'] = 0;
1293
-        // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1294
-        $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1295
-        return $headers;
1296
-    }
1297
-
1298
-
1299
-    /**
1300
-     *    nocache_headers
1301
-     *
1302
-     * @access    public
1303
-     * @return    void
1304
-     */
1305
-    public static function nocache_headers()
1306
-    {
1307
-        nocache_headers();
1308
-    }
1309
-
1310
-
1311
-    /**
1312
-     * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1313
-     * never returned with the function.
1314
-     *
1315
-     * @param  array $exclude_array any existing pages being excluded are in this array.
1316
-     * @return array
1317
-     */
1318
-    public function remove_pages_from_wp_list_pages($exclude_array)
1319
-    {
1320
-        return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1321
-    }
30
+	/**
31
+	 * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
32
+	 * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
33
+	 */
34
+	const req_type_normal = 0;
35
+
36
+	/**
37
+	 * Indicates this is a brand new installation of EE so we should install
38
+	 * tables and default data etc
39
+	 */
40
+	const req_type_new_activation = 1;
41
+
42
+	/**
43
+	 * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
44
+	 * and we just exited maintenance mode). We MUST check the database is setup properly
45
+	 * and that default data is setup too
46
+	 */
47
+	const req_type_reactivation = 2;
48
+
49
+	/**
50
+	 * indicates that EE has been upgraded since its previous request.
51
+	 * We may have data migration scripts to call and will want to trigger maintenance mode
52
+	 */
53
+	const req_type_upgrade = 3;
54
+
55
+	/**
56
+	 * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
57
+	 */
58
+	const req_type_downgrade = 4;
59
+
60
+	/**
61
+	 * @deprecated since version 4.6.0.dev.006
62
+	 * Now whenever a new_activation is detected the request type is still just
63
+	 * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
64
+	 * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
65
+	 * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
66
+	 * (Specifically, when the migration manager indicates migrations are finished
67
+	 * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
68
+	 */
69
+	const req_type_activation_but_not_installed = 5;
70
+
71
+	/**
72
+	 * option prefix for recording the activation history (like core's "espresso_db_update") of addons
73
+	 */
74
+	const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
75
+
76
+	/**
77
+	 * @var EE_System $_instance
78
+	 */
79
+	private static $_instance;
80
+
81
+	/**
82
+	 * @var EE_Registry $registry
83
+	 */
84
+	private $registry;
85
+
86
+	/**
87
+	 * @var LoaderInterface $loader
88
+	 */
89
+	private $loader;
90
+
91
+	/**
92
+	 * @var EE_Capabilities $capabilities
93
+	 */
94
+	private $capabilities;
95
+
96
+	/**
97
+	 * @var RequestInterface $request
98
+	 */
99
+	private $request;
100
+
101
+	/**
102
+	 * @var EE_Maintenance_Mode $maintenance_mode
103
+	 */
104
+	private $maintenance_mode;
105
+
106
+	/**
107
+	 * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
108
+	 * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
109
+	 *
110
+	 * @var int $_req_type
111
+	 */
112
+	private $_req_type;
113
+
114
+	/**
115
+	 * Whether or not there was a non-micro version change in EE core version during this request
116
+	 *
117
+	 * @var boolean $_major_version_change
118
+	 */
119
+	private $_major_version_change = false;
120
+
121
+	/**
122
+	 * A Context DTO dedicated solely to identifying the current request type.
123
+	 *
124
+	 * @var RequestTypeContextCheckerInterface $request_type
125
+	 */
126
+	private $request_type;
127
+
128
+
129
+	/**
130
+	 * @singleton method used to instantiate class object
131
+	 * @param EE_Registry|null         $registry
132
+	 * @param LoaderInterface|null     $loader
133
+	 * @param RequestInterface|null    $request
134
+	 * @param EE_Maintenance_Mode|null $maintenance_mode
135
+	 * @return EE_System
136
+	 */
137
+	public static function instance(
138
+		EE_Registry $registry = null,
139
+		LoaderInterface $loader = null,
140
+		RequestInterface $request = null,
141
+		EE_Maintenance_Mode $maintenance_mode = null
142
+	) {
143
+		// check if class object is instantiated
144
+		if (! self::$_instance instanceof EE_System) {
145
+			self::$_instance = new self($registry, $loader, $request, $maintenance_mode);
146
+		}
147
+		return self::$_instance;
148
+	}
149
+
150
+
151
+	/**
152
+	 * resets the instance and returns it
153
+	 *
154
+	 * @return EE_System
155
+	 */
156
+	public static function reset()
157
+	{
158
+		self::$_instance->_req_type = null;
159
+		// make sure none of the old hooks are left hanging around
160
+		remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
161
+		// we need to reset the migration manager in order for it to detect DMSs properly
162
+		EE_Data_Migration_Manager::reset();
163
+		self::instance()->detect_activations_or_upgrades();
164
+		self::instance()->perform_activations_upgrades_and_migrations();
165
+		return self::instance();
166
+	}
167
+
168
+
169
+	/**
170
+	 * sets hooks for running rest of system
171
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
172
+	 * starting EE Addons from any other point may lead to problems
173
+	 *
174
+	 * @param EE_Registry         $registry
175
+	 * @param LoaderInterface     $loader
176
+	 * @param RequestInterface    $request
177
+	 * @param EE_Maintenance_Mode $maintenance_mode
178
+	 */
179
+	private function __construct(
180
+		EE_Registry $registry,
181
+		LoaderInterface $loader,
182
+		RequestInterface $request,
183
+		EE_Maintenance_Mode $maintenance_mode
184
+	) {
185
+		$this->registry = $registry;
186
+		$this->loader = $loader;
187
+		$this->request = $request;
188
+		$this->maintenance_mode = $maintenance_mode;
189
+		do_action('AHEE__EE_System__construct__begin', $this);
190
+		add_action(
191
+			'AHEE__EE_Bootstrap__load_espresso_addons',
192
+			array($this, 'loadCapabilities'),
193
+			5
194
+		);
195
+		add_action(
196
+			'AHEE__EE_Bootstrap__load_espresso_addons',
197
+			array($this, 'loadCommandBus'),
198
+			7
199
+		);
200
+		add_action(
201
+			'AHEE__EE_Bootstrap__load_espresso_addons',
202
+			array($this, 'loadPluginApi'),
203
+			9
204
+		);
205
+		// allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
206
+		add_action(
207
+			'AHEE__EE_Bootstrap__load_espresso_addons',
208
+			array($this, 'load_espresso_addons')
209
+		);
210
+		// when an ee addon is activated, we want to call the core hook(s) again
211
+		// because the newly-activated addon didn't get a chance to run at all
212
+		add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
213
+		// detect whether install or upgrade
214
+		add_action(
215
+			'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
216
+			array($this, 'detect_activations_or_upgrades'),
217
+			3
218
+		);
219
+		// load EE_Config, EE_Textdomain, etc
220
+		add_action(
221
+			'AHEE__EE_Bootstrap__load_core_configuration',
222
+			array($this, 'load_core_configuration'),
223
+			5
224
+		);
225
+		// load specifications for matching routes to current request
226
+		add_action(
227
+			'AHEE__EE_Bootstrap__load_core_configuration',
228
+			array($this, 'loadRouteMatchSpecifications')
229
+		);
230
+		// load EE_Config, EE_Textdomain, etc
231
+		add_action(
232
+			'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
233
+			array($this, 'register_shortcodes_modules_and_widgets'),
234
+			7
235
+		);
236
+		// you wanna get going? I wanna get going... let's get going!
237
+		add_action(
238
+			'AHEE__EE_Bootstrap__brew_espresso',
239
+			array($this, 'brew_espresso'),
240
+			9
241
+		);
242
+		// other housekeeping
243
+		// exclude EE critical pages from wp_list_pages
244
+		add_filter(
245
+			'wp_list_pages_excludes',
246
+			array($this, 'remove_pages_from_wp_list_pages'),
247
+			10
248
+		);
249
+		// ALL EE Addons should use the following hook point to attach their initial setup too
250
+		// it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
251
+		do_action('AHEE__EE_System__construct__complete', $this);
252
+	}
253
+
254
+
255
+	/**
256
+	 * load and setup EE_Capabilities
257
+	 *
258
+	 * @return void
259
+	 * @throws EE_Error
260
+	 */
261
+	public function loadCapabilities()
262
+	{
263
+		$this->capabilities = $this->loader->getShared('EE_Capabilities');
264
+		add_action(
265
+			'AHEE__EE_Capabilities__init_caps__before_initialization',
266
+			function () {
267
+				LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
268
+			}
269
+		);
270
+	}
271
+
272
+
273
+	/**
274
+	 * create and cache the CommandBus, and also add middleware
275
+	 * The CapChecker middleware requires the use of EE_Capabilities
276
+	 * which is why we need to load the CommandBus after Caps are set up
277
+	 *
278
+	 * @return void
279
+	 * @throws EE_Error
280
+	 */
281
+	public function loadCommandBus()
282
+	{
283
+		$this->loader->getShared(
284
+			'CommandBusInterface',
285
+			array(
286
+				null,
287
+				apply_filters(
288
+					'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
289
+					array(
290
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
291
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
292
+					)
293
+				),
294
+			)
295
+		);
296
+	}
297
+
298
+
299
+	/**
300
+	 * @return void
301
+	 * @throws EE_Error
302
+	 */
303
+	public function loadPluginApi()
304
+	{
305
+		// set autoloaders for all of the classes implementing EEI_Plugin_API
306
+		// which provide helpers for EE plugin authors to more easily register certain components with EE.
307
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
308
+		$this->loader->getShared('EE_Request_Handler');
309
+	}
310
+
311
+
312
+	/**
313
+	 * @param string $addon_name
314
+	 * @param string $version_constant
315
+	 * @param string $min_version_required
316
+	 * @param string $load_callback
317
+	 * @param string $plugin_file_constant
318
+	 * @return void
319
+	 */
320
+	private function deactivateIncompatibleAddon(
321
+		$addon_name,
322
+		$version_constant,
323
+		$min_version_required,
324
+		$load_callback,
325
+		$plugin_file_constant
326
+	) {
327
+		if (! defined($version_constant)) {
328
+			return;
329
+		}
330
+		$addon_version = constant($version_constant);
331
+		if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
332
+			remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
333
+			if (! function_exists('deactivate_plugins')) {
334
+				require_once ABSPATH . 'wp-admin/includes/plugin.php';
335
+			}
336
+			deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
337
+			unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
338
+			EE_Error::add_error(
339
+				sprintf(
340
+					esc_html__(
341
+						'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.',
342
+						'event_espresso'
343
+					),
344
+					$addon_name,
345
+					$min_version_required
346
+				),
347
+				__FILE__,
348
+				__FUNCTION__ . "({$addon_name})",
349
+				__LINE__
350
+			);
351
+			EE_Error::get_notices(false, true);
352
+		}
353
+	}
354
+
355
+
356
+	/**
357
+	 * load_espresso_addons
358
+	 * allow addons to load first so that they can set hooks for running DMS's, etc
359
+	 * this is hooked into both:
360
+	 *    'AHEE__EE_Bootstrap__load_core_configuration'
361
+	 *        which runs during the WP 'plugins_loaded' action at priority 5
362
+	 *    and the WP 'activate_plugin' hook point
363
+	 *
364
+	 * @access public
365
+	 * @return void
366
+	 */
367
+	public function load_espresso_addons()
368
+	{
369
+		$this->deactivateIncompatibleAddon(
370
+			'Wait Lists',
371
+			'EE_WAIT_LISTS_VERSION',
372
+			'1.0.0.beta.074',
373
+			'load_espresso_wait_lists',
374
+			'EE_WAIT_LISTS_PLUGIN_FILE'
375
+		);
376
+		$this->deactivateIncompatibleAddon(
377
+			'Automated Upcoming Event Notifications',
378
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
379
+			'1.0.0.beta.091',
380
+			'load_espresso_automated_upcoming_event_notification',
381
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
382
+		);
383
+		do_action('AHEE__EE_System__load_espresso_addons');
384
+		// if the WP API basic auth plugin isn't already loaded, load it now.
385
+		// We want it for mobile apps. Just include the entire plugin
386
+		// also, don't load the basic auth when a plugin is getting activated, because
387
+		// it could be the basic auth plugin, and it doesn't check if its methods are already defined
388
+		// and causes a fatal error
389
+		if ($this->request->getRequestParam('activate') !== 'true'
390
+			&& ! function_exists('json_basic_auth_handler')
391
+			&& ! function_exists('json_basic_auth_error')
392
+			&& ! in_array(
393
+				$this->request->getRequestParam('action'),
394
+				array('activate', 'activate-selected'),
395
+				true
396
+			)
397
+		) {
398
+			include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
399
+		}
400
+		do_action('AHEE__EE_System__load_espresso_addons__complete');
401
+	}
402
+
403
+
404
+	/**
405
+	 * detect_activations_or_upgrades
406
+	 * Checks for activation or upgrade of core first;
407
+	 * then also checks if any registered addons have been activated or upgraded
408
+	 * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
409
+	 * which runs during the WP 'plugins_loaded' action at priority 3
410
+	 *
411
+	 * @access public
412
+	 * @return void
413
+	 */
414
+	public function detect_activations_or_upgrades()
415
+	{
416
+		// first off: let's make sure to handle core
417
+		$this->detect_if_activation_or_upgrade();
418
+		foreach ($this->registry->addons as $addon) {
419
+			if ($addon instanceof EE_Addon) {
420
+				// detect teh request type for that addon
421
+				$addon->detect_activation_or_upgrade();
422
+			}
423
+		}
424
+	}
425
+
426
+
427
+	/**
428
+	 * detect_if_activation_or_upgrade
429
+	 * Takes care of detecting whether this is a brand new install or code upgrade,
430
+	 * and either setting up the DB or setting up maintenance mode etc.
431
+	 *
432
+	 * @access public
433
+	 * @return void
434
+	 */
435
+	public function detect_if_activation_or_upgrade()
436
+	{
437
+		do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
438
+		// check if db has been updated, or if its a brand-new installation
439
+		$espresso_db_update = $this->fix_espresso_db_upgrade_option();
440
+		$request_type = $this->detect_req_type($espresso_db_update);
441
+		// EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
442
+		switch ($request_type) {
443
+			case EE_System::req_type_new_activation:
444
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
445
+				$this->_handle_core_version_change($espresso_db_update);
446
+				break;
447
+			case EE_System::req_type_reactivation:
448
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
449
+				$this->_handle_core_version_change($espresso_db_update);
450
+				break;
451
+			case EE_System::req_type_upgrade:
452
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
453
+				// migrations may be required now that we've upgraded
454
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
455
+				$this->_handle_core_version_change($espresso_db_update);
456
+				break;
457
+			case EE_System::req_type_downgrade:
458
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
459
+				// its possible migrations are no longer required
460
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
461
+				$this->_handle_core_version_change($espresso_db_update);
462
+				break;
463
+			case EE_System::req_type_normal:
464
+			default:
465
+				break;
466
+		}
467
+		do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
468
+	}
469
+
470
+
471
+	/**
472
+	 * Updates the list of installed versions and sets hooks for
473
+	 * initializing the database later during the request
474
+	 *
475
+	 * @param array $espresso_db_update
476
+	 */
477
+	private function _handle_core_version_change($espresso_db_update)
478
+	{
479
+		$this->update_list_of_installed_versions($espresso_db_update);
480
+		// get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
481
+		add_action(
482
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
483
+			array($this, 'initialize_db_if_no_migrations_required')
484
+		);
485
+	}
486
+
487
+
488
+	/**
489
+	 * standardizes the wp option 'espresso_db_upgrade' which actually stores
490
+	 * information about what versions of EE have been installed and activated,
491
+	 * NOT necessarily the state of the database
492
+	 *
493
+	 * @param mixed $espresso_db_update           the value of the WordPress option.
494
+	 *                                            If not supplied, fetches it from the options table
495
+	 * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
496
+	 */
497
+	private function fix_espresso_db_upgrade_option($espresso_db_update = null)
498
+	{
499
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
500
+		if (! $espresso_db_update) {
501
+			$espresso_db_update = get_option('espresso_db_update');
502
+		}
503
+		// check that option is an array
504
+		if (! is_array($espresso_db_update)) {
505
+			// if option is FALSE, then it never existed
506
+			if ($espresso_db_update === false) {
507
+				// make $espresso_db_update an array and save option with autoload OFF
508
+				$espresso_db_update = array();
509
+				add_option('espresso_db_update', $espresso_db_update, '', 'no');
510
+			} else {
511
+				// option is NOT FALSE but also is NOT an array, so make it an array and save it
512
+				$espresso_db_update = array($espresso_db_update => array());
513
+				update_option('espresso_db_update', $espresso_db_update);
514
+			}
515
+		} else {
516
+			$corrected_db_update = array();
517
+			// if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
518
+			foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
519
+				if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
520
+					// the key is an int, and the value IS NOT an array
521
+					// so it must be numerically-indexed, where values are versions installed...
522
+					// fix it!
523
+					$version_string = $should_be_array;
524
+					$corrected_db_update[ $version_string ] = array('unknown-date');
525
+				} else {
526
+					// ok it checks out
527
+					$corrected_db_update[ $should_be_version_string ] = $should_be_array;
528
+				}
529
+			}
530
+			$espresso_db_update = $corrected_db_update;
531
+			update_option('espresso_db_update', $espresso_db_update);
532
+		}
533
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
534
+		return $espresso_db_update;
535
+	}
536
+
537
+
538
+	/**
539
+	 * Does the traditional work of setting up the plugin's database and adding default data.
540
+	 * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
541
+	 * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
542
+	 * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
543
+	 * so that it will be done when migrations are finished
544
+	 *
545
+	 * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
546
+	 * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
547
+	 *                                       This is a resource-intensive job
548
+	 *                                       so we prefer to only do it when necessary
549
+	 * @return void
550
+	 * @throws EE_Error
551
+	 */
552
+	public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
553
+	{
554
+		$request_type = $this->detect_req_type();
555
+		// only initialize system if we're not in maintenance mode.
556
+		if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
557
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
558
+			$rewrite_rules = $this->loader->getShared(
559
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
560
+			);
561
+			$rewrite_rules->flush();
562
+			if ($verify_schema) {
563
+				EEH_Activation::initialize_db_and_folders();
564
+			}
565
+			EEH_Activation::initialize_db_content();
566
+			EEH_Activation::system_initialization();
567
+			if ($initialize_addons_too) {
568
+				$this->initialize_addons();
569
+			}
570
+		} else {
571
+			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
572
+		}
573
+		if ($request_type === EE_System::req_type_new_activation
574
+			|| $request_type === EE_System::req_type_reactivation
575
+			|| (
576
+				$request_type === EE_System::req_type_upgrade
577
+				&& $this->is_major_version_change()
578
+			)
579
+		) {
580
+			add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
581
+		}
582
+	}
583
+
584
+
585
+	/**
586
+	 * Initializes the db for all registered addons
587
+	 *
588
+	 * @throws EE_Error
589
+	 */
590
+	public function initialize_addons()
591
+	{
592
+		// foreach registered addon, make sure its db is up-to-date too
593
+		foreach ($this->registry->addons as $addon) {
594
+			if ($addon instanceof EE_Addon) {
595
+				$addon->initialize_db_if_no_migrations_required();
596
+			}
597
+		}
598
+	}
599
+
600
+
601
+	/**
602
+	 * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
603
+	 *
604
+	 * @param    array  $version_history
605
+	 * @param    string $current_version_to_add version to be added to the version history
606
+	 * @return    boolean success as to whether or not this option was changed
607
+	 */
608
+	public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
609
+	{
610
+		if (! $version_history) {
611
+			$version_history = $this->fix_espresso_db_upgrade_option($version_history);
612
+		}
613
+		if ($current_version_to_add === null) {
614
+			$current_version_to_add = espresso_version();
615
+		}
616
+		$version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
617
+		// re-save
618
+		return update_option('espresso_db_update', $version_history);
619
+	}
620
+
621
+
622
+	/**
623
+	 * Detects if the current version indicated in the has existed in the list of
624
+	 * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
625
+	 *
626
+	 * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
627
+	 *                                  If not supplied, fetches it from the options table.
628
+	 *                                  Also, caches its result so later parts of the code can also know whether
629
+	 *                                  there's been an update or not. This way we can add the current version to
630
+	 *                                  espresso_db_update, but still know if this is a new install or not
631
+	 * @return int one of the constants on EE_System::req_type_
632
+	 */
633
+	public function detect_req_type($espresso_db_update = null)
634
+	{
635
+		if ($this->_req_type === null) {
636
+			$espresso_db_update = ! empty($espresso_db_update)
637
+				? $espresso_db_update
638
+				: $this->fix_espresso_db_upgrade_option();
639
+			$this->_req_type = EE_System::detect_req_type_given_activation_history(
640
+				$espresso_db_update,
641
+				'ee_espresso_activation',
642
+				espresso_version()
643
+			);
644
+			$this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
645
+			$this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal);
646
+		}
647
+		return $this->_req_type;
648
+	}
649
+
650
+
651
+	/**
652
+	 * Returns whether or not there was a non-micro version change (ie, change in either
653
+	 * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
654
+	 * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
655
+	 *
656
+	 * @param $activation_history
657
+	 * @return bool
658
+	 */
659
+	private function _detect_major_version_change($activation_history)
660
+	{
661
+		$previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
662
+		$previous_version_parts = explode('.', $previous_version);
663
+		$current_version_parts = explode('.', espresso_version());
664
+		return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
665
+			   && ($previous_version_parts[0] !== $current_version_parts[0]
666
+				   || $previous_version_parts[1] !== $current_version_parts[1]
667
+			   );
668
+	}
669
+
670
+
671
+	/**
672
+	 * Returns true if either the major or minor version of EE changed during this request.
673
+	 * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001
674
+	 *
675
+	 * @return bool
676
+	 */
677
+	public function is_major_version_change()
678
+	{
679
+		return $this->_major_version_change;
680
+	}
681
+
682
+
683
+	/**
684
+	 * Determines the request type for any ee addon, given three piece of info: the current array of activation
685
+	 * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
686
+	 * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
687
+	 * just activated to (for core that will always be espresso_version())
688
+	 *
689
+	 * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
690
+	 *                                                 ee plugin. for core that's 'espresso_db_update'
691
+	 * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
692
+	 *                                                 indicate that this plugin was just activated
693
+	 * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
694
+	 *                                                 espresso_version())
695
+	 * @return int one of the constants on EE_System::req_type_*
696
+	 */
697
+	public static function detect_req_type_given_activation_history(
698
+		$activation_history_for_addon,
699
+		$activation_indicator_option_name,
700
+		$version_to_upgrade_to
701
+	) {
702
+		$version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
703
+		if ($activation_history_for_addon) {
704
+			// it exists, so this isn't a completely new install
705
+			// check if this version already in that list of previously installed versions
706
+			if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) {
707
+				// it a version we haven't seen before
708
+				if ($version_is_higher === 1) {
709
+					$req_type = EE_System::req_type_upgrade;
710
+				} else {
711
+					$req_type = EE_System::req_type_downgrade;
712
+				}
713
+				delete_option($activation_indicator_option_name);
714
+			} else {
715
+				// its not an update. maybe a reactivation?
716
+				if (get_option($activation_indicator_option_name, false)) {
717
+					if ($version_is_higher === -1) {
718
+						$req_type = EE_System::req_type_downgrade;
719
+					} elseif ($version_is_higher === 0) {
720
+						// we've seen this version before, but it's an activation. must be a reactivation
721
+						$req_type = EE_System::req_type_reactivation;
722
+					} else {// $version_is_higher === 1
723
+						$req_type = EE_System::req_type_upgrade;
724
+					}
725
+					delete_option($activation_indicator_option_name);
726
+				} else {
727
+					// we've seen this version before and the activation indicate doesn't show it was just activated
728
+					if ($version_is_higher === -1) {
729
+						$req_type = EE_System::req_type_downgrade;
730
+					} elseif ($version_is_higher === 0) {
731
+						// we've seen this version before and it's not an activation. its normal request
732
+						$req_type = EE_System::req_type_normal;
733
+					} else {// $version_is_higher === 1
734
+						$req_type = EE_System::req_type_upgrade;
735
+					}
736
+				}
737
+			}
738
+		} else {
739
+			// brand new install
740
+			$req_type = EE_System::req_type_new_activation;
741
+			delete_option($activation_indicator_option_name);
742
+		}
743
+		return $req_type;
744
+	}
745
+
746
+
747
+	/**
748
+	 * Detects if the $version_to_upgrade_to is higher than the most recent version in
749
+	 * the $activation_history_for_addon
750
+	 *
751
+	 * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
752
+	 *                                             sometimes containing 'unknown-date'
753
+	 * @param string $version_to_upgrade_to        (current version)
754
+	 * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
755
+	 *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
756
+	 *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
757
+	 *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
758
+	 */
759
+	private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
760
+	{
761
+		// find the most recently-activated version
762
+		$most_recently_active_version =
763
+			EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
764
+		return version_compare($version_to_upgrade_to, $most_recently_active_version);
765
+	}
766
+
767
+
768
+	/**
769
+	 * Gets the most recently active version listed in the activation history,
770
+	 * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
771
+	 *
772
+	 * @param array $activation_history  (keys are versions, values are arrays of times activated,
773
+	 *                                   sometimes containing 'unknown-date'
774
+	 * @return string
775
+	 */
776
+	private static function _get_most_recently_active_version_from_activation_history($activation_history)
777
+	{
778
+		$most_recently_active_version_activation = '1970-01-01 00:00:00';
779
+		$most_recently_active_version = '0.0.0.dev.000';
780
+		if (is_array($activation_history)) {
781
+			foreach ($activation_history as $version => $times_activated) {
782
+				// check there is a record of when this version was activated. Otherwise,
783
+				// mark it as unknown
784
+				if (! $times_activated) {
785
+					$times_activated = array('unknown-date');
786
+				}
787
+				if (is_string($times_activated)) {
788
+					$times_activated = array($times_activated);
789
+				}
790
+				foreach ($times_activated as $an_activation) {
791
+					if ($an_activation !== 'unknown-date'
792
+						&& $an_activation
793
+						   > $most_recently_active_version_activation) {
794
+						$most_recently_active_version = $version;
795
+						$most_recently_active_version_activation = $an_activation === 'unknown-date'
796
+							? '1970-01-01 00:00:00'
797
+							: $an_activation;
798
+					}
799
+				}
800
+			}
801
+		}
802
+		return $most_recently_active_version;
803
+	}
804
+
805
+
806
+	/**
807
+	 * This redirects to the about EE page after activation
808
+	 *
809
+	 * @return void
810
+	 */
811
+	public function redirect_to_about_ee()
812
+	{
813
+		$notices = EE_Error::get_notices(false);
814
+		// if current user is an admin and it's not an ajax or rest request
815
+		if (! isset($notices['errors'])
816
+			&& $this->request->isAdmin()
817
+			&& apply_filters(
818
+				'FHEE__EE_System__redirect_to_about_ee__do_redirect',
819
+				$this->capabilities->current_user_can('manage_options', 'espresso_about_default')
820
+			)
821
+		) {
822
+			$query_params = array('page' => 'espresso_about');
823
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
824
+				$query_params['new_activation'] = true;
825
+			}
826
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
827
+				$query_params['reactivation'] = true;
828
+			}
829
+			$url = add_query_arg($query_params, admin_url('admin.php'));
830
+			wp_safe_redirect($url);
831
+			exit();
832
+		}
833
+	}
834
+
835
+
836
+	/**
837
+	 * load_core_configuration
838
+	 * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
839
+	 * which runs during the WP 'plugins_loaded' action at priority 5
840
+	 *
841
+	 * @return void
842
+	 * @throws ReflectionException
843
+	 * @throws Exception
844
+	 */
845
+	public function load_core_configuration()
846
+	{
847
+		do_action('AHEE__EE_System__load_core_configuration__begin', $this);
848
+		$this->loader->getShared('EE_Load_Textdomain');
849
+		// load textdomain
850
+		EE_Load_Textdomain::load_textdomain();
851
+		// load and setup EE_Config and EE_Network_Config
852
+		$config = $this->loader->getShared('EE_Config');
853
+		$this->loader->getShared('EE_Network_Config');
854
+		// setup autoloaders
855
+		// enable logging?
856
+		if ($config->admin->use_full_logging) {
857
+			$this->loader->getShared('EE_Log');
858
+		}
859
+		// check for activation errors
860
+		$activation_errors = get_option('ee_plugin_activation_errors', false);
861
+		if ($activation_errors) {
862
+			EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
863
+			update_option('ee_plugin_activation_errors', false);
864
+		}
865
+		// get model names
866
+		$this->_parse_model_names();
867
+		// load caf stuff a chance to play during the activation process too.
868
+		$this->_maybe_brew_regular();
869
+		// configure custom post type definitions
870
+		$this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions');
871
+		$this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions');
872
+		do_action('AHEE__EE_System__load_core_configuration__complete', $this);
873
+	}
874
+
875
+
876
+	/**
877
+	 * cycles through all of the models/*.model.php files, and assembles an array of model names
878
+	 *
879
+	 * @return void
880
+	 * @throws ReflectionException
881
+	 */
882
+	private function _parse_model_names()
883
+	{
884
+		// get all the files in the EE_MODELS folder that end in .model.php
885
+		$models = glob(EE_MODELS . '*.model.php');
886
+		$model_names = array();
887
+		$non_abstract_db_models = array();
888
+		foreach ($models as $model) {
889
+			// get model classname
890
+			$classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
891
+			$short_name = str_replace('EEM_', '', $classname);
892
+			$reflectionClass = new ReflectionClass($classname);
893
+			if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
894
+				$non_abstract_db_models[ $short_name ] = $classname;
895
+			}
896
+			$model_names[ $short_name ] = $classname;
897
+		}
898
+		$this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
899
+		$this->registry->non_abstract_db_models = apply_filters(
900
+			'FHEE__EE_System__parse_implemented_model_names',
901
+			$non_abstract_db_models
902
+		);
903
+	}
904
+
905
+
906
+	/**
907
+	 * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
908
+	 * that need to be setup before our EE_System launches.
909
+	 *
910
+	 * @return void
911
+	 * @throws DomainException
912
+	 * @throws InvalidArgumentException
913
+	 * @throws InvalidDataTypeException
914
+	 * @throws InvalidInterfaceException
915
+	 * @throws InvalidClassException
916
+	 * @throws InvalidFilePathException
917
+	 */
918
+	private function _maybe_brew_regular()
919
+	{
920
+		/** @var Domain $domain */
921
+		$domain = DomainFactory::getShared(
922
+			new FullyQualifiedName(
923
+				'EventEspresso\core\domain\Domain'
924
+			),
925
+			array(
926
+				new FilePath(EVENT_ESPRESSO_MAIN_FILE),
927
+				Version::fromString(espresso_version()),
928
+			)
929
+		);
930
+		if ($domain->isCaffeinated()) {
931
+			require_once EE_CAFF_PATH . 'brewing_regular.php';
932
+		}
933
+	}
934
+
935
+
936
+	/**
937
+	 * @since $VID:$
938
+	 * @throws Exception
939
+	 */
940
+	public function loadRouteMatchSpecifications()
941
+	{
942
+		try {
943
+			$this->loader->getShared(
944
+				'EventEspresso\core\services\route_match\RouteMatchSpecificationManager'
945
+			);
946
+		} catch (Exception $exception) {
947
+			new ExceptionStackTraceDisplay($exception);
948
+		}
949
+		do_action('AHEE__EE_System__loadRouteMatchSpecifications');
950
+	}
951
+
952
+
953
+	/**
954
+	 * register_shortcodes_modules_and_widgets
955
+	 * generate lists of shortcodes and modules, then verify paths and classes
956
+	 * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
957
+	 * which runs during the WP 'plugins_loaded' action at priority 7
958
+	 *
959
+	 * @access public
960
+	 * @return void
961
+	 * @throws Exception
962
+	 */
963
+	public function register_shortcodes_modules_and_widgets()
964
+	{
965
+		if ($this->request->isFrontend() || $this->request->isIframe() || $this->request->isAjax()) {
966
+			try {
967
+				// load, register, and add shortcodes the new way
968
+				$this->loader->getShared(
969
+					'EventEspresso\core\services\shortcodes\ShortcodesManager',
970
+					array(
971
+						// and the old way, but we'll put it under control of the new system
972
+						EE_Config::getLegacyShortcodesManager(),
973
+					)
974
+				);
975
+			} catch (Exception $exception) {
976
+				new ExceptionStackTraceDisplay($exception);
977
+			}
978
+		}
979
+		do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
980
+		// check for addons using old hook point
981
+		if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
982
+			$this->_incompatible_addon_error();
983
+		}
984
+	}
985
+
986
+
987
+	/**
988
+	 * _incompatible_addon_error
989
+	 *
990
+	 * @access public
991
+	 * @return void
992
+	 */
993
+	private function _incompatible_addon_error()
994
+	{
995
+		// get array of classes hooking into here
996
+		$class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
997
+			'AHEE__EE_System__register_shortcodes_modules_and_addons'
998
+		);
999
+		if (! empty($class_names)) {
1000
+			$msg = __(
1001
+				'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
1002
+				'event_espresso'
1003
+			);
1004
+			$msg .= '<ul>';
1005
+			foreach ($class_names as $class_name) {
1006
+				$msg .= '<li><b>Event Espresso - '
1007
+						. str_replace(
1008
+							array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'),
1009
+							'',
1010
+							$class_name
1011
+						) . '</b></li>';
1012
+			}
1013
+			$msg .= '</ul>';
1014
+			$msg .= __(
1015
+				'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
1016
+				'event_espresso'
1017
+			);
1018
+			// save list of incompatible addons to wp-options for later use
1019
+			add_option('ee_incompatible_addons', $class_names, '', 'no');
1020
+			if (is_admin()) {
1021
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1022
+			}
1023
+		}
1024
+	}
1025
+
1026
+
1027
+	/**
1028
+	 * brew_espresso
1029
+	 * begins the process of setting hooks for initializing EE in the correct order
1030
+	 * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1031
+	 * which runs during the WP 'plugins_loaded' action at priority 9
1032
+	 *
1033
+	 * @return void
1034
+	 */
1035
+	public function brew_espresso()
1036
+	{
1037
+		do_action('AHEE__EE_System__brew_espresso__begin', $this);
1038
+		// load some final core systems
1039
+		add_action('init', array($this, 'set_hooks_for_core'), 1);
1040
+		add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1041
+		add_action('init', array($this, 'load_CPTs_and_session'), 5);
1042
+		add_action('init', array($this, 'load_controllers'), 7);
1043
+		add_action('init', array($this, 'core_loaded_and_ready'), 9);
1044
+		add_action('init', array($this, 'initialize'), 10);
1045
+		add_action('init', array($this, 'initialize_last'), 100);
1046
+		if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
1047
+			// pew pew pew
1048
+			$this->loader->getShared('EventEspresso\core\services\licensing\LicenseService');
1049
+			do_action('AHEE__EE_System__brew_espresso__after_pue_init');
1050
+		}
1051
+		do_action('AHEE__EE_System__brew_espresso__complete', $this);
1052
+	}
1053
+
1054
+
1055
+	/**
1056
+	 *    set_hooks_for_core
1057
+	 *
1058
+	 * @access public
1059
+	 * @return    void
1060
+	 * @throws EE_Error
1061
+	 */
1062
+	public function set_hooks_for_core()
1063
+	{
1064
+		$this->_deactivate_incompatible_addons();
1065
+		do_action('AHEE__EE_System__set_hooks_for_core');
1066
+		$this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan');
1067
+		// caps need to be initialized on every request so that capability maps are set.
1068
+		// @see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1069
+		$this->registry->CAP->init_caps();
1070
+	}
1071
+
1072
+
1073
+	/**
1074
+	 * Using the information gathered in EE_System::_incompatible_addon_error,
1075
+	 * deactivates any addons considered incompatible with the current version of EE
1076
+	 */
1077
+	private function _deactivate_incompatible_addons()
1078
+	{
1079
+		$incompatible_addons = get_option('ee_incompatible_addons', array());
1080
+		if (! empty($incompatible_addons)) {
1081
+			$active_plugins = get_option('active_plugins', array());
1082
+			foreach ($active_plugins as $active_plugin) {
1083
+				foreach ($incompatible_addons as $incompatible_addon) {
1084
+					if (strpos($active_plugin, $incompatible_addon) !== false) {
1085
+						unset($_GET['activate']);
1086
+						espresso_deactivate_plugin($active_plugin);
1087
+					}
1088
+				}
1089
+			}
1090
+		}
1091
+	}
1092
+
1093
+
1094
+	/**
1095
+	 *    perform_activations_upgrades_and_migrations
1096
+	 *
1097
+	 * @access public
1098
+	 * @return    void
1099
+	 */
1100
+	public function perform_activations_upgrades_and_migrations()
1101
+	{
1102
+		do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1103
+	}
1104
+
1105
+
1106
+	/**
1107
+	 * @return void
1108
+	 * @throws DomainException
1109
+	 */
1110
+	public function load_CPTs_and_session()
1111
+	{
1112
+		do_action('AHEE__EE_System__load_CPTs_and_session__start');
1113
+		/** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies $register_custom_taxonomies */
1114
+		$register_custom_taxonomies = $this->loader->getShared(
1115
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'
1116
+		);
1117
+		$register_custom_taxonomies->registerCustomTaxonomies();
1118
+		/** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */
1119
+		$register_custom_post_types = $this->loader->getShared(
1120
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'
1121
+		);
1122
+		$register_custom_post_types->registerCustomPostTypes();
1123
+		/** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms */
1124
+		$register_custom_taxonomy_terms = $this->loader->getShared(
1125
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms'
1126
+		);
1127
+		$register_custom_taxonomy_terms->registerCustomTaxonomyTerms();
1128
+		// load legacy Custom Post Types and Taxonomies
1129
+		$this->loader->getShared('EE_Register_CPTs');
1130
+		do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1131
+	}
1132
+
1133
+
1134
+	/**
1135
+	 * load_controllers
1136
+	 * this is the best place to load any additional controllers that needs access to EE core.
1137
+	 * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1138
+	 * time
1139
+	 *
1140
+	 * @access public
1141
+	 * @return void
1142
+	 */
1143
+	public function load_controllers()
1144
+	{
1145
+		do_action('AHEE__EE_System__load_controllers__start');
1146
+		// let's get it started
1147
+		if (! $this->maintenance_mode->level()
1148
+			&& ($this->request->isFrontend() || $this->request->isFrontAjax())
1149
+		) {
1150
+			do_action('AHEE__EE_System__load_controllers__load_front_controllers');
1151
+			$this->loader->getShared('EE_Front_Controller');
1152
+		} elseif ($this->request->isAdmin() || $this->request->isAdminAjax()) {
1153
+			do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1154
+			$this->loader->getShared('EE_Admin');
1155
+		}
1156
+		do_action('AHEE__EE_System__load_controllers__complete');
1157
+	}
1158
+
1159
+
1160
+	/**
1161
+	 * core_loaded_and_ready
1162
+	 * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1163
+	 *
1164
+	 * @access public
1165
+	 * @return void
1166
+	 * @throws Exception
1167
+	 */
1168
+	public function core_loaded_and_ready()
1169
+	{
1170
+		if ($this->request->isAdmin()
1171
+			|| $this->request->isFrontend()
1172
+			|| $this->request->isIframe()
1173
+			|| $this->request->isWordPressApi()
1174
+		) {
1175
+			try {
1176
+				$this->loader->getShared('EventEspresso\core\services\assets\Registry');
1177
+				$this->loader->getShared('EventEspresso\core\domain\services\assets\CoreAssetManager');
1178
+				if (function_exists('register_block_type')) {
1179
+					$this->loader->getShared(
1180
+						'EventEspresso\core\services\editor\BlockRegistrationManager'
1181
+					);
1182
+				}
1183
+			} catch (Exception $exception) {
1184
+				new ExceptionStackTraceDisplay($exception);
1185
+			}
1186
+		}
1187
+		if ($this->request->isAdmin()
1188
+			|| $this->request->isEeAjax()
1189
+			|| $this->request->isFrontend()
1190
+		) {
1191
+			$this->loader->getShared('EE_Session');
1192
+		}
1193
+		// integrate WP_Query with the EE models
1194
+		$this->loader->getShared('EE_CPT_Strategy');
1195
+		do_action('AHEE__EE_System__core_loaded_and_ready');
1196
+		// always load template tags, because it's faster than checking if it's a front-end request, and many page
1197
+		// builders require these even on the front-end
1198
+		require_once EE_PUBLIC . 'template_tags.php';
1199
+		do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1200
+	}
1201
+
1202
+
1203
+	/**
1204
+	 * initialize
1205
+	 * this is the best place to begin initializing client code
1206
+	 *
1207
+	 * @access public
1208
+	 * @return void
1209
+	 */
1210
+	public function initialize()
1211
+	{
1212
+		do_action('AHEE__EE_System__initialize');
1213
+	}
1214
+
1215
+
1216
+	/**
1217
+	 * initialize_last
1218
+	 * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1219
+	 * initialize has done so
1220
+	 *
1221
+	 * @access public
1222
+	 * @return void
1223
+	 */
1224
+	public function initialize_last()
1225
+	{
1226
+		do_action('AHEE__EE_System__initialize_last');
1227
+		/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
1228
+		$rewrite_rules = $this->loader->getShared(
1229
+			'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
1230
+		);
1231
+		$rewrite_rules->flushRewriteRules();
1232
+		add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1233
+		if (($this->request->isAjax() || $this->request->isAdmin())
1234
+			&& $this->maintenance_mode->models_can_query()) {
1235
+			$this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager');
1236
+			$this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager');
1237
+		}
1238
+	}
1239
+
1240
+
1241
+	/**
1242
+	 * @return void
1243
+	 * @throws EE_Error
1244
+	 */
1245
+	public function addEspressoToolbar()
1246
+	{
1247
+		$this->loader->getShared(
1248
+			'EventEspresso\core\domain\services\admin\AdminToolBar',
1249
+			array($this->registry->CAP)
1250
+		);
1251
+	}
1252
+
1253
+
1254
+	/**
1255
+	 * do_not_cache
1256
+	 * sets no cache headers and defines no cache constants for WP plugins
1257
+	 *
1258
+	 * @access public
1259
+	 * @return void
1260
+	 */
1261
+	public static function do_not_cache()
1262
+	{
1263
+		// set no cache constants
1264
+		if (! defined('DONOTCACHEPAGE')) {
1265
+			define('DONOTCACHEPAGE', true);
1266
+		}
1267
+		if (! defined('DONOTCACHCEOBJECT')) {
1268
+			define('DONOTCACHCEOBJECT', true);
1269
+		}
1270
+		if (! defined('DONOTCACHEDB')) {
1271
+			define('DONOTCACHEDB', true);
1272
+		}
1273
+		// add no cache headers
1274
+		add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1275
+		// plus a little extra for nginx and Google Chrome
1276
+		add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1277
+		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1278
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1279
+	}
1280
+
1281
+
1282
+	/**
1283
+	 *    extra_nocache_headers
1284
+	 *
1285
+	 * @access    public
1286
+	 * @param $headers
1287
+	 * @return    array
1288
+	 */
1289
+	public static function extra_nocache_headers($headers)
1290
+	{
1291
+		// for NGINX
1292
+		$headers['X-Accel-Expires'] = 0;
1293
+		// plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1294
+		$headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1295
+		return $headers;
1296
+	}
1297
+
1298
+
1299
+	/**
1300
+	 *    nocache_headers
1301
+	 *
1302
+	 * @access    public
1303
+	 * @return    void
1304
+	 */
1305
+	public static function nocache_headers()
1306
+	{
1307
+		nocache_headers();
1308
+	}
1309
+
1310
+
1311
+	/**
1312
+	 * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1313
+	 * never returned with the function.
1314
+	 *
1315
+	 * @param  array $exclude_array any existing pages being excluded are in this array.
1316
+	 * @return array
1317
+	 */
1318
+	public function remove_pages_from_wp_list_pages($exclude_array)
1319
+	{
1320
+		return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1321
+	}
1322 1322
 }
Please login to merge, or discard this patch.
core/libraries/form_sections/inputs/EE_State_Select_Input.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -13,60 +13,60 @@
 block discarded – undo
13 13
 class EE_State_Select_Input extends EE_Select_Input
14 14
 {
15 15
 
16
-    /**
17
-     * @param array $state_options
18
-     * @param array $input_settings
19
-     * @throws EE_Error
20
-     * @throws InvalidArgumentException
21
-     * @throws InvalidDataTypeException
22
-     * @throws InvalidInterfaceException
23
-     * @throws ReflectionException
24
-     */
25
-    public function __construct($state_options, $input_settings = array())
26
-    {
27
-        $state_options = apply_filters(
28
-            'FHEE__EE_State_Select_Input____construct__state_options',
29
-            $this->get_state_answer_options($state_options),
30
-            $this
31
-        );
32
-        $input_settings['html_class'] = isset($input_settings['html_class'])
33
-            ? $input_settings['html_class'] . ' ee-state-select-js'
34
-            : 'ee-state-select-js';
35
-        parent::__construct($state_options, $input_settings);
36
-    }
16
+	/**
17
+	 * @param array $state_options
18
+	 * @param array $input_settings
19
+	 * @throws EE_Error
20
+	 * @throws InvalidArgumentException
21
+	 * @throws InvalidDataTypeException
22
+	 * @throws InvalidInterfaceException
23
+	 * @throws ReflectionException
24
+	 */
25
+	public function __construct($state_options, $input_settings = array())
26
+	{
27
+		$state_options = apply_filters(
28
+			'FHEE__EE_State_Select_Input____construct__state_options',
29
+			$this->get_state_answer_options($state_options),
30
+			$this
31
+		);
32
+		$input_settings['html_class'] = isset($input_settings['html_class'])
33
+			? $input_settings['html_class'] . ' ee-state-select-js'
34
+			: 'ee-state-select-js';
35
+		parent::__construct($state_options, $input_settings);
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * get_state_answer_options
41
-     *
42
-     * @param array $state_options
43
-     * @return array
44
-     * @throws EE_Error
45
-     * @throws InvalidArgumentException
46
-     * @throws ReflectionException
47
-     * @throws InvalidDataTypeException
48
-     * @throws InvalidInterfaceException
49
-     */
50
-    public function get_state_answer_options($state_options = null)
51
-    {
52
-        // if passed something that is NOT an array
53
-        if (! is_array($state_options) || empty($state_options)) {
54
-            // get possibly cached list of states
55
-            $states = EEM_State::instance()->get_all_active_states();
56
-        }
57
-        if (is_array($state_options) && reset($state_options) instanceof EE_State) {
58
-            $states = $state_options;
59
-            $state_options = array();
60
-        }
61
-        if (! empty($states)) {
62
-            // set the default
63
-            $state_options[''][''] = '';
64
-            foreach ($states as $state) {
65
-                if ($state instanceof EE_State) {
66
-                    $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
67
-                }
68
-            }
69
-        }
70
-        return $state_options;
71
-    }
39
+	/**
40
+	 * get_state_answer_options
41
+	 *
42
+	 * @param array $state_options
43
+	 * @return array
44
+	 * @throws EE_Error
45
+	 * @throws InvalidArgumentException
46
+	 * @throws ReflectionException
47
+	 * @throws InvalidDataTypeException
48
+	 * @throws InvalidInterfaceException
49
+	 */
50
+	public function get_state_answer_options($state_options = null)
51
+	{
52
+		// if passed something that is NOT an array
53
+		if (! is_array($state_options) || empty($state_options)) {
54
+			// get possibly cached list of states
55
+			$states = EEM_State::instance()->get_all_active_states();
56
+		}
57
+		if (is_array($state_options) && reset($state_options) instanceof EE_State) {
58
+			$states = $state_options;
59
+			$state_options = array();
60
+		}
61
+		if (! empty($states)) {
62
+			// set the default
63
+			$state_options[''][''] = '';
64
+			foreach ($states as $state) {
65
+				if ($state instanceof EE_State) {
66
+					$state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
67
+				}
68
+			}
69
+		}
70
+		return $state_options;
71
+	}
72 72
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
             $this
31 31
         );
32 32
         $input_settings['html_class'] = isset($input_settings['html_class'])
33
-            ? $input_settings['html_class'] . ' ee-state-select-js'
33
+            ? $input_settings['html_class'].' ee-state-select-js'
34 34
             : 'ee-state-select-js';
35 35
         parent::__construct($state_options, $input_settings);
36 36
     }
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public function get_state_answer_options($state_options = null)
51 51
     {
52 52
         // if passed something that is NOT an array
53
-        if (! is_array($state_options) || empty($state_options)) {
53
+        if ( ! is_array($state_options) || empty($state_options)) {
54 54
             // get possibly cached list of states
55 55
             $states = EEM_State::instance()->get_all_active_states();
56 56
         }
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
             $states = $state_options;
59 59
             $state_options = array();
60 60
         }
61
-        if (! empty($states)) {
61
+        if ( ! empty($states)) {
62 62
             // set the default
63 63
             $state_options[''][''] = '';
64 64
             foreach ($states as $state) {
65 65
                 if ($state instanceof EE_State) {
66
-                    $state_options[ $state->country()->name() ][ $state->ID() ] = $state->name();
66
+                    $state_options[$state->country()->name()][$state->ID()] = $state->name();
67 67
                 }
68 68
             }
69 69
         }
Please login to merge, or discard this patch.
core/services/address/CountrySubRegionDao.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@
 block discarded – undo
156 156
 
157 157
     /**
158 158
      * @param string $url
159
-     * @return array
159
+     * @return string
160 160
      */
161 161
     private function retrieveJsonData($url)
162 162
     {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         $data = [];
79 79
         if (empty($this->countries)) {
80 80
             $this->data_version = $this->getCountrySubRegionDataVersion();
81
-            $data = $this->retrieveJsonData(self::REPO_URL . 'countries.json');
81
+            $data = $this->retrieveJsonData(self::REPO_URL.'countries.json');
82 82
         }
83 83
         if (empty($data)) {
84 84
             EE_Error::add_error(
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                 __LINE__
89 89
             );
90 90
         }
91
-        if (! $has_sub_regions
91
+        if ( ! $has_sub_regions
92 92
             || (isset($data->version) && version_compare($data->version, $this->data_version))
93 93
         ) {
94 94
             if (isset($data->countries)
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      */
138 138
     private function processCountryData($CNT_ISO, $countries = array())
139 139
     {
140
-        if (! empty($countries)) {
140
+        if ( ! empty($countries)) {
141 141
             foreach ($countries as $key => $country) {
142 142
                 if ($country instanceof stdClass
143 143
                     && $country->code === $CNT_ISO
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                     && ! empty($country->filename)
146 146
                 ) {
147 147
                     $country->sub_regions = $this->retrieveJsonData(
148
-                        self::REPO_URL . 'countries/' . $country->filename . '.json'
148
+                        self::REPO_URL.'countries/'.$country->filename.'.json'
149 149
                     );
150 150
                     return $this->saveSubRegionData($country, $country->sub_regions);
151 151
                 }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
             foreach ($sub_regions as $sub_region) {
206 206
                 // remove country code from sub region code
207 207
                 $abbrev = str_replace(
208
-                    $country->code . '-',
208
+                    $country->code.'-',
209 209
                     '',
210 210
                     sanitize_text_field($sub_region->code)
211 211
                 );
Please login to merge, or discard this patch.
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -24,208 +24,208 @@
 block discarded – undo
24 24
 class CountrySubRegionDao
25 25
 {
26 26
 
27
-    const REPO_URL = 'https://raw.githubusercontent.com/eventespresso/countries-and-subregions/master/';
28
-
29
-    const OPTION_NAME_COUNTRY_DATA_VERSION = 'espresso-country-sub-region-data-version';
30
-
31
-    /**
32
-     * @var EEM_State $state_model
33
-     */
34
-    private $state_model;
35
-
36
-    /**
37
-     * @var JsonValidator $json_validator
38
-     */
39
-    private $json_validator;
40
-
41
-    /**
42
-     * @var string $data_version
43
-     */
44
-    private $data_version;
45
-
46
-    /**
47
-     * @var array $countries
48
-     */
49
-    private $countries = array();
50
-
51
-
52
-    /**
53
-     * CountrySubRegionDao constructor.
54
-     *
55
-     * @param EEM_State     $state_model
56
-     * @param JsonValidator $json_validator
57
-     */
58
-    public function __construct(EEM_State $state_model, JsonValidator $json_validator)
59
-    {
60
-        $this->state_model = $state_model;
61
-        $this->json_validator = $json_validator;
62
-    }
63
-
64
-
65
-    /**
66
-     * @param EE_Country $country_object
67
-     * @return void
68
-     * @throws EE_Error
69
-     * @throws InvalidArgumentException
70
-     * @throws InvalidDataTypeException
71
-     * @throws InvalidInterfaceException
72
-     * @throws ReflectionException
73
-     */
74
-    public function saveCountrySubRegions(EE_Country $country_object)
75
-    {
76
-        $CNT_ISO = $country_object->ID();
77
-        $has_sub_regions = $this->state_model->count(array(array('Country.CNT_ISO' => $CNT_ISO)));
78
-        $data = [];
79
-        if (empty($this->countries)) {
80
-            $this->data_version = $this->getCountrySubRegionDataVersion();
81
-            $data = $this->retrieveJsonData(self::REPO_URL . 'countries.json');
82
-        }
83
-        if (empty($data)) {
84
-            EE_Error::add_error(
85
-                'Country Subregion Data could not be retrieved',
86
-                __FILE__,
87
-                __METHOD__,
88
-                __LINE__
89
-            );
90
-        }
91
-        if (! $has_sub_regions
92
-            || (isset($data->version) && version_compare($data->version, $this->data_version))
93
-        ) {
94
-            if (isset($data->countries)
95
-                && $this->processCountryData($CNT_ISO, $data->countries) > 0
96
-            ) {
97
-                $this->countries = $data->countries;
98
-                $this->updateCountrySubRegionDataVersion($data->version);
99
-            }
100
-        }
101
-    }
102
-
103
-
104
-    /**
105
-     * @since 4.9.70.p
106
-     * @return string
107
-     */
108
-    private function getCountrySubRegionDataVersion()
109
-    {
110
-        return get_option(self::OPTION_NAME_COUNTRY_DATA_VERSION, null);
111
-    }
112
-
113
-
114
-    /**
115
-     * @param string $version
116
-     */
117
-    private function updateCountrySubRegionDataVersion($version = '')
118
-    {
119
-        // add version option if it has never been added before, or update existing
120
-        if ($this->data_version === null) {
121
-            add_option(self::OPTION_NAME_COUNTRY_DATA_VERSION, $version, '', false);
122
-        } else {
123
-            update_option(self::OPTION_NAME_COUNTRY_DATA_VERSION, $version);
124
-        }
125
-    }
126
-
127
-
128
-    /**
129
-     * @param string $CNT_ISO
130
-     * @param array  $countries
131
-     * @since 4.9.70.p
132
-     * @return int
133
-     * @throws EE_Error
134
-     * @throws InvalidArgumentException
135
-     * @throws InvalidDataTypeException
136
-     * @throws InvalidInterfaceException
137
-     */
138
-    private function processCountryData($CNT_ISO, $countries = array())
139
-    {
140
-        if (! empty($countries)) {
141
-            foreach ($countries as $key => $country) {
142
-                if ($country instanceof stdClass
143
-                    && $country->code === $CNT_ISO
144
-                    && empty($country->sub_regions)
145
-                    && ! empty($country->filename)
146
-                ) {
147
-                    $country->sub_regions = $this->retrieveJsonData(
148
-                        self::REPO_URL . 'countries/' . $country->filename . '.json'
149
-                    );
150
-                    return $this->saveSubRegionData($country, $country->sub_regions);
151
-                }
152
-            }
153
-        }
154
-        return 0;
155
-    }
156
-
157
-
158
-    /**
159
-     * @param string $url
160
-     * @return array
161
-     */
162
-    private function retrieveJsonData($url)
163
-    {
164
-        if (empty($url)) {
165
-            EE_Error::add_error(
166
-                'No URL was provided!',
167
-                __FILE__,
168
-                __METHOD__,
169
-                __LINE__
170
-            );
171
-            return array();
172
-        }
173
-        $request = wp_safe_remote_get($url);
174
-        if ($request instanceof WP_Error) {
175
-            EE_Error::add_error(
176
-                $request->get_error_message(),
177
-                __FILE__,
178
-                __METHOD__,
179
-                __LINE__
180
-            );
181
-            return array();
182
-        }
183
-        $body = wp_remote_retrieve_body($request);
184
-        $json = json_decode($body);
185
-        if ($this->json_validator->isValid(__FILE__, __METHOD__, __LINE__)) {
186
-            return $json;
187
-        }
188
-        return array();
189
-    }
190
-
191
-
192
-    /**
193
-     * @param stdClass $country
194
-     * @param array    $sub_regions
195
-     * @return int
196
-     * @throws EE_Error
197
-     * @throws InvalidArgumentException
198
-     * @throws InvalidDataTypeException
199
-     * @throws InvalidInterfaceException
200
-     */
201
-    private function saveSubRegionData(stdClass $country, $sub_regions = array())
202
-    {
203
-        $results = 0;
204
-        if (is_array($sub_regions)) {
205
-            foreach ($sub_regions as $sub_region) {
206
-                // remove country code from sub region code
207
-                $abbrev = str_replace(
208
-                    $country->code . '-',
209
-                    '',
210
-                    sanitize_text_field($sub_region->code)
211
-                );
212
-                // but NOT if sub region code results in only a number
213
-                if (absint($abbrev) !== 0) {
214
-                    $abbrev = sanitize_text_field($sub_region->code);
215
-                }
216
-                if ($this->state_model->insert(
217
-                    array(
218
-                        // STA_ID CNT_ISO STA_abbrev STA_name STA_active
219
-                        'CNT_ISO'    => $country->code,
220
-                        'STA_abbrev' => $abbrev,
221
-                        'STA_name'   => sanitize_text_field($sub_region->name),
222
-                        'STA_active' => 1,
223
-                    )
224
-                )) {
225
-                    $results++;
226
-                }
227
-            }
228
-        }
229
-        return $results;
230
-    }
27
+	const REPO_URL = 'https://raw.githubusercontent.com/eventespresso/countries-and-subregions/master/';
28
+
29
+	const OPTION_NAME_COUNTRY_DATA_VERSION = 'espresso-country-sub-region-data-version';
30
+
31
+	/**
32
+	 * @var EEM_State $state_model
33
+	 */
34
+	private $state_model;
35
+
36
+	/**
37
+	 * @var JsonValidator $json_validator
38
+	 */
39
+	private $json_validator;
40
+
41
+	/**
42
+	 * @var string $data_version
43
+	 */
44
+	private $data_version;
45
+
46
+	/**
47
+	 * @var array $countries
48
+	 */
49
+	private $countries = array();
50
+
51
+
52
+	/**
53
+	 * CountrySubRegionDao constructor.
54
+	 *
55
+	 * @param EEM_State     $state_model
56
+	 * @param JsonValidator $json_validator
57
+	 */
58
+	public function __construct(EEM_State $state_model, JsonValidator $json_validator)
59
+	{
60
+		$this->state_model = $state_model;
61
+		$this->json_validator = $json_validator;
62
+	}
63
+
64
+
65
+	/**
66
+	 * @param EE_Country $country_object
67
+	 * @return void
68
+	 * @throws EE_Error
69
+	 * @throws InvalidArgumentException
70
+	 * @throws InvalidDataTypeException
71
+	 * @throws InvalidInterfaceException
72
+	 * @throws ReflectionException
73
+	 */
74
+	public function saveCountrySubRegions(EE_Country $country_object)
75
+	{
76
+		$CNT_ISO = $country_object->ID();
77
+		$has_sub_regions = $this->state_model->count(array(array('Country.CNT_ISO' => $CNT_ISO)));
78
+		$data = [];
79
+		if (empty($this->countries)) {
80
+			$this->data_version = $this->getCountrySubRegionDataVersion();
81
+			$data = $this->retrieveJsonData(self::REPO_URL . 'countries.json');
82
+		}
83
+		if (empty($data)) {
84
+			EE_Error::add_error(
85
+				'Country Subregion Data could not be retrieved',
86
+				__FILE__,
87
+				__METHOD__,
88
+				__LINE__
89
+			);
90
+		}
91
+		if (! $has_sub_regions
92
+			|| (isset($data->version) && version_compare($data->version, $this->data_version))
93
+		) {
94
+			if (isset($data->countries)
95
+				&& $this->processCountryData($CNT_ISO, $data->countries) > 0
96
+			) {
97
+				$this->countries = $data->countries;
98
+				$this->updateCountrySubRegionDataVersion($data->version);
99
+			}
100
+		}
101
+	}
102
+
103
+
104
+	/**
105
+	 * @since 4.9.70.p
106
+	 * @return string
107
+	 */
108
+	private function getCountrySubRegionDataVersion()
109
+	{
110
+		return get_option(self::OPTION_NAME_COUNTRY_DATA_VERSION, null);
111
+	}
112
+
113
+
114
+	/**
115
+	 * @param string $version
116
+	 */
117
+	private function updateCountrySubRegionDataVersion($version = '')
118
+	{
119
+		// add version option if it has never been added before, or update existing
120
+		if ($this->data_version === null) {
121
+			add_option(self::OPTION_NAME_COUNTRY_DATA_VERSION, $version, '', false);
122
+		} else {
123
+			update_option(self::OPTION_NAME_COUNTRY_DATA_VERSION, $version);
124
+		}
125
+	}
126
+
127
+
128
+	/**
129
+	 * @param string $CNT_ISO
130
+	 * @param array  $countries
131
+	 * @since 4.9.70.p
132
+	 * @return int
133
+	 * @throws EE_Error
134
+	 * @throws InvalidArgumentException
135
+	 * @throws InvalidDataTypeException
136
+	 * @throws InvalidInterfaceException
137
+	 */
138
+	private function processCountryData($CNT_ISO, $countries = array())
139
+	{
140
+		if (! empty($countries)) {
141
+			foreach ($countries as $key => $country) {
142
+				if ($country instanceof stdClass
143
+					&& $country->code === $CNT_ISO
144
+					&& empty($country->sub_regions)
145
+					&& ! empty($country->filename)
146
+				) {
147
+					$country->sub_regions = $this->retrieveJsonData(
148
+						self::REPO_URL . 'countries/' . $country->filename . '.json'
149
+					);
150
+					return $this->saveSubRegionData($country, $country->sub_regions);
151
+				}
152
+			}
153
+		}
154
+		return 0;
155
+	}
156
+
157
+
158
+	/**
159
+	 * @param string $url
160
+	 * @return array
161
+	 */
162
+	private function retrieveJsonData($url)
163
+	{
164
+		if (empty($url)) {
165
+			EE_Error::add_error(
166
+				'No URL was provided!',
167
+				__FILE__,
168
+				__METHOD__,
169
+				__LINE__
170
+			);
171
+			return array();
172
+		}
173
+		$request = wp_safe_remote_get($url);
174
+		if ($request instanceof WP_Error) {
175
+			EE_Error::add_error(
176
+				$request->get_error_message(),
177
+				__FILE__,
178
+				__METHOD__,
179
+				__LINE__
180
+			);
181
+			return array();
182
+		}
183
+		$body = wp_remote_retrieve_body($request);
184
+		$json = json_decode($body);
185
+		if ($this->json_validator->isValid(__FILE__, __METHOD__, __LINE__)) {
186
+			return $json;
187
+		}
188
+		return array();
189
+	}
190
+
191
+
192
+	/**
193
+	 * @param stdClass $country
194
+	 * @param array    $sub_regions
195
+	 * @return int
196
+	 * @throws EE_Error
197
+	 * @throws InvalidArgumentException
198
+	 * @throws InvalidDataTypeException
199
+	 * @throws InvalidInterfaceException
200
+	 */
201
+	private function saveSubRegionData(stdClass $country, $sub_regions = array())
202
+	{
203
+		$results = 0;
204
+		if (is_array($sub_regions)) {
205
+			foreach ($sub_regions as $sub_region) {
206
+				// remove country code from sub region code
207
+				$abbrev = str_replace(
208
+					$country->code . '-',
209
+					'',
210
+					sanitize_text_field($sub_region->code)
211
+				);
212
+				// but NOT if sub region code results in only a number
213
+				if (absint($abbrev) !== 0) {
214
+					$abbrev = sanitize_text_field($sub_region->code);
215
+				}
216
+				if ($this->state_model->insert(
217
+					array(
218
+						// STA_ID CNT_ISO STA_abbrev STA_name STA_active
219
+						'CNT_ISO'    => $country->code,
220
+						'STA_abbrev' => $abbrev,
221
+						'STA_name'   => sanitize_text_field($sub_region->name),
222
+						'STA_active' => 1,
223
+					)
224
+				)) {
225
+					$results++;
226
+				}
227
+			}
228
+		}
229
+		return $results;
230
+	}
231 231
 }
Please login to merge, or discard this patch.
admin_pages/general_settings/OrganizationSettings.php 1 patch
Indentation   +515 added lines, -515 removed lines patch added patch discarded remove patch
@@ -44,540 +44,540 @@
 block discarded – undo
44 44
 class OrganizationSettings extends FormHandler
45 45
 {
46 46
 
47
-    /**
48
-     * @var EE_Organization_Config
49
-     */
50
-    protected $organization_config;
47
+	/**
48
+	 * @var EE_Organization_Config
49
+	 */
50
+	protected $organization_config;
51 51
 
52
-    /**
53
-     * @var EE_Core_Config
54
-     */
55
-    protected $core_config;
52
+	/**
53
+	 * @var EE_Core_Config
54
+	 */
55
+	protected $core_config;
56 56
 
57 57
 
58
-    /**
59
-     * @var EE_Network_Core_Config
60
-     */
61
-    protected $network_core_config;
58
+	/**
59
+	 * @var EE_Network_Core_Config
60
+	 */
61
+	protected $network_core_config;
62 62
 
63
-    /**
64
-     * @var CountrySubRegionDao $countrySubRegionDao
65
-     */
66
-    protected $countrySubRegionDao;
63
+	/**
64
+	 * @var CountrySubRegionDao $countrySubRegionDao
65
+	 */
66
+	protected $countrySubRegionDao;
67 67
 
68
-    /**
69
-     * Form constructor.
70
-     *
71
-     * @param EE_Registry             $registry
72
-     * @param EE_Organization_Config  $organization_config
73
-     * @param EE_Core_Config          $core_config
74
-     * @param EE_Network_Core_Config $network_core_config
75
-     * @param CountrySubRegionDao $countrySubRegionDao
76
-     * @throws InvalidArgumentException
77
-     * @throws InvalidDataTypeException
78
-     * @throws DomainException
79
-     */
80
-    public function __construct(
81
-        EE_Registry $registry,
82
-        EE_Organization_Config $organization_config,
83
-        EE_Core_Config $core_config,
84
-        EE_Network_Core_Config $network_core_config,
85
-        CountrySubRegionDao $countrySubRegionDao
86
-    ) {
87
-        $this->organization_config = $organization_config;
88
-        $this->core_config = $core_config;
89
-        $this->network_core_config = $network_core_config;
90
-        $this->countrySubRegionDao = $countrySubRegionDao;
91
-        parent::__construct(
92
-            esc_html__('Your Organization Settings', 'event_espresso'),
93
-            esc_html__('Your Organization Settings', 'event_espresso'),
94
-            'organization_settings',
95
-            '',
96
-            FormHandler::DO_NOT_SETUP_FORM,
97
-            $registry
98
-        );
99
-    }
68
+	/**
69
+	 * Form constructor.
70
+	 *
71
+	 * @param EE_Registry             $registry
72
+	 * @param EE_Organization_Config  $organization_config
73
+	 * @param EE_Core_Config          $core_config
74
+	 * @param EE_Network_Core_Config $network_core_config
75
+	 * @param CountrySubRegionDao $countrySubRegionDao
76
+	 * @throws InvalidArgumentException
77
+	 * @throws InvalidDataTypeException
78
+	 * @throws DomainException
79
+	 */
80
+	public function __construct(
81
+		EE_Registry $registry,
82
+		EE_Organization_Config $organization_config,
83
+		EE_Core_Config $core_config,
84
+		EE_Network_Core_Config $network_core_config,
85
+		CountrySubRegionDao $countrySubRegionDao
86
+	) {
87
+		$this->organization_config = $organization_config;
88
+		$this->core_config = $core_config;
89
+		$this->network_core_config = $network_core_config;
90
+		$this->countrySubRegionDao = $countrySubRegionDao;
91
+		parent::__construct(
92
+			esc_html__('Your Organization Settings', 'event_espresso'),
93
+			esc_html__('Your Organization Settings', 'event_espresso'),
94
+			'organization_settings',
95
+			'',
96
+			FormHandler::DO_NOT_SETUP_FORM,
97
+			$registry
98
+		);
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * creates and returns the actual form
104
-     *
105
-     * @return EE_Form_Section_Proper
106
-     * @throws EE_Error
107
-     * @throws InvalidArgumentException
108
-     * @throws InvalidDataTypeException
109
-     * @throws InvalidInterfaceException
110
-     * @throws ReflectionException
111
-     */
112
-    public function generate()
113
-    {
114
-        $has_sub_regions = EEM_State::instance()->count(
115
-            array(array('Country.CNT_ISO' => $this->organization_config->CNT_ISO))
116
-        );
117
-        $form = new EE_Form_Section_Proper(
118
-            array(
119
-                'name'            => 'organization_settings',
120
-                'html_id'         => 'organization_settings',
121
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
122
-                'subsections'     => array(
123
-                    'contact_information_hdr'        => new EE_Form_Section_HTML(
124
-                        EEH_HTML::h2(
125
-                            esc_html__('Contact Information', 'event_espresso')
126
-                            . ' '
127
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
128
-                            '',
129
-                            'contact-information-hdr'
130
-                        )
131
-                    ),
132
-                    'organization_name'      => new EE_Text_Input(
133
-                        array(
134
-                            'html_name' => 'organization_name',
135
-                            'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
136
-                            'html_help_text'  => esc_html__(
137
-                                'Displayed on all emails and invoices.',
138
-                                'event_espresso'
139
-                            ),
140
-                            'default'         => $this->organization_config->get_pretty('name'),
141
-                            'required'        => false,
142
-                        )
143
-                    ),
144
-                    'organization_address_1'      => new EE_Text_Input(
145
-                        array(
146
-                            'html_name' => 'organization_address_1',
147
-                            'html_label_text' => esc_html__('Street Address', 'event_espresso'),
148
-                            'default'         => $this->organization_config->get_pretty('address_1'),
149
-                            'required'        => false,
150
-                        )
151
-                    ),
152
-                    'organization_address_2'      => new EE_Text_Input(
153
-                        array(
154
-                            'html_name' => 'organization_address_2',
155
-                            'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
156
-                            'default'         => $this->organization_config->get_pretty('address_2'),
157
-                            'required'        => false,
158
-                        )
159
-                    ),
160
-                    'organization_city'      => new EE_Text_Input(
161
-                        array(
162
-                            'html_name' => 'organization_city',
163
-                            'html_label_text' => esc_html__('City', 'event_espresso'),
164
-                            'default'         => $this->organization_config->get_pretty('city'),
165
-                            'required'        => false,
166
-                        )
167
-                    ),
168
-                    'organization_country'      => new EE_Country_Select_Input(
169
-                        null,
170
-                        array(
171
-                            EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL,
172
-                            'html_name'       => 'organization_country',
173
-                            'html_label_text' => esc_html__('Country', 'event_espresso'),
174
-                            'default'         => $this->organization_config->CNT_ISO,
175
-                            'required'        => false,
176
-                            'html_help_text'  => sprintf(
177
-                                esc_html__(
178
-                                    '%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',
179
-                                    'event_espresso'
180
-                                ),
181
-                                '<span class="reminder-spn">',
182
-                                '</span>'
183
-                            ),
184
-                        )
185
-                    ),
186
-                    'organization_state' => new EE_State_Select_Input(
187
-                        null,
188
-                        array(
189
-                            'html_name'       => 'organization_state',
190
-                            'html_label_text' => esc_html__('State/Province', 'event_espresso'),
191
-                            'default'         => $this->organization_config->STA_ID,
192
-                            'required'        => false,
193
-                            'html_help_text' => empty($this->organization_config->STA_ID) || ! $has_sub_regions
194
-                                ? sprintf(
195
-                                    esc_html__(
196
-                                        'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s',
197
-                                        'event_espresso'
198
-                                    ),
199
-                                    '<span class="reminder-spn">',
200
-                                    '</span>',
201
-                                    '<br />'
202
-                                )
203
-                                : '',
204
-                        )
205
-                    ),
206
-                    'organization_zip'      => new EE_Text_Input(
207
-                        array(
208
-                            'html_name' => 'organization_zip',
209
-                            'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
210
-                            'default'         => $this->organization_config->get_pretty('zip'),
211
-                            'required'        => false,
212
-                        )
213
-                    ),
214
-                    'organization_email'      => new EE_Text_Input(
215
-                        array(
216
-                            'html_name' => 'organization_email',
217
-                            'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
218
-                            'html_help_text'  => sprintf(
219
-                                esc_html__(
220
-                                    'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
221
-                                    'event_espresso'
222
-                                ),
223
-                                '<code>[CO_FORMATTED_EMAIL]</code>',
224
-                                '<code>[CO_EMAIL]</code>'
225
-                            ),
226
-                            'default'         => $this->organization_config->get_pretty('email'),
227
-                            'required'        => false,
228
-                        )
229
-                    ),
230
-                    'organization_phone'      => new EE_Text_Input(
231
-                        array(
232
-                            'html_name' => 'organization_phone',
233
-                            'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
234
-                            'html_help_text'  => esc_html__(
235
-                                'The phone number for your organization.',
236
-                                'event_espresso'
237
-                            ),
238
-                            'default'         => $this->organization_config->get_pretty('phone'),
239
-                            'required'        => false,
240
-                        )
241
-                    ),
242
-                    'organization_vat'      => new EE_Text_Input(
243
-                        array(
244
-                            'html_name' => 'organization_vat',
245
-                            'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
246
-                            'html_help_text'  => esc_html__(
247
-                                'The VAT/Tax Number may be displayed on invoices and receipts.',
248
-                                'event_espresso'
249
-                            ),
250
-                            'default'         => $this->organization_config->get_pretty('vat'),
251
-                            'required'        => false,
252
-                        )
253
-                    ),
254
-                    'company_logo_hdr'        => new EE_Form_Section_HTML(
255
-                        EEH_HTML::h2(
256
-                            esc_html__('Company Logo', 'event_espresso')
257
-                            . ' '
258
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
259
-                            '',
260
-                            'company-logo-hdr'
261
-                        )
262
-                    ),
263
-                    'organization_logo_url'      => new EE_Admin_File_Uploader_Input(
264
-                        array(
265
-                            'html_name' => 'organization_logo_url',
266
-                            'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
267
-                            'html_help_text'  => esc_html__(
268
-                                'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
269
-                                'event_espresso'
270
-                            ),
271
-                            'default'         => $this->organization_config->get_pretty('logo_url'),
272
-                            'required'        => false,
273
-                        )
274
-                    ),
275
-                    'social_links_hdr'        => new EE_Form_Section_HTML(
276
-                        EEH_HTML::h2(
277
-                            esc_html__('Social Links', 'event_espresso')
278
-                            . ' '
279
-                            . EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
280
-                            . EEH_HTML::br()
281
-                            . EEH_HTML::p(
282
-                                esc_html__(
283
-                                    'Enter any links to social accounts for your organization here',
284
-                                    'event_espresso'
285
-                                ),
286
-                                '',
287
-                                'description'
288
-                            ),
289
-                            '',
290
-                            'social-links-hdr'
291
-                        )
292
-                    ),
293
-                    'organization_facebook'      => new EE_Text_Input(
294
-                        array(
295
-                            'html_name' => 'organization_facebook',
296
-                            'html_label_text' => esc_html__('Facebook', 'event_espresso'),
297
-                            'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
298
-                            'default'         => $this->organization_config->get_pretty('facebook'),
299
-                            'required'        => false,
300
-                        )
301
-                    ),
302
-                    'organization_twitter'      => new EE_Text_Input(
303
-                        array(
304
-                            'html_name' => 'organization_twitter',
305
-                            'html_label_text' => esc_html__('Twitter', 'event_espresso'),
306
-                            'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
307
-                            'default'         => $this->organization_config->get_pretty('twitter'),
308
-                            'required'        => false,
309
-                        )
310
-                    ),
311
-                    'organization_linkedin'      => new EE_Text_Input(
312
-                        array(
313
-                            'html_name' => 'organization_linkedin',
314
-                            'html_label_text' => esc_html__('LinkedIn', 'event_espresso'),
315
-                            'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
316
-                            'default'         => $this->organization_config->get_pretty('linkedin'),
317
-                            'required'        => false,
318
-                        )
319
-                    ),
320
-                    'organization_pinterest'      => new EE_Text_Input(
321
-                        array(
322
-                            'html_name' => 'organization_pinterest',
323
-                            'html_label_text' => esc_html__('Pinterest', 'event_espresso'),
324
-                            'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
325
-                            'default'         => $this->organization_config->get_pretty('pinterest'),
326
-                            'required'        => false,
327
-                        )
328
-                    ),
329
-                    'organization_google'      => new EE_Text_Input(
330
-                        array(
331
-                            'html_name' => 'organization_google',
332
-                            'html_label_text' => esc_html__('Google+', 'event_espresso'),
333
-                            'other_html_attributes' => ' placeholder="google.com/+profilename"',
334
-                            'default'         => $this->organization_config->get_pretty('google'),
335
-                            'required'        => false,
336
-                        )
337
-                    ),
338
-                    'organization_instagram'      => new EE_Text_Input(
339
-                        array(
340
-                            'html_name' => 'organization_instagram',
341
-                            'html_label_text' => esc_html__('Instagram', 'event_espresso'),
342
-                            'other_html_attributes' => ' placeholder="instagram.com/handle"',
343
-                            'default'         => $this->organization_config->get_pretty('instagram'),
344
-                            'required'        => false,
345
-                        )
346
-                    ),
347
-                ),
348
-            )
349
-        );
350
-        if (is_main_site()) {
351
-            $form->add_subsections(
352
-                array(
353
-                    'site_license_key_hdr' => new EE_Form_Section_HTML(
354
-                        EEH_HTML::h2(
355
-                            esc_html__('Your Event Espresso License Key', 'event_espresso')
356
-                            . ' '
357
-                            . EEH_HTML::span(
358
-                                EEH_Template::get_help_tab_link('site_license_key_info'),
359
-                                'help_tour_activation'
360
-                            ),
361
-                            '',
362
-                            'site-license-key-hdr'
363
-                        )
364
-                    ),
365
-                    'site_license_key' => $this->getSiteLicenseKeyField()
366
-                )
367
-            );
368
-            $form->add_subsections(
369
-                array(
370
-                    'uxip_optin_hdr' => new EE_Form_Section_HTML(
371
-                        $this->uxipOptinText()
372
-                    ),
373
-                    'ueip_optin' => new EE_Checkbox_Multi_Input(
374
-                        array(
375
-                            true => __('Yes! I want to help improve Event Espresso!', 'event_espresso')
376
-                        ),
377
-                        array(
378
-                            'html_name' => EE_Core_Config::OPTION_NAME_UXIP,
379
-                            'html_label_text' => esc_html__(
380
-                                'UXIP Opt In?',
381
-                                'event_espresso'
382
-                            ),
383
-                            'default'         => isset($this->core_config->ee_ueip_optin)
384
-                                ? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
385
-                                : false,
386
-                            'required'        => false,
387
-                        )
388
-                    ),
389
-                ),
390
-                'organization_instagram',
391
-                false
392
-            );
393
-        }
394
-        return $form;
395
-    }
102
+	/**
103
+	 * creates and returns the actual form
104
+	 *
105
+	 * @return EE_Form_Section_Proper
106
+	 * @throws EE_Error
107
+	 * @throws InvalidArgumentException
108
+	 * @throws InvalidDataTypeException
109
+	 * @throws InvalidInterfaceException
110
+	 * @throws ReflectionException
111
+	 */
112
+	public function generate()
113
+	{
114
+		$has_sub_regions = EEM_State::instance()->count(
115
+			array(array('Country.CNT_ISO' => $this->organization_config->CNT_ISO))
116
+		);
117
+		$form = new EE_Form_Section_Proper(
118
+			array(
119
+				'name'            => 'organization_settings',
120
+				'html_id'         => 'organization_settings',
121
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
122
+				'subsections'     => array(
123
+					'contact_information_hdr'        => new EE_Form_Section_HTML(
124
+						EEH_HTML::h2(
125
+							esc_html__('Contact Information', 'event_espresso')
126
+							. ' '
127
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('contact_info_info')),
128
+							'',
129
+							'contact-information-hdr'
130
+						)
131
+					),
132
+					'organization_name'      => new EE_Text_Input(
133
+						array(
134
+							'html_name' => 'organization_name',
135
+							'html_label_text' => esc_html__('Organization Name', 'event_espresso'),
136
+							'html_help_text'  => esc_html__(
137
+								'Displayed on all emails and invoices.',
138
+								'event_espresso'
139
+							),
140
+							'default'         => $this->organization_config->get_pretty('name'),
141
+							'required'        => false,
142
+						)
143
+					),
144
+					'organization_address_1'      => new EE_Text_Input(
145
+						array(
146
+							'html_name' => 'organization_address_1',
147
+							'html_label_text' => esc_html__('Street Address', 'event_espresso'),
148
+							'default'         => $this->organization_config->get_pretty('address_1'),
149
+							'required'        => false,
150
+						)
151
+					),
152
+					'organization_address_2'      => new EE_Text_Input(
153
+						array(
154
+							'html_name' => 'organization_address_2',
155
+							'html_label_text' => esc_html__('Street Address 2', 'event_espresso'),
156
+							'default'         => $this->organization_config->get_pretty('address_2'),
157
+							'required'        => false,
158
+						)
159
+					),
160
+					'organization_city'      => new EE_Text_Input(
161
+						array(
162
+							'html_name' => 'organization_city',
163
+							'html_label_text' => esc_html__('City', 'event_espresso'),
164
+							'default'         => $this->organization_config->get_pretty('city'),
165
+							'required'        => false,
166
+						)
167
+					),
168
+					'organization_country'      => new EE_Country_Select_Input(
169
+						null,
170
+						array(
171
+							EE_Country_Select_Input::OPTION_GET_KEY => EE_Country_Select_Input::OPTION_GET_ALL,
172
+							'html_name'       => 'organization_country',
173
+							'html_label_text' => esc_html__('Country', 'event_espresso'),
174
+							'default'         => $this->organization_config->CNT_ISO,
175
+							'required'        => false,
176
+							'html_help_text'  => sprintf(
177
+								esc_html__(
178
+									'%1$sThe Country set here will have the effect of setting the currency used for all ticket prices.%2$s',
179
+									'event_espresso'
180
+								),
181
+								'<span class="reminder-spn">',
182
+								'</span>'
183
+							),
184
+						)
185
+					),
186
+					'organization_state' => new EE_State_Select_Input(
187
+						null,
188
+						array(
189
+							'html_name'       => 'organization_state',
190
+							'html_label_text' => esc_html__('State/Province', 'event_espresso'),
191
+							'default'         => $this->organization_config->STA_ID,
192
+							'required'        => false,
193
+							'html_help_text' => empty($this->organization_config->STA_ID) || ! $has_sub_regions
194
+								? sprintf(
195
+									esc_html__(
196
+										'If the States/Provinces for the selected Country do not appear in this list, then click "Save".%3$sIf data exists, then the list will be populated when the page reloads and you will be able to make a selection at that time.%3$s%1$sMake sure you click "Save" again after selecting a State/Province that has just been loaded in order to keep that selection.%2$s',
197
+										'event_espresso'
198
+									),
199
+									'<span class="reminder-spn">',
200
+									'</span>',
201
+									'<br />'
202
+								)
203
+								: '',
204
+						)
205
+					),
206
+					'organization_zip'      => new EE_Text_Input(
207
+						array(
208
+							'html_name' => 'organization_zip',
209
+							'html_label_text' => esc_html__('Zip/Postal Code', 'event_espresso'),
210
+							'default'         => $this->organization_config->get_pretty('zip'),
211
+							'required'        => false,
212
+						)
213
+					),
214
+					'organization_email'      => new EE_Text_Input(
215
+						array(
216
+							'html_name' => 'organization_email',
217
+							'html_label_text' => esc_html__('Primary Contact Email', 'event_espresso'),
218
+							'html_help_text'  => sprintf(
219
+								esc_html__(
220
+									'This is where notifications go to when you use the %1$s and %2$s shortcodes in the message templates.',
221
+									'event_espresso'
222
+								),
223
+								'<code>[CO_FORMATTED_EMAIL]</code>',
224
+								'<code>[CO_EMAIL]</code>'
225
+							),
226
+							'default'         => $this->organization_config->get_pretty('email'),
227
+							'required'        => false,
228
+						)
229
+					),
230
+					'organization_phone'      => new EE_Text_Input(
231
+						array(
232
+							'html_name' => 'organization_phone',
233
+							'html_label_text' => esc_html__('Phone Number', 'event_espresso'),
234
+							'html_help_text'  => esc_html__(
235
+								'The phone number for your organization.',
236
+								'event_espresso'
237
+							),
238
+							'default'         => $this->organization_config->get_pretty('phone'),
239
+							'required'        => false,
240
+						)
241
+					),
242
+					'organization_vat'      => new EE_Text_Input(
243
+						array(
244
+							'html_name' => 'organization_vat',
245
+							'html_label_text' => esc_html__('VAT/Tax Number', 'event_espresso'),
246
+							'html_help_text'  => esc_html__(
247
+								'The VAT/Tax Number may be displayed on invoices and receipts.',
248
+								'event_espresso'
249
+							),
250
+							'default'         => $this->organization_config->get_pretty('vat'),
251
+							'required'        => false,
252
+						)
253
+					),
254
+					'company_logo_hdr'        => new EE_Form_Section_HTML(
255
+						EEH_HTML::h2(
256
+							esc_html__('Company Logo', 'event_espresso')
257
+							. ' '
258
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('organization_logo_info')),
259
+							'',
260
+							'company-logo-hdr'
261
+						)
262
+					),
263
+					'organization_logo_url'      => new EE_Admin_File_Uploader_Input(
264
+						array(
265
+							'html_name' => 'organization_logo_url',
266
+							'html_label_text' => esc_html__('Upload New Logo', 'event_espresso'),
267
+							'html_help_text'  => esc_html__(
268
+								'Your logo will be used on custom invoices, tickets, certificates, and payment templates.',
269
+								'event_espresso'
270
+							),
271
+							'default'         => $this->organization_config->get_pretty('logo_url'),
272
+							'required'        => false,
273
+						)
274
+					),
275
+					'social_links_hdr'        => new EE_Form_Section_HTML(
276
+						EEH_HTML::h2(
277
+							esc_html__('Social Links', 'event_espresso')
278
+							. ' '
279
+							. EEH_HTML::span(EEH_Template::get_help_tab_link('social_links_info'))
280
+							. EEH_HTML::br()
281
+							. EEH_HTML::p(
282
+								esc_html__(
283
+									'Enter any links to social accounts for your organization here',
284
+									'event_espresso'
285
+								),
286
+								'',
287
+								'description'
288
+							),
289
+							'',
290
+							'social-links-hdr'
291
+						)
292
+					),
293
+					'organization_facebook'      => new EE_Text_Input(
294
+						array(
295
+							'html_name' => 'organization_facebook',
296
+							'html_label_text' => esc_html__('Facebook', 'event_espresso'),
297
+							'other_html_attributes' => ' placeholder="facebook.com/profile.name"',
298
+							'default'         => $this->organization_config->get_pretty('facebook'),
299
+							'required'        => false,
300
+						)
301
+					),
302
+					'organization_twitter'      => new EE_Text_Input(
303
+						array(
304
+							'html_name' => 'organization_twitter',
305
+							'html_label_text' => esc_html__('Twitter', 'event_espresso'),
306
+							'other_html_attributes' => ' placeholder="twitter.com/twitterhandle"',
307
+							'default'         => $this->organization_config->get_pretty('twitter'),
308
+							'required'        => false,
309
+						)
310
+					),
311
+					'organization_linkedin'      => new EE_Text_Input(
312
+						array(
313
+							'html_name' => 'organization_linkedin',
314
+							'html_label_text' => esc_html__('LinkedIn', 'event_espresso'),
315
+							'other_html_attributes' => ' placeholder="linkedin.com/in/profilename"',
316
+							'default'         => $this->organization_config->get_pretty('linkedin'),
317
+							'required'        => false,
318
+						)
319
+					),
320
+					'organization_pinterest'      => new EE_Text_Input(
321
+						array(
322
+							'html_name' => 'organization_pinterest',
323
+							'html_label_text' => esc_html__('Pinterest', 'event_espresso'),
324
+							'other_html_attributes' => ' placeholder="pinterest.com/profilename"',
325
+							'default'         => $this->organization_config->get_pretty('pinterest'),
326
+							'required'        => false,
327
+						)
328
+					),
329
+					'organization_google'      => new EE_Text_Input(
330
+						array(
331
+							'html_name' => 'organization_google',
332
+							'html_label_text' => esc_html__('Google+', 'event_espresso'),
333
+							'other_html_attributes' => ' placeholder="google.com/+profilename"',
334
+							'default'         => $this->organization_config->get_pretty('google'),
335
+							'required'        => false,
336
+						)
337
+					),
338
+					'organization_instagram'      => new EE_Text_Input(
339
+						array(
340
+							'html_name' => 'organization_instagram',
341
+							'html_label_text' => esc_html__('Instagram', 'event_espresso'),
342
+							'other_html_attributes' => ' placeholder="instagram.com/handle"',
343
+							'default'         => $this->organization_config->get_pretty('instagram'),
344
+							'required'        => false,
345
+						)
346
+					),
347
+				),
348
+			)
349
+		);
350
+		if (is_main_site()) {
351
+			$form->add_subsections(
352
+				array(
353
+					'site_license_key_hdr' => new EE_Form_Section_HTML(
354
+						EEH_HTML::h2(
355
+							esc_html__('Your Event Espresso License Key', 'event_espresso')
356
+							. ' '
357
+							. EEH_HTML::span(
358
+								EEH_Template::get_help_tab_link('site_license_key_info'),
359
+								'help_tour_activation'
360
+							),
361
+							'',
362
+							'site-license-key-hdr'
363
+						)
364
+					),
365
+					'site_license_key' => $this->getSiteLicenseKeyField()
366
+				)
367
+			);
368
+			$form->add_subsections(
369
+				array(
370
+					'uxip_optin_hdr' => new EE_Form_Section_HTML(
371
+						$this->uxipOptinText()
372
+					),
373
+					'ueip_optin' => new EE_Checkbox_Multi_Input(
374
+						array(
375
+							true => __('Yes! I want to help improve Event Espresso!', 'event_espresso')
376
+						),
377
+						array(
378
+							'html_name' => EE_Core_Config::OPTION_NAME_UXIP,
379
+							'html_label_text' => esc_html__(
380
+								'UXIP Opt In?',
381
+								'event_espresso'
382
+							),
383
+							'default'         => isset($this->core_config->ee_ueip_optin)
384
+								? filter_var($this->core_config->ee_ueip_optin, FILTER_VALIDATE_BOOLEAN)
385
+								: false,
386
+							'required'        => false,
387
+						)
388
+					),
389
+				),
390
+				'organization_instagram',
391
+				false
392
+			);
393
+		}
394
+		return $form;
395
+	}
396 396
 
397 397
 
398
-    /**
399
-     * takes the generated form and displays it along with ony other non-form HTML that may be required
400
-     * returns a string of HTML that can be directly echoed in a template
401
-     *
402
-     * @return string
403
-     * @throws EE_Error
404
-     * @throws InvalidArgumentException
405
-     * @throws InvalidDataTypeException
406
-     * @throws InvalidInterfaceException
407
-     * @throws LogicException
408
-     */
409
-    public function display()
410
-    {
411
-        $this->form()->enqueue_js();
412
-        return parent::display();
413
-    }
398
+	/**
399
+	 * takes the generated form and displays it along with ony other non-form HTML that may be required
400
+	 * returns a string of HTML that can be directly echoed in a template
401
+	 *
402
+	 * @return string
403
+	 * @throws EE_Error
404
+	 * @throws InvalidArgumentException
405
+	 * @throws InvalidDataTypeException
406
+	 * @throws InvalidInterfaceException
407
+	 * @throws LogicException
408
+	 */
409
+	public function display()
410
+	{
411
+		$this->form()->enqueue_js();
412
+		return parent::display();
413
+	}
414 414
 
415 415
 
416
-    /**
417
-     * handles processing the form submission
418
-     * returns true or false depending on whether the form was processed successfully or not
419
-     *
420
-     * @param array $form_data
421
-     * @return bool
422
-     * @throws InvalidFormSubmissionException
423
-     * @throws EE_Error
424
-     * @throws LogicException
425
-     * @throws InvalidArgumentException
426
-     * @throws InvalidDataTypeException
427
-     * @throws ReflectionException
428
-     */
429
-    public function process($form_data = array())
430
-    {
431
-        // process form
432
-        $valid_data = (array) parent::process($form_data);
433
-        if (empty($valid_data)) {
434
-            return false;
435
-        }
416
+	/**
417
+	 * handles processing the form submission
418
+	 * returns true or false depending on whether the form was processed successfully or not
419
+	 *
420
+	 * @param array $form_data
421
+	 * @return bool
422
+	 * @throws InvalidFormSubmissionException
423
+	 * @throws EE_Error
424
+	 * @throws LogicException
425
+	 * @throws InvalidArgumentException
426
+	 * @throws InvalidDataTypeException
427
+	 * @throws ReflectionException
428
+	 */
429
+	public function process($form_data = array())
430
+	{
431
+		// process form
432
+		$valid_data = (array) parent::process($form_data);
433
+		if (empty($valid_data)) {
434
+			return false;
435
+		}
436 436
 
437
-        if (is_main_site()) {
438
-            $this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
439
-                ? sanitize_text_field($form_data['ee_site_license_key'])
440
-                : $this->network_core_config->site_license_key;
441
-        }
442
-        $this->organization_config->name = isset($form_data['organization_name'])
443
-            ? sanitize_text_field($form_data['organization_name'])
444
-            : $this->organization_config->name;
445
-        $this->organization_config->address_1 = isset($form_data['organization_address_1'])
446
-            ? sanitize_text_field($form_data['organization_address_1'])
447
-            : $this->organization_config->address_1;
448
-        $this->organization_config->address_2 = isset($form_data['organization_address_2'])
449
-            ? sanitize_text_field($form_data['organization_address_2'])
450
-            : $this->organization_config->address_2;
451
-        $this->organization_config->city = isset($form_data['organization_city'])
452
-            ? sanitize_text_field($form_data['organization_city'])
453
-            : $this->organization_config->city;
454
-        $this->organization_config->STA_ID = isset($form_data['organization_state'])
455
-            ? absint($form_data['organization_state'])
456
-            : $this->organization_config->STA_ID;
457
-        $this->organization_config->CNT_ISO = isset($form_data['organization_country'])
458
-            ? sanitize_text_field($form_data['organization_country'])
459
-            : $this->organization_config->CNT_ISO;
460
-        $this->organization_config->zip = isset($form_data['organization_zip'])
461
-            ? sanitize_text_field($form_data['organization_zip'])
462
-            : $this->organization_config->zip;
463
-        $this->organization_config->email = isset($form_data['organization_email'])
464
-            ? sanitize_email($form_data['organization_email'])
465
-            : $this->organization_config->email;
466
-        $this->organization_config->vat = isset($form_data['organization_vat'])
467
-            ? sanitize_text_field($form_data['organization_vat'])
468
-            : $this->organization_config->vat;
469
-        $this->organization_config->phone = isset($form_data['organization_phone'])
470
-            ? sanitize_text_field($form_data['organization_phone'])
471
-            : $this->organization_config->phone;
472
-        $this->organization_config->logo_url = isset($form_data['organization_logo_url'])
473
-            ? esc_url_raw($form_data['organization_logo_url'])
474
-            : $this->organization_config->logo_url;
475
-        $this->organization_config->facebook = isset($form_data['organization_facebook'])
476
-            ? esc_url_raw($form_data['organization_facebook'])
477
-            : $this->organization_config->facebook;
478
-        $this->organization_config->twitter = isset($form_data['organization_twitter'])
479
-            ? esc_url_raw($form_data['organization_twitter'])
480
-            : $this->organization_config->twitter;
481
-        $this->organization_config->linkedin = isset($form_data['organization_linkedin'])
482
-            ? esc_url_raw($form_data['organization_linkedin'])
483
-            : $this->organization_config->linkedin;
484
-        $this->organization_config->pinterest = isset($form_data['organization_pinterest'])
485
-            ? esc_url_raw($form_data['organization_pinterest'])
486
-            : $this->organization_config->pinterest;
487
-        $this->organization_config->google = isset($form_data['organization_google'])
488
-            ? esc_url_raw($form_data['organization_google'])
489
-            : $this->organization_config->google;
490
-        $this->organization_config->instagram = isset($form_data['organization_instagram'])
491
-            ? esc_url_raw($form_data['organization_instagram'])
492
-            : $this->organization_config->instagram;
493
-        $this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
494
-            ? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
495
-            : false;
496
-        $this->core_config->ee_ueip_has_notified = true;
437
+		if (is_main_site()) {
438
+			$this->network_core_config->site_license_key = isset($form_data['ee_site_license_key'])
439
+				? sanitize_text_field($form_data['ee_site_license_key'])
440
+				: $this->network_core_config->site_license_key;
441
+		}
442
+		$this->organization_config->name = isset($form_data['organization_name'])
443
+			? sanitize_text_field($form_data['organization_name'])
444
+			: $this->organization_config->name;
445
+		$this->organization_config->address_1 = isset($form_data['organization_address_1'])
446
+			? sanitize_text_field($form_data['organization_address_1'])
447
+			: $this->organization_config->address_1;
448
+		$this->organization_config->address_2 = isset($form_data['organization_address_2'])
449
+			? sanitize_text_field($form_data['organization_address_2'])
450
+			: $this->organization_config->address_2;
451
+		$this->organization_config->city = isset($form_data['organization_city'])
452
+			? sanitize_text_field($form_data['organization_city'])
453
+			: $this->organization_config->city;
454
+		$this->organization_config->STA_ID = isset($form_data['organization_state'])
455
+			? absint($form_data['organization_state'])
456
+			: $this->organization_config->STA_ID;
457
+		$this->organization_config->CNT_ISO = isset($form_data['organization_country'])
458
+			? sanitize_text_field($form_data['organization_country'])
459
+			: $this->organization_config->CNT_ISO;
460
+		$this->organization_config->zip = isset($form_data['organization_zip'])
461
+			? sanitize_text_field($form_data['organization_zip'])
462
+			: $this->organization_config->zip;
463
+		$this->organization_config->email = isset($form_data['organization_email'])
464
+			? sanitize_email($form_data['organization_email'])
465
+			: $this->organization_config->email;
466
+		$this->organization_config->vat = isset($form_data['organization_vat'])
467
+			? sanitize_text_field($form_data['organization_vat'])
468
+			: $this->organization_config->vat;
469
+		$this->organization_config->phone = isset($form_data['organization_phone'])
470
+			? sanitize_text_field($form_data['organization_phone'])
471
+			: $this->organization_config->phone;
472
+		$this->organization_config->logo_url = isset($form_data['organization_logo_url'])
473
+			? esc_url_raw($form_data['organization_logo_url'])
474
+			: $this->organization_config->logo_url;
475
+		$this->organization_config->facebook = isset($form_data['organization_facebook'])
476
+			? esc_url_raw($form_data['organization_facebook'])
477
+			: $this->organization_config->facebook;
478
+		$this->organization_config->twitter = isset($form_data['organization_twitter'])
479
+			? esc_url_raw($form_data['organization_twitter'])
480
+			: $this->organization_config->twitter;
481
+		$this->organization_config->linkedin = isset($form_data['organization_linkedin'])
482
+			? esc_url_raw($form_data['organization_linkedin'])
483
+			: $this->organization_config->linkedin;
484
+		$this->organization_config->pinterest = isset($form_data['organization_pinterest'])
485
+			? esc_url_raw($form_data['organization_pinterest'])
486
+			: $this->organization_config->pinterest;
487
+		$this->organization_config->google = isset($form_data['organization_google'])
488
+			? esc_url_raw($form_data['organization_google'])
489
+			: $this->organization_config->google;
490
+		$this->organization_config->instagram = isset($form_data['organization_instagram'])
491
+			? esc_url_raw($form_data['organization_instagram'])
492
+			: $this->organization_config->instagram;
493
+		$this->core_config->ee_ueip_optin = isset($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0])
494
+			? filter_var($form_data[ EE_Core_Config::OPTION_NAME_UXIP ][0], FILTER_VALIDATE_BOOLEAN)
495
+			: false;
496
+		$this->core_config->ee_ueip_has_notified = true;
497 497
 
498
-        $this->registry->CFG->currency = new EE_Currency_Config(
499
-            $this->organization_config->CNT_ISO
500
-        );
501
-        /** @var EE_Country $country */
502
-        $country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO);
503
-        if ($country instanceof EE_Country) {
504
-            $country->set('CNT_active', 1);
505
-            $country->save();
506
-            $this->countrySubRegionDao->saveCountrySubRegions($country);
507
-        }
508
-        return true;
509
-    }
498
+		$this->registry->CFG->currency = new EE_Currency_Config(
499
+			$this->organization_config->CNT_ISO
500
+		);
501
+		/** @var EE_Country $country */
502
+		$country = EEM_Country::instance()->get_one_by_ID($this->organization_config->CNT_ISO);
503
+		if ($country instanceof EE_Country) {
504
+			$country->set('CNT_active', 1);
505
+			$country->save();
506
+			$this->countrySubRegionDao->saveCountrySubRegions($country);
507
+		}
508
+		return true;
509
+	}
510 510
 
511 511
 
512
-    /**
513
-     * @return string
514
-     */
515
-    private function uxipOptinText()
516
-    {
517
-        ob_start();
518
-        Stats::optinText(false);
519
-        return ob_get_clean();
520
-    }
512
+	/**
513
+	 * @return string
514
+	 */
515
+	private function uxipOptinText()
516
+	{
517
+		ob_start();
518
+		Stats::optinText(false);
519
+		return ob_get_clean();
520
+	}
521 521
 
522 522
 
523
-    /**
524
-     * Return whether the site license key has been verified or not.
525
-     * @return bool
526
-     */
527
-    private function licenseKeyVerified()
528
-    {
529
-        if (empty($this->network_core_config->site_license_key)) {
530
-            return false;
531
-        }
532
-        $ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
533
-        $verify_fail = get_option($ver_option_key, false);
534
-        return $verify_fail === false
535
-                  || (! empty($this->network_core_config->site_license_key)
536
-                        && $verify_fail === false
537
-                  );
538
-    }
523
+	/**
524
+	 * Return whether the site license key has been verified or not.
525
+	 * @return bool
526
+	 */
527
+	private function licenseKeyVerified()
528
+	{
529
+		if (empty($this->network_core_config->site_license_key)) {
530
+			return false;
531
+		}
532
+		$ver_option_key = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
533
+		$verify_fail = get_option($ver_option_key, false);
534
+		return $verify_fail === false
535
+				  || (! empty($this->network_core_config->site_license_key)
536
+						&& $verify_fail === false
537
+				  );
538
+	}
539 539
 
540 540
 
541
-    /**
542
-     * @return EE_Text_Input
543
-     */
544
-    private function getSiteLicenseKeyField()
545
-    {
546
-        $text_input = new EE_Text_Input(
547
-            array(
548
-                'html_name' => 'ee_site_license_key',
549
-                'html_id' => 'site_license_key',
550
-                'html_label_text' => esc_html__('Support License Key', 'event_espresso'),
551
-                /** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
552
-                'html_help_text'  => sprintf(
553
-                    esc_html__(
554
-                        'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
555
-                        'event_espresso'
556
-                    ),
557
-                    '<strong>',
558
-                    '</strong>'
559
-                ),
560
-                /** phpcs:enable */
561
-                'default'         => isset($this->network_core_config->site_license_key)
562
-                    ? $this->network_core_config->site_license_key
563
-                    : '',
564
-                'required'        => false,
565
-                'form_html_filter' => new VsprintfFilter(
566
-                    '%2$s %1$s',
567
-                    array($this->getValidationIndicator())
568
-                )
569
-            )
570
-        );
571
-        return $text_input;
572
-    }
541
+	/**
542
+	 * @return EE_Text_Input
543
+	 */
544
+	private function getSiteLicenseKeyField()
545
+	{
546
+		$text_input = new EE_Text_Input(
547
+			array(
548
+				'html_name' => 'ee_site_license_key',
549
+				'html_id' => 'site_license_key',
550
+				'html_label_text' => esc_html__('Support License Key', 'event_espresso'),
551
+				/** phpcs:disable WordPress.WP.I18n.UnorderedPlaceholdersText */
552
+				'html_help_text'  => sprintf(
553
+					esc_html__(
554
+						'Adding a valid Support License Key will enable automatic update notifications and backend updates for Event Espresso Core and any installed add-ons. If this is a Development or Test site, %sDO NOT%s enter your Support License Key.',
555
+						'event_espresso'
556
+					),
557
+					'<strong>',
558
+					'</strong>'
559
+				),
560
+				/** phpcs:enable */
561
+				'default'         => isset($this->network_core_config->site_license_key)
562
+					? $this->network_core_config->site_license_key
563
+					: '',
564
+				'required'        => false,
565
+				'form_html_filter' => new VsprintfFilter(
566
+					'%2$s %1$s',
567
+					array($this->getValidationIndicator())
568
+				)
569
+			)
570
+		);
571
+		return $text_input;
572
+	}
573 573
 
574 574
 
575
-    /**
576
-     * @return string
577
-     */
578
-    private function getValidationIndicator()
579
-    {
580
-        $verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
581
-        return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
582
-    }
575
+	/**
576
+	 * @return string
577
+	 */
578
+	private function getValidationIndicator()
579
+	{
580
+		$verified_class = $this->licenseKeyVerified() ? 'ee-icon-color-ee-green' : 'ee-icon-color-ee-red';
581
+		return '<span class="dashicons dashicons-admin-network ' . $verified_class . ' ee-icon-size-20"></span>';
582
+	}
583 583
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 1 patch
Indentation   +4019 added lines, -4019 removed lines patch added patch discarded remove patch
@@ -17,4086 +17,4086 @@
 block discarded – undo
17 17
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
18 18
 {
19 19
 
20
-    /**
21
-     * @var LoaderInterface $loader
22
-     */
23
-    protected $loader;
20
+	/**
21
+	 * @var LoaderInterface $loader
22
+	 */
23
+	protected $loader;
24 24
 
25
-    // set in _init_page_props()
26
-    public $page_slug;
25
+	// set in _init_page_props()
26
+	public $page_slug;
27 27
 
28
-    public $page_label;
28
+	public $page_label;
29 29
 
30
-    public $page_folder;
30
+	public $page_folder;
31 31
 
32
-    // set in define_page_props()
33
-    protected $_admin_base_url;
32
+	// set in define_page_props()
33
+	protected $_admin_base_url;
34 34
 
35
-    protected $_admin_base_path;
35
+	protected $_admin_base_path;
36 36
 
37
-    protected $_admin_page_title;
37
+	protected $_admin_page_title;
38 38
 
39
-    protected $_labels;
39
+	protected $_labels;
40 40
 
41 41
 
42
-    // set early within EE_Admin_Init
43
-    protected $_wp_page_slug;
42
+	// set early within EE_Admin_Init
43
+	protected $_wp_page_slug;
44 44
 
45
-    // navtabs
46
-    protected $_nav_tabs;
45
+	// navtabs
46
+	protected $_nav_tabs;
47 47
 
48
-    protected $_default_nav_tab_name;
48
+	protected $_default_nav_tab_name;
49 49
 
50
-    /**
51
-     * @var array $_help_tour
52
-     */
53
-    protected $_help_tour = array();
50
+	/**
51
+	 * @var array $_help_tour
52
+	 */
53
+	protected $_help_tour = array();
54 54
 
55 55
 
56
-    // template variables (used by templates)
57
-    protected $_template_path;
56
+	// template variables (used by templates)
57
+	protected $_template_path;
58 58
 
59
-    protected $_column_template_path;
59
+	protected $_column_template_path;
60 60
 
61
-    /**
62
-     * @var array $_template_args
63
-     */
64
-    protected $_template_args = array();
61
+	/**
62
+	 * @var array $_template_args
63
+	 */
64
+	protected $_template_args = array();
65 65
 
66
-    /**
67
-     * this will hold the list table object for a given view.
68
-     *
69
-     * @var EE_Admin_List_Table $_list_table_object
70
-     */
71
-    protected $_list_table_object;
66
+	/**
67
+	 * this will hold the list table object for a given view.
68
+	 *
69
+	 * @var EE_Admin_List_Table $_list_table_object
70
+	 */
71
+	protected $_list_table_object;
72 72
 
73
-    // bools
74
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
73
+	// bools
74
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
75 75
 
76
-    protected $_routing;
76
+	protected $_routing;
77 77
 
78
-    // list table args
79
-    protected $_view;
78
+	// list table args
79
+	protected $_view;
80 80
 
81
-    protected $_views;
81
+	protected $_views;
82 82
 
83 83
 
84
-    // action => method pairs used for routing incoming requests
85
-    protected $_page_routes;
84
+	// action => method pairs used for routing incoming requests
85
+	protected $_page_routes;
86 86
 
87
-    /**
88
-     * @var array $_page_config
89
-     */
90
-    protected $_page_config;
87
+	/**
88
+	 * @var array $_page_config
89
+	 */
90
+	protected $_page_config;
91 91
 
92
-    /**
93
-     * the current page route and route config
94
-     *
95
-     * @var string $_route
96
-     */
97
-    protected $_route;
92
+	/**
93
+	 * the current page route and route config
94
+	 *
95
+	 * @var string $_route
96
+	 */
97
+	protected $_route;
98 98
 
99
-    /**
100
-     * @var string $_cpt_route
101
-     */
102
-    protected $_cpt_route;
99
+	/**
100
+	 * @var string $_cpt_route
101
+	 */
102
+	protected $_cpt_route;
103 103
 
104
-    /**
105
-     * @var array $_route_config
106
-     */
107
-    protected $_route_config;
108
-
109
-    /**
110
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
111
-     * actions.
112
-     *
113
-     * @since 4.6.x
114
-     * @var array.
115
-     */
116
-    protected $_default_route_query_args;
117
-
118
-    // set via request page and action args.
119
-    protected $_current_page;
120
-
121
-    protected $_current_view;
122
-
123
-    protected $_current_page_view_url;
124
-
125
-    // sanitized request action (and nonce)
126
-
127
-    /**
128
-     * @var string $_req_action
129
-     */
130
-    protected $_req_action;
131
-
132
-    /**
133
-     * @var string $_req_nonce
134
-     */
135
-    protected $_req_nonce;
136
-
137
-    // search related
138
-    protected $_search_btn_label;
139
-
140
-    protected $_search_box_callback;
141
-
142
-    /**
143
-     * WP Current Screen object
144
-     *
145
-     * @var WP_Screen
146
-     */
147
-    protected $_current_screen;
148
-
149
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
150
-    protected $_hook_obj;
151
-
152
-    // for holding incoming request data
153
-    protected $_req_data;
154
-
155
-    // yes / no array for admin form fields
156
-    protected $_yes_no_values = array();
157
-
158
-    // some default things shared by all child classes
159
-    protected $_default_espresso_metaboxes;
160
-
161
-    /**
162
-     *    EE_Registry Object
163
-     *
164
-     * @var    EE_Registry
165
-     */
166
-    protected $EE = null;
167
-
168
-
169
-    /**
170
-     * This is just a property that flags whether the given route is a caffeinated route or not.
171
-     *
172
-     * @var boolean
173
-     */
174
-    protected $_is_caf = false;
175
-
176
-
177
-    /**
178
-     * @Constructor
179
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
-     * @throws EE_Error
181
-     * @throws InvalidArgumentException
182
-     * @throws ReflectionException
183
-     * @throws InvalidDataTypeException
184
-     * @throws InvalidInterfaceException
185
-     */
186
-    public function __construct($routing = true)
187
-    {
188
-        $this->loader = LoaderFactory::getLoader();
189
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
190
-            $this->_is_caf = true;
191
-        }
192
-        $this->_yes_no_values = array(
193
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
194
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
195
-        );
196
-        // set the _req_data property.
197
-        $this->_req_data = array_merge($_GET, $_POST);
198
-        // routing enabled?
199
-        $this->_routing = $routing;
200
-        // set initial page props (child method)
201
-        $this->_init_page_props();
202
-        // set global defaults
203
-        $this->_set_defaults();
204
-        // set early because incoming requests could be ajax related and we need to register those hooks.
205
-        $this->_global_ajax_hooks();
206
-        $this->_ajax_hooks();
207
-        // other_page_hooks have to be early too.
208
-        $this->_do_other_page_hooks();
209
-        // This just allows us to have extending classes do something specific
210
-        // before the parent constructor runs _page_setup().
211
-        if (method_exists($this, '_before_page_setup')) {
212
-            $this->_before_page_setup();
213
-        }
214
-        // set up page dependencies
215
-        $this->_page_setup();
216
-    }
217
-
218
-
219
-    /**
220
-     * _init_page_props
221
-     * Child classes use to set at least the following properties:
222
-     * $page_slug.
223
-     * $page_label.
224
-     *
225
-     * @abstract
226
-     * @return void
227
-     */
228
-    abstract protected function _init_page_props();
229
-
230
-
231
-    /**
232
-     * _ajax_hooks
233
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
234
-     * Note: within the ajax callback methods.
235
-     *
236
-     * @abstract
237
-     * @return void
238
-     */
239
-    abstract protected function _ajax_hooks();
240
-
241
-
242
-    /**
243
-     * _define_page_props
244
-     * child classes define page properties in here.  Must include at least:
245
-     * $_admin_base_url = base_url for all admin pages
246
-     * $_admin_page_title = default admin_page_title for admin pages
247
-     * $_labels = array of default labels for various automatically generated elements:
248
-     *    array(
249
-     *        'buttons' => array(
250
-     *            'add' => esc_html__('label for add new button'),
251
-     *            'edit' => esc_html__('label for edit button'),
252
-     *            'delete' => esc_html__('label for delete button')
253
-     *            )
254
-     *        )
255
-     *
256
-     * @abstract
257
-     * @return void
258
-     */
259
-    abstract protected function _define_page_props();
260
-
261
-
262
-    /**
263
-     * _set_page_routes
264
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
265
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
266
-     * have a 'default' route. Here's the format
267
-     * $this->_page_routes = array(
268
-     *        'default' => array(
269
-     *            'func' => '_default_method_handling_route',
270
-     *            'args' => array('array','of','args'),
271
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
272
-     *            ajax request, backend processing)
273
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
274
-     *            headers route after.  The string you enter here should match the defined route reference for a
275
-     *            headers sent route.
276
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
277
-     *            this route.
278
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
279
-     *            checks).
280
-     *        ),
281
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
282
-     *        handling method.
283
-     *        )
284
-     * )
285
-     *
286
-     * @abstract
287
-     * @return void
288
-     */
289
-    abstract protected function _set_page_routes();
290
-
291
-
292
-    /**
293
-     * _set_page_config
294
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
295
-     * array corresponds to the page_route for the loaded page. Format:
296
-     * $this->_page_config = array(
297
-     *        'default' => array(
298
-     *            'labels' => array(
299
-     *                'buttons' => array(
300
-     *                    'add' => esc_html__('label for adding item'),
301
-     *                    'edit' => esc_html__('label for editing item'),
302
-     *                    'delete' => esc_html__('label for deleting item')
303
-     *                ),
304
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
305
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
306
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
307
-     *            _define_page_props() method
308
-     *            'nav' => array(
309
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
310
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
311
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
312
-     *                'order' => 10, //required to indicate tab position.
313
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
314
-     *                displayed then add this parameter.
315
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
316
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
317
-     *            metaboxes set for eventespresso admin pages.
318
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
319
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
320
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
321
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
322
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
323
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
324
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
325
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
326
-     *            want to display.
327
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
328
-     *                'tab_id' => array(
329
-     *                    'title' => 'tab_title',
330
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
331
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
332
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
333
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
334
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
335
-     *                    attempt to use the callback which should match the name of a method in the class
336
-     *                    ),
337
-     *                'tab2_id' => array(
338
-     *                    'title' => 'tab2 title',
339
-     *                    'filename' => 'file_name_2'
340
-     *                    'callback' => 'callback_method_for_content',
341
-     *                 ),
342
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
343
-     *            help tab area on an admin page. @link
344
-     *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
345
-     *            'help_tour' => array(
346
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
347
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
348
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
349
-     *            ),
350
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
351
-     *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
352
-     *            just set
353
-     *            'require_nonce' to FALSE
354
-     *            )
355
-     * )
356
-     *
357
-     * @abstract
358
-     * @return void
359
-     */
360
-    abstract protected function _set_page_config();
361
-
362
-
363
-
364
-
365
-
366
-    /** end sample help_tour methods **/
367
-    /**
368
-     * _add_screen_options
369
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
370
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
371
-     * to a particular view.
372
-     *
373
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
374
-     *         see also WP_Screen object documents...
375
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
376
-     * @abstract
377
-     * @return void
378
-     */
379
-    abstract protected function _add_screen_options();
380
-
381
-
382
-    /**
383
-     * _add_feature_pointers
384
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
385
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
386
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
387
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
388
-     * extended) also see:
389
-     *
390
-     * @link   http://eamann.com/tech/wordpress-portland/
391
-     * @abstract
392
-     * @return void
393
-     */
394
-    abstract protected function _add_feature_pointers();
395
-
396
-
397
-    /**
398
-     * load_scripts_styles
399
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
400
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
401
-     * scripts/styles per view by putting them in a dynamic function in this format
402
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
403
-     *
404
-     * @abstract
405
-     * @return void
406
-     */
407
-    abstract public function load_scripts_styles();
408
-
409
-
410
-    /**
411
-     * admin_init
412
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
413
-     * all pages/views loaded by child class.
414
-     *
415
-     * @abstract
416
-     * @return void
417
-     */
418
-    abstract public function admin_init();
419
-
420
-
421
-    /**
422
-     * admin_notices
423
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
424
-     * all pages/views loaded by child class.
425
-     *
426
-     * @abstract
427
-     * @return void
428
-     */
429
-    abstract public function admin_notices();
430
-
431
-
432
-    /**
433
-     * admin_footer_scripts
434
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
435
-     * will apply to all pages/views loaded by child class.
436
-     *
437
-     * @return void
438
-     */
439
-    abstract public function admin_footer_scripts();
440
-
441
-
442
-    /**
443
-     * admin_footer
444
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
445
-     * apply to all pages/views loaded by child class.
446
-     *
447
-     * @return void
448
-     */
449
-    public function admin_footer()
450
-    {
451
-    }
452
-
453
-
454
-    /**
455
-     * _global_ajax_hooks
456
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
457
-     * Note: within the ajax callback methods.
458
-     *
459
-     * @abstract
460
-     * @return void
461
-     */
462
-    protected function _global_ajax_hooks()
463
-    {
464
-        // for lazy loading of metabox content
465
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
466
-    }
467
-
468
-
469
-    public function ajax_metabox_content()
470
-    {
471
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
472
-        $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
473
-        self::cached_rss_display($contentid, $url);
474
-        wp_die();
475
-    }
476
-
477
-
478
-    /**
479
-     * _page_setup
480
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
481
-     * doesn't match the object.
482
-     *
483
-     * @final
484
-     * @return void
485
-     * @throws EE_Error
486
-     * @throws InvalidArgumentException
487
-     * @throws ReflectionException
488
-     * @throws InvalidDataTypeException
489
-     * @throws InvalidInterfaceException
490
-     */
491
-    final protected function _page_setup()
492
-    {
493
-        // requires?
494
-        // admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
495
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
496
-        // next verify if we need to load anything...
497
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
498
-        $this->page_folder = strtolower(
499
-            str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
500
-        );
501
-        global $ee_menu_slugs;
502
-        $ee_menu_slugs = (array) $ee_menu_slugs;
503
-        if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
504
-            return;
505
-        }
506
-        // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
507
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
508
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
509
-                ? $this->_req_data['action2']
510
-                : $this->_req_data['action'];
511
-        }
512
-        // then set blank or -1 action values to 'default'
513
-        $this->_req_action = isset($this->_req_data['action'])
514
-                             && ! empty($this->_req_data['action'])
515
-                             && $this->_req_data['action'] !== '-1'
516
-            ? sanitize_key($this->_req_data['action'])
517
-            : 'default';
518
-        // if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
519
-        //  This covers cases where we're coming in from a list table that isn't on the default route.
520
-        $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
521
-            ? $this->_req_data['route'] : $this->_req_action;
522
-        // however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
523
-        $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
524
-            ? $this->_req_data['route']
525
-            : $this->_req_action;
526
-        $this->_current_view = $this->_req_action;
527
-        $this->_req_nonce = $this->_req_action . '_nonce';
528
-        $this->_define_page_props();
529
-        $this->_current_page_view_url = add_query_arg(
530
-            array('page' => $this->_current_page, 'action' => $this->_current_view),
531
-            $this->_admin_base_url
532
-        );
533
-        // default things
534
-        $this->_default_espresso_metaboxes = array(
535
-            '_espresso_news_post_box',
536
-            '_espresso_links_post_box',
537
-            '_espresso_ratings_request',
538
-            '_espresso_sponsors_post_box',
539
-        );
540
-        // set page configs
541
-        $this->_set_page_routes();
542
-        $this->_set_page_config();
543
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
544
-        if (isset($this->_req_data['wp_referer'])) {
545
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
546
-        }
547
-        // for caffeinated and other extended functionality.
548
-        //  If there is a _extend_page_config method
549
-        // then let's run that to modify the all the various page configuration arrays
550
-        if (method_exists($this, '_extend_page_config')) {
551
-            $this->_extend_page_config();
552
-        }
553
-        // for CPT and other extended functionality.
554
-        // If there is an _extend_page_config_for_cpt
555
-        // then let's run that to modify all the various page configuration arrays.
556
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
557
-            $this->_extend_page_config_for_cpt();
558
-        }
559
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
560
-        $this->_page_routes = apply_filters(
561
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
562
-            $this->_page_routes,
563
-            $this
564
-        );
565
-        $this->_page_config = apply_filters(
566
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
567
-            $this->_page_config,
568
-            $this
569
-        );
570
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
571
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
572
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
573
-            add_action(
574
-                'AHEE__EE_Admin_Page__route_admin_request',
575
-                array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
576
-                10,
577
-                2
578
-            );
579
-        }
580
-        // next route only if routing enabled
581
-        if ($this->_routing && ! defined('DOING_AJAX')) {
582
-            $this->_verify_routes();
583
-            // next let's just check user_access and kill if no access
584
-            $this->check_user_access();
585
-            if ($this->_is_UI_request) {
586
-                // admin_init stuff - global, all views for this page class, specific view
587
-                add_action('admin_init', array($this, 'admin_init'), 10);
588
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
589
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
590
-                }
591
-            } else {
592
-                // hijack regular WP loading and route admin request immediately
593
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
594
-                $this->route_admin_request();
595
-            }
596
-        }
597
-    }
598
-
599
-
600
-    /**
601
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
602
-     *
603
-     * @return void
604
-     * @throws ReflectionException
605
-     * @throws EE_Error
606
-     */
607
-    private function _do_other_page_hooks()
608
-    {
609
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
610
-        foreach ($registered_pages as $page) {
611
-            // now let's setup the file name and class that should be present
612
-            $classname = str_replace('.class.php', '', $page);
613
-            // autoloaders should take care of loading file
614
-            if (! class_exists($classname)) {
615
-                $error_msg[] = sprintf(
616
-                    esc_html__(
617
-                        'Something went wrong with loading the %s admin hooks page.',
618
-                        'event_espresso'
619
-                    ),
620
-                    $page
621
-                );
622
-                $error_msg[] = $error_msg[0]
623
-                               . "\r\n"
624
-                               . sprintf(
625
-                                   esc_html__(
626
-                                       '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',
627
-                                       'event_espresso'
628
-                                   ),
629
-                                   $page,
630
-                                   '<br />',
631
-                                   '<strong>' . $classname . '</strong>'
632
-                               );
633
-                throw new EE_Error(implode('||', $error_msg));
634
-            }
635
-            $a = new ReflectionClass($classname);
636
-            // notice we are passing the instance of this class to the hook object.
637
-            $hookobj[] = $a->newInstance($this);
638
-        }
639
-    }
640
-
641
-
642
-    public function load_page_dependencies()
643
-    {
644
-        try {
645
-            $this->_load_page_dependencies();
646
-        } catch (EE_Error $e) {
647
-            $e->get_error();
648
-        }
649
-    }
650
-
651
-
652
-    /**
653
-     * load_page_dependencies
654
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
655
-     *
656
-     * @return void
657
-     * @throws DomainException
658
-     * @throws EE_Error
659
-     * @throws InvalidArgumentException
660
-     * @throws InvalidDataTypeException
661
-     * @throws InvalidInterfaceException
662
-     * @throws ReflectionException
663
-     */
664
-    protected function _load_page_dependencies()
665
-    {
666
-        // let's set the current_screen and screen options to override what WP set
667
-        $this->_current_screen = get_current_screen();
668
-        // load admin_notices - global, page class, and view specific
669
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
670
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
671
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
672
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
673
-        }
674
-        // load network admin_notices - global, page class, and view specific
675
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
676
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
677
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
678
-        }
679
-        // this will save any per_page screen options if they are present
680
-        $this->_set_per_page_screen_options();
681
-        // setup list table properties
682
-        $this->_set_list_table();
683
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
684
-        // However in some cases the metaboxes will need to be added within a route handling callback.
685
-        $this->_add_registered_meta_boxes();
686
-        $this->_add_screen_columns();
687
-        // add screen options - global, page child class, and view specific
688
-        $this->_add_global_screen_options();
689
-        $this->_add_screen_options();
690
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
691
-        if (method_exists($this, $add_screen_options)) {
692
-            $this->{$add_screen_options}();
693
-        }
694
-        // add help tab(s) and tours- set via page_config and qtips.
695
-        $this->_add_help_tour();
696
-        $this->_add_help_tabs();
697
-        $this->_add_qtips();
698
-        // add feature_pointers - global, page child class, and view specific
699
-        $this->_add_feature_pointers();
700
-        $this->_add_global_feature_pointers();
701
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
702
-        if (method_exists($this, $add_feature_pointer)) {
703
-            $this->{$add_feature_pointer}();
704
-        }
705
-        // enqueue scripts/styles - global, page class, and view specific
706
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
707
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
708
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
709
-            add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
710
-        }
711
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
712
-        // admin_print_footer_scripts - global, page child class, and view specific.
713
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
714
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
715
-        // is a good use case. Notice the late priority we're giving these
716
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
717
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
718
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
719
-            add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
720
-        }
721
-        // admin footer scripts
722
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
723
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
724
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
725
-            add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
726
-        }
727
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
728
-        // targeted hook
729
-        do_action(
730
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
731
-        );
732
-    }
733
-
734
-
735
-    /**
736
-     * _set_defaults
737
-     * This sets some global defaults for class properties.
738
-     */
739
-    private function _set_defaults()
740
-    {
741
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
742
-        $this->_event = $this->_template_path = $this->_column_template_path = null;
743
-        $this->_nav_tabs = $this->_views = $this->_page_routes = array();
744
-        $this->_page_config = $this->_default_route_query_args = array();
745
-        $this->_default_nav_tab_name = 'overview';
746
-        // init template args
747
-        $this->_template_args = array(
748
-            'admin_page_header'  => '',
749
-            'admin_page_content' => '',
750
-            'post_body_content'  => '',
751
-            'before_list_table'  => '',
752
-            'after_list_table'   => '',
753
-        );
754
-    }
755
-
756
-
757
-    /**
758
-     * route_admin_request
759
-     *
760
-     * @see    _route_admin_request()
761
-     * @return exception|void error
762
-     * @throws InvalidArgumentException
763
-     * @throws InvalidInterfaceException
764
-     * @throws InvalidDataTypeException
765
-     * @throws EE_Error
766
-     * @throws ReflectionException
767
-     */
768
-    public function route_admin_request()
769
-    {
770
-        try {
771
-            $this->_route_admin_request();
772
-        } catch (EE_Error $e) {
773
-            $e->get_error();
774
-        }
775
-    }
776
-
777
-
778
-    public function set_wp_page_slug($wp_page_slug)
779
-    {
780
-        $this->_wp_page_slug = $wp_page_slug;
781
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
782
-        if (is_network_admin()) {
783
-            $this->_wp_page_slug .= '-network';
784
-        }
785
-    }
786
-
787
-
788
-    /**
789
-     * _verify_routes
790
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
791
-     * we know if we need to drop out.
792
-     *
793
-     * @return bool
794
-     * @throws EE_Error
795
-     */
796
-    protected function _verify_routes()
797
-    {
798
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
799
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
800
-            return false;
801
-        }
802
-        $this->_route = false;
803
-        // check that the page_routes array is not empty
804
-        if (empty($this->_page_routes)) {
805
-            // user error msg
806
-            $error_msg = sprintf(
807
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
808
-                $this->_admin_page_title
809
-            );
810
-            // developer error msg
811
-            $error_msg .= '||' . $error_msg
812
-                          . esc_html__(
813
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
814
-                              'event_espresso'
815
-                          );
816
-            throw new EE_Error($error_msg);
817
-        }
818
-        // and that the requested page route exists
819
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
820
-            $this->_route = $this->_page_routes[ $this->_req_action ];
821
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
822
-                ? $this->_page_config[ $this->_req_action ] : array();
823
-        } else {
824
-            // user error msg
825
-            $error_msg = sprintf(
826
-                esc_html__(
827
-                    'The requested page route does not exist for the %s admin page.',
828
-                    'event_espresso'
829
-                ),
830
-                $this->_admin_page_title
831
-            );
832
-            // developer error msg
833
-            $error_msg .= '||' . $error_msg
834
-                          . sprintf(
835
-                              esc_html__(
836
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
837
-                                  'event_espresso'
838
-                              ),
839
-                              $this->_req_action
840
-                          );
841
-            throw new EE_Error($error_msg);
842
-        }
843
-        // and that a default route exists
844
-        if (! array_key_exists('default', $this->_page_routes)) {
845
-            // user error msg
846
-            $error_msg = sprintf(
847
-                esc_html__(
848
-                    'A default page route has not been set for the % admin page.',
849
-                    'event_espresso'
850
-                ),
851
-                $this->_admin_page_title
852
-            );
853
-            // developer error msg
854
-            $error_msg .= '||' . $error_msg
855
-                          . esc_html__(
856
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
857
-                              'event_espresso'
858
-                          );
859
-            throw new EE_Error($error_msg);
860
-        }
861
-        // first lets' catch if the UI request has EVER been set.
862
-        if ($this->_is_UI_request === null) {
863
-            // lets set if this is a UI request or not.
864
-            $this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
865
-            // wait a minute... we might have a noheader in the route array
866
-            $this->_is_UI_request = is_array($this->_route)
867
-                                    && isset($this->_route['noheader'])
868
-                                    && $this->_route['noheader'] ? false : $this->_is_UI_request;
869
-        }
870
-        $this->_set_current_labels();
871
-        return true;
872
-    }
873
-
874
-
875
-    /**
876
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
877
-     *
878
-     * @param  string $route the route name we're verifying
879
-     * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
880
-     * @throws EE_Error
881
-     */
882
-    protected function _verify_route($route)
883
-    {
884
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
885
-            return true;
886
-        }
887
-        // user error msg
888
-        $error_msg = sprintf(
889
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
890
-            $this->_admin_page_title
891
-        );
892
-        // developer error msg
893
-        $error_msg .= '||' . $error_msg
894
-                      . sprintf(
895
-                          esc_html__(
896
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
897
-                              'event_espresso'
898
-                          ),
899
-                          $route
900
-                      );
901
-        throw new EE_Error($error_msg);
902
-    }
903
-
904
-
905
-    /**
906
-     * perform nonce verification
907
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
908
-     * using this method (and save retyping!)
909
-     *
910
-     * @param  string $nonce     The nonce sent
911
-     * @param  string $nonce_ref The nonce reference string (name0)
912
-     * @return void
913
-     * @throws EE_Error
914
-     */
915
-    protected function _verify_nonce($nonce, $nonce_ref)
916
-    {
917
-        // verify nonce against expected value
918
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
919
-            // these are not the droids you are looking for !!!
920
-            $msg = sprintf(
921
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
922
-                '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
923
-                '</a>'
924
-            );
925
-            if (WP_DEBUG) {
926
-                $msg .= "\n  "
927
-                        . sprintf(
928
-                            esc_html__(
929
-                                'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
930
-                                'event_espresso'
931
-                            ),
932
-                            __CLASS__
933
-                        );
934
-            }
935
-            if (! defined('DOING_AJAX')) {
936
-                wp_die($msg);
937
-            } else {
938
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
939
-                $this->_return_json();
940
-            }
941
-        }
942
-    }
943
-
944
-
945
-    /**
946
-     * _route_admin_request()
947
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
948
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
949
-     * in the page routes and then will try to load the corresponding method.
950
-     *
951
-     * @return void
952
-     * @throws EE_Error
953
-     * @throws InvalidArgumentException
954
-     * @throws InvalidDataTypeException
955
-     * @throws InvalidInterfaceException
956
-     * @throws ReflectionException
957
-     */
958
-    protected function _route_admin_request()
959
-    {
960
-        if (! $this->_is_UI_request) {
961
-            $this->_verify_routes();
962
-        }
963
-        $nonce_check = isset($this->_route_config['require_nonce'])
964
-            ? $this->_route_config['require_nonce']
965
-            : true;
966
-        if ($this->_req_action !== 'default' && $nonce_check) {
967
-            // set nonce from post data
968
-            $nonce = isset($this->_req_data[ $this->_req_nonce ])
969
-                ? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
970
-                : '';
971
-            $this->_verify_nonce($nonce, $this->_req_nonce);
972
-        }
973
-        // set the nav_tabs array but ONLY if this is  UI_request
974
-        if ($this->_is_UI_request) {
975
-            $this->_set_nav_tabs();
976
-        }
977
-        // grab callback function
978
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
979
-        // check if callback has args
980
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
981
-        $error_msg = '';
982
-        // action right before calling route
983
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
984
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
985
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
986
-        }
987
-        // right before calling the route, let's remove _wp_http_referer from the
988
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
989
-        $_SERVER['REQUEST_URI'] = remove_query_arg(
990
-            '_wp_http_referer',
991
-            wp_unslash($_SERVER['REQUEST_URI'])
992
-        );
993
-        if (! empty($func)) {
994
-            if (is_array($func)) {
995
-                list($class, $method) = $func;
996
-            } elseif (strpos($func, '::') !== false) {
997
-                list($class, $method) = explode('::', $func);
998
-            } else {
999
-                $class = $this;
1000
-                $method = $func;
1001
-            }
1002
-            if (! (is_object($class) && $class === $this)) {
1003
-                // send along this admin page object for access by addons.
1004
-                $args['admin_page_object'] = $this;
1005
-            }
1006
-            if (// is it a method on a class that doesn't work?
1007
-                (
1008
-                    (
1009
-                        method_exists($class, $method)
1010
-                        && call_user_func_array(array($class, $method), $args) === false
1011
-                    )
1012
-                    && (
1013
-                        // is it a standalone function that doesn't work?
1014
-                        function_exists($method)
1015
-                        && call_user_func_array(
1016
-                            $func,
1017
-                            array_merge(array('admin_page_object' => $this), $args)
1018
-                        ) === false
1019
-                    )
1020
-                )
1021
-                || (
1022
-                    // is it neither a class method NOR a standalone function?
1023
-                    ! method_exists($class, $method)
1024
-                    && ! function_exists($method)
1025
-                )
1026
-            ) {
1027
-                // user error msg
1028
-                $error_msg = esc_html__(
1029
-                    'An error occurred. The  requested page route could not be found.',
1030
-                    'event_espresso'
1031
-                );
1032
-                // developer error msg
1033
-                $error_msg .= '||';
1034
-                $error_msg .= sprintf(
1035
-                    esc_html__(
1036
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1037
-                        'event_espresso'
1038
-                    ),
1039
-                    $method
1040
-                );
1041
-            }
1042
-            if (! empty($error_msg)) {
1043
-                throw new EE_Error($error_msg);
1044
-            }
1045
-        }
1046
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1047
-        // then we need to reset the routing properties to the new route.
1048
-        // 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.
1049
-        if ($this->_is_UI_request === false
1050
-            && is_array($this->_route)
1051
-            && ! empty($this->_route['headers_sent_route'])
1052
-        ) {
1053
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1054
-        }
1055
-    }
1056
-
1057
-
1058
-    /**
1059
-     * This method just allows the resetting of page properties in the case where a no headers
1060
-     * route redirects to a headers route in its route config.
1061
-     *
1062
-     * @since   4.3.0
1063
-     * @param  string $new_route New (non header) route to redirect to.
1064
-     * @return   void
1065
-     * @throws ReflectionException
1066
-     * @throws InvalidArgumentException
1067
-     * @throws InvalidInterfaceException
1068
-     * @throws InvalidDataTypeException
1069
-     * @throws EE_Error
1070
-     */
1071
-    protected function _reset_routing_properties($new_route)
1072
-    {
1073
-        $this->_is_UI_request = true;
1074
-        // now we set the current route to whatever the headers_sent_route is set at
1075
-        $this->_req_data['action'] = $new_route;
1076
-        // rerun page setup
1077
-        $this->_page_setup();
1078
-    }
1079
-
1080
-
1081
-    /**
1082
-     * _add_query_arg
1083
-     * adds nonce to array of arguments then calls WP add_query_arg function
1084
-     *(internally just uses EEH_URL's function with the same name)
1085
-     *
1086
-     * @param array  $args
1087
-     * @param string $url
1088
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1089
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1090
-     *                                        Example usage: If the current page is:
1091
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1092
-     *                                        &action=default&event_id=20&month_range=March%202015
1093
-     *                                        &_wpnonce=5467821
1094
-     *                                        and you call:
1095
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1096
-     *                                        array(
1097
-     *                                        'action' => 'resend_something',
1098
-     *                                        'page=>espresso_registrations'
1099
-     *                                        ),
1100
-     *                                        $some_url,
1101
-     *                                        true
1102
-     *                                        );
1103
-     *                                        It will produce a url in this structure:
1104
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1105
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1106
-     *                                        month_range]=March%202015
1107
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1108
-     * @return string
1109
-     */
1110
-    public static function add_query_args_and_nonce(
1111
-        $args = array(),
1112
-        $url = false,
1113
-        $sticky = false,
1114
-        $exclude_nonce = false
1115
-    ) {
1116
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1117
-        if ($sticky) {
1118
-            $request = $_REQUEST;
1119
-            unset($request['_wp_http_referer']);
1120
-            unset($request['wp_referer']);
1121
-            foreach ($request as $key => $value) {
1122
-                // do not add nonces
1123
-                if (strpos($key, 'nonce') !== false) {
1124
-                    continue;
1125
-                }
1126
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1127
-            }
1128
-        }
1129
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1130
-    }
1131
-
1132
-
1133
-    /**
1134
-     * This returns a generated link that will load the related help tab.
1135
-     *
1136
-     * @param  string $help_tab_id the id for the connected help tab
1137
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1138
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1139
-     * @uses EEH_Template::get_help_tab_link()
1140
-     * @return string              generated link
1141
-     */
1142
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1143
-    {
1144
-        return EEH_Template::get_help_tab_link(
1145
-            $help_tab_id,
1146
-            $this->page_slug,
1147
-            $this->_req_action,
1148
-            $icon_style,
1149
-            $help_text
1150
-        );
1151
-    }
1152
-
1153
-
1154
-    /**
1155
-     * _add_help_tabs
1156
-     * Note child classes define their help tabs within the page_config array.
1157
-     *
1158
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1159
-     * @return void
1160
-     * @throws DomainException
1161
-     * @throws EE_Error
1162
-     */
1163
-    protected function _add_help_tabs()
1164
-    {
1165
-        $tour_buttons = '';
1166
-        if (isset($this->_page_config[ $this->_req_action ])) {
1167
-            $config = $this->_page_config[ $this->_req_action ];
1168
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1169
-            if (isset($this->_help_tour[ $this->_req_action ])) {
1170
-                $tb = array();
1171
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1172
-                foreach ($this->_help_tour['tours'] as $tour) {
1173
-                    // if this is the end tour then we don't need to setup a button
1174
-                    if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1175
-                        continue;
1176
-                    }
1177
-                    $tb[] = '<button id="trigger-tour-'
1178
-                            . $tour->get_slug()
1179
-                            . '" class="button-primary trigger-ee-help-tour">'
1180
-                            . $tour->get_label()
1181
-                            . '</button>';
1182
-                }
1183
-                $tour_buttons .= implode('<br />', $tb);
1184
-                $tour_buttons .= '</div></div>';
1185
-            }
1186
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1187
-            if (is_array($config) && isset($config['help_sidebar'])) {
1188
-                // check that the callback given is valid
1189
-                if (! method_exists($this, $config['help_sidebar'])) {
1190
-                    throw new EE_Error(
1191
-                        sprintf(
1192
-                            esc_html__(
1193
-                                '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',
1194
-                                'event_espresso'
1195
-                            ),
1196
-                            $config['help_sidebar'],
1197
-                            get_class($this)
1198
-                        )
1199
-                    );
1200
-                }
1201
-                $content = apply_filters(
1202
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1203
-                    $this->{$config['help_sidebar']}()
1204
-                );
1205
-                $content .= $tour_buttons; // add help tour buttons.
1206
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1207
-                $this->_current_screen->set_help_sidebar($content);
1208
-            }
1209
-            // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1210
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1211
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1212
-            }
1213
-            // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1214
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1215
-                $_ht['id'] = $this->page_slug;
1216
-                $_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1217
-                $_ht['content'] = '<p>'
1218
-                                  . esc_html__(
1219
-                                      'The buttons to the right allow you to start/restart any help tours available for this page',
1220
-                                      'event_espresso'
1221
-                                  ) . '</p>';
1222
-                $this->_current_screen->add_help_tab($_ht);
1223
-            }
1224
-            if (! isset($config['help_tabs'])) {
1225
-                return;
1226
-            } //no help tabs for this route
1227
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1228
-                // we're here so there ARE help tabs!
1229
-                // make sure we've got what we need
1230
-                if (! isset($cfg['title'])) {
1231
-                    throw new EE_Error(
1232
-                        esc_html__(
1233
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1234
-                            'event_espresso'
1235
-                        )
1236
-                    );
1237
-                }
1238
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1239
-                    throw new EE_Error(
1240
-                        esc_html__(
1241
-                            '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',
1242
-                            'event_espresso'
1243
-                        )
1244
-                    );
1245
-                }
1246
-                // first priority goes to content.
1247
-                if (! empty($cfg['content'])) {
1248
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1249
-                    // second priority goes to filename
1250
-                } elseif (! empty($cfg['filename'])) {
1251
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1252
-                    // 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)
1253
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1254
-                                                             . basename($this->_get_dir())
1255
-                                                             . '/help_tabs/'
1256
-                                                             . $cfg['filename']
1257
-                                                             . '.help_tab.php' : $file_path;
1258
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1259
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1260
-                        EE_Error::add_error(
1261
-                            sprintf(
1262
-                                esc_html__(
1263
-                                    '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',
1264
-                                    'event_espresso'
1265
-                                ),
1266
-                                $tab_id,
1267
-                                key($config),
1268
-                                $file_path
1269
-                            ),
1270
-                            __FILE__,
1271
-                            __FUNCTION__,
1272
-                            __LINE__
1273
-                        );
1274
-                        return;
1275
-                    }
1276
-                    $template_args['admin_page_obj'] = $this;
1277
-                    $content = EEH_Template::display_template(
1278
-                        $file_path,
1279
-                        $template_args,
1280
-                        true
1281
-                    );
1282
-                } else {
1283
-                    $content = '';
1284
-                }
1285
-                // check if callback is valid
1286
-                if (empty($content) && (
1287
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1288
-                    )
1289
-                ) {
1290
-                    EE_Error::add_error(
1291
-                        sprintf(
1292
-                            esc_html__(
1293
-                                '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.',
1294
-                                'event_espresso'
1295
-                            ),
1296
-                            $cfg['title']
1297
-                        ),
1298
-                        __FILE__,
1299
-                        __FUNCTION__,
1300
-                        __LINE__
1301
-                    );
1302
-                    return;
1303
-                }
1304
-                // setup config array for help tab method
1305
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1306
-                $_ht = array(
1307
-                    'id'       => $id,
1308
-                    'title'    => $cfg['title'],
1309
-                    'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1310
-                    'content'  => $content,
1311
-                );
1312
-                $this->_current_screen->add_help_tab($_ht);
1313
-            }
1314
-        }
1315
-    }
1316
-
1317
-
1318
-    /**
1319
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1320
-     * an array with properties for setting up usage of the joyride plugin
1321
-     *
1322
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1323
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1324
-     *         _set_page_config() comments
1325
-     * @return void
1326
-     * @throws EE_Error
1327
-     * @throws InvalidArgumentException
1328
-     * @throws InvalidDataTypeException
1329
-     * @throws InvalidInterfaceException
1330
-     */
1331
-    protected function _add_help_tour()
1332
-    {
1333
-        $tours = array();
1334
-        $this->_help_tour = array();
1335
-        // exit early if help tours are turned off globally
1336
-        if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1337
-            || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1338
-        ) {
1339
-            return;
1340
-        }
1341
-        // loop through _page_config to find any help_tour defined
1342
-        foreach ($this->_page_config as $route => $config) {
1343
-            // we're only going to set things up for this route
1344
-            if ($route !== $this->_req_action) {
1345
-                continue;
1346
-            }
1347
-            if (isset($config['help_tour'])) {
1348
-                foreach ($config['help_tour'] as $tour) {
1349
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1350
-                    // let's see if we can get that file...
1351
-                    // if not its possible this is a decaf route not set in caffeinated
1352
-                    // so lets try and get the caffeinated equivalent
1353
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1354
-                                                             . basename($this->_get_dir())
1355
-                                                             . '/help_tours/'
1356
-                                                             . $tour
1357
-                                                             . '.class.php' : $file_path;
1358
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1359
-                    if (! is_readable($file_path)) {
1360
-                        EE_Error::add_error(
1361
-                            sprintf(
1362
-                                esc_html__(
1363
-                                    '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',
1364
-                                    'event_espresso'
1365
-                                ),
1366
-                                $file_path,
1367
-                                $tour
1368
-                            ),
1369
-                            __FILE__,
1370
-                            __FUNCTION__,
1371
-                            __LINE__
1372
-                        );
1373
-                        return;
1374
-                    }
1375
-                    require_once $file_path;
1376
-                    if (! class_exists($tour)) {
1377
-                        $error_msg[] = sprintf(
1378
-                            esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1379
-                            $tour
1380
-                        );
1381
-                        $error_msg[] = $error_msg[0] . "\r\n"
1382
-                                       . sprintf(
1383
-                                           esc_html__(
1384
-                                               '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.',
1385
-                                               'event_espresso'
1386
-                                           ),
1387
-                                           $tour,
1388
-                                           '<br />',
1389
-                                           $tour,
1390
-                                           $this->_req_action,
1391
-                                           get_class($this)
1392
-                                       );
1393
-                        throw new EE_Error(implode('||', $error_msg));
1394
-                    }
1395
-                    $tour_obj = new $tour($this->_is_caf);
1396
-                    $tours[] = $tour_obj;
1397
-                    $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1398
-                }
1399
-                // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1400
-                $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1401
-                $tours[] = $end_stop_tour;
1402
-                $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1403
-            }
1404
-        }
1405
-        if (! empty($tours)) {
1406
-            $this->_help_tour['tours'] = $tours;
1407
-        }
1408
-        // that's it!  Now that the $_help_tours property is set (or not)
1409
-        // the scripts and html should be taken care of automatically.
1410
-    }
1411
-
1412
-
1413
-    /**
1414
-     * This simply sets up any qtips that have been defined in the page config
1415
-     *
1416
-     * @return void
1417
-     */
1418
-    protected function _add_qtips()
1419
-    {
1420
-        if (isset($this->_route_config['qtips'])) {
1421
-            $qtips = (array) $this->_route_config['qtips'];
1422
-            // load qtip loader
1423
-            $path = array(
1424
-                $this->_get_dir() . '/qtips/',
1425
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1426
-            );
1427
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1428
-        }
1429
-    }
1430
-
1431
-
1432
-    /**
1433
-     * _set_nav_tabs
1434
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1435
-     * wish to add additional tabs or modify accordingly.
1436
-     *
1437
-     * @return void
1438
-     * @throws InvalidArgumentException
1439
-     * @throws InvalidInterfaceException
1440
-     * @throws InvalidDataTypeException
1441
-     */
1442
-    protected function _set_nav_tabs()
1443
-    {
1444
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1445
-        $i = 0;
1446
-        foreach ($this->_page_config as $slug => $config) {
1447
-            if (! is_array($config)
1448
-                || (
1449
-                    is_array($config)
1450
-                    && (
1451
-                        (isset($config['nav']) && ! $config['nav'])
1452
-                        || ! isset($config['nav'])
1453
-                    )
1454
-                )
1455
-            ) {
1456
-                continue;
1457
-            }
1458
-            // no nav tab for this config
1459
-            // check for persistent flag
1460
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1461
-                // nav tab is only to appear when route requested.
1462
-                continue;
1463
-            }
1464
-            if (! $this->check_user_access($slug, true)) {
1465
-                // no nav tab because current user does not have access.
1466
-                continue;
1467
-            }
1468
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1469
-            $this->_nav_tabs[ $slug ] = array(
1470
-                'url'       => isset($config['nav']['url'])
1471
-                    ? $config['nav']['url']
1472
-                    : self::add_query_args_and_nonce(
1473
-                        array('action' => $slug),
1474
-                        $this->_admin_base_url
1475
-                    ),
1476
-                'link_text' => isset($config['nav']['label'])
1477
-                    ? $config['nav']['label']
1478
-                    : ucwords(
1479
-                        str_replace('_', ' ', $slug)
1480
-                    ),
1481
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1482
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1483
-            );
1484
-            $i++;
1485
-        }
1486
-        // if $this->_nav_tabs is empty then lets set the default
1487
-        if (empty($this->_nav_tabs)) {
1488
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1489
-                'url'       => $this->_admin_base_url,
1490
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1491
-                'css_class' => 'nav-tab-active',
1492
-                'order'     => 10,
1493
-            );
1494
-        }
1495
-        // now let's sort the tabs according to order
1496
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1497
-    }
1498
-
1499
-
1500
-    /**
1501
-     * _set_current_labels
1502
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1503
-     * property array
1504
-     *
1505
-     * @return void
1506
-     */
1507
-    private function _set_current_labels()
1508
-    {
1509
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1510
-            foreach ($this->_route_config['labels'] as $label => $text) {
1511
-                if (is_array($text)) {
1512
-                    foreach ($text as $sublabel => $subtext) {
1513
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1514
-                    }
1515
-                } else {
1516
-                    $this->_labels[ $label ] = $text;
1517
-                }
1518
-            }
1519
-        }
1520
-    }
1521
-
1522
-
1523
-    /**
1524
-     *        verifies user access for this admin page
1525
-     *
1526
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1527
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1528
-     *                               return false if verify fail.
1529
-     * @return bool
1530
-     * @throws InvalidArgumentException
1531
-     * @throws InvalidDataTypeException
1532
-     * @throws InvalidInterfaceException
1533
-     */
1534
-    public function check_user_access($route_to_check = '', $verify_only = false)
1535
-    {
1536
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1537
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1538
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1539
-                      && is_array(
1540
-                          $this->_page_routes[ $route_to_check ]
1541
-                      )
1542
-                      && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1543
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1544
-        if (empty($capability) && empty($route_to_check)) {
1545
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1546
-                : $this->_route['capability'];
1547
-        } else {
1548
-            $capability = empty($capability) ? 'manage_options' : $capability;
1549
-        }
1550
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1551
-        if (! defined('DOING_AJAX')
1552
-            && (
1553
-                ! function_exists('is_admin')
1554
-                || ! EE_Registry::instance()->CAP->current_user_can(
1555
-                    $capability,
1556
-                    $this->page_slug
1557
-                    . '_'
1558
-                    . $route_to_check,
1559
-                    $id
1560
-                )
1561
-            )
1562
-        ) {
1563
-            if ($verify_only) {
1564
-                return false;
1565
-            }
1566
-            if (is_user_logged_in()) {
1567
-                wp_die(__('You do not have access to this route.', 'event_espresso'));
1568
-            } else {
1569
-                return false;
1570
-            }
1571
-        }
1572
-        return true;
1573
-    }
1574
-
1575
-
1576
-    /**
1577
-     * admin_init_global
1578
-     * This runs all the code that we want executed within the WP admin_init hook.
1579
-     * This method executes for ALL EE Admin pages.
1580
-     *
1581
-     * @return void
1582
-     */
1583
-    public function admin_init_global()
1584
-    {
1585
-    }
1586
-
1587
-
1588
-    /**
1589
-     * wp_loaded_global
1590
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1591
-     * EE_Admin page and will execute on every EE Admin Page load
1592
-     *
1593
-     * @return void
1594
-     */
1595
-    public function wp_loaded()
1596
-    {
1597
-    }
1598
-
1599
-
1600
-    /**
1601
-     * admin_notices
1602
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1603
-     * ALL EE_Admin pages.
1604
-     *
1605
-     * @return void
1606
-     */
1607
-    public function admin_notices_global()
1608
-    {
1609
-        $this->_display_no_javascript_warning();
1610
-        $this->_display_espresso_notices();
1611
-    }
1612
-
1613
-
1614
-    public function network_admin_notices_global()
1615
-    {
1616
-        $this->_display_no_javascript_warning();
1617
-        $this->_display_espresso_notices();
1618
-    }
1619
-
1620
-
1621
-    /**
1622
-     * admin_footer_scripts_global
1623
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1624
-     * will apply on ALL EE_Admin pages.
1625
-     *
1626
-     * @return void
1627
-     */
1628
-    public function admin_footer_scripts_global()
1629
-    {
1630
-        $this->_add_admin_page_ajax_loading_img();
1631
-        $this->_add_admin_page_overlay();
1632
-        // if metaboxes are present we need to add the nonce field
1633
-        if (isset($this->_route_config['metaboxes'])
1634
-            || isset($this->_route_config['list_table'])
1635
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1636
-        ) {
1637
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1638
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1639
-        }
1640
-    }
1641
-
1642
-
1643
-    /**
1644
-     * admin_footer_global
1645
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1646
-     * ALL EE_Admin Pages.
1647
-     *
1648
-     * @return void
1649
-     * @throws EE_Error
1650
-     */
1651
-    public function admin_footer_global()
1652
-    {
1653
-        // dialog container for dialog helper
1654
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1655
-        $d_cont .= '<div class="ee-notices"></div>';
1656
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1657
-        $d_cont .= '</div>';
1658
-        echo $d_cont;
1659
-        // help tour stuff?
1660
-        if (isset($this->_help_tour[ $this->_req_action ])) {
1661
-            echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1662
-        }
1663
-        // current set timezone for timezone js
1664
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1665
-    }
1666
-
1667
-
1668
-    /**
1669
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1670
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1671
-     * help popups then in your templates or your content you set "triggers" for the content using the
1672
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1673
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1674
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1675
-     * for the
1676
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1677
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1678
-     *    'help_trigger_id' => array(
1679
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1680
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1681
-     *    )
1682
-     * );
1683
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1684
-     *
1685
-     * @param array $help_array
1686
-     * @param bool  $display
1687
-     * @return string content
1688
-     * @throws DomainException
1689
-     * @throws EE_Error
1690
-     */
1691
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1692
-    {
1693
-        $content = '';
1694
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1695
-        // loop through the array and setup content
1696
-        foreach ($help_array as $trigger => $help) {
1697
-            // make sure the array is setup properly
1698
-            if (! isset($help['title']) || ! isset($help['content'])) {
1699
-                throw new EE_Error(
1700
-                    esc_html__(
1701
-                        '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',
1702
-                        'event_espresso'
1703
-                    )
1704
-                );
1705
-            }
1706
-            // we're good so let'd setup the template vars and then assign parsed template content to our content.
1707
-            $template_args = array(
1708
-                'help_popup_id'      => $trigger,
1709
-                'help_popup_title'   => $help['title'],
1710
-                'help_popup_content' => $help['content'],
1711
-            );
1712
-            $content .= EEH_Template::display_template(
1713
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1714
-                $template_args,
1715
-                true
1716
-            );
1717
-        }
1718
-        if ($display) {
1719
-            echo $content;
1720
-            return '';
1721
-        }
1722
-        return $content;
1723
-    }
1724
-
1725
-
1726
-    /**
1727
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1728
-     *
1729
-     * @return array properly formatted array for help popup content
1730
-     * @throws EE_Error
1731
-     */
1732
-    private function _get_help_content()
1733
-    {
1734
-        // what is the method we're looking for?
1735
-        $method_name = '_help_popup_content_' . $this->_req_action;
1736
-        // if method doesn't exist let's get out.
1737
-        if (! method_exists($this, $method_name)) {
1738
-            return array();
1739
-        }
1740
-        // k we're good to go let's retrieve the help array
1741
-        $help_array = call_user_func(array($this, $method_name));
1742
-        // make sure we've got an array!
1743
-        if (! is_array($help_array)) {
1744
-            throw new EE_Error(
1745
-                esc_html__(
1746
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1747
-                    'event_espresso'
1748
-                )
1749
-            );
1750
-        }
1751
-        return $help_array;
1752
-    }
1753
-
1754
-
1755
-    /**
1756
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1757
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1758
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1759
-     *
1760
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1761
-     * @param boolean $display    if false then we return the trigger string
1762
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1763
-     * @return string
1764
-     * @throws DomainException
1765
-     * @throws EE_Error
1766
-     */
1767
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1768
-    {
1769
-        if (defined('DOING_AJAX')) {
1770
-            return '';
1771
-        }
1772
-        // 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
1773
-        $help_array = $this->_get_help_content();
1774
-        $help_content = '';
1775
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1776
-            $help_array[ $trigger_id ] = array(
1777
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1778
-                'content' => esc_html__(
1779
-                    '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.)',
1780
-                    'event_espresso'
1781
-                ),
1782
-            );
1783
-            $help_content = $this->_set_help_popup_content($help_array, false);
1784
-        }
1785
-        // let's setup the trigger
1786
-        $content = '<a class="ee-dialog" href="?height='
1787
-                   . $dimensions[0]
1788
-                   . '&width='
1789
-                   . $dimensions[1]
1790
-                   . '&inlineId='
1791
-                   . $trigger_id
1792
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1793
-        $content .= $help_content;
1794
-        if ($display) {
1795
-            echo $content;
1796
-            return '';
1797
-        }
1798
-        return $content;
1799
-    }
1800
-
1801
-
1802
-    /**
1803
-     * _add_global_screen_options
1804
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1805
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1806
-     *
1807
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1808
-     *         see also WP_Screen object documents...
1809
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1810
-     * @abstract
1811
-     * @return void
1812
-     */
1813
-    private function _add_global_screen_options()
1814
-    {
1815
-    }
1816
-
1817
-
1818
-    /**
1819
-     * _add_global_feature_pointers
1820
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1821
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1822
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1823
-     *
1824
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1825
-     *         extended) also see:
1826
-     * @link   http://eamann.com/tech/wordpress-portland/
1827
-     * @abstract
1828
-     * @return void
1829
-     */
1830
-    private function _add_global_feature_pointers()
1831
-    {
1832
-    }
1833
-
1834
-
1835
-    /**
1836
-     * load_global_scripts_styles
1837
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1838
-     *
1839
-     * @return void
1840
-     * @throws EE_Error
1841
-     */
1842
-    public function load_global_scripts_styles()
1843
-    {
1844
-        /** STYLES **/
1845
-        // add debugging styles
1846
-        if (WP_DEBUG) {
1847
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1848
-        }
1849
-        // register all styles
1850
-        wp_register_style(
1851
-            'espresso-ui-theme',
1852
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1853
-            array(),
1854
-            EVENT_ESPRESSO_VERSION
1855
-        );
1856
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1857
-        // helpers styles
1858
-        wp_register_style(
1859
-            'ee-text-links',
1860
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1861
-            array(),
1862
-            EVENT_ESPRESSO_VERSION
1863
-        );
1864
-        /** SCRIPTS **/
1865
-        // register all scripts
1866
-        wp_register_script(
1867
-            'ee-dialog',
1868
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1869
-            array('jquery', 'jquery-ui-draggable'),
1870
-            EVENT_ESPRESSO_VERSION,
1871
-            true
1872
-        );
1873
-        wp_register_script(
1874
-            'ee_admin_js',
1875
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1876
-            array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1877
-            EVENT_ESPRESSO_VERSION,
1878
-            true
1879
-        );
1880
-        wp_register_script(
1881
-            'jquery-ui-timepicker-addon',
1882
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1883
-            array('jquery-ui-datepicker', 'jquery-ui-slider'),
1884
-            EVENT_ESPRESSO_VERSION,
1885
-            true
1886
-        );
1887
-        add_filter('FHEE_load_joyride', '__return_true');
1888
-        // script for sorting tables
1889
-        wp_register_script(
1890
-            'espresso_ajax_table_sorting',
1891
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1892
-            array('ee_admin_js', 'jquery-ui-sortable'),
1893
-            EVENT_ESPRESSO_VERSION,
1894
-            true
1895
-        );
1896
-        // script for parsing uri's
1897
-        wp_register_script(
1898
-            'ee-parse-uri',
1899
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1900
-            array(),
1901
-            EVENT_ESPRESSO_VERSION,
1902
-            true
1903
-        );
1904
-        // and parsing associative serialized form elements
1905
-        wp_register_script(
1906
-            'ee-serialize-full-array',
1907
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1908
-            array('jquery'),
1909
-            EVENT_ESPRESSO_VERSION,
1910
-            true
1911
-        );
1912
-        // helpers scripts
1913
-        wp_register_script(
1914
-            'ee-text-links',
1915
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1916
-            array('jquery'),
1917
-            EVENT_ESPRESSO_VERSION,
1918
-            true
1919
-        );
1920
-        wp_register_script(
1921
-            'ee-moment-core',
1922
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1923
-            array(),
1924
-            EVENT_ESPRESSO_VERSION,
1925
-            true
1926
-        );
1927
-        wp_register_script(
1928
-            'ee-moment',
1929
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1930
-            array('ee-moment-core'),
1931
-            EVENT_ESPRESSO_VERSION,
1932
-            true
1933
-        );
1934
-        wp_register_script(
1935
-            'ee-datepicker',
1936
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1937
-            array('jquery-ui-timepicker-addon', 'ee-moment'),
1938
-            EVENT_ESPRESSO_VERSION,
1939
-            true
1940
-        );
1941
-        // google charts
1942
-        wp_register_script(
1943
-            'google-charts',
1944
-            'https://www.gstatic.com/charts/loader.js',
1945
-            array(),
1946
-            EVENT_ESPRESSO_VERSION,
1947
-            false
1948
-        );
1949
-        // ENQUEUE ALL BASICS BY DEFAULT
1950
-        wp_enqueue_style('ee-admin-css');
1951
-        wp_enqueue_script('ee_admin_js');
1952
-        wp_enqueue_script('ee-accounting');
1953
-        wp_enqueue_script('jquery-validate');
1954
-        // taking care of metaboxes
1955
-        if (empty($this->_cpt_route)
1956
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1957
-        ) {
1958
-            wp_enqueue_script('dashboard');
1959
-        }
1960
-        // LOCALIZED DATA
1961
-        // localize script for ajax lazy loading
1962
-        $lazy_loader_container_ids = apply_filters(
1963
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1964
-            array('espresso_news_post_box_content')
1965
-        );
1966
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1967
-        /**
1968
-         * help tour stuff
1969
-         */
1970
-        if (! empty($this->_help_tour)) {
1971
-            // register the js for kicking things off
1972
-            wp_enqueue_script(
1973
-                'ee-help-tour',
1974
-                EE_ADMIN_URL . 'assets/ee-help-tour.js',
1975
-                array('jquery-joyride'),
1976
-                EVENT_ESPRESSO_VERSION,
1977
-                true
1978
-            );
1979
-            $tours = array();
1980
-            // setup tours for the js tour object
1981
-            foreach ($this->_help_tour['tours'] as $tour) {
1982
-                if ($tour instanceof EE_Help_Tour) {
1983
-                    $tours[] = array(
1984
-                        'id'      => $tour->get_slug(),
1985
-                        'options' => $tour->get_options(),
1986
-                    );
1987
-                }
1988
-            }
1989
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1990
-            // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1991
-        }
1992
-    }
1993
-
1994
-
1995
-    /**
1996
-     *        admin_footer_scripts_eei18n_js_strings
1997
-     *
1998
-     * @return        void
1999
-     */
2000
-    public function admin_footer_scripts_eei18n_js_strings()
2001
-    {
2002
-        EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
2003
-        EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2004
-            '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!!!',
2005
-            'event_espresso'
2006
-        );
2007
-        EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
2008
-        EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
2009
-        EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
2010
-        EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
2011
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2012
-        EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
2013
-        EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
2014
-        EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
2015
-        EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
2016
-        EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
2017
-        EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
2018
-        EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
2019
-        EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
2020
-        EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
2021
-        EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
2022
-        EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
2023
-        EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2024
-        EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
2025
-        EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
2026
-        EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
2027
-        EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2028
-        EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2029
-        EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2030
-        EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2031
-        EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2032
-        EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2033
-        EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2034
-        EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2035
-        EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2036
-        EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2037
-        EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2038
-        EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2039
-        EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2040
-        EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2041
-        EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2042
-        EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2043
-        EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2044
-        EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2045
-    }
2046
-
2047
-
2048
-    /**
2049
-     *        load enhanced xdebug styles for ppl with failing eyesight
2050
-     *
2051
-     * @return        void
2052
-     */
2053
-    public function add_xdebug_style()
2054
-    {
2055
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2056
-    }
2057
-
2058
-
2059
-    /************************/
2060
-    /** LIST TABLE METHODS **/
2061
-    /************************/
2062
-    /**
2063
-     * this sets up the list table if the current view requires it.
2064
-     *
2065
-     * @return void
2066
-     * @throws EE_Error
2067
-     */
2068
-    protected function _set_list_table()
2069
-    {
2070
-        // first is this a list_table view?
2071
-        if (! isset($this->_route_config['list_table'])) {
2072
-            return;
2073
-        } //not a list_table view so get out.
2074
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2075
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2076
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2077
-            // user error msg
2078
-            $error_msg = esc_html__(
2079
-                'An error occurred. The requested list table views could not be found.',
2080
-                'event_espresso'
2081
-            );
2082
-            // developer error msg
2083
-            $error_msg .= '||'
2084
-                          . sprintf(
2085
-                              esc_html__(
2086
-                                  '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.',
2087
-                                  'event_espresso'
2088
-                              ),
2089
-                              $this->_req_action,
2090
-                              $list_table_view
2091
-                          );
2092
-            throw new EE_Error($error_msg);
2093
-        }
2094
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2095
-        $this->_views = apply_filters(
2096
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2097
-            $this->_views
2098
-        );
2099
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2100
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2101
-        $this->_set_list_table_view();
2102
-        $this->_set_list_table_object();
2103
-    }
2104
-
2105
-
2106
-    /**
2107
-     * set current view for List Table
2108
-     *
2109
-     * @return void
2110
-     */
2111
-    protected function _set_list_table_view()
2112
-    {
2113
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2114
-        // looking at active items or dumpster diving ?
2115
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2116
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2117
-        } else {
2118
-            $this->_view = sanitize_key($this->_req_data['status']);
2119
-        }
2120
-    }
2121
-
2122
-
2123
-    /**
2124
-     * _set_list_table_object
2125
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2126
-     *
2127
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2128
-     * @throws \InvalidArgumentException
2129
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2130
-     * @throws EE_Error
2131
-     * @throws InvalidInterfaceException
2132
-     */
2133
-    protected function _set_list_table_object()
2134
-    {
2135
-        if (isset($this->_route_config['list_table'])) {
2136
-            if (! class_exists($this->_route_config['list_table'])) {
2137
-                throw new EE_Error(
2138
-                    sprintf(
2139
-                        esc_html__(
2140
-                            '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.',
2141
-                            'event_espresso'
2142
-                        ),
2143
-                        $this->_route_config['list_table'],
2144
-                        get_class($this)
2145
-                    )
2146
-                );
2147
-            }
2148
-            $this->_list_table_object = $this->loader->getShared(
2149
-                $this->_route_config['list_table'],
2150
-                array($this)
2151
-            );
2152
-        }
2153
-    }
2154
-
2155
-
2156
-    /**
2157
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2158
-     *
2159
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2160
-     *                                                    urls.  The array should be indexed by the view it is being
2161
-     *                                                    added to.
2162
-     * @return array
2163
-     */
2164
-    public function get_list_table_view_RLs($extra_query_args = array())
2165
-    {
2166
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2167
-        if (empty($this->_views)) {
2168
-            $this->_views = array();
2169
-        }
2170
-        // cycle thru views
2171
-        foreach ($this->_views as $key => $view) {
2172
-            $query_args = array();
2173
-            // check for current view
2174
-            $this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2175
-            $query_args['action'] = $this->_req_action;
2176
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2177
-            $query_args['status'] = $view['slug'];
2178
-            // merge any other arguments sent in.
2179
-            if (isset($extra_query_args[ $view['slug'] ])) {
2180
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2181
-            }
2182
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2183
-        }
2184
-        return $this->_views;
2185
-    }
2186
-
2187
-
2188
-    /**
2189
-     * _entries_per_page_dropdown
2190
-     * generates a drop down box for selecting the number of visible rows in an admin page list table
2191
-     *
2192
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2193
-     *         WP does it.
2194
-     * @param int $max_entries total number of rows in the table
2195
-     * @return string
2196
-     */
2197
-    protected function _entries_per_page_dropdown($max_entries = 0)
2198
-    {
2199
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2200
-        $values = array(10, 25, 50, 100);
2201
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2202
-        if ($max_entries) {
2203
-            $values[] = $max_entries;
2204
-            sort($values);
2205
-        }
2206
-        $entries_per_page_dropdown = '
104
+	/**
105
+	 * @var array $_route_config
106
+	 */
107
+	protected $_route_config;
108
+
109
+	/**
110
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
111
+	 * actions.
112
+	 *
113
+	 * @since 4.6.x
114
+	 * @var array.
115
+	 */
116
+	protected $_default_route_query_args;
117
+
118
+	// set via request page and action args.
119
+	protected $_current_page;
120
+
121
+	protected $_current_view;
122
+
123
+	protected $_current_page_view_url;
124
+
125
+	// sanitized request action (and nonce)
126
+
127
+	/**
128
+	 * @var string $_req_action
129
+	 */
130
+	protected $_req_action;
131
+
132
+	/**
133
+	 * @var string $_req_nonce
134
+	 */
135
+	protected $_req_nonce;
136
+
137
+	// search related
138
+	protected $_search_btn_label;
139
+
140
+	protected $_search_box_callback;
141
+
142
+	/**
143
+	 * WP Current Screen object
144
+	 *
145
+	 * @var WP_Screen
146
+	 */
147
+	protected $_current_screen;
148
+
149
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
150
+	protected $_hook_obj;
151
+
152
+	// for holding incoming request data
153
+	protected $_req_data;
154
+
155
+	// yes / no array for admin form fields
156
+	protected $_yes_no_values = array();
157
+
158
+	// some default things shared by all child classes
159
+	protected $_default_espresso_metaboxes;
160
+
161
+	/**
162
+	 *    EE_Registry Object
163
+	 *
164
+	 * @var    EE_Registry
165
+	 */
166
+	protected $EE = null;
167
+
168
+
169
+	/**
170
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
171
+	 *
172
+	 * @var boolean
173
+	 */
174
+	protected $_is_caf = false;
175
+
176
+
177
+	/**
178
+	 * @Constructor
179
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
180
+	 * @throws EE_Error
181
+	 * @throws InvalidArgumentException
182
+	 * @throws ReflectionException
183
+	 * @throws InvalidDataTypeException
184
+	 * @throws InvalidInterfaceException
185
+	 */
186
+	public function __construct($routing = true)
187
+	{
188
+		$this->loader = LoaderFactory::getLoader();
189
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
190
+			$this->_is_caf = true;
191
+		}
192
+		$this->_yes_no_values = array(
193
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
194
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
195
+		);
196
+		// set the _req_data property.
197
+		$this->_req_data = array_merge($_GET, $_POST);
198
+		// routing enabled?
199
+		$this->_routing = $routing;
200
+		// set initial page props (child method)
201
+		$this->_init_page_props();
202
+		// set global defaults
203
+		$this->_set_defaults();
204
+		// set early because incoming requests could be ajax related and we need to register those hooks.
205
+		$this->_global_ajax_hooks();
206
+		$this->_ajax_hooks();
207
+		// other_page_hooks have to be early too.
208
+		$this->_do_other_page_hooks();
209
+		// This just allows us to have extending classes do something specific
210
+		// before the parent constructor runs _page_setup().
211
+		if (method_exists($this, '_before_page_setup')) {
212
+			$this->_before_page_setup();
213
+		}
214
+		// set up page dependencies
215
+		$this->_page_setup();
216
+	}
217
+
218
+
219
+	/**
220
+	 * _init_page_props
221
+	 * Child classes use to set at least the following properties:
222
+	 * $page_slug.
223
+	 * $page_label.
224
+	 *
225
+	 * @abstract
226
+	 * @return void
227
+	 */
228
+	abstract protected function _init_page_props();
229
+
230
+
231
+	/**
232
+	 * _ajax_hooks
233
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
234
+	 * Note: within the ajax callback methods.
235
+	 *
236
+	 * @abstract
237
+	 * @return void
238
+	 */
239
+	abstract protected function _ajax_hooks();
240
+
241
+
242
+	/**
243
+	 * _define_page_props
244
+	 * child classes define page properties in here.  Must include at least:
245
+	 * $_admin_base_url = base_url for all admin pages
246
+	 * $_admin_page_title = default admin_page_title for admin pages
247
+	 * $_labels = array of default labels for various automatically generated elements:
248
+	 *    array(
249
+	 *        'buttons' => array(
250
+	 *            'add' => esc_html__('label for add new button'),
251
+	 *            'edit' => esc_html__('label for edit button'),
252
+	 *            'delete' => esc_html__('label for delete button')
253
+	 *            )
254
+	 *        )
255
+	 *
256
+	 * @abstract
257
+	 * @return void
258
+	 */
259
+	abstract protected function _define_page_props();
260
+
261
+
262
+	/**
263
+	 * _set_page_routes
264
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
265
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
266
+	 * have a 'default' route. Here's the format
267
+	 * $this->_page_routes = array(
268
+	 *        'default' => array(
269
+	 *            'func' => '_default_method_handling_route',
270
+	 *            'args' => array('array','of','args'),
271
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
272
+	 *            ajax request, backend processing)
273
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
274
+	 *            headers route after.  The string you enter here should match the defined route reference for a
275
+	 *            headers sent route.
276
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
277
+	 *            this route.
278
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
279
+	 *            checks).
280
+	 *        ),
281
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
282
+	 *        handling method.
283
+	 *        )
284
+	 * )
285
+	 *
286
+	 * @abstract
287
+	 * @return void
288
+	 */
289
+	abstract protected function _set_page_routes();
290
+
291
+
292
+	/**
293
+	 * _set_page_config
294
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
295
+	 * array corresponds to the page_route for the loaded page. Format:
296
+	 * $this->_page_config = array(
297
+	 *        'default' => array(
298
+	 *            'labels' => array(
299
+	 *                'buttons' => array(
300
+	 *                    'add' => esc_html__('label for adding item'),
301
+	 *                    'edit' => esc_html__('label for editing item'),
302
+	 *                    'delete' => esc_html__('label for deleting item')
303
+	 *                ),
304
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
305
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
306
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
307
+	 *            _define_page_props() method
308
+	 *            'nav' => array(
309
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
310
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
311
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
312
+	 *                'order' => 10, //required to indicate tab position.
313
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
314
+	 *                displayed then add this parameter.
315
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
316
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
317
+	 *            metaboxes set for eventespresso admin pages.
318
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
319
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
320
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
321
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
322
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
323
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
324
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
325
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
326
+	 *            want to display.
327
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
328
+	 *                'tab_id' => array(
329
+	 *                    'title' => 'tab_title',
330
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
331
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
332
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
333
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
334
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
335
+	 *                    attempt to use the callback which should match the name of a method in the class
336
+	 *                    ),
337
+	 *                'tab2_id' => array(
338
+	 *                    'title' => 'tab2 title',
339
+	 *                    'filename' => 'file_name_2'
340
+	 *                    'callback' => 'callback_method_for_content',
341
+	 *                 ),
342
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
343
+	 *            help tab area on an admin page. @link
344
+	 *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
345
+	 *            'help_tour' => array(
346
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
347
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
348
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
349
+	 *            ),
350
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
351
+	 *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
352
+	 *            just set
353
+	 *            'require_nonce' to FALSE
354
+	 *            )
355
+	 * )
356
+	 *
357
+	 * @abstract
358
+	 * @return void
359
+	 */
360
+	abstract protected function _set_page_config();
361
+
362
+
363
+
364
+
365
+
366
+	/** end sample help_tour methods **/
367
+	/**
368
+	 * _add_screen_options
369
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
370
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
371
+	 * to a particular view.
372
+	 *
373
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
374
+	 *         see also WP_Screen object documents...
375
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
376
+	 * @abstract
377
+	 * @return void
378
+	 */
379
+	abstract protected function _add_screen_options();
380
+
381
+
382
+	/**
383
+	 * _add_feature_pointers
384
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
385
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
386
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
387
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
388
+	 * extended) also see:
389
+	 *
390
+	 * @link   http://eamann.com/tech/wordpress-portland/
391
+	 * @abstract
392
+	 * @return void
393
+	 */
394
+	abstract protected function _add_feature_pointers();
395
+
396
+
397
+	/**
398
+	 * load_scripts_styles
399
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
400
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
401
+	 * scripts/styles per view by putting them in a dynamic function in this format
402
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
403
+	 *
404
+	 * @abstract
405
+	 * @return void
406
+	 */
407
+	abstract public function load_scripts_styles();
408
+
409
+
410
+	/**
411
+	 * admin_init
412
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
413
+	 * all pages/views loaded by child class.
414
+	 *
415
+	 * @abstract
416
+	 * @return void
417
+	 */
418
+	abstract public function admin_init();
419
+
420
+
421
+	/**
422
+	 * admin_notices
423
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
424
+	 * all pages/views loaded by child class.
425
+	 *
426
+	 * @abstract
427
+	 * @return void
428
+	 */
429
+	abstract public function admin_notices();
430
+
431
+
432
+	/**
433
+	 * admin_footer_scripts
434
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
435
+	 * will apply to all pages/views loaded by child class.
436
+	 *
437
+	 * @return void
438
+	 */
439
+	abstract public function admin_footer_scripts();
440
+
441
+
442
+	/**
443
+	 * admin_footer
444
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
445
+	 * apply to all pages/views loaded by child class.
446
+	 *
447
+	 * @return void
448
+	 */
449
+	public function admin_footer()
450
+	{
451
+	}
452
+
453
+
454
+	/**
455
+	 * _global_ajax_hooks
456
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
457
+	 * Note: within the ajax callback methods.
458
+	 *
459
+	 * @abstract
460
+	 * @return void
461
+	 */
462
+	protected function _global_ajax_hooks()
463
+	{
464
+		// for lazy loading of metabox content
465
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
466
+	}
467
+
468
+
469
+	public function ajax_metabox_content()
470
+	{
471
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
472
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
473
+		self::cached_rss_display($contentid, $url);
474
+		wp_die();
475
+	}
476
+
477
+
478
+	/**
479
+	 * _page_setup
480
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
481
+	 * doesn't match the object.
482
+	 *
483
+	 * @final
484
+	 * @return void
485
+	 * @throws EE_Error
486
+	 * @throws InvalidArgumentException
487
+	 * @throws ReflectionException
488
+	 * @throws InvalidDataTypeException
489
+	 * @throws InvalidInterfaceException
490
+	 */
491
+	final protected function _page_setup()
492
+	{
493
+		// requires?
494
+		// admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
495
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
496
+		// next verify if we need to load anything...
497
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
498
+		$this->page_folder = strtolower(
499
+			str_replace(array('_Admin_Page', 'Extend_'), '', get_class($this))
500
+		);
501
+		global $ee_menu_slugs;
502
+		$ee_menu_slugs = (array) $ee_menu_slugs;
503
+		if (! defined('DOING_AJAX') && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))) {
504
+			return;
505
+		}
506
+		// becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
507
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] === '-1') {
508
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] !== '-1'
509
+				? $this->_req_data['action2']
510
+				: $this->_req_data['action'];
511
+		}
512
+		// then set blank or -1 action values to 'default'
513
+		$this->_req_action = isset($this->_req_data['action'])
514
+							 && ! empty($this->_req_data['action'])
515
+							 && $this->_req_data['action'] !== '-1'
516
+			? sanitize_key($this->_req_data['action'])
517
+			: 'default';
518
+		// if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.
519
+		//  This covers cases where we're coming in from a list table that isn't on the default route.
520
+		$this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
521
+			? $this->_req_data['route'] : $this->_req_action;
522
+		// however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
523
+		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route'])
524
+			? $this->_req_data['route']
525
+			: $this->_req_action;
526
+		$this->_current_view = $this->_req_action;
527
+		$this->_req_nonce = $this->_req_action . '_nonce';
528
+		$this->_define_page_props();
529
+		$this->_current_page_view_url = add_query_arg(
530
+			array('page' => $this->_current_page, 'action' => $this->_current_view),
531
+			$this->_admin_base_url
532
+		);
533
+		// default things
534
+		$this->_default_espresso_metaboxes = array(
535
+			'_espresso_news_post_box',
536
+			'_espresso_links_post_box',
537
+			'_espresso_ratings_request',
538
+			'_espresso_sponsors_post_box',
539
+		);
540
+		// set page configs
541
+		$this->_set_page_routes();
542
+		$this->_set_page_config();
543
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
544
+		if (isset($this->_req_data['wp_referer'])) {
545
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
546
+		}
547
+		// for caffeinated and other extended functionality.
548
+		//  If there is a _extend_page_config method
549
+		// then let's run that to modify the all the various page configuration arrays
550
+		if (method_exists($this, '_extend_page_config')) {
551
+			$this->_extend_page_config();
552
+		}
553
+		// for CPT and other extended functionality.
554
+		// If there is an _extend_page_config_for_cpt
555
+		// then let's run that to modify all the various page configuration arrays.
556
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
557
+			$this->_extend_page_config_for_cpt();
558
+		}
559
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
560
+		$this->_page_routes = apply_filters(
561
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
562
+			$this->_page_routes,
563
+			$this
564
+		);
565
+		$this->_page_config = apply_filters(
566
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
567
+			$this->_page_config,
568
+			$this
569
+		);
570
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
571
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
572
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
573
+			add_action(
574
+				'AHEE__EE_Admin_Page__route_admin_request',
575
+				array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
576
+				10,
577
+				2
578
+			);
579
+		}
580
+		// next route only if routing enabled
581
+		if ($this->_routing && ! defined('DOING_AJAX')) {
582
+			$this->_verify_routes();
583
+			// next let's just check user_access and kill if no access
584
+			$this->check_user_access();
585
+			if ($this->_is_UI_request) {
586
+				// admin_init stuff - global, all views for this page class, specific view
587
+				add_action('admin_init', array($this, 'admin_init'), 10);
588
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
589
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
590
+				}
591
+			} else {
592
+				// hijack regular WP loading and route admin request immediately
593
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
594
+				$this->route_admin_request();
595
+			}
596
+		}
597
+	}
598
+
599
+
600
+	/**
601
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
602
+	 *
603
+	 * @return void
604
+	 * @throws ReflectionException
605
+	 * @throws EE_Error
606
+	 */
607
+	private function _do_other_page_hooks()
608
+	{
609
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
610
+		foreach ($registered_pages as $page) {
611
+			// now let's setup the file name and class that should be present
612
+			$classname = str_replace('.class.php', '', $page);
613
+			// autoloaders should take care of loading file
614
+			if (! class_exists($classname)) {
615
+				$error_msg[] = sprintf(
616
+					esc_html__(
617
+						'Something went wrong with loading the %s admin hooks page.',
618
+						'event_espresso'
619
+					),
620
+					$page
621
+				);
622
+				$error_msg[] = $error_msg[0]
623
+							   . "\r\n"
624
+							   . sprintf(
625
+								   esc_html__(
626
+									   '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',
627
+									   'event_espresso'
628
+								   ),
629
+								   $page,
630
+								   '<br />',
631
+								   '<strong>' . $classname . '</strong>'
632
+							   );
633
+				throw new EE_Error(implode('||', $error_msg));
634
+			}
635
+			$a = new ReflectionClass($classname);
636
+			// notice we are passing the instance of this class to the hook object.
637
+			$hookobj[] = $a->newInstance($this);
638
+		}
639
+	}
640
+
641
+
642
+	public function load_page_dependencies()
643
+	{
644
+		try {
645
+			$this->_load_page_dependencies();
646
+		} catch (EE_Error $e) {
647
+			$e->get_error();
648
+		}
649
+	}
650
+
651
+
652
+	/**
653
+	 * load_page_dependencies
654
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
655
+	 *
656
+	 * @return void
657
+	 * @throws DomainException
658
+	 * @throws EE_Error
659
+	 * @throws InvalidArgumentException
660
+	 * @throws InvalidDataTypeException
661
+	 * @throws InvalidInterfaceException
662
+	 * @throws ReflectionException
663
+	 */
664
+	protected function _load_page_dependencies()
665
+	{
666
+		// let's set the current_screen and screen options to override what WP set
667
+		$this->_current_screen = get_current_screen();
668
+		// load admin_notices - global, page class, and view specific
669
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
670
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
671
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
672
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
673
+		}
674
+		// load network admin_notices - global, page class, and view specific
675
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
676
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
677
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
678
+		}
679
+		// this will save any per_page screen options if they are present
680
+		$this->_set_per_page_screen_options();
681
+		// setup list table properties
682
+		$this->_set_list_table();
683
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
684
+		// However in some cases the metaboxes will need to be added within a route handling callback.
685
+		$this->_add_registered_meta_boxes();
686
+		$this->_add_screen_columns();
687
+		// add screen options - global, page child class, and view specific
688
+		$this->_add_global_screen_options();
689
+		$this->_add_screen_options();
690
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
691
+		if (method_exists($this, $add_screen_options)) {
692
+			$this->{$add_screen_options}();
693
+		}
694
+		// add help tab(s) and tours- set via page_config and qtips.
695
+		$this->_add_help_tour();
696
+		$this->_add_help_tabs();
697
+		$this->_add_qtips();
698
+		// add feature_pointers - global, page child class, and view specific
699
+		$this->_add_feature_pointers();
700
+		$this->_add_global_feature_pointers();
701
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
702
+		if (method_exists($this, $add_feature_pointer)) {
703
+			$this->{$add_feature_pointer}();
704
+		}
705
+		// enqueue scripts/styles - global, page class, and view specific
706
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
707
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
708
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
709
+			add_action('admin_enqueue_scripts', array($this, "load_scripts_styles_{$this->_current_view}"), 15);
710
+		}
711
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
712
+		// admin_print_footer_scripts - global, page child class, and view specific.
713
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
714
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
715
+		// is a good use case. Notice the late priority we're giving these
716
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
717
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
718
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
719
+			add_action('admin_print_footer_scripts', array($this, "admin_footer_scripts_{$this->_current_view}"), 101);
720
+		}
721
+		// admin footer scripts
722
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
723
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
724
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
725
+			add_action('admin_footer', array($this, "admin_footer_{$this->_current_view}"), 101);
726
+		}
727
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
728
+		// targeted hook
729
+		do_action(
730
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
731
+		);
732
+	}
733
+
734
+
735
+	/**
736
+	 * _set_defaults
737
+	 * This sets some global defaults for class properties.
738
+	 */
739
+	private function _set_defaults()
740
+	{
741
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
742
+		$this->_event = $this->_template_path = $this->_column_template_path = null;
743
+		$this->_nav_tabs = $this->_views = $this->_page_routes = array();
744
+		$this->_page_config = $this->_default_route_query_args = array();
745
+		$this->_default_nav_tab_name = 'overview';
746
+		// init template args
747
+		$this->_template_args = array(
748
+			'admin_page_header'  => '',
749
+			'admin_page_content' => '',
750
+			'post_body_content'  => '',
751
+			'before_list_table'  => '',
752
+			'after_list_table'   => '',
753
+		);
754
+	}
755
+
756
+
757
+	/**
758
+	 * route_admin_request
759
+	 *
760
+	 * @see    _route_admin_request()
761
+	 * @return exception|void error
762
+	 * @throws InvalidArgumentException
763
+	 * @throws InvalidInterfaceException
764
+	 * @throws InvalidDataTypeException
765
+	 * @throws EE_Error
766
+	 * @throws ReflectionException
767
+	 */
768
+	public function route_admin_request()
769
+	{
770
+		try {
771
+			$this->_route_admin_request();
772
+		} catch (EE_Error $e) {
773
+			$e->get_error();
774
+		}
775
+	}
776
+
777
+
778
+	public function set_wp_page_slug($wp_page_slug)
779
+	{
780
+		$this->_wp_page_slug = $wp_page_slug;
781
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
782
+		if (is_network_admin()) {
783
+			$this->_wp_page_slug .= '-network';
784
+		}
785
+	}
786
+
787
+
788
+	/**
789
+	 * _verify_routes
790
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
791
+	 * we know if we need to drop out.
792
+	 *
793
+	 * @return bool
794
+	 * @throws EE_Error
795
+	 */
796
+	protected function _verify_routes()
797
+	{
798
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
799
+		if (! $this->_current_page && ! defined('DOING_AJAX')) {
800
+			return false;
801
+		}
802
+		$this->_route = false;
803
+		// check that the page_routes array is not empty
804
+		if (empty($this->_page_routes)) {
805
+			// user error msg
806
+			$error_msg = sprintf(
807
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
808
+				$this->_admin_page_title
809
+			);
810
+			// developer error msg
811
+			$error_msg .= '||' . $error_msg
812
+						  . esc_html__(
813
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
814
+							  'event_espresso'
815
+						  );
816
+			throw new EE_Error($error_msg);
817
+		}
818
+		// and that the requested page route exists
819
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
820
+			$this->_route = $this->_page_routes[ $this->_req_action ];
821
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
822
+				? $this->_page_config[ $this->_req_action ] : array();
823
+		} else {
824
+			// user error msg
825
+			$error_msg = sprintf(
826
+				esc_html__(
827
+					'The requested page route does not exist for the %s admin page.',
828
+					'event_espresso'
829
+				),
830
+				$this->_admin_page_title
831
+			);
832
+			// developer error msg
833
+			$error_msg .= '||' . $error_msg
834
+						  . sprintf(
835
+							  esc_html__(
836
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
837
+								  'event_espresso'
838
+							  ),
839
+							  $this->_req_action
840
+						  );
841
+			throw new EE_Error($error_msg);
842
+		}
843
+		// and that a default route exists
844
+		if (! array_key_exists('default', $this->_page_routes)) {
845
+			// user error msg
846
+			$error_msg = sprintf(
847
+				esc_html__(
848
+					'A default page route has not been set for the % admin page.',
849
+					'event_espresso'
850
+				),
851
+				$this->_admin_page_title
852
+			);
853
+			// developer error msg
854
+			$error_msg .= '||' . $error_msg
855
+						  . esc_html__(
856
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
857
+							  'event_espresso'
858
+						  );
859
+			throw new EE_Error($error_msg);
860
+		}
861
+		// first lets' catch if the UI request has EVER been set.
862
+		if ($this->_is_UI_request === null) {
863
+			// lets set if this is a UI request or not.
864
+			$this->_is_UI_request = ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true;
865
+			// wait a minute... we might have a noheader in the route array
866
+			$this->_is_UI_request = is_array($this->_route)
867
+									&& isset($this->_route['noheader'])
868
+									&& $this->_route['noheader'] ? false : $this->_is_UI_request;
869
+		}
870
+		$this->_set_current_labels();
871
+		return true;
872
+	}
873
+
874
+
875
+	/**
876
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
877
+	 *
878
+	 * @param  string $route the route name we're verifying
879
+	 * @return mixed (bool|Exception)      we'll throw an exception if this isn't a valid route.
880
+	 * @throws EE_Error
881
+	 */
882
+	protected function _verify_route($route)
883
+	{
884
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
885
+			return true;
886
+		}
887
+		// user error msg
888
+		$error_msg = sprintf(
889
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
890
+			$this->_admin_page_title
891
+		);
892
+		// developer error msg
893
+		$error_msg .= '||' . $error_msg
894
+					  . sprintf(
895
+						  esc_html__(
896
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
897
+							  'event_espresso'
898
+						  ),
899
+						  $route
900
+					  );
901
+		throw new EE_Error($error_msg);
902
+	}
903
+
904
+
905
+	/**
906
+	 * perform nonce verification
907
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
908
+	 * using this method (and save retyping!)
909
+	 *
910
+	 * @param  string $nonce     The nonce sent
911
+	 * @param  string $nonce_ref The nonce reference string (name0)
912
+	 * @return void
913
+	 * @throws EE_Error
914
+	 */
915
+	protected function _verify_nonce($nonce, $nonce_ref)
916
+	{
917
+		// verify nonce against expected value
918
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
919
+			// these are not the droids you are looking for !!!
920
+			$msg = sprintf(
921
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
922
+				'<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
923
+				'</a>'
924
+			);
925
+			if (WP_DEBUG) {
926
+				$msg .= "\n  "
927
+						. sprintf(
928
+							esc_html__(
929
+								'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
930
+								'event_espresso'
931
+							),
932
+							__CLASS__
933
+						);
934
+			}
935
+			if (! defined('DOING_AJAX')) {
936
+				wp_die($msg);
937
+			} else {
938
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
939
+				$this->_return_json();
940
+			}
941
+		}
942
+	}
943
+
944
+
945
+	/**
946
+	 * _route_admin_request()
947
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
948
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
949
+	 * in the page routes and then will try to load the corresponding method.
950
+	 *
951
+	 * @return void
952
+	 * @throws EE_Error
953
+	 * @throws InvalidArgumentException
954
+	 * @throws InvalidDataTypeException
955
+	 * @throws InvalidInterfaceException
956
+	 * @throws ReflectionException
957
+	 */
958
+	protected function _route_admin_request()
959
+	{
960
+		if (! $this->_is_UI_request) {
961
+			$this->_verify_routes();
962
+		}
963
+		$nonce_check = isset($this->_route_config['require_nonce'])
964
+			? $this->_route_config['require_nonce']
965
+			: true;
966
+		if ($this->_req_action !== 'default' && $nonce_check) {
967
+			// set nonce from post data
968
+			$nonce = isset($this->_req_data[ $this->_req_nonce ])
969
+				? sanitize_text_field($this->_req_data[ $this->_req_nonce ])
970
+				: '';
971
+			$this->_verify_nonce($nonce, $this->_req_nonce);
972
+		}
973
+		// set the nav_tabs array but ONLY if this is  UI_request
974
+		if ($this->_is_UI_request) {
975
+			$this->_set_nav_tabs();
976
+		}
977
+		// grab callback function
978
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
979
+		// check if callback has args
980
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
981
+		$error_msg = '';
982
+		// action right before calling route
983
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
984
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
985
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
986
+		}
987
+		// right before calling the route, let's remove _wp_http_referer from the
988
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
989
+		$_SERVER['REQUEST_URI'] = remove_query_arg(
990
+			'_wp_http_referer',
991
+			wp_unslash($_SERVER['REQUEST_URI'])
992
+		);
993
+		if (! empty($func)) {
994
+			if (is_array($func)) {
995
+				list($class, $method) = $func;
996
+			} elseif (strpos($func, '::') !== false) {
997
+				list($class, $method) = explode('::', $func);
998
+			} else {
999
+				$class = $this;
1000
+				$method = $func;
1001
+			}
1002
+			if (! (is_object($class) && $class === $this)) {
1003
+				// send along this admin page object for access by addons.
1004
+				$args['admin_page_object'] = $this;
1005
+			}
1006
+			if (// is it a method on a class that doesn't work?
1007
+				(
1008
+					(
1009
+						method_exists($class, $method)
1010
+						&& call_user_func_array(array($class, $method), $args) === false
1011
+					)
1012
+					&& (
1013
+						// is it a standalone function that doesn't work?
1014
+						function_exists($method)
1015
+						&& call_user_func_array(
1016
+							$func,
1017
+							array_merge(array('admin_page_object' => $this), $args)
1018
+						) === false
1019
+					)
1020
+				)
1021
+				|| (
1022
+					// is it neither a class method NOR a standalone function?
1023
+					! method_exists($class, $method)
1024
+					&& ! function_exists($method)
1025
+				)
1026
+			) {
1027
+				// user error msg
1028
+				$error_msg = esc_html__(
1029
+					'An error occurred. The  requested page route could not be found.',
1030
+					'event_espresso'
1031
+				);
1032
+				// developer error msg
1033
+				$error_msg .= '||';
1034
+				$error_msg .= sprintf(
1035
+					esc_html__(
1036
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1037
+						'event_espresso'
1038
+					),
1039
+					$method
1040
+				);
1041
+			}
1042
+			if (! empty($error_msg)) {
1043
+				throw new EE_Error($error_msg);
1044
+			}
1045
+		}
1046
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1047
+		// then we need to reset the routing properties to the new route.
1048
+		// 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.
1049
+		if ($this->_is_UI_request === false
1050
+			&& is_array($this->_route)
1051
+			&& ! empty($this->_route['headers_sent_route'])
1052
+		) {
1053
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1054
+		}
1055
+	}
1056
+
1057
+
1058
+	/**
1059
+	 * This method just allows the resetting of page properties in the case where a no headers
1060
+	 * route redirects to a headers route in its route config.
1061
+	 *
1062
+	 * @since   4.3.0
1063
+	 * @param  string $new_route New (non header) route to redirect to.
1064
+	 * @return   void
1065
+	 * @throws ReflectionException
1066
+	 * @throws InvalidArgumentException
1067
+	 * @throws InvalidInterfaceException
1068
+	 * @throws InvalidDataTypeException
1069
+	 * @throws EE_Error
1070
+	 */
1071
+	protected function _reset_routing_properties($new_route)
1072
+	{
1073
+		$this->_is_UI_request = true;
1074
+		// now we set the current route to whatever the headers_sent_route is set at
1075
+		$this->_req_data['action'] = $new_route;
1076
+		// rerun page setup
1077
+		$this->_page_setup();
1078
+	}
1079
+
1080
+
1081
+	/**
1082
+	 * _add_query_arg
1083
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1084
+	 *(internally just uses EEH_URL's function with the same name)
1085
+	 *
1086
+	 * @param array  $args
1087
+	 * @param string $url
1088
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1089
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1090
+	 *                                        Example usage: If the current page is:
1091
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1092
+	 *                                        &action=default&event_id=20&month_range=March%202015
1093
+	 *                                        &_wpnonce=5467821
1094
+	 *                                        and you call:
1095
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1096
+	 *                                        array(
1097
+	 *                                        'action' => 'resend_something',
1098
+	 *                                        'page=>espresso_registrations'
1099
+	 *                                        ),
1100
+	 *                                        $some_url,
1101
+	 *                                        true
1102
+	 *                                        );
1103
+	 *                                        It will produce a url in this structure:
1104
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1105
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1106
+	 *                                        month_range]=March%202015
1107
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1108
+	 * @return string
1109
+	 */
1110
+	public static function add_query_args_and_nonce(
1111
+		$args = array(),
1112
+		$url = false,
1113
+		$sticky = false,
1114
+		$exclude_nonce = false
1115
+	) {
1116
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1117
+		if ($sticky) {
1118
+			$request = $_REQUEST;
1119
+			unset($request['_wp_http_referer']);
1120
+			unset($request['wp_referer']);
1121
+			foreach ($request as $key => $value) {
1122
+				// do not add nonces
1123
+				if (strpos($key, 'nonce') !== false) {
1124
+					continue;
1125
+				}
1126
+				$args[ 'wp_referer[' . $key . ']' ] = $value;
1127
+			}
1128
+		}
1129
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1130
+	}
1131
+
1132
+
1133
+	/**
1134
+	 * This returns a generated link that will load the related help tab.
1135
+	 *
1136
+	 * @param  string $help_tab_id the id for the connected help tab
1137
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1138
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1139
+	 * @uses EEH_Template::get_help_tab_link()
1140
+	 * @return string              generated link
1141
+	 */
1142
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1143
+	{
1144
+		return EEH_Template::get_help_tab_link(
1145
+			$help_tab_id,
1146
+			$this->page_slug,
1147
+			$this->_req_action,
1148
+			$icon_style,
1149
+			$help_text
1150
+		);
1151
+	}
1152
+
1153
+
1154
+	/**
1155
+	 * _add_help_tabs
1156
+	 * Note child classes define their help tabs within the page_config array.
1157
+	 *
1158
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1159
+	 * @return void
1160
+	 * @throws DomainException
1161
+	 * @throws EE_Error
1162
+	 */
1163
+	protected function _add_help_tabs()
1164
+	{
1165
+		$tour_buttons = '';
1166
+		if (isset($this->_page_config[ $this->_req_action ])) {
1167
+			$config = $this->_page_config[ $this->_req_action ];
1168
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1169
+			if (isset($this->_help_tour[ $this->_req_action ])) {
1170
+				$tb = array();
1171
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1172
+				foreach ($this->_help_tour['tours'] as $tour) {
1173
+					// if this is the end tour then we don't need to setup a button
1174
+					if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1175
+						continue;
1176
+					}
1177
+					$tb[] = '<button id="trigger-tour-'
1178
+							. $tour->get_slug()
1179
+							. '" class="button-primary trigger-ee-help-tour">'
1180
+							. $tour->get_label()
1181
+							. '</button>';
1182
+				}
1183
+				$tour_buttons .= implode('<br />', $tb);
1184
+				$tour_buttons .= '</div></div>';
1185
+			}
1186
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1187
+			if (is_array($config) && isset($config['help_sidebar'])) {
1188
+				// check that the callback given is valid
1189
+				if (! method_exists($this, $config['help_sidebar'])) {
1190
+					throw new EE_Error(
1191
+						sprintf(
1192
+							esc_html__(
1193
+								'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',
1194
+								'event_espresso'
1195
+							),
1196
+							$config['help_sidebar'],
1197
+							get_class($this)
1198
+						)
1199
+					);
1200
+				}
1201
+				$content = apply_filters(
1202
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1203
+					$this->{$config['help_sidebar']}()
1204
+				);
1205
+				$content .= $tour_buttons; // add help tour buttons.
1206
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1207
+				$this->_current_screen->set_help_sidebar($content);
1208
+			}
1209
+			// if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1210
+			if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1211
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1212
+			}
1213
+			// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1214
+			if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1215
+				$_ht['id'] = $this->page_slug;
1216
+				$_ht['title'] = esc_html__('Help Tours', 'event_espresso');
1217
+				$_ht['content'] = '<p>'
1218
+								  . esc_html__(
1219
+									  'The buttons to the right allow you to start/restart any help tours available for this page',
1220
+									  'event_espresso'
1221
+								  ) . '</p>';
1222
+				$this->_current_screen->add_help_tab($_ht);
1223
+			}
1224
+			if (! isset($config['help_tabs'])) {
1225
+				return;
1226
+			} //no help tabs for this route
1227
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1228
+				// we're here so there ARE help tabs!
1229
+				// make sure we've got what we need
1230
+				if (! isset($cfg['title'])) {
1231
+					throw new EE_Error(
1232
+						esc_html__(
1233
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1234
+							'event_espresso'
1235
+						)
1236
+					);
1237
+				}
1238
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1239
+					throw new EE_Error(
1240
+						esc_html__(
1241
+							'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',
1242
+							'event_espresso'
1243
+						)
1244
+					);
1245
+				}
1246
+				// first priority goes to content.
1247
+				if (! empty($cfg['content'])) {
1248
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1249
+					// second priority goes to filename
1250
+				} elseif (! empty($cfg['filename'])) {
1251
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1252
+					// 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)
1253
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1254
+															 . basename($this->_get_dir())
1255
+															 . '/help_tabs/'
1256
+															 . $cfg['filename']
1257
+															 . '.help_tab.php' : $file_path;
1258
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1259
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1260
+						EE_Error::add_error(
1261
+							sprintf(
1262
+								esc_html__(
1263
+									'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',
1264
+									'event_espresso'
1265
+								),
1266
+								$tab_id,
1267
+								key($config),
1268
+								$file_path
1269
+							),
1270
+							__FILE__,
1271
+							__FUNCTION__,
1272
+							__LINE__
1273
+						);
1274
+						return;
1275
+					}
1276
+					$template_args['admin_page_obj'] = $this;
1277
+					$content = EEH_Template::display_template(
1278
+						$file_path,
1279
+						$template_args,
1280
+						true
1281
+					);
1282
+				} else {
1283
+					$content = '';
1284
+				}
1285
+				// check if callback is valid
1286
+				if (empty($content) && (
1287
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1288
+					)
1289
+				) {
1290
+					EE_Error::add_error(
1291
+						sprintf(
1292
+							esc_html__(
1293
+								'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.',
1294
+								'event_espresso'
1295
+							),
1296
+							$cfg['title']
1297
+						),
1298
+						__FILE__,
1299
+						__FUNCTION__,
1300
+						__LINE__
1301
+					);
1302
+					return;
1303
+				}
1304
+				// setup config array for help tab method
1305
+				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1306
+				$_ht = array(
1307
+					'id'       => $id,
1308
+					'title'    => $cfg['title'],
1309
+					'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1310
+					'content'  => $content,
1311
+				);
1312
+				$this->_current_screen->add_help_tab($_ht);
1313
+			}
1314
+		}
1315
+	}
1316
+
1317
+
1318
+	/**
1319
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1320
+	 * an array with properties for setting up usage of the joyride plugin
1321
+	 *
1322
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1323
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1324
+	 *         _set_page_config() comments
1325
+	 * @return void
1326
+	 * @throws EE_Error
1327
+	 * @throws InvalidArgumentException
1328
+	 * @throws InvalidDataTypeException
1329
+	 * @throws InvalidInterfaceException
1330
+	 */
1331
+	protected function _add_help_tour()
1332
+	{
1333
+		$tours = array();
1334
+		$this->_help_tour = array();
1335
+		// exit early if help tours are turned off globally
1336
+		if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1337
+			|| ! EE_Registry::instance()->CFG->admin->help_tour_activation
1338
+		) {
1339
+			return;
1340
+		}
1341
+		// loop through _page_config to find any help_tour defined
1342
+		foreach ($this->_page_config as $route => $config) {
1343
+			// we're only going to set things up for this route
1344
+			if ($route !== $this->_req_action) {
1345
+				continue;
1346
+			}
1347
+			if (isset($config['help_tour'])) {
1348
+				foreach ($config['help_tour'] as $tour) {
1349
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1350
+					// let's see if we can get that file...
1351
+					// if not its possible this is a decaf route not set in caffeinated
1352
+					// so lets try and get the caffeinated equivalent
1353
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1354
+															 . basename($this->_get_dir())
1355
+															 . '/help_tours/'
1356
+															 . $tour
1357
+															 . '.class.php' : $file_path;
1358
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1359
+					if (! is_readable($file_path)) {
1360
+						EE_Error::add_error(
1361
+							sprintf(
1362
+								esc_html__(
1363
+									'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',
1364
+									'event_espresso'
1365
+								),
1366
+								$file_path,
1367
+								$tour
1368
+							),
1369
+							__FILE__,
1370
+							__FUNCTION__,
1371
+							__LINE__
1372
+						);
1373
+						return;
1374
+					}
1375
+					require_once $file_path;
1376
+					if (! class_exists($tour)) {
1377
+						$error_msg[] = sprintf(
1378
+							esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1379
+							$tour
1380
+						);
1381
+						$error_msg[] = $error_msg[0] . "\r\n"
1382
+									   . sprintf(
1383
+										   esc_html__(
1384
+											   '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.',
1385
+											   'event_espresso'
1386
+										   ),
1387
+										   $tour,
1388
+										   '<br />',
1389
+										   $tour,
1390
+										   $this->_req_action,
1391
+										   get_class($this)
1392
+									   );
1393
+						throw new EE_Error(implode('||', $error_msg));
1394
+					}
1395
+					$tour_obj = new $tour($this->_is_caf);
1396
+					$tours[] = $tour_obj;
1397
+					$this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1398
+				}
1399
+				// let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1400
+				$end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1401
+				$tours[] = $end_stop_tour;
1402
+				$this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1403
+			}
1404
+		}
1405
+		if (! empty($tours)) {
1406
+			$this->_help_tour['tours'] = $tours;
1407
+		}
1408
+		// that's it!  Now that the $_help_tours property is set (or not)
1409
+		// the scripts and html should be taken care of automatically.
1410
+	}
1411
+
1412
+
1413
+	/**
1414
+	 * This simply sets up any qtips that have been defined in the page config
1415
+	 *
1416
+	 * @return void
1417
+	 */
1418
+	protected function _add_qtips()
1419
+	{
1420
+		if (isset($this->_route_config['qtips'])) {
1421
+			$qtips = (array) $this->_route_config['qtips'];
1422
+			// load qtip loader
1423
+			$path = array(
1424
+				$this->_get_dir() . '/qtips/',
1425
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1426
+			);
1427
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1428
+		}
1429
+	}
1430
+
1431
+
1432
+	/**
1433
+	 * _set_nav_tabs
1434
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1435
+	 * wish to add additional tabs or modify accordingly.
1436
+	 *
1437
+	 * @return void
1438
+	 * @throws InvalidArgumentException
1439
+	 * @throws InvalidInterfaceException
1440
+	 * @throws InvalidDataTypeException
1441
+	 */
1442
+	protected function _set_nav_tabs()
1443
+	{
1444
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1445
+		$i = 0;
1446
+		foreach ($this->_page_config as $slug => $config) {
1447
+			if (! is_array($config)
1448
+				|| (
1449
+					is_array($config)
1450
+					&& (
1451
+						(isset($config['nav']) && ! $config['nav'])
1452
+						|| ! isset($config['nav'])
1453
+					)
1454
+				)
1455
+			) {
1456
+				continue;
1457
+			}
1458
+			// no nav tab for this config
1459
+			// check for persistent flag
1460
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1461
+				// nav tab is only to appear when route requested.
1462
+				continue;
1463
+			}
1464
+			if (! $this->check_user_access($slug, true)) {
1465
+				// no nav tab because current user does not have access.
1466
+				continue;
1467
+			}
1468
+			$css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1469
+			$this->_nav_tabs[ $slug ] = array(
1470
+				'url'       => isset($config['nav']['url'])
1471
+					? $config['nav']['url']
1472
+					: self::add_query_args_and_nonce(
1473
+						array('action' => $slug),
1474
+						$this->_admin_base_url
1475
+					),
1476
+				'link_text' => isset($config['nav']['label'])
1477
+					? $config['nav']['label']
1478
+					: ucwords(
1479
+						str_replace('_', ' ', $slug)
1480
+					),
1481
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1482
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1483
+			);
1484
+			$i++;
1485
+		}
1486
+		// if $this->_nav_tabs is empty then lets set the default
1487
+		if (empty($this->_nav_tabs)) {
1488
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = array(
1489
+				'url'       => $this->_admin_base_url,
1490
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1491
+				'css_class' => 'nav-tab-active',
1492
+				'order'     => 10,
1493
+			);
1494
+		}
1495
+		// now let's sort the tabs according to order
1496
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1497
+	}
1498
+
1499
+
1500
+	/**
1501
+	 * _set_current_labels
1502
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1503
+	 * property array
1504
+	 *
1505
+	 * @return void
1506
+	 */
1507
+	private function _set_current_labels()
1508
+	{
1509
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1510
+			foreach ($this->_route_config['labels'] as $label => $text) {
1511
+				if (is_array($text)) {
1512
+					foreach ($text as $sublabel => $subtext) {
1513
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1514
+					}
1515
+				} else {
1516
+					$this->_labels[ $label ] = $text;
1517
+				}
1518
+			}
1519
+		}
1520
+	}
1521
+
1522
+
1523
+	/**
1524
+	 *        verifies user access for this admin page
1525
+	 *
1526
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1527
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1528
+	 *                               return false if verify fail.
1529
+	 * @return bool
1530
+	 * @throws InvalidArgumentException
1531
+	 * @throws InvalidDataTypeException
1532
+	 * @throws InvalidInterfaceException
1533
+	 */
1534
+	public function check_user_access($route_to_check = '', $verify_only = false)
1535
+	{
1536
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1537
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1538
+		$capability = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1539
+					  && is_array(
1540
+						  $this->_page_routes[ $route_to_check ]
1541
+					  )
1542
+					  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1543
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1544
+		if (empty($capability) && empty($route_to_check)) {
1545
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1546
+				: $this->_route['capability'];
1547
+		} else {
1548
+			$capability = empty($capability) ? 'manage_options' : $capability;
1549
+		}
1550
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1551
+		if (! defined('DOING_AJAX')
1552
+			&& (
1553
+				! function_exists('is_admin')
1554
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1555
+					$capability,
1556
+					$this->page_slug
1557
+					. '_'
1558
+					. $route_to_check,
1559
+					$id
1560
+				)
1561
+			)
1562
+		) {
1563
+			if ($verify_only) {
1564
+				return false;
1565
+			}
1566
+			if (is_user_logged_in()) {
1567
+				wp_die(__('You do not have access to this route.', 'event_espresso'));
1568
+			} else {
1569
+				return false;
1570
+			}
1571
+		}
1572
+		return true;
1573
+	}
1574
+
1575
+
1576
+	/**
1577
+	 * admin_init_global
1578
+	 * This runs all the code that we want executed within the WP admin_init hook.
1579
+	 * This method executes for ALL EE Admin pages.
1580
+	 *
1581
+	 * @return void
1582
+	 */
1583
+	public function admin_init_global()
1584
+	{
1585
+	}
1586
+
1587
+
1588
+	/**
1589
+	 * wp_loaded_global
1590
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1591
+	 * EE_Admin page and will execute on every EE Admin Page load
1592
+	 *
1593
+	 * @return void
1594
+	 */
1595
+	public function wp_loaded()
1596
+	{
1597
+	}
1598
+
1599
+
1600
+	/**
1601
+	 * admin_notices
1602
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1603
+	 * ALL EE_Admin pages.
1604
+	 *
1605
+	 * @return void
1606
+	 */
1607
+	public function admin_notices_global()
1608
+	{
1609
+		$this->_display_no_javascript_warning();
1610
+		$this->_display_espresso_notices();
1611
+	}
1612
+
1613
+
1614
+	public function network_admin_notices_global()
1615
+	{
1616
+		$this->_display_no_javascript_warning();
1617
+		$this->_display_espresso_notices();
1618
+	}
1619
+
1620
+
1621
+	/**
1622
+	 * admin_footer_scripts_global
1623
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1624
+	 * will apply on ALL EE_Admin pages.
1625
+	 *
1626
+	 * @return void
1627
+	 */
1628
+	public function admin_footer_scripts_global()
1629
+	{
1630
+		$this->_add_admin_page_ajax_loading_img();
1631
+		$this->_add_admin_page_overlay();
1632
+		// if metaboxes are present we need to add the nonce field
1633
+		if (isset($this->_route_config['metaboxes'])
1634
+			|| isset($this->_route_config['list_table'])
1635
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1636
+		) {
1637
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1638
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1639
+		}
1640
+	}
1641
+
1642
+
1643
+	/**
1644
+	 * admin_footer_global
1645
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1646
+	 * ALL EE_Admin Pages.
1647
+	 *
1648
+	 * @return void
1649
+	 * @throws EE_Error
1650
+	 */
1651
+	public function admin_footer_global()
1652
+	{
1653
+		// dialog container for dialog helper
1654
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1655
+		$d_cont .= '<div class="ee-notices"></div>';
1656
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1657
+		$d_cont .= '</div>';
1658
+		echo $d_cont;
1659
+		// help tour stuff?
1660
+		if (isset($this->_help_tour[ $this->_req_action ])) {
1661
+			echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1662
+		}
1663
+		// current set timezone for timezone js
1664
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1665
+	}
1666
+
1667
+
1668
+	/**
1669
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1670
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1671
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1672
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1673
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1674
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1675
+	 * for the
1676
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1677
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1678
+	 *    'help_trigger_id' => array(
1679
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1680
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1681
+	 *    )
1682
+	 * );
1683
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1684
+	 *
1685
+	 * @param array $help_array
1686
+	 * @param bool  $display
1687
+	 * @return string content
1688
+	 * @throws DomainException
1689
+	 * @throws EE_Error
1690
+	 */
1691
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1692
+	{
1693
+		$content = '';
1694
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1695
+		// loop through the array and setup content
1696
+		foreach ($help_array as $trigger => $help) {
1697
+			// make sure the array is setup properly
1698
+			if (! isset($help['title']) || ! isset($help['content'])) {
1699
+				throw new EE_Error(
1700
+					esc_html__(
1701
+						'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',
1702
+						'event_espresso'
1703
+					)
1704
+				);
1705
+			}
1706
+			// we're good so let'd setup the template vars and then assign parsed template content to our content.
1707
+			$template_args = array(
1708
+				'help_popup_id'      => $trigger,
1709
+				'help_popup_title'   => $help['title'],
1710
+				'help_popup_content' => $help['content'],
1711
+			);
1712
+			$content .= EEH_Template::display_template(
1713
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1714
+				$template_args,
1715
+				true
1716
+			);
1717
+		}
1718
+		if ($display) {
1719
+			echo $content;
1720
+			return '';
1721
+		}
1722
+		return $content;
1723
+	}
1724
+
1725
+
1726
+	/**
1727
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1728
+	 *
1729
+	 * @return array properly formatted array for help popup content
1730
+	 * @throws EE_Error
1731
+	 */
1732
+	private function _get_help_content()
1733
+	{
1734
+		// what is the method we're looking for?
1735
+		$method_name = '_help_popup_content_' . $this->_req_action;
1736
+		// if method doesn't exist let's get out.
1737
+		if (! method_exists($this, $method_name)) {
1738
+			return array();
1739
+		}
1740
+		// k we're good to go let's retrieve the help array
1741
+		$help_array = call_user_func(array($this, $method_name));
1742
+		// make sure we've got an array!
1743
+		if (! is_array($help_array)) {
1744
+			throw new EE_Error(
1745
+				esc_html__(
1746
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1747
+					'event_espresso'
1748
+				)
1749
+			);
1750
+		}
1751
+		return $help_array;
1752
+	}
1753
+
1754
+
1755
+	/**
1756
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1757
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1758
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1759
+	 *
1760
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1761
+	 * @param boolean $display    if false then we return the trigger string
1762
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1763
+	 * @return string
1764
+	 * @throws DomainException
1765
+	 * @throws EE_Error
1766
+	 */
1767
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1768
+	{
1769
+		if (defined('DOING_AJAX')) {
1770
+			return '';
1771
+		}
1772
+		// 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
1773
+		$help_array = $this->_get_help_content();
1774
+		$help_content = '';
1775
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1776
+			$help_array[ $trigger_id ] = array(
1777
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1778
+				'content' => esc_html__(
1779
+					'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.)',
1780
+					'event_espresso'
1781
+				),
1782
+			);
1783
+			$help_content = $this->_set_help_popup_content($help_array, false);
1784
+		}
1785
+		// let's setup the trigger
1786
+		$content = '<a class="ee-dialog" href="?height='
1787
+				   . $dimensions[0]
1788
+				   . '&width='
1789
+				   . $dimensions[1]
1790
+				   . '&inlineId='
1791
+				   . $trigger_id
1792
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1793
+		$content .= $help_content;
1794
+		if ($display) {
1795
+			echo $content;
1796
+			return '';
1797
+		}
1798
+		return $content;
1799
+	}
1800
+
1801
+
1802
+	/**
1803
+	 * _add_global_screen_options
1804
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1805
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1806
+	 *
1807
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1808
+	 *         see also WP_Screen object documents...
1809
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1810
+	 * @abstract
1811
+	 * @return void
1812
+	 */
1813
+	private function _add_global_screen_options()
1814
+	{
1815
+	}
1816
+
1817
+
1818
+	/**
1819
+	 * _add_global_feature_pointers
1820
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1821
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1822
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1823
+	 *
1824
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1825
+	 *         extended) also see:
1826
+	 * @link   http://eamann.com/tech/wordpress-portland/
1827
+	 * @abstract
1828
+	 * @return void
1829
+	 */
1830
+	private function _add_global_feature_pointers()
1831
+	{
1832
+	}
1833
+
1834
+
1835
+	/**
1836
+	 * load_global_scripts_styles
1837
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1838
+	 *
1839
+	 * @return void
1840
+	 * @throws EE_Error
1841
+	 */
1842
+	public function load_global_scripts_styles()
1843
+	{
1844
+		/** STYLES **/
1845
+		// add debugging styles
1846
+		if (WP_DEBUG) {
1847
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1848
+		}
1849
+		// register all styles
1850
+		wp_register_style(
1851
+			'espresso-ui-theme',
1852
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1853
+			array(),
1854
+			EVENT_ESPRESSO_VERSION
1855
+		);
1856
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1857
+		// helpers styles
1858
+		wp_register_style(
1859
+			'ee-text-links',
1860
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1861
+			array(),
1862
+			EVENT_ESPRESSO_VERSION
1863
+		);
1864
+		/** SCRIPTS **/
1865
+		// register all scripts
1866
+		wp_register_script(
1867
+			'ee-dialog',
1868
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1869
+			array('jquery', 'jquery-ui-draggable'),
1870
+			EVENT_ESPRESSO_VERSION,
1871
+			true
1872
+		);
1873
+		wp_register_script(
1874
+			'ee_admin_js',
1875
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1876
+			array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1877
+			EVENT_ESPRESSO_VERSION,
1878
+			true
1879
+		);
1880
+		wp_register_script(
1881
+			'jquery-ui-timepicker-addon',
1882
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1883
+			array('jquery-ui-datepicker', 'jquery-ui-slider'),
1884
+			EVENT_ESPRESSO_VERSION,
1885
+			true
1886
+		);
1887
+		add_filter('FHEE_load_joyride', '__return_true');
1888
+		// script for sorting tables
1889
+		wp_register_script(
1890
+			'espresso_ajax_table_sorting',
1891
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1892
+			array('ee_admin_js', 'jquery-ui-sortable'),
1893
+			EVENT_ESPRESSO_VERSION,
1894
+			true
1895
+		);
1896
+		// script for parsing uri's
1897
+		wp_register_script(
1898
+			'ee-parse-uri',
1899
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1900
+			array(),
1901
+			EVENT_ESPRESSO_VERSION,
1902
+			true
1903
+		);
1904
+		// and parsing associative serialized form elements
1905
+		wp_register_script(
1906
+			'ee-serialize-full-array',
1907
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1908
+			array('jquery'),
1909
+			EVENT_ESPRESSO_VERSION,
1910
+			true
1911
+		);
1912
+		// helpers scripts
1913
+		wp_register_script(
1914
+			'ee-text-links',
1915
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1916
+			array('jquery'),
1917
+			EVENT_ESPRESSO_VERSION,
1918
+			true
1919
+		);
1920
+		wp_register_script(
1921
+			'ee-moment-core',
1922
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1923
+			array(),
1924
+			EVENT_ESPRESSO_VERSION,
1925
+			true
1926
+		);
1927
+		wp_register_script(
1928
+			'ee-moment',
1929
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1930
+			array('ee-moment-core'),
1931
+			EVENT_ESPRESSO_VERSION,
1932
+			true
1933
+		);
1934
+		wp_register_script(
1935
+			'ee-datepicker',
1936
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1937
+			array('jquery-ui-timepicker-addon', 'ee-moment'),
1938
+			EVENT_ESPRESSO_VERSION,
1939
+			true
1940
+		);
1941
+		// google charts
1942
+		wp_register_script(
1943
+			'google-charts',
1944
+			'https://www.gstatic.com/charts/loader.js',
1945
+			array(),
1946
+			EVENT_ESPRESSO_VERSION,
1947
+			false
1948
+		);
1949
+		// ENQUEUE ALL BASICS BY DEFAULT
1950
+		wp_enqueue_style('ee-admin-css');
1951
+		wp_enqueue_script('ee_admin_js');
1952
+		wp_enqueue_script('ee-accounting');
1953
+		wp_enqueue_script('jquery-validate');
1954
+		// taking care of metaboxes
1955
+		if (empty($this->_cpt_route)
1956
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1957
+		) {
1958
+			wp_enqueue_script('dashboard');
1959
+		}
1960
+		// LOCALIZED DATA
1961
+		// localize script for ajax lazy loading
1962
+		$lazy_loader_container_ids = apply_filters(
1963
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1964
+			array('espresso_news_post_box_content')
1965
+		);
1966
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1967
+		/**
1968
+		 * help tour stuff
1969
+		 */
1970
+		if (! empty($this->_help_tour)) {
1971
+			// register the js for kicking things off
1972
+			wp_enqueue_script(
1973
+				'ee-help-tour',
1974
+				EE_ADMIN_URL . 'assets/ee-help-tour.js',
1975
+				array('jquery-joyride'),
1976
+				EVENT_ESPRESSO_VERSION,
1977
+				true
1978
+			);
1979
+			$tours = array();
1980
+			// setup tours for the js tour object
1981
+			foreach ($this->_help_tour['tours'] as $tour) {
1982
+				if ($tour instanceof EE_Help_Tour) {
1983
+					$tours[] = array(
1984
+						'id'      => $tour->get_slug(),
1985
+						'options' => $tour->get_options(),
1986
+					);
1987
+				}
1988
+			}
1989
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1990
+			// admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1991
+		}
1992
+	}
1993
+
1994
+
1995
+	/**
1996
+	 *        admin_footer_scripts_eei18n_js_strings
1997
+	 *
1998
+	 * @return        void
1999
+	 */
2000
+	public function admin_footer_scripts_eei18n_js_strings()
2001
+	{
2002
+		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
2003
+		EE_Registry::$i18n_js_strings['confirm_delete'] = esc_html__(
2004
+			'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!!!',
2005
+			'event_espresso'
2006
+		);
2007
+		EE_Registry::$i18n_js_strings['January'] = esc_html__('January', 'event_espresso');
2008
+		EE_Registry::$i18n_js_strings['February'] = esc_html__('February', 'event_espresso');
2009
+		EE_Registry::$i18n_js_strings['March'] = esc_html__('March', 'event_espresso');
2010
+		EE_Registry::$i18n_js_strings['April'] = esc_html__('April', 'event_espresso');
2011
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2012
+		EE_Registry::$i18n_js_strings['June'] = esc_html__('June', 'event_espresso');
2013
+		EE_Registry::$i18n_js_strings['July'] = esc_html__('July', 'event_espresso');
2014
+		EE_Registry::$i18n_js_strings['August'] = esc_html__('August', 'event_espresso');
2015
+		EE_Registry::$i18n_js_strings['September'] = esc_html__('September', 'event_espresso');
2016
+		EE_Registry::$i18n_js_strings['October'] = esc_html__('October', 'event_espresso');
2017
+		EE_Registry::$i18n_js_strings['November'] = esc_html__('November', 'event_espresso');
2018
+		EE_Registry::$i18n_js_strings['December'] = esc_html__('December', 'event_espresso');
2019
+		EE_Registry::$i18n_js_strings['Jan'] = esc_html__('Jan', 'event_espresso');
2020
+		EE_Registry::$i18n_js_strings['Feb'] = esc_html__('Feb', 'event_espresso');
2021
+		EE_Registry::$i18n_js_strings['Mar'] = esc_html__('Mar', 'event_espresso');
2022
+		EE_Registry::$i18n_js_strings['Apr'] = esc_html__('Apr', 'event_espresso');
2023
+		EE_Registry::$i18n_js_strings['May'] = esc_html__('May', 'event_espresso');
2024
+		EE_Registry::$i18n_js_strings['Jun'] = esc_html__('Jun', 'event_espresso');
2025
+		EE_Registry::$i18n_js_strings['Jul'] = esc_html__('Jul', 'event_espresso');
2026
+		EE_Registry::$i18n_js_strings['Aug'] = esc_html__('Aug', 'event_espresso');
2027
+		EE_Registry::$i18n_js_strings['Sep'] = esc_html__('Sep', 'event_espresso');
2028
+		EE_Registry::$i18n_js_strings['Oct'] = esc_html__('Oct', 'event_espresso');
2029
+		EE_Registry::$i18n_js_strings['Nov'] = esc_html__('Nov', 'event_espresso');
2030
+		EE_Registry::$i18n_js_strings['Dec'] = esc_html__('Dec', 'event_espresso');
2031
+		EE_Registry::$i18n_js_strings['Sunday'] = esc_html__('Sunday', 'event_espresso');
2032
+		EE_Registry::$i18n_js_strings['Monday'] = esc_html__('Monday', 'event_espresso');
2033
+		EE_Registry::$i18n_js_strings['Tuesday'] = esc_html__('Tuesday', 'event_espresso');
2034
+		EE_Registry::$i18n_js_strings['Wednesday'] = esc_html__('Wednesday', 'event_espresso');
2035
+		EE_Registry::$i18n_js_strings['Thursday'] = esc_html__('Thursday', 'event_espresso');
2036
+		EE_Registry::$i18n_js_strings['Friday'] = esc_html__('Friday', 'event_espresso');
2037
+		EE_Registry::$i18n_js_strings['Saturday'] = esc_html__('Saturday', 'event_espresso');
2038
+		EE_Registry::$i18n_js_strings['Sun'] = esc_html__('Sun', 'event_espresso');
2039
+		EE_Registry::$i18n_js_strings['Mon'] = esc_html__('Mon', 'event_espresso');
2040
+		EE_Registry::$i18n_js_strings['Tue'] = esc_html__('Tue', 'event_espresso');
2041
+		EE_Registry::$i18n_js_strings['Wed'] = esc_html__('Wed', 'event_espresso');
2042
+		EE_Registry::$i18n_js_strings['Thu'] = esc_html__('Thu', 'event_espresso');
2043
+		EE_Registry::$i18n_js_strings['Fri'] = esc_html__('Fri', 'event_espresso');
2044
+		EE_Registry::$i18n_js_strings['Sat'] = esc_html__('Sat', 'event_espresso');
2045
+	}
2046
+
2047
+
2048
+	/**
2049
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2050
+	 *
2051
+	 * @return        void
2052
+	 */
2053
+	public function add_xdebug_style()
2054
+	{
2055
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2056
+	}
2057
+
2058
+
2059
+	/************************/
2060
+	/** LIST TABLE METHODS **/
2061
+	/************************/
2062
+	/**
2063
+	 * this sets up the list table if the current view requires it.
2064
+	 *
2065
+	 * @return void
2066
+	 * @throws EE_Error
2067
+	 */
2068
+	protected function _set_list_table()
2069
+	{
2070
+		// first is this a list_table view?
2071
+		if (! isset($this->_route_config['list_table'])) {
2072
+			return;
2073
+		} //not a list_table view so get out.
2074
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2075
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2076
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2077
+			// user error msg
2078
+			$error_msg = esc_html__(
2079
+				'An error occurred. The requested list table views could not be found.',
2080
+				'event_espresso'
2081
+			);
2082
+			// developer error msg
2083
+			$error_msg .= '||'
2084
+						  . sprintf(
2085
+							  esc_html__(
2086
+								  '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.',
2087
+								  'event_espresso'
2088
+							  ),
2089
+							  $this->_req_action,
2090
+							  $list_table_view
2091
+						  );
2092
+			throw new EE_Error($error_msg);
2093
+		}
2094
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2095
+		$this->_views = apply_filters(
2096
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2097
+			$this->_views
2098
+		);
2099
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2100
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2101
+		$this->_set_list_table_view();
2102
+		$this->_set_list_table_object();
2103
+	}
2104
+
2105
+
2106
+	/**
2107
+	 * set current view for List Table
2108
+	 *
2109
+	 * @return void
2110
+	 */
2111
+	protected function _set_list_table_view()
2112
+	{
2113
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2114
+		// looking at active items or dumpster diving ?
2115
+		if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2116
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2117
+		} else {
2118
+			$this->_view = sanitize_key($this->_req_data['status']);
2119
+		}
2120
+	}
2121
+
2122
+
2123
+	/**
2124
+	 * _set_list_table_object
2125
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2126
+	 *
2127
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2128
+	 * @throws \InvalidArgumentException
2129
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2130
+	 * @throws EE_Error
2131
+	 * @throws InvalidInterfaceException
2132
+	 */
2133
+	protected function _set_list_table_object()
2134
+	{
2135
+		if (isset($this->_route_config['list_table'])) {
2136
+			if (! class_exists($this->_route_config['list_table'])) {
2137
+				throw new EE_Error(
2138
+					sprintf(
2139
+						esc_html__(
2140
+							'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.',
2141
+							'event_espresso'
2142
+						),
2143
+						$this->_route_config['list_table'],
2144
+						get_class($this)
2145
+					)
2146
+				);
2147
+			}
2148
+			$this->_list_table_object = $this->loader->getShared(
2149
+				$this->_route_config['list_table'],
2150
+				array($this)
2151
+			);
2152
+		}
2153
+	}
2154
+
2155
+
2156
+	/**
2157
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2158
+	 *
2159
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2160
+	 *                                                    urls.  The array should be indexed by the view it is being
2161
+	 *                                                    added to.
2162
+	 * @return array
2163
+	 */
2164
+	public function get_list_table_view_RLs($extra_query_args = array())
2165
+	{
2166
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2167
+		if (empty($this->_views)) {
2168
+			$this->_views = array();
2169
+		}
2170
+		// cycle thru views
2171
+		foreach ($this->_views as $key => $view) {
2172
+			$query_args = array();
2173
+			// check for current view
2174
+			$this->_views[ $key ]['class'] = $this->_view === $view['slug'] ? 'current' : '';
2175
+			$query_args['action'] = $this->_req_action;
2176
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2177
+			$query_args['status'] = $view['slug'];
2178
+			// merge any other arguments sent in.
2179
+			if (isset($extra_query_args[ $view['slug'] ])) {
2180
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2181
+			}
2182
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2183
+		}
2184
+		return $this->_views;
2185
+	}
2186
+
2187
+
2188
+	/**
2189
+	 * _entries_per_page_dropdown
2190
+	 * generates a drop down box for selecting the number of visible rows in an admin page list table
2191
+	 *
2192
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2193
+	 *         WP does it.
2194
+	 * @param int $max_entries total number of rows in the table
2195
+	 * @return string
2196
+	 */
2197
+	protected function _entries_per_page_dropdown($max_entries = 0)
2198
+	{
2199
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2200
+		$values = array(10, 25, 50, 100);
2201
+		$per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2202
+		if ($max_entries) {
2203
+			$values[] = $max_entries;
2204
+			sort($values);
2205
+		}
2206
+		$entries_per_page_dropdown = '
2207 2207
 			<div id="entries-per-page-dv" class="alignleft actions">
2208 2208
 				<label class="hide-if-no-js">
2209 2209
 					Show
2210 2210
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2211
-        foreach ($values as $value) {
2212
-            if ($value < $max_entries) {
2213
-                $selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2214
-                $entries_per_page_dropdown .= '
2211
+		foreach ($values as $value) {
2212
+			if ($value < $max_entries) {
2213
+				$selected = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2214
+				$entries_per_page_dropdown .= '
2215 2215
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2216
-            }
2217
-        }
2218
-        $selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2219
-        $entries_per_page_dropdown .= '
2216
+			}
2217
+		}
2218
+		$selected = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2219
+		$entries_per_page_dropdown .= '
2220 2220
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2221
-        $entries_per_page_dropdown .= '
2221
+		$entries_per_page_dropdown .= '
2222 2222
 					</select>
2223 2223
 					entries
2224 2224
 				</label>
2225 2225
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2226 2226
 			</div>
2227 2227
 		';
2228
-        return $entries_per_page_dropdown;
2229
-    }
2230
-
2231
-
2232
-    /**
2233
-     *        _set_search_attributes
2234
-     *
2235
-     * @return        void
2236
-     */
2237
-    public function _set_search_attributes()
2238
-    {
2239
-        $this->_template_args['search']['btn_label'] = sprintf(
2240
-            esc_html__('Search %s', 'event_espresso'),
2241
-            empty($this->_search_btn_label) ? $this->page_label
2242
-                : $this->_search_btn_label
2243
-        );
2244
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2245
-    }
2246
-
2247
-
2248
-
2249
-    /*** END LIST TABLE METHODS **/
2250
-
2251
-
2252
-    /**
2253
-     * _add_registered_metaboxes
2254
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2255
-     *
2256
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2257
-     * @return void
2258
-     * @throws EE_Error
2259
-     */
2260
-    private function _add_registered_meta_boxes()
2261
-    {
2262
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2263
-        // we only add meta boxes if the page_route calls for it
2264
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2265
-            && is_array(
2266
-                $this->_route_config['metaboxes']
2267
-            )
2268
-        ) {
2269
-            // this simply loops through the callbacks provided
2270
-            // and checks if there is a corresponding callback registered by the child
2271
-            // if there is then we go ahead and process the metabox loader.
2272
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2273
-                // first check for Closures
2274
-                if ($metabox_callback instanceof Closure) {
2275
-                    $result = $metabox_callback();
2276
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2277
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2278
-                } else {
2279
-                    $result = call_user_func(array($this, &$metabox_callback));
2280
-                }
2281
-                if ($result === false) {
2282
-                    // user error msg
2283
-                    $error_msg = esc_html__(
2284
-                        'An error occurred. The  requested metabox could not be found.',
2285
-                        'event_espresso'
2286
-                    );
2287
-                    // developer error msg
2288
-                    $error_msg .= '||'
2289
-                                  . sprintf(
2290
-                                      esc_html__(
2291
-                                          '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.',
2292
-                                          'event_espresso'
2293
-                                      ),
2294
-                                      $metabox_callback
2295
-                                  );
2296
-                    throw new EE_Error($error_msg);
2297
-                }
2298
-            }
2299
-        }
2300
-    }
2301
-
2302
-
2303
-    /**
2304
-     * _add_screen_columns
2305
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2306
-     * the dynamic column template and we'll setup the column options for the page.
2307
-     *
2308
-     * @return void
2309
-     */
2310
-    private function _add_screen_columns()
2311
-    {
2312
-        if (is_array($this->_route_config)
2313
-            && isset($this->_route_config['columns'])
2314
-            && is_array($this->_route_config['columns'])
2315
-            && count($this->_route_config['columns']) === 2
2316
-        ) {
2317
-            add_screen_option(
2318
-                'layout_columns',
2319
-                array(
2320
-                    'max'     => (int) $this->_route_config['columns'][0],
2321
-                    'default' => (int) $this->_route_config['columns'][1],
2322
-                )
2323
-            );
2324
-            $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2325
-            $screen_id = $this->_current_screen->id;
2326
-            $screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2327
-            $total_columns = ! empty($screen_columns)
2328
-                ? $screen_columns
2329
-                : $this->_route_config['columns'][1];
2330
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2331
-            $this->_template_args['current_page'] = $this->_wp_page_slug;
2332
-            $this->_template_args['screen'] = $this->_current_screen;
2333
-            $this->_column_template_path = EE_ADMIN_TEMPLATE
2334
-                                           . 'admin_details_metabox_column_wrapper.template.php';
2335
-            // finally if we don't have has_metaboxes set in the route config
2336
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2337
-            $this->_route_config['has_metaboxes'] = true;
2338
-        }
2339
-    }
2340
-
2341
-
2342
-
2343
-    /** GLOBALLY AVAILABLE METABOXES **/
2344
-
2345
-
2346
-    /**
2347
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2348
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2349
-     * these get loaded on.
2350
-     */
2351
-    private function _espresso_news_post_box()
2352
-    {
2353
-        $news_box_title = apply_filters(
2354
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2355
-            esc_html__('New @ Event Espresso', 'event_espresso')
2356
-        );
2357
-        add_meta_box(
2358
-            'espresso_news_post_box',
2359
-            $news_box_title,
2360
-            array(
2361
-                $this,
2362
-                'espresso_news_post_box',
2363
-            ),
2364
-            $this->_wp_page_slug,
2365
-            'side'
2366
-        );
2367
-    }
2368
-
2369
-
2370
-    /**
2371
-     * Code for setting up espresso ratings request metabox.
2372
-     */
2373
-    protected function _espresso_ratings_request()
2374
-    {
2375
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2376
-            return;
2377
-        }
2378
-        $ratings_box_title = apply_filters(
2379
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2380
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2381
-        );
2382
-        add_meta_box(
2383
-            'espresso_ratings_request',
2384
-            $ratings_box_title,
2385
-            array(
2386
-                $this,
2387
-                'espresso_ratings_request',
2388
-            ),
2389
-            $this->_wp_page_slug,
2390
-            'side'
2391
-        );
2392
-    }
2393
-
2394
-
2395
-    /**
2396
-     * Code for setting up espresso ratings request metabox content.
2397
-     *
2398
-     * @throws DomainException
2399
-     */
2400
-    public function espresso_ratings_request()
2401
-    {
2402
-        EEH_Template::display_template(
2403
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2404
-            array()
2405
-        );
2406
-    }
2407
-
2408
-
2409
-    public static function cached_rss_display($rss_id, $url)
2410
-    {
2411
-        $loading = '<p class="widget-loading hide-if-no-js">'
2412
-                   . __('Loading&#8230;', 'event_espresso')
2413
-                   . '</p><p class="hide-if-js">'
2414
-                   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2415
-                   . '</p>';
2416
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
2417
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2418
-        $post = '</div>' . "\n";
2419
-        $cache_key = 'ee_rss_' . md5($rss_id);
2420
-        $output = get_transient($cache_key);
2421
-        if ($output !== false) {
2422
-            echo $pre . $output . $post;
2423
-            return true;
2424
-        }
2425
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2426
-            echo $pre . $loading . $post;
2427
-            return false;
2428
-        }
2429
-        ob_start();
2430
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2431
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2432
-        return true;
2433
-    }
2434
-
2435
-
2436
-    public function espresso_news_post_box()
2437
-    {
2438
-        ?>
2228
+		return $entries_per_page_dropdown;
2229
+	}
2230
+
2231
+
2232
+	/**
2233
+	 *        _set_search_attributes
2234
+	 *
2235
+	 * @return        void
2236
+	 */
2237
+	public function _set_search_attributes()
2238
+	{
2239
+		$this->_template_args['search']['btn_label'] = sprintf(
2240
+			esc_html__('Search %s', 'event_espresso'),
2241
+			empty($this->_search_btn_label) ? $this->page_label
2242
+				: $this->_search_btn_label
2243
+		);
2244
+		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
2245
+	}
2246
+
2247
+
2248
+
2249
+	/*** END LIST TABLE METHODS **/
2250
+
2251
+
2252
+	/**
2253
+	 * _add_registered_metaboxes
2254
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2255
+	 *
2256
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2257
+	 * @return void
2258
+	 * @throws EE_Error
2259
+	 */
2260
+	private function _add_registered_meta_boxes()
2261
+	{
2262
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2263
+		// we only add meta boxes if the page_route calls for it
2264
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2265
+			&& is_array(
2266
+				$this->_route_config['metaboxes']
2267
+			)
2268
+		) {
2269
+			// this simply loops through the callbacks provided
2270
+			// and checks if there is a corresponding callback registered by the child
2271
+			// if there is then we go ahead and process the metabox loader.
2272
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2273
+				// first check for Closures
2274
+				if ($metabox_callback instanceof Closure) {
2275
+					$result = $metabox_callback();
2276
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2277
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2278
+				} else {
2279
+					$result = call_user_func(array($this, &$metabox_callback));
2280
+				}
2281
+				if ($result === false) {
2282
+					// user error msg
2283
+					$error_msg = esc_html__(
2284
+						'An error occurred. The  requested metabox could not be found.',
2285
+						'event_espresso'
2286
+					);
2287
+					// developer error msg
2288
+					$error_msg .= '||'
2289
+								  . sprintf(
2290
+									  esc_html__(
2291
+										  '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.',
2292
+										  'event_espresso'
2293
+									  ),
2294
+									  $metabox_callback
2295
+								  );
2296
+					throw new EE_Error($error_msg);
2297
+				}
2298
+			}
2299
+		}
2300
+	}
2301
+
2302
+
2303
+	/**
2304
+	 * _add_screen_columns
2305
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2306
+	 * the dynamic column template and we'll setup the column options for the page.
2307
+	 *
2308
+	 * @return void
2309
+	 */
2310
+	private function _add_screen_columns()
2311
+	{
2312
+		if (is_array($this->_route_config)
2313
+			&& isset($this->_route_config['columns'])
2314
+			&& is_array($this->_route_config['columns'])
2315
+			&& count($this->_route_config['columns']) === 2
2316
+		) {
2317
+			add_screen_option(
2318
+				'layout_columns',
2319
+				array(
2320
+					'max'     => (int) $this->_route_config['columns'][0],
2321
+					'default' => (int) $this->_route_config['columns'][1],
2322
+				)
2323
+			);
2324
+			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
2325
+			$screen_id = $this->_current_screen->id;
2326
+			$screen_columns = (int) get_user_option("screen_layout_{$screen_id}");
2327
+			$total_columns = ! empty($screen_columns)
2328
+				? $screen_columns
2329
+				: $this->_route_config['columns'][1];
2330
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2331
+			$this->_template_args['current_page'] = $this->_wp_page_slug;
2332
+			$this->_template_args['screen'] = $this->_current_screen;
2333
+			$this->_column_template_path = EE_ADMIN_TEMPLATE
2334
+										   . 'admin_details_metabox_column_wrapper.template.php';
2335
+			// finally if we don't have has_metaboxes set in the route config
2336
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2337
+			$this->_route_config['has_metaboxes'] = true;
2338
+		}
2339
+	}
2340
+
2341
+
2342
+
2343
+	/** GLOBALLY AVAILABLE METABOXES **/
2344
+
2345
+
2346
+	/**
2347
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2348
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2349
+	 * these get loaded on.
2350
+	 */
2351
+	private function _espresso_news_post_box()
2352
+	{
2353
+		$news_box_title = apply_filters(
2354
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2355
+			esc_html__('New @ Event Espresso', 'event_espresso')
2356
+		);
2357
+		add_meta_box(
2358
+			'espresso_news_post_box',
2359
+			$news_box_title,
2360
+			array(
2361
+				$this,
2362
+				'espresso_news_post_box',
2363
+			),
2364
+			$this->_wp_page_slug,
2365
+			'side'
2366
+		);
2367
+	}
2368
+
2369
+
2370
+	/**
2371
+	 * Code for setting up espresso ratings request metabox.
2372
+	 */
2373
+	protected function _espresso_ratings_request()
2374
+	{
2375
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2376
+			return;
2377
+		}
2378
+		$ratings_box_title = apply_filters(
2379
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2380
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2381
+		);
2382
+		add_meta_box(
2383
+			'espresso_ratings_request',
2384
+			$ratings_box_title,
2385
+			array(
2386
+				$this,
2387
+				'espresso_ratings_request',
2388
+			),
2389
+			$this->_wp_page_slug,
2390
+			'side'
2391
+		);
2392
+	}
2393
+
2394
+
2395
+	/**
2396
+	 * Code for setting up espresso ratings request metabox content.
2397
+	 *
2398
+	 * @throws DomainException
2399
+	 */
2400
+	public function espresso_ratings_request()
2401
+	{
2402
+		EEH_Template::display_template(
2403
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2404
+			array()
2405
+		);
2406
+	}
2407
+
2408
+
2409
+	public static function cached_rss_display($rss_id, $url)
2410
+	{
2411
+		$loading = '<p class="widget-loading hide-if-no-js">'
2412
+				   . __('Loading&#8230;', 'event_espresso')
2413
+				   . '</p><p class="hide-if-js">'
2414
+				   . esc_html__('This widget requires JavaScript.', 'event_espresso')
2415
+				   . '</p>';
2416
+		$pre = '<div class="espresso-rss-display">' . "\n\t";
2417
+		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2418
+		$post = '</div>' . "\n";
2419
+		$cache_key = 'ee_rss_' . md5($rss_id);
2420
+		$output = get_transient($cache_key);
2421
+		if ($output !== false) {
2422
+			echo $pre . $output . $post;
2423
+			return true;
2424
+		}
2425
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2426
+			echo $pre . $loading . $post;
2427
+			return false;
2428
+		}
2429
+		ob_start();
2430
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2431
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2432
+		return true;
2433
+	}
2434
+
2435
+
2436
+	public function espresso_news_post_box()
2437
+	{
2438
+		?>
2439 2439
         <div class="padding">
2440 2440
             <div id="espresso_news_post_box_content" class="infolinks">
2441 2441
                 <?php
2442
-                // Get RSS Feed(s)
2443
-                self::cached_rss_display(
2444
-                    'espresso_news_post_box_content',
2445
-                    urlencode(
2446
-                        apply_filters(
2447
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2448
-                            'http://eventespresso.com/feed/'
2449
-                        )
2450
-                    )
2451
-                );
2452
-                ?>
2442
+				// Get RSS Feed(s)
2443
+				self::cached_rss_display(
2444
+					'espresso_news_post_box_content',
2445
+					urlencode(
2446
+						apply_filters(
2447
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2448
+							'http://eventespresso.com/feed/'
2449
+						)
2450
+					)
2451
+				);
2452
+				?>
2453 2453
             </div>
2454 2454
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2455 2455
         </div>
2456 2456
         <?php
2457
-    }
2458
-
2459
-
2460
-    private function _espresso_links_post_box()
2461
-    {
2462
-        // Hiding until we actually have content to put in here...
2463
-        // 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');
2464
-    }
2465
-
2466
-
2467
-    public function espresso_links_post_box()
2468
-    {
2469
-        // Hiding until we actually have content to put in here...
2470
-        // EEH_Template::display_template(
2471
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2472
-        // );
2473
-    }
2474
-
2475
-
2476
-    protected function _espresso_sponsors_post_box()
2477
-    {
2478
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2479
-            add_meta_box(
2480
-                'espresso_sponsors_post_box',
2481
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2482
-                array($this, 'espresso_sponsors_post_box'),
2483
-                $this->_wp_page_slug,
2484
-                'side'
2485
-            );
2486
-        }
2487
-    }
2488
-
2489
-
2490
-    public function espresso_sponsors_post_box()
2491
-    {
2492
-        EEH_Template::display_template(
2493
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2494
-        );
2495
-    }
2496
-
2497
-
2498
-    private function _publish_post_box()
2499
-    {
2500
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2501
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2502
-        // then we'll use that for the metabox label.
2503
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2504
-        if (! empty($this->_labels['publishbox'])) {
2505
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2506
-                : $this->_labels['publishbox'];
2507
-        } else {
2508
-            $box_label = esc_html__('Publish', 'event_espresso');
2509
-        }
2510
-        $box_label = apply_filters(
2511
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2512
-            $box_label,
2513
-            $this->_req_action,
2514
-            $this
2515
-        );
2516
-        add_meta_box(
2517
-            $meta_box_ref,
2518
-            $box_label,
2519
-            array($this, 'editor_overview'),
2520
-            $this->_current_screen->id,
2521
-            'side',
2522
-            'high'
2523
-        );
2524
-    }
2525
-
2526
-
2527
-    public function editor_overview()
2528
-    {
2529
-        // if we have extra content set let's add it in if not make sure its empty
2530
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2531
-            ? $this->_template_args['publish_box_extra_content']
2532
-            : '';
2533
-        echo EEH_Template::display_template(
2534
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2535
-            $this->_template_args,
2536
-            true
2537
-        );
2538
-    }
2539
-
2540
-
2541
-    /** end of globally available metaboxes section **/
2542
-
2543
-
2544
-    /**
2545
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2546
-     * protected method.
2547
-     *
2548
-     * @see   $this->_set_publish_post_box_vars for param details
2549
-     * @since 4.6.0
2550
-     * @param string $name
2551
-     * @param int    $id
2552
-     * @param bool   $delete
2553
-     * @param string $save_close_redirect_URL
2554
-     * @param bool   $both_btns
2555
-     * @throws EE_Error
2556
-     * @throws InvalidArgumentException
2557
-     * @throws InvalidDataTypeException
2558
-     * @throws InvalidInterfaceException
2559
-     */
2560
-    public function set_publish_post_box_vars(
2561
-        $name = '',
2562
-        $id = 0,
2563
-        $delete = false,
2564
-        $save_close_redirect_URL = '',
2565
-        $both_btns = true
2566
-    ) {
2567
-        $this->_set_publish_post_box_vars(
2568
-            $name,
2569
-            $id,
2570
-            $delete,
2571
-            $save_close_redirect_URL,
2572
-            $both_btns
2573
-        );
2574
-    }
2575
-
2576
-
2577
-    /**
2578
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2579
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2580
-     * save, and save and close buttons to work properly, then you will want to include a
2581
-     * values for the name and id arguments.
2582
-     *
2583
-     * @todo  Add in validation for name/id arguments.
2584
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2585
-     * @param    int     $id                      id attached to the item published
2586
-     * @param    string  $delete                  page route callback for the delete action
2587
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2588
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2589
-     *                                            the Save button
2590
-     * @throws EE_Error
2591
-     * @throws InvalidArgumentException
2592
-     * @throws InvalidDataTypeException
2593
-     * @throws InvalidInterfaceException
2594
-     */
2595
-    protected function _set_publish_post_box_vars(
2596
-        $name = '',
2597
-        $id = 0,
2598
-        $delete = '',
2599
-        $save_close_redirect_URL = '',
2600
-        $both_btns = true
2601
-    ) {
2602
-        // if Save & Close, use a custom redirect URL or default to the main page?
2603
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2604
-            ? $save_close_redirect_URL
2605
-            : $this->_admin_base_url;
2606
-        // create the Save & Close and Save buttons
2607
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2608
-        // if we have extra content set let's add it in if not make sure its empty
2609
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2610
-            ? $this->_template_args['publish_box_extra_content']
2611
-            : '';
2612
-        if ($delete && ! empty($id)) {
2613
-            // make sure we have a default if just true is sent.
2614
-            $delete = ! empty($delete) ? $delete : 'delete';
2615
-            $delete_link_args = array($name => $id);
2616
-            $delete = $this->get_action_link_or_button(
2617
-                $delete,
2618
-                $delete,
2619
-                $delete_link_args,
2620
-                'submitdelete deletion',
2621
-                '',
2622
-                false
2623
-            );
2624
-        }
2625
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2626
-        if (! empty($name) && ! empty($id)) {
2627
-            $hidden_field_arr[ $name ] = array(
2628
-                'type'  => 'hidden',
2629
-                'value' => $id,
2630
-            );
2631
-            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2632
-        } else {
2633
-            $hf = '';
2634
-        }
2635
-        // add hidden field
2636
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2637
-            ? $hf[ $name ]['field']
2638
-            : $hf;
2639
-    }
2640
-
2641
-
2642
-    /**
2643
-     * displays an error message to ppl who have javascript disabled
2644
-     *
2645
-     * @return void
2646
-     */
2647
-    private function _display_no_javascript_warning()
2648
-    {
2649
-        ?>
2457
+	}
2458
+
2459
+
2460
+	private function _espresso_links_post_box()
2461
+	{
2462
+		// Hiding until we actually have content to put in here...
2463
+		// 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');
2464
+	}
2465
+
2466
+
2467
+	public function espresso_links_post_box()
2468
+	{
2469
+		// Hiding until we actually have content to put in here...
2470
+		// EEH_Template::display_template(
2471
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2472
+		// );
2473
+	}
2474
+
2475
+
2476
+	protected function _espresso_sponsors_post_box()
2477
+	{
2478
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2479
+			add_meta_box(
2480
+				'espresso_sponsors_post_box',
2481
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2482
+				array($this, 'espresso_sponsors_post_box'),
2483
+				$this->_wp_page_slug,
2484
+				'side'
2485
+			);
2486
+		}
2487
+	}
2488
+
2489
+
2490
+	public function espresso_sponsors_post_box()
2491
+	{
2492
+		EEH_Template::display_template(
2493
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2494
+		);
2495
+	}
2496
+
2497
+
2498
+	private function _publish_post_box()
2499
+	{
2500
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2501
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2502
+		// then we'll use that for the metabox label.
2503
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2504
+		if (! empty($this->_labels['publishbox'])) {
2505
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2506
+				: $this->_labels['publishbox'];
2507
+		} else {
2508
+			$box_label = esc_html__('Publish', 'event_espresso');
2509
+		}
2510
+		$box_label = apply_filters(
2511
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2512
+			$box_label,
2513
+			$this->_req_action,
2514
+			$this
2515
+		);
2516
+		add_meta_box(
2517
+			$meta_box_ref,
2518
+			$box_label,
2519
+			array($this, 'editor_overview'),
2520
+			$this->_current_screen->id,
2521
+			'side',
2522
+			'high'
2523
+		);
2524
+	}
2525
+
2526
+
2527
+	public function editor_overview()
2528
+	{
2529
+		// if we have extra content set let's add it in if not make sure its empty
2530
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2531
+			? $this->_template_args['publish_box_extra_content']
2532
+			: '';
2533
+		echo EEH_Template::display_template(
2534
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2535
+			$this->_template_args,
2536
+			true
2537
+		);
2538
+	}
2539
+
2540
+
2541
+	/** end of globally available metaboxes section **/
2542
+
2543
+
2544
+	/**
2545
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2546
+	 * protected method.
2547
+	 *
2548
+	 * @see   $this->_set_publish_post_box_vars for param details
2549
+	 * @since 4.6.0
2550
+	 * @param string $name
2551
+	 * @param int    $id
2552
+	 * @param bool   $delete
2553
+	 * @param string $save_close_redirect_URL
2554
+	 * @param bool   $both_btns
2555
+	 * @throws EE_Error
2556
+	 * @throws InvalidArgumentException
2557
+	 * @throws InvalidDataTypeException
2558
+	 * @throws InvalidInterfaceException
2559
+	 */
2560
+	public function set_publish_post_box_vars(
2561
+		$name = '',
2562
+		$id = 0,
2563
+		$delete = false,
2564
+		$save_close_redirect_URL = '',
2565
+		$both_btns = true
2566
+	) {
2567
+		$this->_set_publish_post_box_vars(
2568
+			$name,
2569
+			$id,
2570
+			$delete,
2571
+			$save_close_redirect_URL,
2572
+			$both_btns
2573
+		);
2574
+	}
2575
+
2576
+
2577
+	/**
2578
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2579
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2580
+	 * save, and save and close buttons to work properly, then you will want to include a
2581
+	 * values for the name and id arguments.
2582
+	 *
2583
+	 * @todo  Add in validation for name/id arguments.
2584
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2585
+	 * @param    int     $id                      id attached to the item published
2586
+	 * @param    string  $delete                  page route callback for the delete action
2587
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2588
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2589
+	 *                                            the Save button
2590
+	 * @throws EE_Error
2591
+	 * @throws InvalidArgumentException
2592
+	 * @throws InvalidDataTypeException
2593
+	 * @throws InvalidInterfaceException
2594
+	 */
2595
+	protected function _set_publish_post_box_vars(
2596
+		$name = '',
2597
+		$id = 0,
2598
+		$delete = '',
2599
+		$save_close_redirect_URL = '',
2600
+		$both_btns = true
2601
+	) {
2602
+		// if Save & Close, use a custom redirect URL or default to the main page?
2603
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2604
+			? $save_close_redirect_URL
2605
+			: $this->_admin_base_url;
2606
+		// create the Save & Close and Save buttons
2607
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2608
+		// if we have extra content set let's add it in if not make sure its empty
2609
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2610
+			? $this->_template_args['publish_box_extra_content']
2611
+			: '';
2612
+		if ($delete && ! empty($id)) {
2613
+			// make sure we have a default if just true is sent.
2614
+			$delete = ! empty($delete) ? $delete : 'delete';
2615
+			$delete_link_args = array($name => $id);
2616
+			$delete = $this->get_action_link_or_button(
2617
+				$delete,
2618
+				$delete,
2619
+				$delete_link_args,
2620
+				'submitdelete deletion',
2621
+				'',
2622
+				false
2623
+			);
2624
+		}
2625
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2626
+		if (! empty($name) && ! empty($id)) {
2627
+			$hidden_field_arr[ $name ] = array(
2628
+				'type'  => 'hidden',
2629
+				'value' => $id,
2630
+			);
2631
+			$hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2632
+		} else {
2633
+			$hf = '';
2634
+		}
2635
+		// add hidden field
2636
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2637
+			? $hf[ $name ]['field']
2638
+			: $hf;
2639
+	}
2640
+
2641
+
2642
+	/**
2643
+	 * displays an error message to ppl who have javascript disabled
2644
+	 *
2645
+	 * @return void
2646
+	 */
2647
+	private function _display_no_javascript_warning()
2648
+	{
2649
+		?>
2650 2650
         <noscript>
2651 2651
             <div id="no-js-message" class="error">
2652 2652
                 <p style="font-size:1.3em;">
2653 2653
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2654 2654
                     <?php esc_html_e(
2655
-                        '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.',
2656
-                        'event_espresso'
2657
-                    ); ?>
2655
+						'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.',
2656
+						'event_espresso'
2657
+					); ?>
2658 2658
                 </p>
2659 2659
             </div>
2660 2660
         </noscript>
2661 2661
         <?php
2662
-    }
2663
-
2664
-
2665
-    /**
2666
-     * displays espresso success and/or error notices
2667
-     *
2668
-     * @return void
2669
-     */
2670
-    private function _display_espresso_notices()
2671
-    {
2672
-        $notices = $this->_get_transient(true);
2673
-        echo stripslashes($notices);
2674
-    }
2675
-
2676
-
2677
-    /**
2678
-     * spinny things pacify the masses
2679
-     *
2680
-     * @return void
2681
-     */
2682
-    protected function _add_admin_page_ajax_loading_img()
2683
-    {
2684
-        ?>
2662
+	}
2663
+
2664
+
2665
+	/**
2666
+	 * displays espresso success and/or error notices
2667
+	 *
2668
+	 * @return void
2669
+	 */
2670
+	private function _display_espresso_notices()
2671
+	{
2672
+		$notices = $this->_get_transient(true);
2673
+		echo stripslashes($notices);
2674
+	}
2675
+
2676
+
2677
+	/**
2678
+	 * spinny things pacify the masses
2679
+	 *
2680
+	 * @return void
2681
+	 */
2682
+	protected function _add_admin_page_ajax_loading_img()
2683
+	{
2684
+		?>
2685 2685
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2686 2686
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2687
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2687
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2688 2688
         </div>
2689 2689
         <?php
2690
-    }
2690
+	}
2691 2691
 
2692 2692
 
2693
-    /**
2694
-     * add admin page overlay for modal boxes
2695
-     *
2696
-     * @return void
2697
-     */
2698
-    protected function _add_admin_page_overlay()
2699
-    {
2700
-        ?>
2693
+	/**
2694
+	 * add admin page overlay for modal boxes
2695
+	 *
2696
+	 * @return void
2697
+	 */
2698
+	protected function _add_admin_page_overlay()
2699
+	{
2700
+		?>
2701 2701
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2702 2702
         <?php
2703
-    }
2704
-
2705
-
2706
-    /**
2707
-     * facade for add_meta_box
2708
-     *
2709
-     * @param string  $action        where the metabox get's displayed
2710
-     * @param string  $title         Title of Metabox (output in metabox header)
2711
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2712
-     *                               instead of the one created in here.
2713
-     * @param array   $callback_args an array of args supplied for the metabox
2714
-     * @param string  $column        what metabox column
2715
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2716
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2717
-     *                               created but just set our own callback for wp's add_meta_box.
2718
-     * @throws \DomainException
2719
-     */
2720
-    public function _add_admin_page_meta_box(
2721
-        $action,
2722
-        $title,
2723
-        $callback,
2724
-        $callback_args,
2725
-        $column = 'normal',
2726
-        $priority = 'high',
2727
-        $create_func = true
2728
-    ) {
2729
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2730
-        // 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.
2731
-        if (empty($callback_args) && $create_func) {
2732
-            $callback_args = array(
2733
-                'template_path' => $this->_template_path,
2734
-                'template_args' => $this->_template_args,
2735
-            );
2736
-        }
2737
-        // 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)
2738
-        $call_back_func = $create_func
2739
-            ? function ($post, $metabox) {
2740
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2741
-                echo EEH_Template::display_template(
2742
-                    $metabox['args']['template_path'],
2743
-                    $metabox['args']['template_args'],
2744
-                    true
2745
-                );
2746
-            }
2747
-            : $callback;
2748
-        add_meta_box(
2749
-            str_replace('_', '-', $action) . '-mbox',
2750
-            $title,
2751
-            $call_back_func,
2752
-            $this->_wp_page_slug,
2753
-            $column,
2754
-            $priority,
2755
-            $callback_args
2756
-        );
2757
-    }
2758
-
2759
-
2760
-    /**
2761
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2762
-     *
2763
-     * @throws DomainException
2764
-     * @throws EE_Error
2765
-     */
2766
-    public function display_admin_page_with_metabox_columns()
2767
-    {
2768
-        $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2769
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2770
-            $this->_column_template_path,
2771
-            $this->_template_args,
2772
-            true
2773
-        );
2774
-        // the final wrapper
2775
-        $this->admin_page_wrapper();
2776
-    }
2777
-
2778
-
2779
-    /**
2780
-     * generates  HTML wrapper for an admin details page
2781
-     *
2782
-     * @return void
2783
-     * @throws EE_Error
2784
-     * @throws DomainException
2785
-     */
2786
-    public function display_admin_page_with_sidebar()
2787
-    {
2788
-        $this->_display_admin_page(true);
2789
-    }
2790
-
2791
-
2792
-    /**
2793
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2794
-     *
2795
-     * @return void
2796
-     * @throws EE_Error
2797
-     * @throws DomainException
2798
-     */
2799
-    public function display_admin_page_with_no_sidebar()
2800
-    {
2801
-        $this->_display_admin_page();
2802
-    }
2803
-
2804
-
2805
-    /**
2806
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2807
-     *
2808
-     * @return void
2809
-     * @throws EE_Error
2810
-     * @throws DomainException
2811
-     */
2812
-    public function display_about_admin_page()
2813
-    {
2814
-        $this->_display_admin_page(false, true);
2815
-    }
2816
-
2817
-
2818
-    /**
2819
-     * display_admin_page
2820
-     * contains the code for actually displaying an admin page
2821
-     *
2822
-     * @param  boolean $sidebar true with sidebar, false without
2823
-     * @param  boolean $about   use the about admin wrapper instead of the default.
2824
-     * @return void
2825
-     * @throws DomainException
2826
-     * @throws EE_Error
2827
-     */
2828
-    private function _display_admin_page($sidebar = false, $about = false)
2829
-    {
2830
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2831
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2832
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2833
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2834
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2835
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2836
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2837
-            ? 'poststuff'
2838
-            : 'espresso-default-admin';
2839
-        $template_path = $sidebar
2840
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2841
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2842
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2843
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2844
-        }
2845
-        $template_path = ! empty($this->_column_template_path)
2846
-            ? $this->_column_template_path : $template_path;
2847
-        $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2848
-            ? $this->_template_args['admin_page_content']
2849
-            : '';
2850
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2851
-            ? $this->_template_args['before_admin_page_content']
2852
-            : '';
2853
-        $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2854
-            ? $this->_template_args['after_admin_page_content']
2855
-            : '';
2856
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2857
-            $template_path,
2858
-            $this->_template_args,
2859
-            true
2860
-        );
2861
-        // the final template wrapper
2862
-        $this->admin_page_wrapper($about);
2863
-    }
2864
-
2865
-
2866
-    /**
2867
-     * This is used to display caf preview pages.
2868
-     *
2869
-     * @since 4.3.2
2870
-     * @param string $utm_campaign_source what is the key used for google analytics link
2871
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2872
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2873
-     * @return void
2874
-     * @throws DomainException
2875
-     * @throws EE_Error
2876
-     * @throws InvalidArgumentException
2877
-     * @throws InvalidDataTypeException
2878
-     * @throws InvalidInterfaceException
2879
-     */
2880
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2881
-    {
2882
-        // let's generate a default preview action button if there isn't one already present.
2883
-        $this->_labels['buttons']['buy_now'] = esc_html__(
2884
-            'Upgrade to Event Espresso 4 Right Now',
2885
-            'event_espresso'
2886
-        );
2887
-        $buy_now_url = add_query_arg(
2888
-            array(
2889
-                'ee_ver'       => 'ee4',
2890
-                'utm_source'   => 'ee4_plugin_admin',
2891
-                'utm_medium'   => 'link',
2892
-                'utm_campaign' => $utm_campaign_source,
2893
-                'utm_content'  => 'buy_now_button',
2894
-            ),
2895
-            'http://eventespresso.com/pricing/'
2896
-        );
2897
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2898
-            ? $this->get_action_link_or_button(
2899
-                '',
2900
-                'buy_now',
2901
-                array(),
2902
-                'button-primary button-large',
2903
-                $buy_now_url,
2904
-                true
2905
-            )
2906
-            : $this->_template_args['preview_action_button'];
2907
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2908
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2909
-            $this->_template_args,
2910
-            true
2911
-        );
2912
-        $this->_display_admin_page($display_sidebar);
2913
-    }
2914
-
2915
-
2916
-    /**
2917
-     * display_admin_list_table_page_with_sidebar
2918
-     * generates HTML wrapper for an admin_page with list_table
2919
-     *
2920
-     * @return void
2921
-     * @throws EE_Error
2922
-     * @throws DomainException
2923
-     */
2924
-    public function display_admin_list_table_page_with_sidebar()
2925
-    {
2926
-        $this->_display_admin_list_table_page(true);
2927
-    }
2928
-
2929
-
2930
-    /**
2931
-     * display_admin_list_table_page_with_no_sidebar
2932
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2933
-     *
2934
-     * @return void
2935
-     * @throws EE_Error
2936
-     * @throws DomainException
2937
-     */
2938
-    public function display_admin_list_table_page_with_no_sidebar()
2939
-    {
2940
-        $this->_display_admin_list_table_page();
2941
-    }
2942
-
2943
-
2944
-    /**
2945
-     * generates html wrapper for an admin_list_table page
2946
-     *
2947
-     * @param boolean $sidebar whether to display with sidebar or not.
2948
-     * @return void
2949
-     * @throws DomainException
2950
-     * @throws EE_Error
2951
-     */
2952
-    private function _display_admin_list_table_page($sidebar = false)
2953
-    {
2954
-        // setup search attributes
2955
-        $this->_set_search_attributes();
2956
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2957
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2958
-        $this->_template_args['table_url'] = defined('DOING_AJAX')
2959
-            ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2960
-            : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2961
-        $this->_template_args['list_table'] = $this->_list_table_object;
2962
-        $this->_template_args['current_route'] = $this->_req_action;
2963
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2964
-        $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2965
-        if (! empty($ajax_sorting_callback)) {
2966
-            $sortable_list_table_form_fields = wp_nonce_field(
2967
-                $ajax_sorting_callback . '_nonce',
2968
-                $ajax_sorting_callback . '_nonce',
2969
-                false,
2970
-                false
2971
-            );
2972
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2973
-                                                . $this->page_slug
2974
-                                                . '" />';
2975
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2976
-                                                . $ajax_sorting_callback
2977
-                                                . '" />';
2978
-        } else {
2979
-            $sortable_list_table_form_fields = '';
2980
-        }
2981
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2982
-        $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
2983
-            ? $this->_template_args['list_table_hidden_fields']
2984
-            : '';
2985
-        $nonce_ref = $this->_req_action . '_nonce';
2986
-        $hidden_form_fields .= '<input type="hidden" name="'
2987
-                               . $nonce_ref
2988
-                               . '" value="'
2989
-                               . wp_create_nonce($nonce_ref)
2990
-                               . '">';
2991
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2992
-        // display message about search results?
2993
-        $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2994
-            ? '<p class="ee-search-results">' . sprintf(
2995
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2996
-                trim($this->_req_data['s'], '%')
2997
-            ) . '</p>'
2998
-            : '';
2999
-        // filter before_list_table template arg
3000
-        $this->_template_args['before_list_table'] = apply_filters(
3001
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3002
-            $this->_template_args['before_list_table'],
3003
-            $this->page_slug,
3004
-            $this->_req_data,
3005
-            $this->_req_action
3006
-        );
3007
-        // convert to array and filter again
3008
-        // arrays are easier to inject new items in a specific location,
3009
-        // but would not be backwards compatible, so we have to add a new filter
3010
-        $this->_template_args['before_list_table'] = implode(
3011
-            " \n",
3012
-            (array) apply_filters(
3013
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3014
-                (array) $this->_template_args['before_list_table'],
3015
-                $this->page_slug,
3016
-                $this->_req_data,
3017
-                $this->_req_action
3018
-            )
3019
-        );
3020
-        // filter after_list_table template arg
3021
-        $this->_template_args['after_list_table'] = apply_filters(
3022
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3023
-            $this->_template_args['after_list_table'],
3024
-            $this->page_slug,
3025
-            $this->_req_data,
3026
-            $this->_req_action
3027
-        );
3028
-        // convert to array and filter again
3029
-        // arrays are easier to inject new items in a specific location,
3030
-        // but would not be backwards compatible, so we have to add a new filter
3031
-        $this->_template_args['after_list_table'] = implode(
3032
-            " \n",
3033
-            (array) apply_filters(
3034
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3035
-                (array) $this->_template_args['after_list_table'],
3036
-                $this->page_slug,
3037
-                $this->_req_data,
3038
-                $this->_req_action
3039
-            )
3040
-        );
3041
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3042
-            $template_path,
3043
-            $this->_template_args,
3044
-            true
3045
-        );
3046
-        // the final template wrapper
3047
-        if ($sidebar) {
3048
-            $this->display_admin_page_with_sidebar();
3049
-        } else {
3050
-            $this->display_admin_page_with_no_sidebar();
3051
-        }
3052
-    }
3053
-
3054
-
3055
-    /**
3056
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3057
-     * html string for the legend.
3058
-     * $items are expected in an array in the following format:
3059
-     * $legend_items = array(
3060
-     *        'item_id' => array(
3061
-     *            'icon' => 'http://url_to_icon_being_described.png',
3062
-     *            'desc' => esc_html__('localized description of item');
3063
-     *        )
3064
-     * );
3065
-     *
3066
-     * @param  array $items see above for format of array
3067
-     * @return string html string of legend
3068
-     * @throws DomainException
3069
-     */
3070
-    protected function _display_legend($items)
3071
-    {
3072
-        $this->_template_args['items'] = apply_filters(
3073
-            'FHEE__EE_Admin_Page___display_legend__items',
3074
-            (array) $items,
3075
-            $this
3076
-        );
3077
-        return EEH_Template::display_template(
3078
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3079
-            $this->_template_args,
3080
-            true
3081
-        );
3082
-    }
3083
-
3084
-
3085
-    /**
3086
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3087
-     * The returned json object is created from an array in the following format:
3088
-     * array(
3089
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3090
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3091
-     *  'notices' => '', // - contains any EE_Error formatted notices
3092
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3093
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3094
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3095
-     *  that might be included in here)
3096
-     * )
3097
-     * The json object is populated by whatever is set in the $_template_args property.
3098
-     *
3099
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3100
-     *                                 instead of displayed.
3101
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3102
-     * @return void
3103
-     * @throws EE_Error
3104
-     */
3105
-    protected function _return_json($sticky_notices = false, $notices_arguments = array())
3106
-    {
3107
-        // make sure any EE_Error notices have been handled.
3108
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3109
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3110
-        unset($this->_template_args['data']);
3111
-        $json = array(
3112
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3113
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3114
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3115
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3116
-            'notices'   => EE_Error::get_notices(),
3117
-            'content'   => isset($this->_template_args['admin_page_content'])
3118
-                ? $this->_template_args['admin_page_content'] : '',
3119
-            'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3120
-            'isEEajax'  => true
3121
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3122
-        );
3123
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3124
-        if (null === error_get_last() || ! headers_sent()) {
3125
-            header('Content-Type: application/json; charset=UTF-8');
3126
-        }
3127
-        echo wp_json_encode($json);
3128
-        exit();
3129
-    }
3130
-
3131
-
3132
-    /**
3133
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3134
-     *
3135
-     * @return void
3136
-     * @throws EE_Error
3137
-     */
3138
-    public function return_json()
3139
-    {
3140
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3141
-            $this->_return_json();
3142
-        } else {
3143
-            throw new EE_Error(
3144
-                sprintf(
3145
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3146
-                    __FUNCTION__
3147
-                )
3148
-            );
3149
-        }
3150
-    }
3151
-
3152
-
3153
-    /**
3154
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3155
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3156
-     *
3157
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3158
-     */
3159
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3160
-    {
3161
-        $this->_hook_obj = $hook_obj;
3162
-    }
3163
-
3164
-
3165
-    /**
3166
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3167
-     *
3168
-     * @param  boolean $about whether to use the special about page wrapper or default.
3169
-     * @return void
3170
-     * @throws DomainException
3171
-     * @throws EE_Error
3172
-     */
3173
-    public function admin_page_wrapper($about = false)
3174
-    {
3175
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3176
-        $this->_nav_tabs = $this->_get_main_nav_tabs();
3177
-        $this->_template_args['nav_tabs'] = $this->_nav_tabs;
3178
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
3179
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3180
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3181
-            isset($this->_template_args['before_admin_page_content'])
3182
-                ? $this->_template_args['before_admin_page_content']
3183
-                : ''
3184
-        );
3185
-        $this->_template_args['after_admin_page_content'] = apply_filters(
3186
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3187
-            isset($this->_template_args['after_admin_page_content'])
3188
-                ? $this->_template_args['after_admin_page_content']
3189
-                : ''
3190
-        );
3191
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3192
-        // load settings page wrapper template
3193
-        $template_path = ! defined('DOING_AJAX')
3194
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3195
-            : EE_ADMIN_TEMPLATE
3196
-              . 'admin_wrapper_ajax.template.php';
3197
-        // about page?
3198
-        $template_path = $about
3199
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3200
-            : $template_path;
3201
-        if (defined('DOING_AJAX')) {
3202
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3203
-                $template_path,
3204
-                $this->_template_args,
3205
-                true
3206
-            );
3207
-            $this->_return_json();
3208
-        } else {
3209
-            EEH_Template::display_template($template_path, $this->_template_args);
3210
-        }
3211
-    }
3212
-
3213
-
3214
-    /**
3215
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3216
-     *
3217
-     * @return string html
3218
-     * @throws EE_Error
3219
-     */
3220
-    protected function _get_main_nav_tabs()
3221
-    {
3222
-        // let's generate the html using the EEH_Tabbed_Content helper.
3223
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3224
-        // (rather than setting in the page_routes array)
3225
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3226
-    }
3227
-
3228
-
3229
-    /**
3230
-     *        sort nav tabs
3231
-     *
3232
-     * @param $a
3233
-     * @param $b
3234
-     * @return int
3235
-     */
3236
-    private function _sort_nav_tabs($a, $b)
3237
-    {
3238
-        if ($a['order'] === $b['order']) {
3239
-            return 0;
3240
-        }
3241
-        return ($a['order'] < $b['order']) ? -1 : 1;
3242
-    }
3243
-
3244
-
3245
-    /**
3246
-     *    generates HTML for the forms used on admin pages
3247
-     *
3248
-     * @param    array $input_vars - array of input field details
3249
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3250
-     *                             use)
3251
-     * @param bool     $id
3252
-     * @return string
3253
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3254
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3255
-     */
3256
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3257
-    {
3258
-        $content = $generator === 'string'
3259
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3260
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3261
-        return $content;
3262
-    }
3263
-
3264
-
3265
-    /**
3266
-     * generates the "Save" and "Save & Close" buttons for edit forms
3267
-     *
3268
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3269
-     *                                   Close" button.
3270
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3271
-     *                                   'Save', [1] => 'save & close')
3272
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3273
-     *                                   via the "name" value in the button).  We can also use this to just dump
3274
-     *                                   default actions by submitting some other value.
3275
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3276
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3277
-     *                                   close (normal form handling).
3278
-     */
3279
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3280
-    {
3281
-        // make sure $text and $actions are in an array
3282
-        $text = (array) $text;
3283
-        $actions = (array) $actions;
3284
-        $referrer_url = empty($referrer)
3285
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3286
-              . $_SERVER['REQUEST_URI']
3287
-              . '" />'
3288
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3289
-              . $referrer
3290
-              . '" />';
3291
-        $button_text = ! empty($text)
3292
-            ? $text
3293
-            : array(
3294
-                esc_html__('Save', 'event_espresso'),
3295
-                esc_html__('Save and Close', 'event_espresso'),
3296
-            );
3297
-        $default_names = array('save', 'save_and_close');
3298
-        // add in a hidden index for the current page (so save and close redirects properly)
3299
-        $this->_template_args['save_buttons'] = $referrer_url;
3300
-        foreach ($button_text as $key => $button) {
3301
-            $ref = $default_names[ $key ];
3302
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3303
-                                                     . $ref
3304
-                                                     . '" value="'
3305
-                                                     . $button
3306
-                                                     . '" name="'
3307
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3308
-                                                     . '" id="'
3309
-                                                     . $this->_current_view . '_' . $ref
3310
-                                                     . '" />';
3311
-            if (! $both) {
3312
-                break;
3313
-            }
3314
-        }
3315
-    }
3316
-
3317
-
3318
-    /**
3319
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3320
-     *
3321
-     * @see   $this->_set_add_edit_form_tags() for details on params
3322
-     * @since 4.6.0
3323
-     * @param string $route
3324
-     * @param array  $additional_hidden_fields
3325
-     */
3326
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3327
-    {
3328
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3329
-    }
3330
-
3331
-
3332
-    /**
3333
-     * set form open and close tags on add/edit pages.
3334
-     *
3335
-     * @param string $route                    the route you want the form to direct to
3336
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3337
-     * @return void
3338
-     */
3339
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3340
-    {
3341
-        if (empty($route)) {
3342
-            $user_msg = esc_html__(
3343
-                'An error occurred. No action was set for this page\'s form.',
3344
-                'event_espresso'
3345
-            );
3346
-            $dev_msg = $user_msg . "\n"
3347
-                       . sprintf(
3348
-                           esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3349
-                           __FUNCTION__,
3350
-                           __CLASS__
3351
-                       );
3352
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3353
-        }
3354
-        // open form
3355
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3356
-                                                             . $this->_admin_base_url
3357
-                                                             . '" id="'
3358
-                                                             . $route
3359
-                                                             . '_event_form" >';
3360
-        // add nonce
3361
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3362
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3363
-        // add REQUIRED form action
3364
-        $hidden_fields = array(
3365
-            'action' => array('type' => 'hidden', 'value' => $route),
3366
-        );
3367
-        // merge arrays
3368
-        $hidden_fields = is_array($additional_hidden_fields)
3369
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3370
-            : $hidden_fields;
3371
-        // generate form fields
3372
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3373
-        // add fields to form
3374
-        foreach ((array) $form_fields as $field_name => $form_field) {
3375
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3376
-        }
3377
-        // close form
3378
-        $this->_template_args['after_admin_page_content'] = '</form>';
3379
-    }
3380
-
3381
-
3382
-    /**
3383
-     * Public Wrapper for _redirect_after_action() method since its
3384
-     * discovered it would be useful for external code to have access.
3385
-     *
3386
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3387
-     * @since 4.5.0
3388
-     * @param bool   $success
3389
-     * @param string $what
3390
-     * @param string $action_desc
3391
-     * @param array  $query_args
3392
-     * @param bool   $override_overwrite
3393
-     * @throws EE_Error
3394
-     */
3395
-    public function redirect_after_action(
3396
-        $success = false,
3397
-        $what = 'item',
3398
-        $action_desc = 'processed',
3399
-        $query_args = array(),
3400
-        $override_overwrite = false
3401
-    ) {
3402
-        $this->_redirect_after_action(
3403
-            $success,
3404
-            $what,
3405
-            $action_desc,
3406
-            $query_args,
3407
-            $override_overwrite
3408
-        );
3409
-    }
3410
-
3411
-
3412
-    /**
3413
-     *    _redirect_after_action
3414
-     *
3415
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3416
-     * @param string $what               - what the action was performed on
3417
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3418
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3419
-     *                                   action is completed
3420
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3421
-     *                                   override this so that they show.
3422
-     * @return void
3423
-     * @throws EE_Error
3424
-     */
3425
-    protected function _redirect_after_action(
3426
-        $success = 0,
3427
-        $what = 'item',
3428
-        $action_desc = 'processed',
3429
-        $query_args = array(),
3430
-        $override_overwrite = false
3431
-    ) {
3432
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3433
-        // class name for actions/filters.
3434
-        $classname = get_class($this);
3435
-        // set redirect url.
3436
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3437
-        // otherwise we go with whatever is set as the _admin_base_url
3438
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3439
-        $notices = EE_Error::get_notices(false);
3440
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3441
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3442
-            EE_Error::overwrite_success();
3443
-        }
3444
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3445
-            // how many records affected ? more than one record ? or just one ?
3446
-            if ($success > 1) {
3447
-                // set plural msg
3448
-                EE_Error::add_success(
3449
-                    sprintf(
3450
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3451
-                        $what,
3452
-                        $action_desc
3453
-                    ),
3454
-                    __FILE__,
3455
-                    __FUNCTION__,
3456
-                    __LINE__
3457
-                );
3458
-            } elseif ($success === 1) {
3459
-                // set singular msg
3460
-                EE_Error::add_success(
3461
-                    sprintf(
3462
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3463
-                        $what,
3464
-                        $action_desc
3465
-                    ),
3466
-                    __FILE__,
3467
-                    __FUNCTION__,
3468
-                    __LINE__
3469
-                );
3470
-            }
3471
-        }
3472
-        // check that $query_args isn't something crazy
3473
-        if (! is_array($query_args)) {
3474
-            $query_args = array();
3475
-        }
3476
-        /**
3477
-         * Allow injecting actions before the query_args are modified for possible different
3478
-         * redirections on save and close actions
3479
-         *
3480
-         * @since 4.2.0
3481
-         * @param array $query_args       The original query_args array coming into the
3482
-         *                                method.
3483
-         */
3484
-        do_action(
3485
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3486
-            $query_args
3487
-        );
3488
-        // calculate where we're going (if we have a "save and close" button pushed)
3489
-        if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3490
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3491
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3492
-            // regenerate query args array from referrer URL
3493
-            parse_str($parsed_url['query'], $query_args);
3494
-            // correct page and action will be in the query args now
3495
-            $redirect_url = admin_url('admin.php');
3496
-        }
3497
-        // merge any default query_args set in _default_route_query_args property
3498
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3499
-            $args_to_merge = array();
3500
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3501
-                // is there a wp_referer array in our _default_route_query_args property?
3502
-                if ($query_param === 'wp_referer') {
3503
-                    $query_value = (array) $query_value;
3504
-                    foreach ($query_value as $reference => $value) {
3505
-                        if (strpos($reference, 'nonce') !== false) {
3506
-                            continue;
3507
-                        }
3508
-                        // finally we will override any arguments in the referer with
3509
-                        // what might be set on the _default_route_query_args array.
3510
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3511
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3512
-                        } else {
3513
-                            $args_to_merge[ $reference ] = urlencode($value);
3514
-                        }
3515
-                    }
3516
-                    continue;
3517
-                }
3518
-                $args_to_merge[ $query_param ] = $query_value;
3519
-            }
3520
-            // now let's merge these arguments but override with what was specifically sent in to the
3521
-            // redirect.
3522
-            $query_args = array_merge($args_to_merge, $query_args);
3523
-        }
3524
-        $this->_process_notices($query_args);
3525
-        // generate redirect url
3526
-        // if redirecting to anything other than the main page, add a nonce
3527
-        if (isset($query_args['action'])) {
3528
-            // manually generate wp_nonce and merge that with the query vars
3529
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3530
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3531
-        }
3532
-        // we're adding some hooks and filters in here for processing any things just before redirects
3533
-        // (example: an admin page has done an insert or update and we want to run something after that).
3534
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3535
-        $redirect_url = apply_filters(
3536
-            'FHEE_redirect_' . $classname . $this->_req_action,
3537
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3538
-            $query_args
3539
-        );
3540
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3541
-        if (defined('DOING_AJAX')) {
3542
-            $default_data = array(
3543
-                'close'        => true,
3544
-                'redirect_url' => $redirect_url,
3545
-                'where'        => 'main',
3546
-                'what'         => 'append',
3547
-            );
3548
-            $this->_template_args['success'] = $success;
3549
-            $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3550
-                $default_data,
3551
-                $this->_template_args['data']
3552
-            ) : $default_data;
3553
-            $this->_return_json();
3554
-        }
3555
-        wp_safe_redirect($redirect_url);
3556
-        exit();
3557
-    }
3558
-
3559
-
3560
-    /**
3561
-     * process any notices before redirecting (or returning ajax request)
3562
-     * This method sets the $this->_template_args['notices'] attribute;
3563
-     *
3564
-     * @param  array $query_args        any query args that need to be used for notice transient ('action')
3565
-     * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3566
-     *                                  page_routes haven't been defined yet.
3567
-     * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3568
-     *                                  still save a transient for the notice.
3569
-     * @return void
3570
-     * @throws EE_Error
3571
-     */
3572
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3573
-    {
3574
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3575
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3576
-            $notices = EE_Error::get_notices(false);
3577
-            if (empty($this->_template_args['success'])) {
3578
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3579
-            }
3580
-            if (empty($this->_template_args['errors'])) {
3581
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3582
-            }
3583
-            if (empty($this->_template_args['attention'])) {
3584
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3585
-            }
3586
-        }
3587
-        $this->_template_args['notices'] = EE_Error::get_notices();
3588
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3589
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3590
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3591
-            $this->_add_transient(
3592
-                $route,
3593
-                $this->_template_args['notices'],
3594
-                true,
3595
-                $skip_route_verify
3596
-            );
3597
-        }
3598
-    }
3599
-
3600
-
3601
-    /**
3602
-     * get_action_link_or_button
3603
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3604
-     *
3605
-     * @param string $action        use this to indicate which action the url is generated with.
3606
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3607
-     *                              property.
3608
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3609
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3610
-     * @param string $base_url      If this is not provided
3611
-     *                              the _admin_base_url will be used as the default for the button base_url.
3612
-     *                              Otherwise this value will be used.
3613
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3614
-     * @return string
3615
-     * @throws InvalidArgumentException
3616
-     * @throws InvalidInterfaceException
3617
-     * @throws InvalidDataTypeException
3618
-     * @throws EE_Error
3619
-     */
3620
-    public function get_action_link_or_button(
3621
-        $action,
3622
-        $type = 'add',
3623
-        $extra_request = array(),
3624
-        $class = 'button-primary',
3625
-        $base_url = '',
3626
-        $exclude_nonce = false
3627
-    ) {
3628
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3629
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3630
-            throw new EE_Error(
3631
-                sprintf(
3632
-                    esc_html__(
3633
-                        'There is no page route for given action for the button.  This action was given: %s',
3634
-                        'event_espresso'
3635
-                    ),
3636
-                    $action
3637
-                )
3638
-            );
3639
-        }
3640
-        if (! isset($this->_labels['buttons'][ $type ])) {
3641
-            throw new EE_Error(
3642
-                sprintf(
3643
-                    __(
3644
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3645
-                        'event_espresso'
3646
-                    ),
3647
-                    $type
3648
-                )
3649
-            );
3650
-        }
3651
-        // finally check user access for this button.
3652
-        $has_access = $this->check_user_access($action, true);
3653
-        if (! $has_access) {
3654
-            return '';
3655
-        }
3656
-        $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3657
-        $query_args = array(
3658
-            'action' => $action,
3659
-        );
3660
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3661
-        if (! empty($extra_request)) {
3662
-            $query_args = array_merge($extra_request, $query_args);
3663
-        }
3664
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3665
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3666
-    }
3667
-
3668
-
3669
-    /**
3670
-     * _per_page_screen_option
3671
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3672
-     *
3673
-     * @return void
3674
-     * @throws InvalidArgumentException
3675
-     * @throws InvalidInterfaceException
3676
-     * @throws InvalidDataTypeException
3677
-     */
3678
-    protected function _per_page_screen_option()
3679
-    {
3680
-        $option = 'per_page';
3681
-        $args = array(
3682
-            'label'   => apply_filters(
3683
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3684
-                $this->_admin_page_title,
3685
-                $this
3686
-            ),
3687
-            'default' => (int) apply_filters(
3688
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3689
-                10
3690
-            ),
3691
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3692
-        );
3693
-        // ONLY add the screen option if the user has access to it.
3694
-        if ($this->check_user_access($this->_current_view, true)) {
3695
-            add_screen_option($option, $args);
3696
-        }
3697
-    }
3698
-
3699
-
3700
-    /**
3701
-     * set_per_page_screen_option
3702
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3703
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3704
-     * admin_menu.
3705
-     *
3706
-     * @return void
3707
-     */
3708
-    private function _set_per_page_screen_options()
3709
-    {
3710
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3711
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3712
-            if (! $user = wp_get_current_user()) {
3713
-                return;
3714
-            }
3715
-            $option = $_POST['wp_screen_options']['option'];
3716
-            $value = $_POST['wp_screen_options']['value'];
3717
-            if ($option != sanitize_key($option)) {
3718
-                return;
3719
-            }
3720
-            $map_option = $option;
3721
-            $option = str_replace('-', '_', $option);
3722
-            switch ($map_option) {
3723
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3724
-                    $value = (int) $value;
3725
-                    $max_value = apply_filters(
3726
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3727
-                        999,
3728
-                        $this->_current_page,
3729
-                        $this->_current_view
3730
-                    );
3731
-                    if ($value < 1) {
3732
-                        return;
3733
-                    }
3734
-                    $value = min($value, $max_value);
3735
-                    break;
3736
-                default:
3737
-                    $value = apply_filters(
3738
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3739
-                        false,
3740
-                        $option,
3741
-                        $value
3742
-                    );
3743
-                    if (false === $value) {
3744
-                        return;
3745
-                    }
3746
-                    break;
3747
-            }
3748
-            update_user_meta($user->ID, $option, $value);
3749
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3750
-            exit;
3751
-        }
3752
-    }
3753
-
3754
-
3755
-    /**
3756
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3757
-     *
3758
-     * @param array $data array that will be assigned to template args.
3759
-     */
3760
-    public function set_template_args($data)
3761
-    {
3762
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3763
-    }
3764
-
3765
-
3766
-    /**
3767
-     * This makes available the WP transient system for temporarily moving data between routes
3768
-     *
3769
-     * @param string $route             the route that should receive the transient
3770
-     * @param array  $data              the data that gets sent
3771
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3772
-     *                                  normal route transient.
3773
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3774
-     *                                  when we are adding a transient before page_routes have been defined.
3775
-     * @return void
3776
-     * @throws EE_Error
3777
-     */
3778
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3779
-    {
3780
-        $user_id = get_current_user_id();
3781
-        if (! $skip_route_verify) {
3782
-            $this->_verify_route($route);
3783
-        }
3784
-        // now let's set the string for what kind of transient we're setting
3785
-        $transient = $notices
3786
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3787
-            : 'rte_tx_' . $route . '_' . $user_id;
3788
-        $data = $notices ? array('notices' => $data) : $data;
3789
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3790
-        $existing = is_multisite() && is_network_admin()
3791
-            ? get_site_transient($transient)
3792
-            : get_transient($transient);
3793
-        if ($existing) {
3794
-            $data = array_merge((array) $data, (array) $existing);
3795
-        }
3796
-        if (is_multisite() && is_network_admin()) {
3797
-            set_site_transient($transient, $data, 8);
3798
-        } else {
3799
-            set_transient($transient, $data, 8);
3800
-        }
3801
-    }
3802
-
3803
-
3804
-    /**
3805
-     * this retrieves the temporary transient that has been set for moving data between routes.
3806
-     *
3807
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3808
-     * @param string $route
3809
-     * @return mixed data
3810
-     */
3811
-    protected function _get_transient($notices = false, $route = '')
3812
-    {
3813
-        $user_id = get_current_user_id();
3814
-        $route = ! $route ? $this->_req_action : $route;
3815
-        $transient = $notices
3816
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3817
-            : 'rte_tx_' . $route . '_' . $user_id;
3818
-        $data = is_multisite() && is_network_admin()
3819
-            ? get_site_transient($transient)
3820
-            : get_transient($transient);
3821
-        // delete transient after retrieval (just in case it hasn't expired);
3822
-        if (is_multisite() && is_network_admin()) {
3823
-            delete_site_transient($transient);
3824
-        } else {
3825
-            delete_transient($transient);
3826
-        }
3827
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3828
-    }
3829
-
3830
-
3831
-    /**
3832
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3833
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3834
-     * default route callback on the EE_Admin page you want it run.)
3835
-     *
3836
-     * @return void
3837
-     */
3838
-    protected function _transient_garbage_collection()
3839
-    {
3840
-        global $wpdb;
3841
-        // retrieve all existing transients
3842
-        $query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3843
-        if ($results = $wpdb->get_results($query)) {
3844
-            foreach ($results as $result) {
3845
-                $transient = str_replace('_transient_', '', $result->option_name);
3846
-                get_transient($transient);
3847
-                if (is_multisite() && is_network_admin()) {
3848
-                    get_site_transient($transient);
3849
-                }
3850
-            }
3851
-        }
3852
-    }
3853
-
3854
-
3855
-    /**
3856
-     * get_view
3857
-     *
3858
-     * @return string content of _view property
3859
-     */
3860
-    public function get_view()
3861
-    {
3862
-        return $this->_view;
3863
-    }
3864
-
3865
-
3866
-    /**
3867
-     * getter for the protected $_views property
3868
-     *
3869
-     * @return array
3870
-     */
3871
-    public function get_views()
3872
-    {
3873
-        return $this->_views;
3874
-    }
3875
-
3876
-
3877
-    /**
3878
-     * get_current_page
3879
-     *
3880
-     * @return string _current_page property value
3881
-     */
3882
-    public function get_current_page()
3883
-    {
3884
-        return $this->_current_page;
3885
-    }
3886
-
3887
-
3888
-    /**
3889
-     * get_current_view
3890
-     *
3891
-     * @return string _current_view property value
3892
-     */
3893
-    public function get_current_view()
3894
-    {
3895
-        return $this->_current_view;
3896
-    }
3897
-
3898
-
3899
-    /**
3900
-     * get_current_screen
3901
-     *
3902
-     * @return object The current WP_Screen object
3903
-     */
3904
-    public function get_current_screen()
3905
-    {
3906
-        return $this->_current_screen;
3907
-    }
3908
-
3909
-
3910
-    /**
3911
-     * get_current_page_view_url
3912
-     *
3913
-     * @return string This returns the url for the current_page_view.
3914
-     */
3915
-    public function get_current_page_view_url()
3916
-    {
3917
-        return $this->_current_page_view_url;
3918
-    }
3919
-
3920
-
3921
-    /**
3922
-     * just returns the _req_data property
3923
-     *
3924
-     * @return array
3925
-     */
3926
-    public function get_request_data()
3927
-    {
3928
-        return $this->_req_data;
3929
-    }
3930
-
3931
-
3932
-    /**
3933
-     * returns the _req_data protected property
3934
-     *
3935
-     * @return string
3936
-     */
3937
-    public function get_req_action()
3938
-    {
3939
-        return $this->_req_action;
3940
-    }
3941
-
3942
-
3943
-    /**
3944
-     * @return bool  value of $_is_caf property
3945
-     */
3946
-    public function is_caf()
3947
-    {
3948
-        return $this->_is_caf;
3949
-    }
3950
-
3951
-
3952
-    /**
3953
-     * @return mixed
3954
-     */
3955
-    public function default_espresso_metaboxes()
3956
-    {
3957
-        return $this->_default_espresso_metaboxes;
3958
-    }
3959
-
3960
-
3961
-    /**
3962
-     * @return mixed
3963
-     */
3964
-    public function admin_base_url()
3965
-    {
3966
-        return $this->_admin_base_url;
3967
-    }
3968
-
3969
-
3970
-    /**
3971
-     * @return mixed
3972
-     */
3973
-    public function wp_page_slug()
3974
-    {
3975
-        return $this->_wp_page_slug;
3976
-    }
3977
-
3978
-
3979
-    /**
3980
-     * updates  espresso configuration settings
3981
-     *
3982
-     * @param string                   $tab
3983
-     * @param EE_Config_Base|EE_Config $config
3984
-     * @param string                   $file file where error occurred
3985
-     * @param string                   $func function  where error occurred
3986
-     * @param string                   $line line no where error occurred
3987
-     * @return boolean
3988
-     */
3989
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3990
-    {
3991
-        // remove any options that are NOT going to be saved with the config settings.
3992
-        if (isset($config->core->ee_ueip_optin)) {
3993
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3994
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3995
-            update_option('ee_ueip_has_notified', true);
3996
-        }
3997
-        // and save it (note we're also doing the network save here)
3998
-        $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3999
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4000
-        if ($config_saved && $net_saved) {
4001
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4002
-            return true;
4003
-        }
4004
-        EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4005
-        return false;
4006
-    }
4007
-
4008
-
4009
-    /**
4010
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4011
-     *
4012
-     * @return array
4013
-     */
4014
-    public function get_yes_no_values()
4015
-    {
4016
-        return $this->_yes_no_values;
4017
-    }
4018
-
4019
-
4020
-    protected function _get_dir()
4021
-    {
4022
-        $reflector = new ReflectionClass(get_class($this));
4023
-        return dirname($reflector->getFileName());
4024
-    }
4025
-
4026
-
4027
-    /**
4028
-     * A helper for getting a "next link".
4029
-     *
4030
-     * @param string $url   The url to link to
4031
-     * @param string $class The class to use.
4032
-     * @return string
4033
-     */
4034
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4035
-    {
4036
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4037
-    }
4038
-
4039
-
4040
-    /**
4041
-     * A helper for getting a "previous link".
4042
-     *
4043
-     * @param string $url   The url to link to
4044
-     * @param string $class The class to use.
4045
-     * @return string
4046
-     */
4047
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4048
-    {
4049
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4050
-    }
4051
-
4052
-
4053
-
4054
-
4055
-
4056
-
4057
-
4058
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4059
-
4060
-
4061
-    /**
4062
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4063
-     * 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
4064
-     * _req_data array.
4065
-     *
4066
-     * @return bool success/fail
4067
-     * @throws EE_Error
4068
-     * @throws InvalidArgumentException
4069
-     * @throws ReflectionException
4070
-     * @throws InvalidDataTypeException
4071
-     * @throws InvalidInterfaceException
4072
-     */
4073
-    protected function _process_resend_registration()
4074
-    {
4075
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4076
-        do_action(
4077
-            'AHEE__EE_Admin_Page___process_resend_registration',
4078
-            $this->_template_args['success'],
4079
-            $this->_req_data
4080
-        );
4081
-        return $this->_template_args['success'];
4082
-    }
4083
-
4084
-
4085
-    /**
4086
-     * This automatically processes any payment message notifications when manual payment has been applied.
4087
-     *
4088
-     * @param \EE_Payment $payment
4089
-     * @return bool success/fail
4090
-     */
4091
-    protected function _process_payment_notification(EE_Payment $payment)
4092
-    {
4093
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4094
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4095
-        $this->_template_args['success'] = apply_filters(
4096
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4097
-            false,
4098
-            $payment
4099
-        );
4100
-        return $this->_template_args['success'];
4101
-    }
2703
+	}
2704
+
2705
+
2706
+	/**
2707
+	 * facade for add_meta_box
2708
+	 *
2709
+	 * @param string  $action        where the metabox get's displayed
2710
+	 * @param string  $title         Title of Metabox (output in metabox header)
2711
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2712
+	 *                               instead of the one created in here.
2713
+	 * @param array   $callback_args an array of args supplied for the metabox
2714
+	 * @param string  $column        what metabox column
2715
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2716
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2717
+	 *                               created but just set our own callback for wp's add_meta_box.
2718
+	 * @throws \DomainException
2719
+	 */
2720
+	public function _add_admin_page_meta_box(
2721
+		$action,
2722
+		$title,
2723
+		$callback,
2724
+		$callback_args,
2725
+		$column = 'normal',
2726
+		$priority = 'high',
2727
+		$create_func = true
2728
+	) {
2729
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2730
+		// 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.
2731
+		if (empty($callback_args) && $create_func) {
2732
+			$callback_args = array(
2733
+				'template_path' => $this->_template_path,
2734
+				'template_args' => $this->_template_args,
2735
+			);
2736
+		}
2737
+		// 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)
2738
+		$call_back_func = $create_func
2739
+			? function ($post, $metabox) {
2740
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2741
+				echo EEH_Template::display_template(
2742
+					$metabox['args']['template_path'],
2743
+					$metabox['args']['template_args'],
2744
+					true
2745
+				);
2746
+			}
2747
+			: $callback;
2748
+		add_meta_box(
2749
+			str_replace('_', '-', $action) . '-mbox',
2750
+			$title,
2751
+			$call_back_func,
2752
+			$this->_wp_page_slug,
2753
+			$column,
2754
+			$priority,
2755
+			$callback_args
2756
+		);
2757
+	}
2758
+
2759
+
2760
+	/**
2761
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2762
+	 *
2763
+	 * @throws DomainException
2764
+	 * @throws EE_Error
2765
+	 */
2766
+	public function display_admin_page_with_metabox_columns()
2767
+	{
2768
+		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2769
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2770
+			$this->_column_template_path,
2771
+			$this->_template_args,
2772
+			true
2773
+		);
2774
+		// the final wrapper
2775
+		$this->admin_page_wrapper();
2776
+	}
2777
+
2778
+
2779
+	/**
2780
+	 * generates  HTML wrapper for an admin details page
2781
+	 *
2782
+	 * @return void
2783
+	 * @throws EE_Error
2784
+	 * @throws DomainException
2785
+	 */
2786
+	public function display_admin_page_with_sidebar()
2787
+	{
2788
+		$this->_display_admin_page(true);
2789
+	}
2790
+
2791
+
2792
+	/**
2793
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2794
+	 *
2795
+	 * @return void
2796
+	 * @throws EE_Error
2797
+	 * @throws DomainException
2798
+	 */
2799
+	public function display_admin_page_with_no_sidebar()
2800
+	{
2801
+		$this->_display_admin_page();
2802
+	}
2803
+
2804
+
2805
+	/**
2806
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2807
+	 *
2808
+	 * @return void
2809
+	 * @throws EE_Error
2810
+	 * @throws DomainException
2811
+	 */
2812
+	public function display_about_admin_page()
2813
+	{
2814
+		$this->_display_admin_page(false, true);
2815
+	}
2816
+
2817
+
2818
+	/**
2819
+	 * display_admin_page
2820
+	 * contains the code for actually displaying an admin page
2821
+	 *
2822
+	 * @param  boolean $sidebar true with sidebar, false without
2823
+	 * @param  boolean $about   use the about admin wrapper instead of the default.
2824
+	 * @return void
2825
+	 * @throws DomainException
2826
+	 * @throws EE_Error
2827
+	 */
2828
+	private function _display_admin_page($sidebar = false, $about = false)
2829
+	{
2830
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2831
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2832
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2833
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2834
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2835
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2836
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2837
+			? 'poststuff'
2838
+			: 'espresso-default-admin';
2839
+		$template_path = $sidebar
2840
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2841
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2842
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2843
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2844
+		}
2845
+		$template_path = ! empty($this->_column_template_path)
2846
+			? $this->_column_template_path : $template_path;
2847
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content'])
2848
+			? $this->_template_args['admin_page_content']
2849
+			: '';
2850
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2851
+			? $this->_template_args['before_admin_page_content']
2852
+			: '';
2853
+		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content'])
2854
+			? $this->_template_args['after_admin_page_content']
2855
+			: '';
2856
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2857
+			$template_path,
2858
+			$this->_template_args,
2859
+			true
2860
+		);
2861
+		// the final template wrapper
2862
+		$this->admin_page_wrapper($about);
2863
+	}
2864
+
2865
+
2866
+	/**
2867
+	 * This is used to display caf preview pages.
2868
+	 *
2869
+	 * @since 4.3.2
2870
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2871
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2872
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2873
+	 * @return void
2874
+	 * @throws DomainException
2875
+	 * @throws EE_Error
2876
+	 * @throws InvalidArgumentException
2877
+	 * @throws InvalidDataTypeException
2878
+	 * @throws InvalidInterfaceException
2879
+	 */
2880
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2881
+	{
2882
+		// let's generate a default preview action button if there isn't one already present.
2883
+		$this->_labels['buttons']['buy_now'] = esc_html__(
2884
+			'Upgrade to Event Espresso 4 Right Now',
2885
+			'event_espresso'
2886
+		);
2887
+		$buy_now_url = add_query_arg(
2888
+			array(
2889
+				'ee_ver'       => 'ee4',
2890
+				'utm_source'   => 'ee4_plugin_admin',
2891
+				'utm_medium'   => 'link',
2892
+				'utm_campaign' => $utm_campaign_source,
2893
+				'utm_content'  => 'buy_now_button',
2894
+			),
2895
+			'http://eventespresso.com/pricing/'
2896
+		);
2897
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2898
+			? $this->get_action_link_or_button(
2899
+				'',
2900
+				'buy_now',
2901
+				array(),
2902
+				'button-primary button-large',
2903
+				$buy_now_url,
2904
+				true
2905
+			)
2906
+			: $this->_template_args['preview_action_button'];
2907
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2908
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2909
+			$this->_template_args,
2910
+			true
2911
+		);
2912
+		$this->_display_admin_page($display_sidebar);
2913
+	}
2914
+
2915
+
2916
+	/**
2917
+	 * display_admin_list_table_page_with_sidebar
2918
+	 * generates HTML wrapper for an admin_page with list_table
2919
+	 *
2920
+	 * @return void
2921
+	 * @throws EE_Error
2922
+	 * @throws DomainException
2923
+	 */
2924
+	public function display_admin_list_table_page_with_sidebar()
2925
+	{
2926
+		$this->_display_admin_list_table_page(true);
2927
+	}
2928
+
2929
+
2930
+	/**
2931
+	 * display_admin_list_table_page_with_no_sidebar
2932
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2933
+	 *
2934
+	 * @return void
2935
+	 * @throws EE_Error
2936
+	 * @throws DomainException
2937
+	 */
2938
+	public function display_admin_list_table_page_with_no_sidebar()
2939
+	{
2940
+		$this->_display_admin_list_table_page();
2941
+	}
2942
+
2943
+
2944
+	/**
2945
+	 * generates html wrapper for an admin_list_table page
2946
+	 *
2947
+	 * @param boolean $sidebar whether to display with sidebar or not.
2948
+	 * @return void
2949
+	 * @throws DomainException
2950
+	 * @throws EE_Error
2951
+	 */
2952
+	private function _display_admin_list_table_page($sidebar = false)
2953
+	{
2954
+		// setup search attributes
2955
+		$this->_set_search_attributes();
2956
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2957
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2958
+		$this->_template_args['table_url'] = defined('DOING_AJAX')
2959
+			? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2960
+			: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2961
+		$this->_template_args['list_table'] = $this->_list_table_object;
2962
+		$this->_template_args['current_route'] = $this->_req_action;
2963
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2964
+		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2965
+		if (! empty($ajax_sorting_callback)) {
2966
+			$sortable_list_table_form_fields = wp_nonce_field(
2967
+				$ajax_sorting_callback . '_nonce',
2968
+				$ajax_sorting_callback . '_nonce',
2969
+				false,
2970
+				false
2971
+			);
2972
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2973
+												. $this->page_slug
2974
+												. '" />';
2975
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2976
+												. $ajax_sorting_callback
2977
+												. '" />';
2978
+		} else {
2979
+			$sortable_list_table_form_fields = '';
2980
+		}
2981
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2982
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields'])
2983
+			? $this->_template_args['list_table_hidden_fields']
2984
+			: '';
2985
+		$nonce_ref = $this->_req_action . '_nonce';
2986
+		$hidden_form_fields .= '<input type="hidden" name="'
2987
+							   . $nonce_ref
2988
+							   . '" value="'
2989
+							   . wp_create_nonce($nonce_ref)
2990
+							   . '">';
2991
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2992
+		// display message about search results?
2993
+		$this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2994
+			? '<p class="ee-search-results">' . sprintf(
2995
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2996
+				trim($this->_req_data['s'], '%')
2997
+			) . '</p>'
2998
+			: '';
2999
+		// filter before_list_table template arg
3000
+		$this->_template_args['before_list_table'] = apply_filters(
3001
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3002
+			$this->_template_args['before_list_table'],
3003
+			$this->page_slug,
3004
+			$this->_req_data,
3005
+			$this->_req_action
3006
+		);
3007
+		// convert to array and filter again
3008
+		// arrays are easier to inject new items in a specific location,
3009
+		// but would not be backwards compatible, so we have to add a new filter
3010
+		$this->_template_args['before_list_table'] = implode(
3011
+			" \n",
3012
+			(array) apply_filters(
3013
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3014
+				(array) $this->_template_args['before_list_table'],
3015
+				$this->page_slug,
3016
+				$this->_req_data,
3017
+				$this->_req_action
3018
+			)
3019
+		);
3020
+		// filter after_list_table template arg
3021
+		$this->_template_args['after_list_table'] = apply_filters(
3022
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3023
+			$this->_template_args['after_list_table'],
3024
+			$this->page_slug,
3025
+			$this->_req_data,
3026
+			$this->_req_action
3027
+		);
3028
+		// convert to array and filter again
3029
+		// arrays are easier to inject new items in a specific location,
3030
+		// but would not be backwards compatible, so we have to add a new filter
3031
+		$this->_template_args['after_list_table'] = implode(
3032
+			" \n",
3033
+			(array) apply_filters(
3034
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3035
+				(array) $this->_template_args['after_list_table'],
3036
+				$this->page_slug,
3037
+				$this->_req_data,
3038
+				$this->_req_action
3039
+			)
3040
+		);
3041
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3042
+			$template_path,
3043
+			$this->_template_args,
3044
+			true
3045
+		);
3046
+		// the final template wrapper
3047
+		if ($sidebar) {
3048
+			$this->display_admin_page_with_sidebar();
3049
+		} else {
3050
+			$this->display_admin_page_with_no_sidebar();
3051
+		}
3052
+	}
3053
+
3054
+
3055
+	/**
3056
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3057
+	 * html string for the legend.
3058
+	 * $items are expected in an array in the following format:
3059
+	 * $legend_items = array(
3060
+	 *        'item_id' => array(
3061
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3062
+	 *            'desc' => esc_html__('localized description of item');
3063
+	 *        )
3064
+	 * );
3065
+	 *
3066
+	 * @param  array $items see above for format of array
3067
+	 * @return string html string of legend
3068
+	 * @throws DomainException
3069
+	 */
3070
+	protected function _display_legend($items)
3071
+	{
3072
+		$this->_template_args['items'] = apply_filters(
3073
+			'FHEE__EE_Admin_Page___display_legend__items',
3074
+			(array) $items,
3075
+			$this
3076
+		);
3077
+		return EEH_Template::display_template(
3078
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3079
+			$this->_template_args,
3080
+			true
3081
+		);
3082
+	}
3083
+
3084
+
3085
+	/**
3086
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3087
+	 * The returned json object is created from an array in the following format:
3088
+	 * array(
3089
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3090
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3091
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3092
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3093
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3094
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3095
+	 *  that might be included in here)
3096
+	 * )
3097
+	 * The json object is populated by whatever is set in the $_template_args property.
3098
+	 *
3099
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3100
+	 *                                 instead of displayed.
3101
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3102
+	 * @return void
3103
+	 * @throws EE_Error
3104
+	 */
3105
+	protected function _return_json($sticky_notices = false, $notices_arguments = array())
3106
+	{
3107
+		// make sure any EE_Error notices have been handled.
3108
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3109
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3110
+		unset($this->_template_args['data']);
3111
+		$json = array(
3112
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3113
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3114
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3115
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3116
+			'notices'   => EE_Error::get_notices(),
3117
+			'content'   => isset($this->_template_args['admin_page_content'])
3118
+				? $this->_template_args['admin_page_content'] : '',
3119
+			'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3120
+			'isEEajax'  => true
3121
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3122
+		);
3123
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3124
+		if (null === error_get_last() || ! headers_sent()) {
3125
+			header('Content-Type: application/json; charset=UTF-8');
3126
+		}
3127
+		echo wp_json_encode($json);
3128
+		exit();
3129
+	}
3130
+
3131
+
3132
+	/**
3133
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3134
+	 *
3135
+	 * @return void
3136
+	 * @throws EE_Error
3137
+	 */
3138
+	public function return_json()
3139
+	{
3140
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3141
+			$this->_return_json();
3142
+		} else {
3143
+			throw new EE_Error(
3144
+				sprintf(
3145
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3146
+					__FUNCTION__
3147
+				)
3148
+			);
3149
+		}
3150
+	}
3151
+
3152
+
3153
+	/**
3154
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3155
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3156
+	 *
3157
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3158
+	 */
3159
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3160
+	{
3161
+		$this->_hook_obj = $hook_obj;
3162
+	}
3163
+
3164
+
3165
+	/**
3166
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3167
+	 *
3168
+	 * @param  boolean $about whether to use the special about page wrapper or default.
3169
+	 * @return void
3170
+	 * @throws DomainException
3171
+	 * @throws EE_Error
3172
+	 */
3173
+	public function admin_page_wrapper($about = false)
3174
+	{
3175
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3176
+		$this->_nav_tabs = $this->_get_main_nav_tabs();
3177
+		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
3178
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
3179
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3180
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3181
+			isset($this->_template_args['before_admin_page_content'])
3182
+				? $this->_template_args['before_admin_page_content']
3183
+				: ''
3184
+		);
3185
+		$this->_template_args['after_admin_page_content'] = apply_filters(
3186
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3187
+			isset($this->_template_args['after_admin_page_content'])
3188
+				? $this->_template_args['after_admin_page_content']
3189
+				: ''
3190
+		);
3191
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3192
+		// load settings page wrapper template
3193
+		$template_path = ! defined('DOING_AJAX')
3194
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3195
+			: EE_ADMIN_TEMPLATE
3196
+			  . 'admin_wrapper_ajax.template.php';
3197
+		// about page?
3198
+		$template_path = $about
3199
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3200
+			: $template_path;
3201
+		if (defined('DOING_AJAX')) {
3202
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3203
+				$template_path,
3204
+				$this->_template_args,
3205
+				true
3206
+			);
3207
+			$this->_return_json();
3208
+		} else {
3209
+			EEH_Template::display_template($template_path, $this->_template_args);
3210
+		}
3211
+	}
3212
+
3213
+
3214
+	/**
3215
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3216
+	 *
3217
+	 * @return string html
3218
+	 * @throws EE_Error
3219
+	 */
3220
+	protected function _get_main_nav_tabs()
3221
+	{
3222
+		// let's generate the html using the EEH_Tabbed_Content helper.
3223
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3224
+		// (rather than setting in the page_routes array)
3225
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3226
+	}
3227
+
3228
+
3229
+	/**
3230
+	 *        sort nav tabs
3231
+	 *
3232
+	 * @param $a
3233
+	 * @param $b
3234
+	 * @return int
3235
+	 */
3236
+	private function _sort_nav_tabs($a, $b)
3237
+	{
3238
+		if ($a['order'] === $b['order']) {
3239
+			return 0;
3240
+		}
3241
+		return ($a['order'] < $b['order']) ? -1 : 1;
3242
+	}
3243
+
3244
+
3245
+	/**
3246
+	 *    generates HTML for the forms used on admin pages
3247
+	 *
3248
+	 * @param    array $input_vars - array of input field details
3249
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3250
+	 *                             use)
3251
+	 * @param bool     $id
3252
+	 * @return string
3253
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3254
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3255
+	 */
3256
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3257
+	{
3258
+		$content = $generator === 'string'
3259
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3260
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3261
+		return $content;
3262
+	}
3263
+
3264
+
3265
+	/**
3266
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3267
+	 *
3268
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3269
+	 *                                   Close" button.
3270
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3271
+	 *                                   'Save', [1] => 'save & close')
3272
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3273
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3274
+	 *                                   default actions by submitting some other value.
3275
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3276
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3277
+	 *                                   close (normal form handling).
3278
+	 */
3279
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3280
+	{
3281
+		// make sure $text and $actions are in an array
3282
+		$text = (array) $text;
3283
+		$actions = (array) $actions;
3284
+		$referrer_url = empty($referrer)
3285
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3286
+			  . $_SERVER['REQUEST_URI']
3287
+			  . '" />'
3288
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3289
+			  . $referrer
3290
+			  . '" />';
3291
+		$button_text = ! empty($text)
3292
+			? $text
3293
+			: array(
3294
+				esc_html__('Save', 'event_espresso'),
3295
+				esc_html__('Save and Close', 'event_espresso'),
3296
+			);
3297
+		$default_names = array('save', 'save_and_close');
3298
+		// add in a hidden index for the current page (so save and close redirects properly)
3299
+		$this->_template_args['save_buttons'] = $referrer_url;
3300
+		foreach ($button_text as $key => $button) {
3301
+			$ref = $default_names[ $key ];
3302
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3303
+													 . $ref
3304
+													 . '" value="'
3305
+													 . $button
3306
+													 . '" name="'
3307
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3308
+													 . '" id="'
3309
+													 . $this->_current_view . '_' . $ref
3310
+													 . '" />';
3311
+			if (! $both) {
3312
+				break;
3313
+			}
3314
+		}
3315
+	}
3316
+
3317
+
3318
+	/**
3319
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3320
+	 *
3321
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3322
+	 * @since 4.6.0
3323
+	 * @param string $route
3324
+	 * @param array  $additional_hidden_fields
3325
+	 */
3326
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3327
+	{
3328
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3329
+	}
3330
+
3331
+
3332
+	/**
3333
+	 * set form open and close tags on add/edit pages.
3334
+	 *
3335
+	 * @param string $route                    the route you want the form to direct to
3336
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3337
+	 * @return void
3338
+	 */
3339
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3340
+	{
3341
+		if (empty($route)) {
3342
+			$user_msg = esc_html__(
3343
+				'An error occurred. No action was set for this page\'s form.',
3344
+				'event_espresso'
3345
+			);
3346
+			$dev_msg = $user_msg . "\n"
3347
+					   . sprintf(
3348
+						   esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3349
+						   __FUNCTION__,
3350
+						   __CLASS__
3351
+					   );
3352
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3353
+		}
3354
+		// open form
3355
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3356
+															 . $this->_admin_base_url
3357
+															 . '" id="'
3358
+															 . $route
3359
+															 . '_event_form" >';
3360
+		// add nonce
3361
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3362
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3363
+		// add REQUIRED form action
3364
+		$hidden_fields = array(
3365
+			'action' => array('type' => 'hidden', 'value' => $route),
3366
+		);
3367
+		// merge arrays
3368
+		$hidden_fields = is_array($additional_hidden_fields)
3369
+			? array_merge($hidden_fields, $additional_hidden_fields)
3370
+			: $hidden_fields;
3371
+		// generate form fields
3372
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3373
+		// add fields to form
3374
+		foreach ((array) $form_fields as $field_name => $form_field) {
3375
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3376
+		}
3377
+		// close form
3378
+		$this->_template_args['after_admin_page_content'] = '</form>';
3379
+	}
3380
+
3381
+
3382
+	/**
3383
+	 * Public Wrapper for _redirect_after_action() method since its
3384
+	 * discovered it would be useful for external code to have access.
3385
+	 *
3386
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3387
+	 * @since 4.5.0
3388
+	 * @param bool   $success
3389
+	 * @param string $what
3390
+	 * @param string $action_desc
3391
+	 * @param array  $query_args
3392
+	 * @param bool   $override_overwrite
3393
+	 * @throws EE_Error
3394
+	 */
3395
+	public function redirect_after_action(
3396
+		$success = false,
3397
+		$what = 'item',
3398
+		$action_desc = 'processed',
3399
+		$query_args = array(),
3400
+		$override_overwrite = false
3401
+	) {
3402
+		$this->_redirect_after_action(
3403
+			$success,
3404
+			$what,
3405
+			$action_desc,
3406
+			$query_args,
3407
+			$override_overwrite
3408
+		);
3409
+	}
3410
+
3411
+
3412
+	/**
3413
+	 *    _redirect_after_action
3414
+	 *
3415
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3416
+	 * @param string $what               - what the action was performed on
3417
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3418
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3419
+	 *                                   action is completed
3420
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3421
+	 *                                   override this so that they show.
3422
+	 * @return void
3423
+	 * @throws EE_Error
3424
+	 */
3425
+	protected function _redirect_after_action(
3426
+		$success = 0,
3427
+		$what = 'item',
3428
+		$action_desc = 'processed',
3429
+		$query_args = array(),
3430
+		$override_overwrite = false
3431
+	) {
3432
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3433
+		// class name for actions/filters.
3434
+		$classname = get_class($this);
3435
+		// set redirect url.
3436
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3437
+		// otherwise we go with whatever is set as the _admin_base_url
3438
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3439
+		$notices = EE_Error::get_notices(false);
3440
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3441
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3442
+			EE_Error::overwrite_success();
3443
+		}
3444
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3445
+			// how many records affected ? more than one record ? or just one ?
3446
+			if ($success > 1) {
3447
+				// set plural msg
3448
+				EE_Error::add_success(
3449
+					sprintf(
3450
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3451
+						$what,
3452
+						$action_desc
3453
+					),
3454
+					__FILE__,
3455
+					__FUNCTION__,
3456
+					__LINE__
3457
+				);
3458
+			} elseif ($success === 1) {
3459
+				// set singular msg
3460
+				EE_Error::add_success(
3461
+					sprintf(
3462
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3463
+						$what,
3464
+						$action_desc
3465
+					),
3466
+					__FILE__,
3467
+					__FUNCTION__,
3468
+					__LINE__
3469
+				);
3470
+			}
3471
+		}
3472
+		// check that $query_args isn't something crazy
3473
+		if (! is_array($query_args)) {
3474
+			$query_args = array();
3475
+		}
3476
+		/**
3477
+		 * Allow injecting actions before the query_args are modified for possible different
3478
+		 * redirections on save and close actions
3479
+		 *
3480
+		 * @since 4.2.0
3481
+		 * @param array $query_args       The original query_args array coming into the
3482
+		 *                                method.
3483
+		 */
3484
+		do_action(
3485
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3486
+			$query_args
3487
+		);
3488
+		// calculate where we're going (if we have a "save and close" button pushed)
3489
+		if (isset($this->_req_data['save_and_close'], $this->_req_data['save_and_close_referrer'])) {
3490
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3491
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3492
+			// regenerate query args array from referrer URL
3493
+			parse_str($parsed_url['query'], $query_args);
3494
+			// correct page and action will be in the query args now
3495
+			$redirect_url = admin_url('admin.php');
3496
+		}
3497
+		// merge any default query_args set in _default_route_query_args property
3498
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3499
+			$args_to_merge = array();
3500
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3501
+				// is there a wp_referer array in our _default_route_query_args property?
3502
+				if ($query_param === 'wp_referer') {
3503
+					$query_value = (array) $query_value;
3504
+					foreach ($query_value as $reference => $value) {
3505
+						if (strpos($reference, 'nonce') !== false) {
3506
+							continue;
3507
+						}
3508
+						// finally we will override any arguments in the referer with
3509
+						// what might be set on the _default_route_query_args array.
3510
+						if (isset($this->_default_route_query_args[ $reference ])) {
3511
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3512
+						} else {
3513
+							$args_to_merge[ $reference ] = urlencode($value);
3514
+						}
3515
+					}
3516
+					continue;
3517
+				}
3518
+				$args_to_merge[ $query_param ] = $query_value;
3519
+			}
3520
+			// now let's merge these arguments but override with what was specifically sent in to the
3521
+			// redirect.
3522
+			$query_args = array_merge($args_to_merge, $query_args);
3523
+		}
3524
+		$this->_process_notices($query_args);
3525
+		// generate redirect url
3526
+		// if redirecting to anything other than the main page, add a nonce
3527
+		if (isset($query_args['action'])) {
3528
+			// manually generate wp_nonce and merge that with the query vars
3529
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3530
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3531
+		}
3532
+		// we're adding some hooks and filters in here for processing any things just before redirects
3533
+		// (example: an admin page has done an insert or update and we want to run something after that).
3534
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3535
+		$redirect_url = apply_filters(
3536
+			'FHEE_redirect_' . $classname . $this->_req_action,
3537
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3538
+			$query_args
3539
+		);
3540
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3541
+		if (defined('DOING_AJAX')) {
3542
+			$default_data = array(
3543
+				'close'        => true,
3544
+				'redirect_url' => $redirect_url,
3545
+				'where'        => 'main',
3546
+				'what'         => 'append',
3547
+			);
3548
+			$this->_template_args['success'] = $success;
3549
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge(
3550
+				$default_data,
3551
+				$this->_template_args['data']
3552
+			) : $default_data;
3553
+			$this->_return_json();
3554
+		}
3555
+		wp_safe_redirect($redirect_url);
3556
+		exit();
3557
+	}
3558
+
3559
+
3560
+	/**
3561
+	 * process any notices before redirecting (or returning ajax request)
3562
+	 * This method sets the $this->_template_args['notices'] attribute;
3563
+	 *
3564
+	 * @param  array $query_args        any query args that need to be used for notice transient ('action')
3565
+	 * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3566
+	 *                                  page_routes haven't been defined yet.
3567
+	 * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3568
+	 *                                  still save a transient for the notice.
3569
+	 * @return void
3570
+	 * @throws EE_Error
3571
+	 */
3572
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3573
+	{
3574
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3575
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3576
+			$notices = EE_Error::get_notices(false);
3577
+			if (empty($this->_template_args['success'])) {
3578
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3579
+			}
3580
+			if (empty($this->_template_args['errors'])) {
3581
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3582
+			}
3583
+			if (empty($this->_template_args['attention'])) {
3584
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3585
+			}
3586
+		}
3587
+		$this->_template_args['notices'] = EE_Error::get_notices();
3588
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3589
+		if (! defined('DOING_AJAX') || $sticky_notices) {
3590
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3591
+			$this->_add_transient(
3592
+				$route,
3593
+				$this->_template_args['notices'],
3594
+				true,
3595
+				$skip_route_verify
3596
+			);
3597
+		}
3598
+	}
3599
+
3600
+
3601
+	/**
3602
+	 * get_action_link_or_button
3603
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3604
+	 *
3605
+	 * @param string $action        use this to indicate which action the url is generated with.
3606
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3607
+	 *                              property.
3608
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3609
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3610
+	 * @param string $base_url      If this is not provided
3611
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3612
+	 *                              Otherwise this value will be used.
3613
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3614
+	 * @return string
3615
+	 * @throws InvalidArgumentException
3616
+	 * @throws InvalidInterfaceException
3617
+	 * @throws InvalidDataTypeException
3618
+	 * @throws EE_Error
3619
+	 */
3620
+	public function get_action_link_or_button(
3621
+		$action,
3622
+		$type = 'add',
3623
+		$extra_request = array(),
3624
+		$class = 'button-primary',
3625
+		$base_url = '',
3626
+		$exclude_nonce = false
3627
+	) {
3628
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3629
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3630
+			throw new EE_Error(
3631
+				sprintf(
3632
+					esc_html__(
3633
+						'There is no page route for given action for the button.  This action was given: %s',
3634
+						'event_espresso'
3635
+					),
3636
+					$action
3637
+				)
3638
+			);
3639
+		}
3640
+		if (! isset($this->_labels['buttons'][ $type ])) {
3641
+			throw new EE_Error(
3642
+				sprintf(
3643
+					__(
3644
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3645
+						'event_espresso'
3646
+					),
3647
+					$type
3648
+				)
3649
+			);
3650
+		}
3651
+		// finally check user access for this button.
3652
+		$has_access = $this->check_user_access($action, true);
3653
+		if (! $has_access) {
3654
+			return '';
3655
+		}
3656
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
3657
+		$query_args = array(
3658
+			'action' => $action,
3659
+		);
3660
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3661
+		if (! empty($extra_request)) {
3662
+			$query_args = array_merge($extra_request, $query_args);
3663
+		}
3664
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3665
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3666
+	}
3667
+
3668
+
3669
+	/**
3670
+	 * _per_page_screen_option
3671
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3672
+	 *
3673
+	 * @return void
3674
+	 * @throws InvalidArgumentException
3675
+	 * @throws InvalidInterfaceException
3676
+	 * @throws InvalidDataTypeException
3677
+	 */
3678
+	protected function _per_page_screen_option()
3679
+	{
3680
+		$option = 'per_page';
3681
+		$args = array(
3682
+			'label'   => apply_filters(
3683
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3684
+				$this->_admin_page_title,
3685
+				$this
3686
+			),
3687
+			'default' => (int) apply_filters(
3688
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3689
+				10
3690
+			),
3691
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3692
+		);
3693
+		// ONLY add the screen option if the user has access to it.
3694
+		if ($this->check_user_access($this->_current_view, true)) {
3695
+			add_screen_option($option, $args);
3696
+		}
3697
+	}
3698
+
3699
+
3700
+	/**
3701
+	 * set_per_page_screen_option
3702
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3703
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3704
+	 * admin_menu.
3705
+	 *
3706
+	 * @return void
3707
+	 */
3708
+	private function _set_per_page_screen_options()
3709
+	{
3710
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3711
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3712
+			if (! $user = wp_get_current_user()) {
3713
+				return;
3714
+			}
3715
+			$option = $_POST['wp_screen_options']['option'];
3716
+			$value = $_POST['wp_screen_options']['value'];
3717
+			if ($option != sanitize_key($option)) {
3718
+				return;
3719
+			}
3720
+			$map_option = $option;
3721
+			$option = str_replace('-', '_', $option);
3722
+			switch ($map_option) {
3723
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3724
+					$value = (int) $value;
3725
+					$max_value = apply_filters(
3726
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3727
+						999,
3728
+						$this->_current_page,
3729
+						$this->_current_view
3730
+					);
3731
+					if ($value < 1) {
3732
+						return;
3733
+					}
3734
+					$value = min($value, $max_value);
3735
+					break;
3736
+				default:
3737
+					$value = apply_filters(
3738
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3739
+						false,
3740
+						$option,
3741
+						$value
3742
+					);
3743
+					if (false === $value) {
3744
+						return;
3745
+					}
3746
+					break;
3747
+			}
3748
+			update_user_meta($user->ID, $option, $value);
3749
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3750
+			exit;
3751
+		}
3752
+	}
3753
+
3754
+
3755
+	/**
3756
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3757
+	 *
3758
+	 * @param array $data array that will be assigned to template args.
3759
+	 */
3760
+	public function set_template_args($data)
3761
+	{
3762
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3763
+	}
3764
+
3765
+
3766
+	/**
3767
+	 * This makes available the WP transient system for temporarily moving data between routes
3768
+	 *
3769
+	 * @param string $route             the route that should receive the transient
3770
+	 * @param array  $data              the data that gets sent
3771
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3772
+	 *                                  normal route transient.
3773
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3774
+	 *                                  when we are adding a transient before page_routes have been defined.
3775
+	 * @return void
3776
+	 * @throws EE_Error
3777
+	 */
3778
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3779
+	{
3780
+		$user_id = get_current_user_id();
3781
+		if (! $skip_route_verify) {
3782
+			$this->_verify_route($route);
3783
+		}
3784
+		// now let's set the string for what kind of transient we're setting
3785
+		$transient = $notices
3786
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3787
+			: 'rte_tx_' . $route . '_' . $user_id;
3788
+		$data = $notices ? array('notices' => $data) : $data;
3789
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3790
+		$existing = is_multisite() && is_network_admin()
3791
+			? get_site_transient($transient)
3792
+			: get_transient($transient);
3793
+		if ($existing) {
3794
+			$data = array_merge((array) $data, (array) $existing);
3795
+		}
3796
+		if (is_multisite() && is_network_admin()) {
3797
+			set_site_transient($transient, $data, 8);
3798
+		} else {
3799
+			set_transient($transient, $data, 8);
3800
+		}
3801
+	}
3802
+
3803
+
3804
+	/**
3805
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3806
+	 *
3807
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3808
+	 * @param string $route
3809
+	 * @return mixed data
3810
+	 */
3811
+	protected function _get_transient($notices = false, $route = '')
3812
+	{
3813
+		$user_id = get_current_user_id();
3814
+		$route = ! $route ? $this->_req_action : $route;
3815
+		$transient = $notices
3816
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3817
+			: 'rte_tx_' . $route . '_' . $user_id;
3818
+		$data = is_multisite() && is_network_admin()
3819
+			? get_site_transient($transient)
3820
+			: get_transient($transient);
3821
+		// delete transient after retrieval (just in case it hasn't expired);
3822
+		if (is_multisite() && is_network_admin()) {
3823
+			delete_site_transient($transient);
3824
+		} else {
3825
+			delete_transient($transient);
3826
+		}
3827
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3828
+	}
3829
+
3830
+
3831
+	/**
3832
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3833
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3834
+	 * default route callback on the EE_Admin page you want it run.)
3835
+	 *
3836
+	 * @return void
3837
+	 */
3838
+	protected function _transient_garbage_collection()
3839
+	{
3840
+		global $wpdb;
3841
+		// retrieve all existing transients
3842
+		$query = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3843
+		if ($results = $wpdb->get_results($query)) {
3844
+			foreach ($results as $result) {
3845
+				$transient = str_replace('_transient_', '', $result->option_name);
3846
+				get_transient($transient);
3847
+				if (is_multisite() && is_network_admin()) {
3848
+					get_site_transient($transient);
3849
+				}
3850
+			}
3851
+		}
3852
+	}
3853
+
3854
+
3855
+	/**
3856
+	 * get_view
3857
+	 *
3858
+	 * @return string content of _view property
3859
+	 */
3860
+	public function get_view()
3861
+	{
3862
+		return $this->_view;
3863
+	}
3864
+
3865
+
3866
+	/**
3867
+	 * getter for the protected $_views property
3868
+	 *
3869
+	 * @return array
3870
+	 */
3871
+	public function get_views()
3872
+	{
3873
+		return $this->_views;
3874
+	}
3875
+
3876
+
3877
+	/**
3878
+	 * get_current_page
3879
+	 *
3880
+	 * @return string _current_page property value
3881
+	 */
3882
+	public function get_current_page()
3883
+	{
3884
+		return $this->_current_page;
3885
+	}
3886
+
3887
+
3888
+	/**
3889
+	 * get_current_view
3890
+	 *
3891
+	 * @return string _current_view property value
3892
+	 */
3893
+	public function get_current_view()
3894
+	{
3895
+		return $this->_current_view;
3896
+	}
3897
+
3898
+
3899
+	/**
3900
+	 * get_current_screen
3901
+	 *
3902
+	 * @return object The current WP_Screen object
3903
+	 */
3904
+	public function get_current_screen()
3905
+	{
3906
+		return $this->_current_screen;
3907
+	}
3908
+
3909
+
3910
+	/**
3911
+	 * get_current_page_view_url
3912
+	 *
3913
+	 * @return string This returns the url for the current_page_view.
3914
+	 */
3915
+	public function get_current_page_view_url()
3916
+	{
3917
+		return $this->_current_page_view_url;
3918
+	}
3919
+
3920
+
3921
+	/**
3922
+	 * just returns the _req_data property
3923
+	 *
3924
+	 * @return array
3925
+	 */
3926
+	public function get_request_data()
3927
+	{
3928
+		return $this->_req_data;
3929
+	}
3930
+
3931
+
3932
+	/**
3933
+	 * returns the _req_data protected property
3934
+	 *
3935
+	 * @return string
3936
+	 */
3937
+	public function get_req_action()
3938
+	{
3939
+		return $this->_req_action;
3940
+	}
3941
+
3942
+
3943
+	/**
3944
+	 * @return bool  value of $_is_caf property
3945
+	 */
3946
+	public function is_caf()
3947
+	{
3948
+		return $this->_is_caf;
3949
+	}
3950
+
3951
+
3952
+	/**
3953
+	 * @return mixed
3954
+	 */
3955
+	public function default_espresso_metaboxes()
3956
+	{
3957
+		return $this->_default_espresso_metaboxes;
3958
+	}
3959
+
3960
+
3961
+	/**
3962
+	 * @return mixed
3963
+	 */
3964
+	public function admin_base_url()
3965
+	{
3966
+		return $this->_admin_base_url;
3967
+	}
3968
+
3969
+
3970
+	/**
3971
+	 * @return mixed
3972
+	 */
3973
+	public function wp_page_slug()
3974
+	{
3975
+		return $this->_wp_page_slug;
3976
+	}
3977
+
3978
+
3979
+	/**
3980
+	 * updates  espresso configuration settings
3981
+	 *
3982
+	 * @param string                   $tab
3983
+	 * @param EE_Config_Base|EE_Config $config
3984
+	 * @param string                   $file file where error occurred
3985
+	 * @param string                   $func function  where error occurred
3986
+	 * @param string                   $line line no where error occurred
3987
+	 * @return boolean
3988
+	 */
3989
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3990
+	{
3991
+		// remove any options that are NOT going to be saved with the config settings.
3992
+		if (isset($config->core->ee_ueip_optin)) {
3993
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3994
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3995
+			update_option('ee_ueip_has_notified', true);
3996
+		}
3997
+		// and save it (note we're also doing the network save here)
3998
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3999
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4000
+		if ($config_saved && $net_saved) {
4001
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4002
+			return true;
4003
+		}
4004
+		EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4005
+		return false;
4006
+	}
4007
+
4008
+
4009
+	/**
4010
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4011
+	 *
4012
+	 * @return array
4013
+	 */
4014
+	public function get_yes_no_values()
4015
+	{
4016
+		return $this->_yes_no_values;
4017
+	}
4018
+
4019
+
4020
+	protected function _get_dir()
4021
+	{
4022
+		$reflector = new ReflectionClass(get_class($this));
4023
+		return dirname($reflector->getFileName());
4024
+	}
4025
+
4026
+
4027
+	/**
4028
+	 * A helper for getting a "next link".
4029
+	 *
4030
+	 * @param string $url   The url to link to
4031
+	 * @param string $class The class to use.
4032
+	 * @return string
4033
+	 */
4034
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4035
+	{
4036
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4037
+	}
4038
+
4039
+
4040
+	/**
4041
+	 * A helper for getting a "previous link".
4042
+	 *
4043
+	 * @param string $url   The url to link to
4044
+	 * @param string $class The class to use.
4045
+	 * @return string
4046
+	 */
4047
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4048
+	{
4049
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4050
+	}
4051
+
4052
+
4053
+
4054
+
4055
+
4056
+
4057
+
4058
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4059
+
4060
+
4061
+	/**
4062
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4063
+	 * 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
4064
+	 * _req_data array.
4065
+	 *
4066
+	 * @return bool success/fail
4067
+	 * @throws EE_Error
4068
+	 * @throws InvalidArgumentException
4069
+	 * @throws ReflectionException
4070
+	 * @throws InvalidDataTypeException
4071
+	 * @throws InvalidInterfaceException
4072
+	 */
4073
+	protected function _process_resend_registration()
4074
+	{
4075
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4076
+		do_action(
4077
+			'AHEE__EE_Admin_Page___process_resend_registration',
4078
+			$this->_template_args['success'],
4079
+			$this->_req_data
4080
+		);
4081
+		return $this->_template_args['success'];
4082
+	}
4083
+
4084
+
4085
+	/**
4086
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4087
+	 *
4088
+	 * @param \EE_Payment $payment
4089
+	 * @return bool success/fail
4090
+	 */
4091
+	protected function _process_payment_notification(EE_Payment $payment)
4092
+	{
4093
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4094
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4095
+		$this->_template_args['success'] = apply_filters(
4096
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4097
+			false,
4098
+			$payment
4099
+		);
4100
+		return $this->_template_args['success'];
4101
+	}
4102 4102
 }
Please login to merge, or discard this patch.
core/services/validators/JsonValidator.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -32,19 +32,19 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public function isValid($file, $func, $line)
34 34
     {
35
-        if (! defined('JSON_ERROR_RECURSION')) {
35
+        if ( ! defined('JSON_ERROR_RECURSION')) {
36 36
             define('JSON_ERROR_RECURSION', 6);
37 37
         }
38
-        if (! defined('JSON_ERROR_INF_OR_NAN')) {
38
+        if ( ! defined('JSON_ERROR_INF_OR_NAN')) {
39 39
             define('JSON_ERROR_INF_OR_NAN', 7);
40 40
         }
41
-        if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
41
+        if ( ! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
42 42
             define('JSON_ERROR_UNSUPPORTED_TYPE', 8);
43 43
         }
44
-        if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
44
+        if ( ! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
45 45
             define('JSON_ERROR_INVALID_PROPERTY_NAME', 9);
46 46
         }
47
-        if (! defined('JSON_ERROR_UTF16')) {
47
+        if ( ! defined('JSON_ERROR_UTF16')) {
48 48
             define('JSON_ERROR_UTF16', 10);
49 49
         }
50 50
         switch (json_last_error()) {
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
                 $error = ': Unknown error';
85 85
                 break;
86 86
         }
87
-        EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line);
87
+        EE_Error::add_error('JSON decoding failed'.$error, $file, $func, $line);
88 88
         return false;
89 89
     }
90 90
 }
Please login to merge, or discard this patch.
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -18,76 +18,76 @@
 block discarded – undo
18 18
 class JsonValidator
19 19
 {
20 20
 
21
-    /**
22
-     * Call this method IMMEDIATELY after json_decode() and
23
-     * it will will return true if the decoded JSON was valid,
24
-     * or return false after adding an error if not valid.
25
-     * The actual JSON file does not need to be supplied,
26
-     * but details re: code execution location are required.
27
-     * ex:
28
-     * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__)
29
-     *
30
-     * @param string $file
31
-     * @param string $func
32
-     * @param string $line
33
-     * @return boolean
34
-     * @since 4.9.70.p
35
-     */
36
-    public function isValid($file, $func, $line)
37
-    {
38
-        if (! defined('JSON_ERROR_RECURSION')) {
39
-            define('JSON_ERROR_RECURSION', 6);
40
-        }
41
-        if (! defined('JSON_ERROR_INF_OR_NAN')) {
42
-            define('JSON_ERROR_INF_OR_NAN', 7);
43
-        }
44
-        if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
45
-            define('JSON_ERROR_UNSUPPORTED_TYPE', 8);
46
-        }
47
-        if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
48
-            define('JSON_ERROR_INVALID_PROPERTY_NAME', 9);
49
-        }
50
-        if (! defined('JSON_ERROR_UTF16')) {
51
-            define('JSON_ERROR_UTF16', 10);
52
-        }
53
-        switch (json_last_error()) {
54
-            case JSON_ERROR_NONE:
55
-                return true;
56
-            case JSON_ERROR_DEPTH:
57
-                $error = ': Maximum stack depth exceeded';
58
-                break;
59
-            case JSON_ERROR_STATE_MISMATCH:
60
-                $error = ': Invalid or malformed JSON';
61
-                break;
62
-            case JSON_ERROR_CTRL_CHAR:
63
-                $error = ': Control character error, possible malformed JSON';
64
-                break;
65
-            case JSON_ERROR_SYNTAX:
66
-                $error = ': Syntax error, malformed JSON';
67
-                break;
68
-            case JSON_ERROR_UTF8:
69
-                $error = ': Malformed UTF-8 characters, possible malformed JSON';
70
-                break;
71
-            case JSON_ERROR_RECURSION:
72
-                $error = ': One or more recursive references in the value to be encoded';
73
-                break;
74
-            case JSON_ERROR_INF_OR_NAN:
75
-                $error = ': One or more NAN or INF values in the value to be encoded';
76
-                break;
77
-            case JSON_ERROR_UNSUPPORTED_TYPE:
78
-                $error = ': A value of a type that cannot be encoded was given';
79
-                break;
80
-            case JSON_ERROR_INVALID_PROPERTY_NAME:
81
-                $error = ': A property name that cannot be encoded was given';
82
-                break;
83
-            case JSON_ERROR_UTF16:
84
-                $error = ': Malformed UTF-16 characters, possibly incorrectly encoded';
85
-                break;
86
-            default:
87
-                $error = ': Unknown error';
88
-                break;
89
-        }
90
-        EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line);
91
-        return false;
92
-    }
21
+	/**
22
+	 * Call this method IMMEDIATELY after json_decode() and
23
+	 * it will will return true if the decoded JSON was valid,
24
+	 * or return false after adding an error if not valid.
25
+	 * The actual JSON file does not need to be supplied,
26
+	 * but details re: code execution location are required.
27
+	 * ex:
28
+	 * JsonValidator::isValid(__FILE__, __METHOD__, __LINE__)
29
+	 *
30
+	 * @param string $file
31
+	 * @param string $func
32
+	 * @param string $line
33
+	 * @return boolean
34
+	 * @since 4.9.70.p
35
+	 */
36
+	public function isValid($file, $func, $line)
37
+	{
38
+		if (! defined('JSON_ERROR_RECURSION')) {
39
+			define('JSON_ERROR_RECURSION', 6);
40
+		}
41
+		if (! defined('JSON_ERROR_INF_OR_NAN')) {
42
+			define('JSON_ERROR_INF_OR_NAN', 7);
43
+		}
44
+		if (! defined('JSON_ERROR_UNSUPPORTED_TYPE')) {
45
+			define('JSON_ERROR_UNSUPPORTED_TYPE', 8);
46
+		}
47
+		if (! defined('JSON_ERROR_INVALID_PROPERTY_NAME')) {
48
+			define('JSON_ERROR_INVALID_PROPERTY_NAME', 9);
49
+		}
50
+		if (! defined('JSON_ERROR_UTF16')) {
51
+			define('JSON_ERROR_UTF16', 10);
52
+		}
53
+		switch (json_last_error()) {
54
+			case JSON_ERROR_NONE:
55
+				return true;
56
+			case JSON_ERROR_DEPTH:
57
+				$error = ': Maximum stack depth exceeded';
58
+				break;
59
+			case JSON_ERROR_STATE_MISMATCH:
60
+				$error = ': Invalid or malformed JSON';
61
+				break;
62
+			case JSON_ERROR_CTRL_CHAR:
63
+				$error = ': Control character error, possible malformed JSON';
64
+				break;
65
+			case JSON_ERROR_SYNTAX:
66
+				$error = ': Syntax error, malformed JSON';
67
+				break;
68
+			case JSON_ERROR_UTF8:
69
+				$error = ': Malformed UTF-8 characters, possible malformed JSON';
70
+				break;
71
+			case JSON_ERROR_RECURSION:
72
+				$error = ': One or more recursive references in the value to be encoded';
73
+				break;
74
+			case JSON_ERROR_INF_OR_NAN:
75
+				$error = ': One or more NAN or INF values in the value to be encoded';
76
+				break;
77
+			case JSON_ERROR_UNSUPPORTED_TYPE:
78
+				$error = ': A value of a type that cannot be encoded was given';
79
+				break;
80
+			case JSON_ERROR_INVALID_PROPERTY_NAME:
81
+				$error = ': A property name that cannot be encoded was given';
82
+				break;
83
+			case JSON_ERROR_UTF16:
84
+				$error = ': Malformed UTF-16 characters, possibly incorrectly encoded';
85
+				break;
86
+			default:
87
+				$error = ': Unknown error';
88
+				break;
89
+		}
90
+		EE_Error::add_error('JSON decoding failed' . $error, $file, $func, $line);
91
+		return false;
92
+	}
93 93
 }
Please login to merge, or discard this patch.
admin_pages/transactions/EE_Admin_Transactions_List_Table.class.php 2 patches
Indentation   +658 added lines, -658 removed lines patch added patch discarded remove patch
@@ -15,121 +15,121 @@  discard block
 block discarded – undo
15 15
 class EE_Admin_Transactions_List_Table extends EE_Admin_List_Table
16 16
 {
17 17
 
18
-    /**
19
-     * @var SessionLifespan $session_lifespan
20
-     */
21
-    private $session_lifespan;
22
-
23
-    private $_status;
24
-
25
-
26
-    /**
27
-     * @param \Transactions_Admin_Page $admin_page
28
-     * @param SessionLifespan          $lifespan
29
-     */
30
-    public function __construct(\Transactions_Admin_Page $admin_page, SessionLifespan $lifespan)
31
-    {
32
-        parent::__construct($admin_page);
33
-        $this->session_lifespan = $lifespan;
34
-        $this->_status = $this->_admin_page->get_transaction_status_array();
35
-    }
36
-
37
-
38
-    /**
39
-     *_setup_data
40
-     */
41
-    protected function _setup_data()
42
-    {
43
-        $this->_data = $this->_admin_page->get_transactions($this->_per_page);
44
-        $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all';
45
-        $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status);
46
-    }
47
-
48
-
49
-    /**
50
-     *_set_properties
51
-     */
52
-    protected function _set_properties()
53
-    {
54
-        $this->_wp_list_args = array(
55
-            'singular' => __('transaction', 'event_espresso'),
56
-            'plural'   => __('transactions', 'event_espresso'),
57
-            'ajax'     => true,
58
-            'screen'   => $this->_admin_page->get_current_screen()->id,
59
-        );
60
-        $ID_column_name = __('ID', 'event_espresso');
61
-        $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
62
-        $ID_column_name .= __('Transaction Date', 'event_espresso');
63
-        $ID_column_name .= '</span> ';
64
-        $this->_columns = array(
65
-            'TXN_ID'        => $ID_column_name,
66
-            'TXN_timestamp' => __('Transaction Date', 'event_espresso'),
67
-            'TXN_total'     => __('Total', 'event_espresso'),
68
-            'TXN_paid'      => __('Paid', 'event_espresso'),
69
-            'ATT_fname'     => __('Primary Registrant', 'event_espresso'),
70
-            'event_name'    => __('Event', 'event_espresso'),
71
-            'actions'       => __('Actions', 'event_espresso'),
72
-        );
73
-
74
-        $this->_sortable_columns = array(
75
-            'TXN_ID'        => array('TXN_ID' => false),
76
-            'event_name'    => array('event_name' => false),
77
-            'ATT_fname'     => array('ATT_fname' => false),
78
-            'TXN_timestamp' => array('TXN_timestamp' => true) // true means its already sorted
79
-        );
80
-
81
-        $this->_primary_column = 'TXN_ID';
82
-
83
-        $this->_hidden_columns = array();
84
-    }
85
-
86
-
87
-    /**
88
-     * This simply sets up the row class for the table rows.
89
-     * Allows for easier overriding of child methods for setting up sorting.
90
-     *
91
-     * @param  EE_Transaction $transaction the current item
92
-     * @return string
93
-     * @throws \EE_Error
94
-     */
95
-    protected function _get_row_class($transaction)
96
-    {
97
-        $class = parent::_get_row_class($transaction);
98
-        // add status class
99
-        $class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
100
-        if ($this->_has_checkbox_column) {
101
-            $class .= ' has-checkbox-column';
102
-        }
103
-        return $class;
104
-    }
105
-
106
-
107
-    /**
108
-     * _get_table_filters
109
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
110
-     * get's shown in the table.
111
-     *
112
-     * @abstract
113
-     * @access protected
114
-     * @return array
115
-     */
116
-    protected function _get_table_filters()
117
-    {
118
-        $filters = array();
119
-        $start_date = isset($this->_req_data['txn-filter-start-date'])
120
-            ? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
121
-            : date(
122
-                'm/d/Y',
123
-                strtotime('-10 year')
124
-            );
125
-        $end_date = isset($this->_req_data['txn-filter-end-date'])
126
-            ? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
127
-            : date(
128
-                'm/d/Y',
129
-                current_time('timestamp')
130
-            );
131
-        ob_start();
132
-        ?>
18
+	/**
19
+	 * @var SessionLifespan $session_lifespan
20
+	 */
21
+	private $session_lifespan;
22
+
23
+	private $_status;
24
+
25
+
26
+	/**
27
+	 * @param \Transactions_Admin_Page $admin_page
28
+	 * @param SessionLifespan          $lifespan
29
+	 */
30
+	public function __construct(\Transactions_Admin_Page $admin_page, SessionLifespan $lifespan)
31
+	{
32
+		parent::__construct($admin_page);
33
+		$this->session_lifespan = $lifespan;
34
+		$this->_status = $this->_admin_page->get_transaction_status_array();
35
+	}
36
+
37
+
38
+	/**
39
+	 *_setup_data
40
+	 */
41
+	protected function _setup_data()
42
+	{
43
+		$this->_data = $this->_admin_page->get_transactions($this->_per_page);
44
+		$status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all';
45
+		$this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status);
46
+	}
47
+
48
+
49
+	/**
50
+	 *_set_properties
51
+	 */
52
+	protected function _set_properties()
53
+	{
54
+		$this->_wp_list_args = array(
55
+			'singular' => __('transaction', 'event_espresso'),
56
+			'plural'   => __('transactions', 'event_espresso'),
57
+			'ajax'     => true,
58
+			'screen'   => $this->_admin_page->get_current_screen()->id,
59
+		);
60
+		$ID_column_name = __('ID', 'event_espresso');
61
+		$ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">';
62
+		$ID_column_name .= __('Transaction Date', 'event_espresso');
63
+		$ID_column_name .= '</span> ';
64
+		$this->_columns = array(
65
+			'TXN_ID'        => $ID_column_name,
66
+			'TXN_timestamp' => __('Transaction Date', 'event_espresso'),
67
+			'TXN_total'     => __('Total', 'event_espresso'),
68
+			'TXN_paid'      => __('Paid', 'event_espresso'),
69
+			'ATT_fname'     => __('Primary Registrant', 'event_espresso'),
70
+			'event_name'    => __('Event', 'event_espresso'),
71
+			'actions'       => __('Actions', 'event_espresso'),
72
+		);
73
+
74
+		$this->_sortable_columns = array(
75
+			'TXN_ID'        => array('TXN_ID' => false),
76
+			'event_name'    => array('event_name' => false),
77
+			'ATT_fname'     => array('ATT_fname' => false),
78
+			'TXN_timestamp' => array('TXN_timestamp' => true) // true means its already sorted
79
+		);
80
+
81
+		$this->_primary_column = 'TXN_ID';
82
+
83
+		$this->_hidden_columns = array();
84
+	}
85
+
86
+
87
+	/**
88
+	 * This simply sets up the row class for the table rows.
89
+	 * Allows for easier overriding of child methods for setting up sorting.
90
+	 *
91
+	 * @param  EE_Transaction $transaction the current item
92
+	 * @return string
93
+	 * @throws \EE_Error
94
+	 */
95
+	protected function _get_row_class($transaction)
96
+	{
97
+		$class = parent::_get_row_class($transaction);
98
+		// add status class
99
+		$class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
100
+		if ($this->_has_checkbox_column) {
101
+			$class .= ' has-checkbox-column';
102
+		}
103
+		return $class;
104
+	}
105
+
106
+
107
+	/**
108
+	 * _get_table_filters
109
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
110
+	 * get's shown in the table.
111
+	 *
112
+	 * @abstract
113
+	 * @access protected
114
+	 * @return array
115
+	 */
116
+	protected function _get_table_filters()
117
+	{
118
+		$filters = array();
119
+		$start_date = isset($this->_req_data['txn-filter-start-date'])
120
+			? wp_strip_all_tags($this->_req_data['txn-filter-start-date'])
121
+			: date(
122
+				'm/d/Y',
123
+				strtotime('-10 year')
124
+			);
125
+		$end_date = isset($this->_req_data['txn-filter-end-date'])
126
+			? wp_strip_all_tags($this->_req_data['txn-filter-end-date'])
127
+			: date(
128
+				'm/d/Y',
129
+				current_time('timestamp')
130
+			);
131
+		ob_start();
132
+		?>
133 133
         <label for="txn-filter-start-date">Display Transactions from </label>
134 134
         <input id="txn-filter-start-date" class="datepicker" type="text" value="<?php echo $start_date; ?>"
135 135
                name="txn-filter-start-date" size="15"/>
@@ -137,578 +137,578 @@  discard block
 block discarded – undo
137 137
         <input id="txn-filter-end-date" class="datepicker" type="text" value="<?php echo $end_date; ?>"
138 138
                name="txn-filter-end-date" size="15"/>
139 139
         <?php
140
-        $filters[] = ob_get_contents();
141
-        ob_end_clean();
142
-        return $filters;
143
-    }
144
-
145
-
146
-    /**
147
-     *_add_view_counts
148
-     */
149
-    protected function _add_view_counts()
150
-    {
151
-        foreach ($this->_views as $view) {
152
-            $this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']);
153
-        }
154
-    }
155
-
156
-
157
-    /**
158
-     *    column TXN_ID
159
-     *
160
-     * @param \EE_Transaction $transaction
161
-     * @return string
162
-     * @throws \EE_Error
163
-     */
164
-    public function column_TXN_ID(EE_Transaction $transaction)
165
-    {
166
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
167
-            array(
168
-                'action' => 'view_transaction',
169
-                'TXN_ID' => $transaction->ID(),
170
-            ),
171
-            TXN_ADMIN_URL
172
-        );
173
-        $content = '<a href="' . $view_lnk_url . '"'
174
-                   . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
175
-                   . $transaction->ID()
176
-                   . '</a>';
177
-
178
-        // txn timestamp
179
-        $content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
180
-        return $content;
181
-    }
182
-
183
-
184
-    /**
185
-     * @param \EE_Transaction $transaction
186
-     * @return string
187
-     * @throws EE_Error
188
-     * @throws InvalidArgumentException
189
-     * @throws InvalidDataTypeException
190
-     * @throws InvalidInterfaceException
191
-     */
192
-    protected function _get_txn_timestamp(EE_Transaction $transaction)
193
-    {
194
-        // is TXN less than 2 hours old ?
195
-        if (($transaction->failed() || $transaction->is_abandoned())
196
-            && $this->session_lifespan->expiration() < $transaction->datetime(false, true)
197
-        ) {
198
-            $timestamp = esc_html__('TXN in progress...', 'event_espresso');
199
-        } else {
200
-            $timestamp = $transaction->get_i18n_datetime('TXN_timestamp');
201
-        }
202
-        return $timestamp;
203
-    }
204
-
205
-
206
-    /**
207
-     *    column_cb
208
-     *
209
-     * @param \EE_Transaction $transaction
210
-     * @return string
211
-     * @throws \EE_Error
212
-     */
213
-    public function column_cb($transaction)
214
-    {
215
-        return sprintf(
216
-            '<input type="checkbox" name="%1$s[]" value="%2$s" />',
217
-            $this->_wp_list_args['singular'],
218
-            $transaction->ID()
219
-        );
220
-    }
221
-
222
-
223
-    /**
224
-     *    column_TXN_timestamp
225
-     *
226
-     * @param \EE_Transaction $transaction
227
-     * @return string
228
-     * @throws \EE_Error
229
-     */
230
-    public function column_TXN_timestamp(EE_Transaction $transaction)
231
-    {
232
-        $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
233
-            array(
234
-                'action' => 'view_transaction',
235
-                'TXN_ID' => $transaction->ID(),
236
-            ),
237
-            TXN_ADMIN_URL
238
-        );
239
-        $txn_date = '<a href="' . $view_lnk_url . '"'
240
-                    . ' title="'
241
-                    . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
242
-                    . $this->_get_txn_timestamp($transaction)
243
-                    . '</a>';
244
-        // status
245
-        $txn_date .= '<br><span class="ee-status-text-small">'
246
-                    . EEH_Template::pretty_status(
247
-                        $transaction->status_ID(),
248
-                        false,
249
-                        'sentence'
250
-                    )
251
-                     . '</span>';
252
-        return $txn_date;
253
-    }
254
-
255
-
256
-    /**
257
-     *    column_TXN_total
258
-     *
259
-     * @param \EE_Transaction $transaction
260
-     * @return string
261
-     * @throws \EE_Error
262
-     */
263
-    public function column_TXN_total(EE_Transaction $transaction)
264
-    {
265
-        if ($transaction->get('TXN_total') > 0) {
266
-            return '<span class="txn-pad-rght">'
267
-                   . apply_filters(
268
-                       'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total',
269
-                       $transaction->get_pretty('TXN_total'),
270
-                       $transaction
271
-                   )
272
-                   . '</span>';
273
-        } else {
274
-            return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
275
-        }
276
-    }
277
-
278
-
279
-    /**
280
-     *    column_TXN_paid
281
-     *
282
-     * @param \EE_Transaction $transaction
283
-     * @return mixed|string
284
-     * @throws \EE_Error
285
-     */
286
-    public function column_TXN_paid(EE_Transaction $transaction)
287
-    {
288
-        $transaction_total = $transaction->get('TXN_total');
289
-        $transaction_paid = $transaction->get('TXN_paid');
290
-
291
-        if (\EEH_Money::compare_floats($transaction_total, 0, '>')) {
292
-            // monies owing
293
-            $span_class = 'txn-overview-part-payment-spn';
294
-            if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) {
295
-                // paid in full
296
-                $span_class = 'txn-overview-full-payment-spn';
297
-            } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) {
298
-                // no payments made
299
-                $span_class = 'txn-overview-no-payment-spn';
300
-            }
301
-        } else {
302
-            // transaction_total == 0 so this is a free event
303
-            $span_class = 'txn-overview-free-event-spn';
304
-        }
305
-
306
-        $payment_method = $transaction->payment_method();
307
-        $payment_method_name = $payment_method instanceof EE_Payment_Method
308
-            ? $payment_method->admin_name()
309
-            : esc_html__('Unknown', 'event_espresso');
310
-
311
-        $content = '<span class="' . $span_class . ' txn-pad-rght">'
312
-                   . $transaction->get_pretty('TXN_paid')
313
-                   . '</span>';
314
-        if ($transaction_paid > 0) {
315
-            $content .= '<br><span class="ee-status-text-small">'
316
-                        . sprintf(
317
-                            esc_html__('...via %s', 'event_espresso'),
318
-                            $payment_method_name
319
-                        )
320
-                        . '</span>';
321
-        }
322
-        return $content;
323
-    }
324
-
325
-
326
-    /**
327
-     *    column_ATT_fname
328
-     *
329
-     * @param \EE_Transaction $transaction
330
-     * @return string
331
-     * @throws EE_Error
332
-     * @throws InvalidArgumentException
333
-     * @throws InvalidDataTypeException
334
-     * @throws InvalidInterfaceException
335
-     */
336
-    public function column_ATT_fname(EE_Transaction $transaction)
337
-    {
338
-        $primary_reg = $transaction->primary_registration();
339
-        $attendee = $primary_reg->get_first_related('Attendee');
340
-        if ($attendee instanceof EE_Attendee) {
341
-            $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
342
-                array(
343
-                    'action'  => 'view_registration',
344
-                    '_REG_ID' => $primary_reg->ID(),
345
-                ),
346
-                REG_ADMIN_URL
347
-            );
348
-            $content = EE_Registry::instance()->CAP->current_user_can(
349
-                'ee_read_registration',
350
-                'espresso_registrations_view_registration',
351
-                $primary_reg->ID()
352
-            )
353
-                ? '<a href="' . $edit_lnk_url . '"'
354
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
355
-                  . $attendee->full_name()
356
-                  . '</a>'
357
-                : $attendee->full_name();
358
-            $content .= '<br>' . $attendee->email();
359
-            return $content;
360
-        }
361
-        return $transaction->failed() || $transaction->is_abandoned()
362
-            ? esc_html__('no contact record.', 'event_espresso')
363
-            : esc_html__(
364
-                'No contact record, because the transaction was abandoned or the registration process failed.',
365
-                'event_espresso'
366
-            );
367
-    }
368
-
369
-
370
-    /**
371
-     *    column_ATT_email
372
-     *
373
-     * @param \EE_Transaction $transaction
374
-     * @return string
375
-     * @throws \EE_Error
376
-     */
377
-    public function column_ATT_email(EE_Transaction $transaction)
378
-    {
379
-        $attendee = $transaction->primary_registration()->get_first_related('Attendee');
380
-        if (! empty($attendee)) {
381
-            return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
382
-                   . $attendee->get('ATT_email')
383
-                   . '</a>';
384
-        } else {
385
-            return $transaction->failed() || $transaction->is_abandoned()
386
-                ? esc_html__('no contact record.', 'event_espresso')
387
-                : esc_html__(
388
-                    'No contact record, because the transaction was abandoned or the registration process failed.',
389
-                    'event_espresso'
390
-                );
391
-        }
392
-    }
393
-
394
-
395
-    /**
396
-     *    column_event_name
397
-     *
398
-     * @param \EE_Transaction $transaction
399
-     * @return string
400
-     * @throws EE_Error
401
-     * @throws InvalidArgumentException
402
-     * @throws InvalidDataTypeException
403
-     * @throws InvalidInterfaceException
404
-     */
405
-    public function column_event_name(EE_Transaction $transaction)
406
-    {
407
-        $actions = array();
408
-        $event = $transaction->primary_registration()->get_first_related('Event');
409
-        if (! empty($event)) {
410
-            $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
411
-                array('action' => 'edit', 'post' => $event->ID()),
412
-                EVENTS_ADMIN_URL
413
-            );
414
-            $event_name = $event->get('EVT_name');
415
-
416
-            // filter this view by transactions for this event
417
-            $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(
418
-                array(
419
-                    'action' => 'default',
420
-                    'EVT_ID' => $event->ID(),
421
-                )
422
-            );
423
-            if (empty($this->_req_data['EVT_ID'])
424
-                && EE_Registry::instance()->CAP->current_user_can(
425
-                    'ee_edit_event',
426
-                    'espresso_events_edit',
427
-                    $event->ID()
428
-                )
429
-            ) {
430
-                $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
431
-                                              . ' title="' . esc_attr__(
432
-                                                  'Filter transactions by this event',
433
-                                                  'event_espresso'
434
-                                              ) . '">'
435
-                                              . esc_html__('View Transactions for this event', 'event_espresso')
436
-                                              . '</a>';
437
-            }
438
-
439
-            return sprintf(
440
-                '%1$s %2$s',
441
-                EE_Registry::instance()->CAP->current_user_can(
442
-                    'ee_edit_event',
443
-                    'espresso_events_edit',
444
-                    $event->ID()
445
-                )
446
-                    ? '<a href="' . $edit_event_url . '"'
447
-                      . ' title="'
448
-                      . sprintf(
449
-                          esc_attr__('Edit Event: %s', 'event_espresso'),
450
-                          $event->get('EVT_name')
451
-                      )
452
-                      . '">'
453
-                      . wp_trim_words(
454
-                          $event_name,
455
-                          30,
456
-                          '...'
457
-                      )
458
-                      . '</a>'
459
-                    : wp_trim_words($event_name, 30, '...'),
460
-                $this->row_actions($actions)
461
-            );
462
-        } else {
463
-            return esc_html__(
464
-                'The event associated with this transaction via the primary registration cannot be retrieved.',
465
-                'event_espresso'
466
-            );
467
-        }
468
-    }
469
-
470
-
471
-    /**
472
-     *    column_actions
473
-     *
474
-     * @param \EE_Transaction $transaction
475
-     * @return string
476
-     * @throws \EE_Error
477
-     */
478
-    public function column_actions(EE_Transaction $transaction)
479
-    {
480
-        return $this->_action_string(
481
-            $this->get_transaction_details_link($transaction)
482
-            . $this->get_invoice_link($transaction)
483
-            . $this->get_receipt_link($transaction)
484
-            . $this->get_primary_registration_details_link($transaction)
485
-            . $this->get_send_payment_reminder_trigger_link($transaction)
486
-            . $this->get_payment_overview_link($transaction)
487
-            . $this->get_related_messages_link($transaction),
488
-            $transaction,
489
-            'ul',
490
-            'txn-overview-actions-ul'
491
-        );
492
-    }
493
-
494
-
495
-    /**
496
-     * Get the transaction details link.
497
-     *
498
-     * @param EE_Transaction $transaction
499
-     * @return string
500
-     * @throws EE_Error
501
-     */
502
-    protected function get_transaction_details_link(EE_Transaction $transaction)
503
-    {
504
-        $url = EE_Admin_Page::add_query_args_and_nonce(
505
-            array(
506
-                'action' => 'view_transaction',
507
-                'TXN_ID' => $transaction->ID(),
508
-            ),
509
-            TXN_ADMIN_URL
510
-        );
511
-        return '
140
+		$filters[] = ob_get_contents();
141
+		ob_end_clean();
142
+		return $filters;
143
+	}
144
+
145
+
146
+	/**
147
+	 *_add_view_counts
148
+	 */
149
+	protected function _add_view_counts()
150
+	{
151
+		foreach ($this->_views as $view) {
152
+			$this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']);
153
+		}
154
+	}
155
+
156
+
157
+	/**
158
+	 *    column TXN_ID
159
+	 *
160
+	 * @param \EE_Transaction $transaction
161
+	 * @return string
162
+	 * @throws \EE_Error
163
+	 */
164
+	public function column_TXN_ID(EE_Transaction $transaction)
165
+	{
166
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
167
+			array(
168
+				'action' => 'view_transaction',
169
+				'TXN_ID' => $transaction->ID(),
170
+			),
171
+			TXN_ADMIN_URL
172
+		);
173
+		$content = '<a href="' . $view_lnk_url . '"'
174
+				   . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
175
+				   . $transaction->ID()
176
+				   . '</a>';
177
+
178
+		// txn timestamp
179
+		$content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
180
+		return $content;
181
+	}
182
+
183
+
184
+	/**
185
+	 * @param \EE_Transaction $transaction
186
+	 * @return string
187
+	 * @throws EE_Error
188
+	 * @throws InvalidArgumentException
189
+	 * @throws InvalidDataTypeException
190
+	 * @throws InvalidInterfaceException
191
+	 */
192
+	protected function _get_txn_timestamp(EE_Transaction $transaction)
193
+	{
194
+		// is TXN less than 2 hours old ?
195
+		if (($transaction->failed() || $transaction->is_abandoned())
196
+			&& $this->session_lifespan->expiration() < $transaction->datetime(false, true)
197
+		) {
198
+			$timestamp = esc_html__('TXN in progress...', 'event_espresso');
199
+		} else {
200
+			$timestamp = $transaction->get_i18n_datetime('TXN_timestamp');
201
+		}
202
+		return $timestamp;
203
+	}
204
+
205
+
206
+	/**
207
+	 *    column_cb
208
+	 *
209
+	 * @param \EE_Transaction $transaction
210
+	 * @return string
211
+	 * @throws \EE_Error
212
+	 */
213
+	public function column_cb($transaction)
214
+	{
215
+		return sprintf(
216
+			'<input type="checkbox" name="%1$s[]" value="%2$s" />',
217
+			$this->_wp_list_args['singular'],
218
+			$transaction->ID()
219
+		);
220
+	}
221
+
222
+
223
+	/**
224
+	 *    column_TXN_timestamp
225
+	 *
226
+	 * @param \EE_Transaction $transaction
227
+	 * @return string
228
+	 * @throws \EE_Error
229
+	 */
230
+	public function column_TXN_timestamp(EE_Transaction $transaction)
231
+	{
232
+		$view_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
233
+			array(
234
+				'action' => 'view_transaction',
235
+				'TXN_ID' => $transaction->ID(),
236
+			),
237
+			TXN_ADMIN_URL
238
+		);
239
+		$txn_date = '<a href="' . $view_lnk_url . '"'
240
+					. ' title="'
241
+					. esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
242
+					. $this->_get_txn_timestamp($transaction)
243
+					. '</a>';
244
+		// status
245
+		$txn_date .= '<br><span class="ee-status-text-small">'
246
+					. EEH_Template::pretty_status(
247
+						$transaction->status_ID(),
248
+						false,
249
+						'sentence'
250
+					)
251
+					 . '</span>';
252
+		return $txn_date;
253
+	}
254
+
255
+
256
+	/**
257
+	 *    column_TXN_total
258
+	 *
259
+	 * @param \EE_Transaction $transaction
260
+	 * @return string
261
+	 * @throws \EE_Error
262
+	 */
263
+	public function column_TXN_total(EE_Transaction $transaction)
264
+	{
265
+		if ($transaction->get('TXN_total') > 0) {
266
+			return '<span class="txn-pad-rght">'
267
+				   . apply_filters(
268
+					   'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total',
269
+					   $transaction->get_pretty('TXN_total'),
270
+					   $transaction
271
+				   )
272
+				   . '</span>';
273
+		} else {
274
+			return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
275
+		}
276
+	}
277
+
278
+
279
+	/**
280
+	 *    column_TXN_paid
281
+	 *
282
+	 * @param \EE_Transaction $transaction
283
+	 * @return mixed|string
284
+	 * @throws \EE_Error
285
+	 */
286
+	public function column_TXN_paid(EE_Transaction $transaction)
287
+	{
288
+		$transaction_total = $transaction->get('TXN_total');
289
+		$transaction_paid = $transaction->get('TXN_paid');
290
+
291
+		if (\EEH_Money::compare_floats($transaction_total, 0, '>')) {
292
+			// monies owing
293
+			$span_class = 'txn-overview-part-payment-spn';
294
+			if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) {
295
+				// paid in full
296
+				$span_class = 'txn-overview-full-payment-spn';
297
+			} elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) {
298
+				// no payments made
299
+				$span_class = 'txn-overview-no-payment-spn';
300
+			}
301
+		} else {
302
+			// transaction_total == 0 so this is a free event
303
+			$span_class = 'txn-overview-free-event-spn';
304
+		}
305
+
306
+		$payment_method = $transaction->payment_method();
307
+		$payment_method_name = $payment_method instanceof EE_Payment_Method
308
+			? $payment_method->admin_name()
309
+			: esc_html__('Unknown', 'event_espresso');
310
+
311
+		$content = '<span class="' . $span_class . ' txn-pad-rght">'
312
+				   . $transaction->get_pretty('TXN_paid')
313
+				   . '</span>';
314
+		if ($transaction_paid > 0) {
315
+			$content .= '<br><span class="ee-status-text-small">'
316
+						. sprintf(
317
+							esc_html__('...via %s', 'event_espresso'),
318
+							$payment_method_name
319
+						)
320
+						. '</span>';
321
+		}
322
+		return $content;
323
+	}
324
+
325
+
326
+	/**
327
+	 *    column_ATT_fname
328
+	 *
329
+	 * @param \EE_Transaction $transaction
330
+	 * @return string
331
+	 * @throws EE_Error
332
+	 * @throws InvalidArgumentException
333
+	 * @throws InvalidDataTypeException
334
+	 * @throws InvalidInterfaceException
335
+	 */
336
+	public function column_ATT_fname(EE_Transaction $transaction)
337
+	{
338
+		$primary_reg = $transaction->primary_registration();
339
+		$attendee = $primary_reg->get_first_related('Attendee');
340
+		if ($attendee instanceof EE_Attendee) {
341
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(
342
+				array(
343
+					'action'  => 'view_registration',
344
+					'_REG_ID' => $primary_reg->ID(),
345
+				),
346
+				REG_ADMIN_URL
347
+			);
348
+			$content = EE_Registry::instance()->CAP->current_user_can(
349
+				'ee_read_registration',
350
+				'espresso_registrations_view_registration',
351
+				$primary_reg->ID()
352
+			)
353
+				? '<a href="' . $edit_lnk_url . '"'
354
+				  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
355
+				  . $attendee->full_name()
356
+				  . '</a>'
357
+				: $attendee->full_name();
358
+			$content .= '<br>' . $attendee->email();
359
+			return $content;
360
+		}
361
+		return $transaction->failed() || $transaction->is_abandoned()
362
+			? esc_html__('no contact record.', 'event_espresso')
363
+			: esc_html__(
364
+				'No contact record, because the transaction was abandoned or the registration process failed.',
365
+				'event_espresso'
366
+			);
367
+	}
368
+
369
+
370
+	/**
371
+	 *    column_ATT_email
372
+	 *
373
+	 * @param \EE_Transaction $transaction
374
+	 * @return string
375
+	 * @throws \EE_Error
376
+	 */
377
+	public function column_ATT_email(EE_Transaction $transaction)
378
+	{
379
+		$attendee = $transaction->primary_registration()->get_first_related('Attendee');
380
+		if (! empty($attendee)) {
381
+			return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
382
+				   . $attendee->get('ATT_email')
383
+				   . '</a>';
384
+		} else {
385
+			return $transaction->failed() || $transaction->is_abandoned()
386
+				? esc_html__('no contact record.', 'event_espresso')
387
+				: esc_html__(
388
+					'No contact record, because the transaction was abandoned or the registration process failed.',
389
+					'event_espresso'
390
+				);
391
+		}
392
+	}
393
+
394
+
395
+	/**
396
+	 *    column_event_name
397
+	 *
398
+	 * @param \EE_Transaction $transaction
399
+	 * @return string
400
+	 * @throws EE_Error
401
+	 * @throws InvalidArgumentException
402
+	 * @throws InvalidDataTypeException
403
+	 * @throws InvalidInterfaceException
404
+	 */
405
+	public function column_event_name(EE_Transaction $transaction)
406
+	{
407
+		$actions = array();
408
+		$event = $transaction->primary_registration()->get_first_related('Event');
409
+		if (! empty($event)) {
410
+			$edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
411
+				array('action' => 'edit', 'post' => $event->ID()),
412
+				EVENTS_ADMIN_URL
413
+			);
414
+			$event_name = $event->get('EVT_name');
415
+
416
+			// filter this view by transactions for this event
417
+			$txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce(
418
+				array(
419
+					'action' => 'default',
420
+					'EVT_ID' => $event->ID(),
421
+				)
422
+			);
423
+			if (empty($this->_req_data['EVT_ID'])
424
+				&& EE_Registry::instance()->CAP->current_user_can(
425
+					'ee_edit_event',
426
+					'espresso_events_edit',
427
+					$event->ID()
428
+				)
429
+			) {
430
+				$actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
431
+											  . ' title="' . esc_attr__(
432
+												  'Filter transactions by this event',
433
+												  'event_espresso'
434
+											  ) . '">'
435
+											  . esc_html__('View Transactions for this event', 'event_espresso')
436
+											  . '</a>';
437
+			}
438
+
439
+			return sprintf(
440
+				'%1$s %2$s',
441
+				EE_Registry::instance()->CAP->current_user_can(
442
+					'ee_edit_event',
443
+					'espresso_events_edit',
444
+					$event->ID()
445
+				)
446
+					? '<a href="' . $edit_event_url . '"'
447
+					  . ' title="'
448
+					  . sprintf(
449
+						  esc_attr__('Edit Event: %s', 'event_espresso'),
450
+						  $event->get('EVT_name')
451
+					  )
452
+					  . '">'
453
+					  . wp_trim_words(
454
+						  $event_name,
455
+						  30,
456
+						  '...'
457
+					  )
458
+					  . '</a>'
459
+					: wp_trim_words($event_name, 30, '...'),
460
+				$this->row_actions($actions)
461
+			);
462
+		} else {
463
+			return esc_html__(
464
+				'The event associated with this transaction via the primary registration cannot be retrieved.',
465
+				'event_espresso'
466
+			);
467
+		}
468
+	}
469
+
470
+
471
+	/**
472
+	 *    column_actions
473
+	 *
474
+	 * @param \EE_Transaction $transaction
475
+	 * @return string
476
+	 * @throws \EE_Error
477
+	 */
478
+	public function column_actions(EE_Transaction $transaction)
479
+	{
480
+		return $this->_action_string(
481
+			$this->get_transaction_details_link($transaction)
482
+			. $this->get_invoice_link($transaction)
483
+			. $this->get_receipt_link($transaction)
484
+			. $this->get_primary_registration_details_link($transaction)
485
+			. $this->get_send_payment_reminder_trigger_link($transaction)
486
+			. $this->get_payment_overview_link($transaction)
487
+			. $this->get_related_messages_link($transaction),
488
+			$transaction,
489
+			'ul',
490
+			'txn-overview-actions-ul'
491
+		);
492
+	}
493
+
494
+
495
+	/**
496
+	 * Get the transaction details link.
497
+	 *
498
+	 * @param EE_Transaction $transaction
499
+	 * @return string
500
+	 * @throws EE_Error
501
+	 */
502
+	protected function get_transaction_details_link(EE_Transaction $transaction)
503
+	{
504
+		$url = EE_Admin_Page::add_query_args_and_nonce(
505
+			array(
506
+				'action' => 'view_transaction',
507
+				'TXN_ID' => $transaction->ID(),
508
+			),
509
+			TXN_ADMIN_URL
510
+		);
511
+		return '
512 512
 			<li>
513 513
 				<a href="' . $url . '"'
514
-               . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
514
+			   . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
515 515
 					<span class="dashicons dashicons-cart"></span>
516 516
 				</a>
517 517
 			</li>';
518
-    }
519
-
520
-
521
-    /**
522
-     * Get the invoice link for the given registration.
523
-     *
524
-     * @param EE_Transaction $transaction
525
-     * @return string
526
-     * @throws EE_Error
527
-     */
528
-    protected function get_invoice_link(EE_Transaction $transaction)
529
-    {
530
-        $registration = $transaction->primary_registration();
531
-        if ($registration instanceof EE_Registration) {
532
-            $url = $registration->invoice_url();
533
-            // only show invoice link if message type is active.
534
-            if ($registration->attendee() instanceof EE_Attendee
535
-                && EEH_MSG_Template::is_mt_active('invoice')
536
-            ) {
537
-                return '
518
+	}
519
+
520
+
521
+	/**
522
+	 * Get the invoice link for the given registration.
523
+	 *
524
+	 * @param EE_Transaction $transaction
525
+	 * @return string
526
+	 * @throws EE_Error
527
+	 */
528
+	protected function get_invoice_link(EE_Transaction $transaction)
529
+	{
530
+		$registration = $transaction->primary_registration();
531
+		if ($registration instanceof EE_Registration) {
532
+			$url = $registration->invoice_url();
533
+			// only show invoice link if message type is active.
534
+			if ($registration->attendee() instanceof EE_Attendee
535
+				&& EEH_MSG_Template::is_mt_active('invoice')
536
+			) {
537
+				return '
538 538
                 <li>
539 539
                     <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"'
540
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
540
+					   . ' target="_blank" href="' . $url . '" class="tiny-text">
541 541
                         <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
542 542
                     </a>
543 543
                 </li>';
544
-            }
545
-        }
546
-        return '';
547
-    }
548
-
549
-
550
-    /**
551
-     * Get the receipt link for the transaction.
552
-     *
553
-     * @param EE_Transaction $transaction
554
-     * @return string
555
-     * @throws EE_Error
556
-     */
557
-    protected function get_receipt_link(EE_Transaction $transaction)
558
-    {
559
-        $registration = $transaction->primary_registration();
560
-        if ($registration instanceof EE_Registration) {
561
-            $url = $registration->receipt_url();
562
-            // only show receipt link if message type is active.
563
-            if ($registration->attendee() instanceof EE_Attendee
564
-                && EEH_MSG_Template::is_mt_active('receipt')) {
565
-                return '
544
+			}
545
+		}
546
+		return '';
547
+	}
548
+
549
+
550
+	/**
551
+	 * Get the receipt link for the transaction.
552
+	 *
553
+	 * @param EE_Transaction $transaction
554
+	 * @return string
555
+	 * @throws EE_Error
556
+	 */
557
+	protected function get_receipt_link(EE_Transaction $transaction)
558
+	{
559
+		$registration = $transaction->primary_registration();
560
+		if ($registration instanceof EE_Registration) {
561
+			$url = $registration->receipt_url();
562
+			// only show receipt link if message type is active.
563
+			if ($registration->attendee() instanceof EE_Attendee
564
+				&& EEH_MSG_Template::is_mt_active('receipt')) {
565
+				return '
566 566
 			<li>
567 567
 				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"'
568
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
568
+					   . ' target="_blank" href="' . $url . '" class="tiny-text">
569 569
 					<span class="dashicons dashicons-media-default ee-icon-size-18"></span>
570 570
 				</a>
571 571
 			</li>';
572
-            }
573
-        }
574
-        return '';
575
-    }
576
-
577
-
578
-    /**
579
-     * Get the link to view the details for the primary registration.
580
-     *
581
-     * @param EE_Transaction $transaction
582
-     * @return string
583
-     * @throws EE_Error
584
-     * @throws InvalidArgumentException
585
-     * @throws InvalidDataTypeException
586
-     * @throws InvalidInterfaceException
587
-     */
588
-    protected function get_primary_registration_details_link(EE_Transaction $transaction)
589
-    {
590
-        $registration = $transaction->primary_registration();
591
-        if ($registration instanceof EE_Registration) {
592
-            $url = EE_Admin_Page::add_query_args_and_nonce(
593
-                array(
594
-                    'action'  => 'view_registration',
595
-                    '_REG_ID' => $registration->ID(),
596
-                ),
597
-                REG_ADMIN_URL
598
-            );
599
-            return EE_Registry::instance()->CAP->current_user_can(
600
-                'ee_read_registration',
601
-                'espresso_registrations_view_registration',
602
-                $registration->ID()
603
-            )
604
-                ? '
572
+			}
573
+		}
574
+		return '';
575
+	}
576
+
577
+
578
+	/**
579
+	 * Get the link to view the details for the primary registration.
580
+	 *
581
+	 * @param EE_Transaction $transaction
582
+	 * @return string
583
+	 * @throws EE_Error
584
+	 * @throws InvalidArgumentException
585
+	 * @throws InvalidDataTypeException
586
+	 * @throws InvalidInterfaceException
587
+	 */
588
+	protected function get_primary_registration_details_link(EE_Transaction $transaction)
589
+	{
590
+		$registration = $transaction->primary_registration();
591
+		if ($registration instanceof EE_Registration) {
592
+			$url = EE_Admin_Page::add_query_args_and_nonce(
593
+				array(
594
+					'action'  => 'view_registration',
595
+					'_REG_ID' => $registration->ID(),
596
+				),
597
+				REG_ADMIN_URL
598
+			);
599
+			return EE_Registry::instance()->CAP->current_user_can(
600
+				'ee_read_registration',
601
+				'espresso_registrations_view_registration',
602
+				$registration->ID()
603
+			)
604
+				? '
605 605
 				<li>
606 606
 					<a href="' . $url . '"'
607
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
607
+				  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
608 608
 						<span class="dashicons dashicons-clipboard"></span>
609 609
 					</a>
610 610
 				</li>'
611
-                : '';
612
-        }
613
-        return '';
614
-    }
615
-
616
-
617
-    /**
618
-     * Get send payment reminder trigger link
619
-     *
620
-     * @param EE_Transaction $transaction
621
-     * @return string
622
-     * @throws EE_Error
623
-     * @throws InvalidArgumentException
624
-     * @throws InvalidDataTypeException
625
-     * @throws InvalidInterfaceException
626
-     */
627
-    protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction)
628
-    {
629
-        $registration = $transaction->primary_registration();
630
-        if ($registration instanceof EE_Registration
631
-            && $registration->attendee() instanceof EE_Attendee
632
-            && EEH_MSG_Template::is_mt_active('payment_reminder')
633
-            && ! in_array(
634
-                $transaction->status_ID(),
635
-                array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code),
636
-                true
637
-            )
638
-            && EE_Registry::instance()->CAP->current_user_can(
639
-                'ee_send_message',
640
-                'espresso_transactions_send_payment_reminder'
641
-            )
642
-        ) {
643
-            $url = EE_Admin_Page::add_query_args_and_nonce(
644
-                array(
645
-                    'action' => 'send_payment_reminder',
646
-                    'TXN_ID' => $transaction->ID(),
647
-                ),
648
-                TXN_ADMIN_URL
649
-            );
650
-            return '
611
+				: '';
612
+		}
613
+		return '';
614
+	}
615
+
616
+
617
+	/**
618
+	 * Get send payment reminder trigger link
619
+	 *
620
+	 * @param EE_Transaction $transaction
621
+	 * @return string
622
+	 * @throws EE_Error
623
+	 * @throws InvalidArgumentException
624
+	 * @throws InvalidDataTypeException
625
+	 * @throws InvalidInterfaceException
626
+	 */
627
+	protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction)
628
+	{
629
+		$registration = $transaction->primary_registration();
630
+		if ($registration instanceof EE_Registration
631
+			&& $registration->attendee() instanceof EE_Attendee
632
+			&& EEH_MSG_Template::is_mt_active('payment_reminder')
633
+			&& ! in_array(
634
+				$transaction->status_ID(),
635
+				array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code),
636
+				true
637
+			)
638
+			&& EE_Registry::instance()->CAP->current_user_can(
639
+				'ee_send_message',
640
+				'espresso_transactions_send_payment_reminder'
641
+			)
642
+		) {
643
+			$url = EE_Admin_Page::add_query_args_and_nonce(
644
+				array(
645
+					'action' => 'send_payment_reminder',
646
+					'TXN_ID' => $transaction->ID(),
647
+				),
648
+				TXN_ADMIN_URL
649
+			);
650
+			return '
651 651
             <li>
652 652
                 <a href="' . $url . '"'
653
-                   . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
653
+				   . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
654 654
                     <span class="dashicons dashicons-email-alt"></span>
655 655
                 </a>
656 656
             </li>';
657
-        }
658
-        return '';
659
-    }
660
-
661
-
662
-    /**
663
-     * Get link to filtered view in the message activity list table of messages for this transaction.
664
-     *
665
-     * @param EE_Transaction $transaction
666
-     * @return string
667
-     * @throws EE_Error
668
-     * @throws InvalidArgumentException
669
-     * @throws InvalidDataTypeException
670
-     * @throws InvalidInterfaceException
671
-     */
672
-    protected function get_related_messages_link(EE_Transaction $transaction)
673
-    {
674
-        $url = EEH_MSG_Template::get_message_action_link(
675
-            'see_notifications_for',
676
-            null,
677
-            array('TXN_ID' => $transaction->ID())
678
-        );
679
-        return EE_Registry::instance()->CAP->current_user_can(
680
-            'ee_read_global_messages',
681
-            'view_filtered_messages'
682
-        )
683
-            ? '<li>' . $url . '</li>'
684
-            : '';
685
-    }
686
-
687
-
688
-    /**
689
-     * Return the link to make a payment on the frontend
690
-     *
691
-     * @param EE_Transaction $transaction
692
-     * @return string
693
-     * @throws EE_Error
694
-     */
695
-    protected function get_payment_overview_link(EE_Transaction $transaction)
696
-    {
697
-        $registration = $transaction->primary_registration();
698
-        if ($registration instanceof EE_Registration
699
-            && $transaction->status_ID() !== EEM_Transaction::complete_status_code
700
-            && $registration->owes_monies_and_can_pay()
701
-        ) {
702
-            return '
657
+		}
658
+		return '';
659
+	}
660
+
661
+
662
+	/**
663
+	 * Get link to filtered view in the message activity list table of messages for this transaction.
664
+	 *
665
+	 * @param EE_Transaction $transaction
666
+	 * @return string
667
+	 * @throws EE_Error
668
+	 * @throws InvalidArgumentException
669
+	 * @throws InvalidDataTypeException
670
+	 * @throws InvalidInterfaceException
671
+	 */
672
+	protected function get_related_messages_link(EE_Transaction $transaction)
673
+	{
674
+		$url = EEH_MSG_Template::get_message_action_link(
675
+			'see_notifications_for',
676
+			null,
677
+			array('TXN_ID' => $transaction->ID())
678
+		);
679
+		return EE_Registry::instance()->CAP->current_user_can(
680
+			'ee_read_global_messages',
681
+			'view_filtered_messages'
682
+		)
683
+			? '<li>' . $url . '</li>'
684
+			: '';
685
+	}
686
+
687
+
688
+	/**
689
+	 * Return the link to make a payment on the frontend
690
+	 *
691
+	 * @param EE_Transaction $transaction
692
+	 * @return string
693
+	 * @throws EE_Error
694
+	 */
695
+	protected function get_payment_overview_link(EE_Transaction $transaction)
696
+	{
697
+		$registration = $transaction->primary_registration();
698
+		if ($registration instanceof EE_Registration
699
+			&& $transaction->status_ID() !== EEM_Transaction::complete_status_code
700
+			&& $registration->owes_monies_and_can_pay()
701
+		) {
702
+			return '
703 703
             <li>
704 704
                 <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"'
705
-                   . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
706
-                   . ' class="tiny-text">
705
+				   . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
706
+				   . ' class="tiny-text">
707 707
                     <span class="dashicons dashicons-money ee-icon-size-18"></span>
708 708
                 </a>
709 709
             </li>
710 710
             ';
711
-        }
712
-        return '';
713
-    }
711
+		}
712
+		return '';
713
+	}
714 714
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     {
97 97
         $class = parent::_get_row_class($transaction);
98 98
         // add status class
99
-        $class .= ' ee-status-strip txn-status-' . $transaction->status_ID();
99
+        $class .= ' ee-status-strip txn-status-'.$transaction->status_ID();
100 100
         if ($this->_has_checkbox_column) {
101 101
             $class .= ' has-checkbox-column';
102 102
         }
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     protected function _add_view_counts()
150 150
     {
151 151
         foreach ($this->_views as $view) {
152
-            $this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']);
152
+            $this->_views[$view['slug']]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']);
153 153
         }
154 154
     }
155 155
 
@@ -170,13 +170,13 @@  discard block
 block discarded – undo
170 170
             ),
171 171
             TXN_ADMIN_URL
172 172
         );
173
-        $content = '<a href="' . $view_lnk_url . '"'
174
-                   . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">'
173
+        $content = '<a href="'.$view_lnk_url.'"'
174
+                   . ' title="'.esc_attr__('Go to Transaction Details', 'event_espresso').'">'
175 175
                    . $transaction->ID()
176 176
                    . '</a>';
177 177
 
178 178
         // txn timestamp
179
-        $content .= '  <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>';
179
+        $content .= '  <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($transaction).'</span>';
180 180
         return $content;
181 181
     }
182 182
 
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
             ),
237 237
             TXN_ADMIN_URL
238 238
         );
239
-        $txn_date = '<a href="' . $view_lnk_url . '"'
239
+        $txn_date = '<a href="'.$view_lnk_url.'"'
240 240
                     . ' title="'
241
-                    . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">'
241
+                    . esc_attr__('View Transaction Details for TXN #', 'event_espresso').$transaction->ID().'">'
242 242
                     . $this->_get_txn_timestamp($transaction)
243 243
                     . '</a>';
244 244
         // status
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
                    )
272 272
                    . '</span>';
273 273
         } else {
274
-            return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>';
274
+            return '<span class="txn-overview-free-event-spn">'.esc_html__('free', 'event_espresso').'</span>';
275 275
         }
276 276
     }
277 277
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             ? $payment_method->admin_name()
309 309
             : esc_html__('Unknown', 'event_espresso');
310 310
 
311
-        $content = '<span class="' . $span_class . ' txn-pad-rght">'
311
+        $content = '<span class="'.$span_class.' txn-pad-rght">'
312 312
                    . $transaction->get_pretty('TXN_paid')
313 313
                    . '</span>';
314 314
         if ($transaction_paid > 0) {
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
                 'espresso_registrations_view_registration',
351 351
                 $primary_reg->ID()
352 352
             )
353
-                ? '<a href="' . $edit_lnk_url . '"'
354
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">'
353
+                ? '<a href="'.$edit_lnk_url.'"'
354
+                  . ' title="'.esc_attr__('View Registration Details', 'event_espresso').'">'
355 355
                   . $attendee->full_name()
356 356
                   . '</a>'
357 357
                 : $attendee->full_name();
358
-            $content .= '<br>' . $attendee->email();
358
+            $content .= '<br>'.$attendee->email();
359 359
             return $content;
360 360
         }
361 361
         return $transaction->failed() || $transaction->is_abandoned()
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
     public function column_ATT_email(EE_Transaction $transaction)
378 378
     {
379 379
         $attendee = $transaction->primary_registration()->get_first_related('Attendee');
380
-        if (! empty($attendee)) {
381
-            return '<a href="mailto:' . $attendee->get('ATT_email') . '">'
380
+        if ( ! empty($attendee)) {
381
+            return '<a href="mailto:'.$attendee->get('ATT_email').'">'
382 382
                    . $attendee->get('ATT_email')
383 383
                    . '</a>';
384 384
         } else {
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
     {
407 407
         $actions = array();
408 408
         $event = $transaction->primary_registration()->get_first_related('Event');
409
-        if (! empty($event)) {
409
+        if ( ! empty($event)) {
410 410
             $edit_event_url = EE_Admin_Page::add_query_args_and_nonce(
411 411
                 array('action' => 'edit', 'post' => $event->ID()),
412 412
                 EVENTS_ADMIN_URL
@@ -427,11 +427,11 @@  discard block
 block discarded – undo
427 427
                     $event->ID()
428 428
                 )
429 429
             ) {
430
-                $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"'
431
-                                              . ' title="' . esc_attr__(
430
+                $actions['filter_by_event'] = '<a href="'.$txn_by_event_lnk.'"'
431
+                                              . ' title="'.esc_attr__(
432 432
                                                   'Filter transactions by this event',
433 433
                                                   'event_espresso'
434
-                                              ) . '">'
434
+                                              ).'">'
435 435
                                               . esc_html__('View Transactions for this event', 'event_espresso')
436 436
                                               . '</a>';
437 437
             }
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
                     'espresso_events_edit',
444 444
                     $event->ID()
445 445
                 )
446
-                    ? '<a href="' . $edit_event_url . '"'
446
+                    ? '<a href="'.$edit_event_url.'"'
447 447
                       . ' title="'
448 448
                       . sprintf(
449 449
                           esc_attr__('Edit Event: %s', 'event_espresso'),
@@ -510,8 +510,8 @@  discard block
 block discarded – undo
510 510
         );
511 511
         return '
512 512
 			<li>
513
-				<a href="' . $url . '"'
514
-               . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text">
513
+				<a href="' . $url.'"'
514
+               . ' title="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="tiny-text">
515 515
 					<span class="dashicons dashicons-cart"></span>
516 516
 				</a>
517 517
 			</li>';
@@ -536,8 +536,8 @@  discard block
 block discarded – undo
536 536
             ) {
537 537
                 return '
538 538
                 <li>
539
-                    <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"'
540
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
539
+                    <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso').'"'
540
+                       . ' target="_blank" href="'.$url.'" class="tiny-text">
541 541
                         <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span>
542 542
                     </a>
543 543
                 </li>';
@@ -564,8 +564,8 @@  discard block
 block discarded – undo
564 564
                 && EEH_MSG_Template::is_mt_active('receipt')) {
565 565
                 return '
566 566
 			<li>
567
-				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"'
568
-                       . ' target="_blank" href="' . $url . '" class="tiny-text">
567
+				<a title="' . esc_attr__('View Transaction Receipt', 'event_espresso').'"'
568
+                       . ' target="_blank" href="'.$url.'" class="tiny-text">
569 569
 					<span class="dashicons dashicons-media-default ee-icon-size-18"></span>
570 570
 				</a>
571 571
 			</li>';
@@ -603,8 +603,8 @@  discard block
 block discarded – undo
603 603
             )
604 604
                 ? '
605 605
 				<li>
606
-					<a href="' . $url . '"'
607
-                  . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text">
606
+					<a href="' . $url.'"'
607
+                  . ' title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text">
608 608
 						<span class="dashicons dashicons-clipboard"></span>
609 609
 					</a>
610 610
 				</li>'
@@ -649,8 +649,8 @@  discard block
 block discarded – undo
649 649
             );
650 650
             return '
651 651
             <li>
652
-                <a href="' . $url . '"'
653
-                   . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text">
652
+                <a href="' . $url.'"'
653
+                   . ' title="'.esc_attr__('Send Payment Reminder', 'event_espresso').'" class="tiny-text">
654 654
                     <span class="dashicons dashicons-email-alt"></span>
655 655
                 </a>
656 656
             </li>';
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
             'ee_read_global_messages',
681 681
             'view_filtered_messages'
682 682
         )
683
-            ? '<li>' . $url . '</li>'
683
+            ? '<li>'.$url.'</li>'
684 684
             : '';
685 685
     }
686 686
 
@@ -701,8 +701,8 @@  discard block
 block discarded – undo
701 701
         ) {
702 702
             return '
703 703
             <li>
704
-                <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"'
705
-                   . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"'
704
+                <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso').'"'
705
+                   . ' target="_blank" href="'.$registration->payment_overview_url(true).'"'
706 706
                    . ' class="tiny-text">
707 707
                     <span class="dashicons dashicons-money ee-icon-size-18"></span>
708 708
                 </a>
Please login to merge, or discard this patch.
core/EE_Config.core.php 1 patch
Indentation   +3146 added lines, -3146 removed lines patch added patch discarded remove patch
@@ -14,2509 +14,2509 @@  discard block
 block discarded – undo
14 14
 final class EE_Config implements ResettableInterface
15 15
 {
16 16
 
17
-    const OPTION_NAME = 'ee_config';
18
-
19
-    const LOG_NAME = 'ee_config_log';
20
-
21
-    const LOG_LENGTH = 100;
22
-
23
-    const ADDON_OPTION_NAMES = 'ee_config_option_names';
24
-
25
-    /**
26
-     *    instance of the EE_Config object
27
-     *
28
-     * @var    EE_Config $_instance
29
-     * @access    private
30
-     */
31
-    private static $_instance;
32
-
33
-    /**
34
-     * @var boolean $_logging_enabled
35
-     */
36
-    private static $_logging_enabled = false;
37
-
38
-    /**
39
-     * @var LegacyShortcodesManager $legacy_shortcodes_manager
40
-     */
41
-    private $legacy_shortcodes_manager;
42
-
43
-    /**
44
-     * An StdClass whose property names are addon slugs,
45
-     * and values are their config classes
46
-     *
47
-     * @var StdClass
48
-     */
49
-    public $addons;
50
-
51
-    /**
52
-     * @var EE_Admin_Config
53
-     */
54
-    public $admin;
55
-
56
-    /**
57
-     * @var EE_Core_Config
58
-     */
59
-    public $core;
60
-
61
-    /**
62
-     * @var EE_Currency_Config
63
-     */
64
-    public $currency;
65
-
66
-    /**
67
-     * @var EE_Organization_Config
68
-     */
69
-    public $organization;
70
-
71
-    /**
72
-     * @var EE_Registration_Config
73
-     */
74
-    public $registration;
75
-
76
-    /**
77
-     * @var EE_Template_Config
78
-     */
79
-    public $template_settings;
80
-
81
-    /**
82
-     * Holds EE environment values.
83
-     *
84
-     * @var EE_Environment_Config
85
-     */
86
-    public $environment;
87
-
88
-    /**
89
-     * settings pertaining to Google maps
90
-     *
91
-     * @var EE_Map_Config
92
-     */
93
-    public $map_settings;
94
-
95
-    /**
96
-     * settings pertaining to Taxes
97
-     *
98
-     * @var EE_Tax_Config
99
-     */
100
-    public $tax_settings;
101
-
102
-    /**
103
-     * Settings pertaining to global messages settings.
104
-     *
105
-     * @var EE_Messages_Config
106
-     */
107
-    public $messages;
108
-
109
-    /**
110
-     * @deprecated
111
-     * @var EE_Gateway_Config
112
-     */
113
-    public $gateway;
114
-
115
-    /**
116
-     * @var    array $_addon_option_names
117
-     * @access    private
118
-     */
119
-    private $_addon_option_names = array();
120
-
121
-    /**
122
-     * @var    array $_module_route_map
123
-     * @access    private
124
-     */
125
-    private static $_module_route_map = array();
126
-
127
-    /**
128
-     * @var    array $_module_forward_map
129
-     * @access    private
130
-     */
131
-    private static $_module_forward_map = array();
132
-
133
-    /**
134
-     * @var    array $_module_view_map
135
-     * @access    private
136
-     */
137
-    private static $_module_view_map = array();
138
-
139
-
140
-    /**
141
-     * @singleton method used to instantiate class object
142
-     * @access    public
143
-     * @return EE_Config instance
144
-     */
145
-    public static function instance()
146
-    {
147
-        // check if class object is instantiated, and instantiated properly
148
-        if (! self::$_instance instanceof EE_Config) {
149
-            self::$_instance = new self();
150
-        }
151
-        return self::$_instance;
152
-    }
153
-
154
-
155
-    /**
156
-     * Resets the config
157
-     *
158
-     * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
159
-     *                               (default) leaves the database alone, and merely resets the EE_Config object to
160
-     *                               reflect its state in the database
161
-     * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
162
-     *                               $_instance as NULL. Useful in case you want to forget about the old instance on
163
-     *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
164
-     *                               site was put into maintenance mode)
165
-     * @return EE_Config
166
-     */
167
-    public static function reset($hard_reset = false, $reinstantiate = true)
168
-    {
169
-        if (self::$_instance instanceof EE_Config) {
170
-            if ($hard_reset) {
171
-                self::$_instance->legacy_shortcodes_manager = null;
172
-                self::$_instance->_addon_option_names = array();
173
-                self::$_instance->_initialize_config();
174
-                self::$_instance->update_espresso_config();
175
-            }
176
-            self::$_instance->update_addon_option_names();
177
-        }
178
-        self::$_instance = null;
179
-        // we don't need to reset the static properties imo because those should
180
-        // only change when a module is added or removed. Currently we don't
181
-        // support removing a module during a request when it previously existed
182
-        if ($reinstantiate) {
183
-            return self::instance();
184
-        } else {
185
-            return null;
186
-        }
187
-    }
188
-
189
-
190
-    /**
191
-     *    class constructor
192
-     *
193
-     * @access    private
194
-     */
195
-    private function __construct()
196
-    {
197
-        do_action('AHEE__EE_Config__construct__begin', $this);
198
-        EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
199
-        // setup empty config classes
200
-        $this->_initialize_config();
201
-        // load existing EE site settings
202
-        $this->_load_core_config();
203
-        // confirm everything loaded correctly and set filtered defaults if not
204
-        $this->_verify_config();
205
-        //  register shortcodes and modules
206
-        add_action(
207
-            'AHEE__EE_System__register_shortcodes_modules_and_widgets',
208
-            array($this, 'register_shortcodes_and_modules'),
209
-            999
210
-        );
211
-        //  initialize shortcodes and modules
212
-        add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
213
-        // register widgets
214
-        add_action('widgets_init', array($this, 'widgets_init'), 10);
215
-        // shutdown
216
-        add_action('shutdown', array($this, 'shutdown'), 10);
217
-        // construct__end hook
218
-        do_action('AHEE__EE_Config__construct__end', $this);
219
-        // hardcoded hack
220
-        $this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
221
-    }
222
-
223
-
224
-    /**
225
-     * @return boolean
226
-     */
227
-    public static function logging_enabled()
228
-    {
229
-        return self::$_logging_enabled;
230
-    }
231
-
232
-
233
-    /**
234
-     * use to get the current theme if needed from static context
235
-     *
236
-     * @return string current theme set.
237
-     */
238
-    public static function get_current_theme()
239
-    {
240
-        return isset(self::$_instance->template_settings->current_espresso_theme)
241
-            ? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
242
-    }
243
-
244
-
245
-    /**
246
-     *        _initialize_config
247
-     *
248
-     * @access private
249
-     * @return void
250
-     */
251
-    private function _initialize_config()
252
-    {
253
-        EE_Config::trim_log();
254
-        // set defaults
255
-        $this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
256
-        $this->addons = new stdClass();
257
-        // set _module_route_map
258
-        EE_Config::$_module_route_map = array();
259
-        // set _module_forward_map
260
-        EE_Config::$_module_forward_map = array();
261
-        // set _module_view_map
262
-        EE_Config::$_module_view_map = array();
263
-    }
264
-
265
-
266
-    /**
267
-     *        load core plugin configuration
268
-     *
269
-     * @access private
270
-     * @return void
271
-     */
272
-    private function _load_core_config()
273
-    {
274
-        // load_core_config__start hook
275
-        do_action('AHEE__EE_Config___load_core_config__start', $this);
276
-        $espresso_config = $this->get_espresso_config();
277
-        foreach ($espresso_config as $config => $settings) {
278
-            // load_core_config__start hook
279
-            $settings = apply_filters(
280
-                'FHEE__EE_Config___load_core_config__config_settings',
281
-                $settings,
282
-                $config,
283
-                $this
284
-            );
285
-            if (is_object($settings) && property_exists($this, $config)) {
286
-                $this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
287
-                // call configs populate method to ensure any defaults are set for empty values.
288
-                if (method_exists($settings, 'populate')) {
289
-                    $this->{$config}->populate();
290
-                }
291
-                if (method_exists($settings, 'do_hooks')) {
292
-                    $this->{$config}->do_hooks();
293
-                }
294
-            }
295
-        }
296
-        if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
297
-            $this->update_espresso_config();
298
-        }
299
-        // load_core_config__end hook
300
-        do_action('AHEE__EE_Config___load_core_config__end', $this);
301
-    }
302
-
303
-
304
-    /**
305
-     *    _verify_config
306
-     *
307
-     * @access    protected
308
-     * @return    void
309
-     */
310
-    protected function _verify_config()
311
-    {
312
-        $this->core = $this->core instanceof EE_Core_Config
313
-            ? $this->core
314
-            : new EE_Core_Config();
315
-        $this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
316
-        $this->organization = $this->organization instanceof EE_Organization_Config
317
-            ? $this->organization
318
-            : new EE_Organization_Config();
319
-        $this->organization = apply_filters(
320
-            'FHEE__EE_Config___initialize_config__organization',
321
-            $this->organization
322
-        );
323
-        $this->currency = $this->currency instanceof EE_Currency_Config
324
-            ? $this->currency
325
-            : new EE_Currency_Config();
326
-        $this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
327
-        $this->registration = $this->registration instanceof EE_Registration_Config
328
-            ? $this->registration
329
-            : new EE_Registration_Config();
330
-        $this->registration = apply_filters(
331
-            'FHEE__EE_Config___initialize_config__registration',
332
-            $this->registration
333
-        );
334
-        $this->admin = $this->admin instanceof EE_Admin_Config
335
-            ? $this->admin
336
-            : new EE_Admin_Config();
337
-        $this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
338
-        $this->template_settings = $this->template_settings instanceof EE_Template_Config
339
-            ? $this->template_settings
340
-            : new EE_Template_Config();
341
-        $this->template_settings = apply_filters(
342
-            'FHEE__EE_Config___initialize_config__template_settings',
343
-            $this->template_settings
344
-        );
345
-        $this->map_settings = $this->map_settings instanceof EE_Map_Config
346
-            ? $this->map_settings
347
-            : new EE_Map_Config();
348
-        $this->map_settings = apply_filters(
349
-            'FHEE__EE_Config___initialize_config__map_settings',
350
-            $this->map_settings
351
-        );
352
-        $this->environment = $this->environment instanceof EE_Environment_Config
353
-            ? $this->environment
354
-            : new EE_Environment_Config();
355
-        $this->environment = apply_filters(
356
-            'FHEE__EE_Config___initialize_config__environment',
357
-            $this->environment
358
-        );
359
-        $this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
360
-            ? $this->tax_settings
361
-            : new EE_Tax_Config();
362
-        $this->tax_settings = apply_filters(
363
-            'FHEE__EE_Config___initialize_config__tax_settings',
364
-            $this->tax_settings
365
-        );
366
-        $this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
367
-        $this->messages = $this->messages instanceof EE_Messages_Config
368
-            ? $this->messages
369
-            : new EE_Messages_Config();
370
-        $this->gateway = $this->gateway instanceof EE_Gateway_Config
371
-            ? $this->gateway
372
-            : new EE_Gateway_Config();
373
-        $this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
374
-        $this->legacy_shortcodes_manager = null;
375
-    }
376
-
377
-
378
-    /**
379
-     *    get_espresso_config
380
-     *
381
-     * @access    public
382
-     * @return    array of espresso config stuff
383
-     */
384
-    public function get_espresso_config()
385
-    {
386
-        // grab espresso configuration
387
-        return apply_filters(
388
-            'FHEE__EE_Config__get_espresso_config__CFG',
389
-            get_option(EE_Config::OPTION_NAME, array())
390
-        );
391
-    }
392
-
393
-
394
-    /**
395
-     *    double_check_config_comparison
396
-     *
397
-     * @access    public
398
-     * @param string $option
399
-     * @param        $old_value
400
-     * @param        $value
401
-     */
402
-    public function double_check_config_comparison($option = '', $old_value, $value)
403
-    {
404
-        // make sure we're checking the ee config
405
-        if ($option === EE_Config::OPTION_NAME) {
406
-            // run a loose comparison of the old value against the new value for type and properties,
407
-            // but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
408
-            if ($value != $old_value) {
409
-                // if they are NOT the same, then remove the hook,
410
-                // which means the subsequent update results will be based solely on the update query results
411
-                // the reason we do this is because, as stated above,
412
-                // WP update_option performs an exact instance comparison (===) on any update values passed to it
413
-                // this happens PRIOR to serialization and any subsequent update.
414
-                // If values are found to match their previous old value,
415
-                // then WP bails before performing any update.
416
-                // Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
417
-                // it just pulled from the db, with the one being passed to it (which will not match).
418
-                // HOWEVER, once the object is serialized and passed off to MySQL to update,
419
-                // MySQL MAY ALSO NOT perform the update because
420
-                // the string it sees in the db looks the same as the new one it has been passed!!!
421
-                // This results in the query returning an "affected rows" value of ZERO,
422
-                // which gets returned immediately by WP update_option and looks like an error.
423
-                remove_action('update_option', array($this, 'check_config_updated'));
424
-            }
425
-        }
426
-    }
427
-
428
-
429
-    /**
430
-     *    update_espresso_config
431
-     *
432
-     * @access   public
433
-     */
434
-    protected function _reset_espresso_addon_config()
435
-    {
436
-        $this->_addon_option_names = array();
437
-        foreach ($this->addons as $addon_name => $addon_config_obj) {
438
-            $addon_config_obj = maybe_unserialize($addon_config_obj);
439
-            if ($addon_config_obj instanceof EE_Config_Base) {
440
-                $this->update_config('addons', $addon_name, $addon_config_obj, false);
441
-            }
442
-            $this->addons->{$addon_name} = null;
443
-        }
444
-    }
445
-
446
-
447
-    /**
448
-     *    update_espresso_config
449
-     *
450
-     * @access   public
451
-     * @param   bool $add_success
452
-     * @param   bool $add_error
453
-     * @return   bool
454
-     */
455
-    public function update_espresso_config($add_success = false, $add_error = true)
456
-    {
457
-        // don't allow config updates during WP heartbeats
458
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
459
-            return false;
460
-        }
461
-        // commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
462
-        // $clone = clone( self::$_instance );
463
-        // self::$_instance = NULL;
464
-        do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
465
-        $this->_reset_espresso_addon_config();
466
-        // hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
467
-        // but BEFORE the actual update occurs
468
-        add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
469
-        // don't want to persist legacy_shortcodes_manager, but don't want to lose it either
470
-        $legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
471
-        $this->legacy_shortcodes_manager = null;
472
-        // now update "ee_config"
473
-        $saved = update_option(EE_Config::OPTION_NAME, $this);
474
-        $this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
475
-        EE_Config::log(EE_Config::OPTION_NAME);
476
-        // if not saved... check if the hook we just added still exists;
477
-        // if it does, it means one of two things:
478
-        // that update_option bailed at the($value === $old_value) conditional,
479
-        // or...
480
-        // the db update query returned 0 rows affected
481
-        // (probably because the data  value was the same from it's perspective)
482
-        // so the existence of the hook means that a negative result from update_option is NOT an error,
483
-        // but just means no update occurred, so don't display an error to the user.
484
-        // BUT... if update_option returns FALSE, AND the hook is missing,
485
-        // then it means that something truly went wrong
486
-        $saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
487
-        // remove our action since we don't want it in the system anymore
488
-        remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
489
-        do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
490
-        // self::$_instance = $clone;
491
-        // unset( $clone );
492
-        // if config remains the same or was updated successfully
493
-        if ($saved) {
494
-            if ($add_success) {
495
-                EE_Error::add_success(
496
-                    __('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
497
-                    __FILE__,
498
-                    __FUNCTION__,
499
-                    __LINE__
500
-                );
501
-            }
502
-            return true;
503
-        } else {
504
-            if ($add_error) {
505
-                EE_Error::add_error(
506
-                    __('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
507
-                    __FILE__,
508
-                    __FUNCTION__,
509
-                    __LINE__
510
-                );
511
-            }
512
-            return false;
513
-        }
514
-    }
515
-
516
-
517
-    /**
518
-     *    _verify_config_params
519
-     *
520
-     * @access    private
521
-     * @param    string         $section
522
-     * @param    string         $name
523
-     * @param    string         $config_class
524
-     * @param    EE_Config_Base $config_obj
525
-     * @param    array          $tests_to_run
526
-     * @param    bool           $display_errors
527
-     * @return    bool    TRUE on success, FALSE on fail
528
-     */
529
-    private function _verify_config_params(
530
-        $section = '',
531
-        $name = '',
532
-        $config_class = '',
533
-        $config_obj = null,
534
-        $tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
535
-        $display_errors = true
536
-    ) {
537
-        try {
538
-            foreach ($tests_to_run as $test) {
539
-                switch ($test) {
540
-                    // TEST #1 : check that section was set
541
-                    case 1:
542
-                        if (empty($section)) {
543
-                            if ($display_errors) {
544
-                                throw new EE_Error(
545
-                                    sprintf(
546
-                                        __(
547
-                                            'No configuration section has been provided while attempting to save "%s".',
548
-                                            'event_espresso'
549
-                                        ),
550
-                                        $config_class
551
-                                    )
552
-                                );
553
-                            }
554
-                            return false;
555
-                        }
556
-                        break;
557
-                    // TEST #2 : check that settings section exists
558
-                    case 2:
559
-                        if (! isset($this->{$section})) {
560
-                            if ($display_errors) {
561
-                                throw new EE_Error(
562
-                                    sprintf(
563
-                                        __('The "%s" configuration section does not exist.', 'event_espresso'),
564
-                                        $section
565
-                                    )
566
-                                );
567
-                            }
568
-                            return false;
569
-                        }
570
-                        break;
571
-                    // TEST #3 : check that section is the proper format
572
-                    case 3:
573
-                        if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
574
-                        ) {
575
-                            if ($display_errors) {
576
-                                throw new EE_Error(
577
-                                    sprintf(
578
-                                        __(
579
-                                            'The "%s" configuration settings have not been formatted correctly.',
580
-                                            'event_espresso'
581
-                                        ),
582
-                                        $section
583
-                                    )
584
-                                );
585
-                            }
586
-                            return false;
587
-                        }
588
-                        break;
589
-                    // TEST #4 : check that config section name has been set
590
-                    case 4:
591
-                        if (empty($name)) {
592
-                            if ($display_errors) {
593
-                                throw new EE_Error(
594
-                                    __(
595
-                                        'No name has been provided for the specific configuration section.',
596
-                                        'event_espresso'
597
-                                    )
598
-                                );
599
-                            }
600
-                            return false;
601
-                        }
602
-                        break;
603
-                    // TEST #5 : check that a config class name has been set
604
-                    case 5:
605
-                        if (empty($config_class)) {
606
-                            if ($display_errors) {
607
-                                throw new EE_Error(
608
-                                    __(
609
-                                        'No class name has been provided for the specific configuration section.',
610
-                                        'event_espresso'
611
-                                    )
612
-                                );
613
-                            }
614
-                            return false;
615
-                        }
616
-                        break;
617
-                    // TEST #6 : verify config class is accessible
618
-                    case 6:
619
-                        if (! class_exists($config_class)) {
620
-                            if ($display_errors) {
621
-                                throw new EE_Error(
622
-                                    sprintf(
623
-                                        __(
624
-                                            'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
625
-                                            'event_espresso'
626
-                                        ),
627
-                                        $config_class
628
-                                    )
629
-                                );
630
-                            }
631
-                            return false;
632
-                        }
633
-                        break;
634
-                    // TEST #7 : check that config has even been set
635
-                    case 7:
636
-                        if (! isset($this->{$section}->{$name})) {
637
-                            if ($display_errors) {
638
-                                throw new EE_Error(
639
-                                    sprintf(
640
-                                        __('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
641
-                                        $section,
642
-                                        $name
643
-                                    )
644
-                                );
645
-                            }
646
-                            return false;
647
-                        } else {
648
-                            // and make sure it's not serialized
649
-                            $this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
650
-                        }
651
-                        break;
652
-                    // TEST #8 : check that config is the requested type
653
-                    case 8:
654
-                        if (! $this->{$section}->{$name} instanceof $config_class) {
655
-                            if ($display_errors) {
656
-                                throw new EE_Error(
657
-                                    sprintf(
658
-                                        __(
659
-                                            'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
660
-                                            'event_espresso'
661
-                                        ),
662
-                                        $section,
663
-                                        $name,
664
-                                        $config_class
665
-                                    )
666
-                                );
667
-                            }
668
-                            return false;
669
-                        }
670
-                        break;
671
-                    // TEST #9 : verify config object
672
-                    case 9:
673
-                        if (! $config_obj instanceof EE_Config_Base) {
674
-                            if ($display_errors) {
675
-                                throw new EE_Error(
676
-                                    sprintf(
677
-                                        __('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
678
-                                        print_r($config_obj, true)
679
-                                    )
680
-                                );
681
-                            }
682
-                            return false;
683
-                        }
684
-                        break;
685
-                }
686
-            }
687
-        } catch (EE_Error $e) {
688
-            $e->get_error();
689
-        }
690
-        // you have successfully run the gauntlet
691
-        return true;
692
-    }
693
-
694
-
695
-    /**
696
-     *    _generate_config_option_name
697
-     *
698
-     * @access        protected
699
-     * @param        string $section
700
-     * @param        string $name
701
-     * @return        string
702
-     */
703
-    private function _generate_config_option_name($section = '', $name = '')
704
-    {
705
-        return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
706
-    }
707
-
708
-
709
-    /**
710
-     *    _set_config_class
711
-     * ensures that a config class is set, either from a passed config class or one generated from the config name
712
-     *
713
-     * @access    private
714
-     * @param    string $config_class
715
-     * @param    string $name
716
-     * @return    string
717
-     */
718
-    private function _set_config_class($config_class = '', $name = '')
719
-    {
720
-        return ! empty($config_class)
721
-            ? $config_class
722
-            : str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
723
-    }
724
-
725
-
726
-    /**
727
-     *    set_config
728
-     *
729
-     * @access    protected
730
-     * @param    string         $section
731
-     * @param    string         $name
732
-     * @param    string         $config_class
733
-     * @param    EE_Config_Base $config_obj
734
-     * @return    EE_Config_Base
735
-     */
736
-    public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
737
-    {
738
-        // ensure config class is set to something
739
-        $config_class = $this->_set_config_class($config_class, $name);
740
-        // run tests 1-4, 6, and 7 to verify all config params are set and valid
741
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
742
-            return null;
743
-        }
744
-        $config_option_name = $this->_generate_config_option_name($section, $name);
745
-        // if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
746
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
747
-            $this->_addon_option_names[ $config_option_name ] = $config_class;
748
-            $this->update_addon_option_names();
749
-        }
750
-        // verify the incoming config object but suppress errors
751
-        if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
752
-            $config_obj = new $config_class();
753
-        }
754
-        if (get_option($config_option_name)) {
755
-            EE_Config::log($config_option_name);
756
-            update_option($config_option_name, $config_obj);
757
-            $this->{$section}->{$name} = $config_obj;
758
-            return $this->{$section}->{$name};
759
-        } else {
760
-            // create a wp-option for this config
761
-            if (add_option($config_option_name, $config_obj, '', 'no')) {
762
-                $this->{$section}->{$name} = maybe_unserialize($config_obj);
763
-                return $this->{$section}->{$name};
764
-            } else {
765
-                EE_Error::add_error(
766
-                    sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
767
-                    __FILE__,
768
-                    __FUNCTION__,
769
-                    __LINE__
770
-                );
771
-                return null;
772
-            }
773
-        }
774
-    }
775
-
776
-
777
-    /**
778
-     *    update_config
779
-     * Important: the config object must ALREADY be set, otherwise this will produce an error.
780
-     *
781
-     * @access    public
782
-     * @param    string                $section
783
-     * @param    string                $name
784
-     * @param    EE_Config_Base|string $config_obj
785
-     * @param    bool                  $throw_errors
786
-     * @return    bool
787
-     */
788
-    public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
789
-    {
790
-        // don't allow config updates during WP heartbeats
791
-        if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
792
-            return false;
793
-        }
794
-        $config_obj = maybe_unserialize($config_obj);
795
-        // get class name of the incoming object
796
-        $config_class = get_class($config_obj);
797
-        // run tests 1-5 and 9 to verify config
798
-        if (! $this->_verify_config_params(
799
-            $section,
800
-            $name,
801
-            $config_class,
802
-            $config_obj,
803
-            array(1, 2, 3, 4, 7, 9)
804
-        )
805
-        ) {
806
-            return false;
807
-        }
808
-        $config_option_name = $this->_generate_config_option_name($section, $name);
809
-        // check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
810
-        if (! isset($this->_addon_option_names[ $config_option_name ])) {
811
-            // save new config to db
812
-            if ($this->set_config($section, $name, $config_class, $config_obj)) {
813
-                return true;
814
-            }
815
-        } else {
816
-            // first check if the record already exists
817
-            $existing_config = get_option($config_option_name);
818
-            $config_obj = serialize($config_obj);
819
-            // just return if db record is already up to date (NOT type safe comparison)
820
-            if ($existing_config == $config_obj) {
821
-                $this->{$section}->{$name} = $config_obj;
822
-                return true;
823
-            } elseif (update_option($config_option_name, $config_obj)) {
824
-                EE_Config::log($config_option_name);
825
-                // update wp-option for this config class
826
-                $this->{$section}->{$name} = $config_obj;
827
-                return true;
828
-            } elseif ($throw_errors) {
829
-                EE_Error::add_error(
830
-                    sprintf(
831
-                        __(
832
-                            'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
833
-                            'event_espresso'
834
-                        ),
835
-                        $config_class,
836
-                        'EE_Config->' . $section . '->' . $name
837
-                    ),
838
-                    __FILE__,
839
-                    __FUNCTION__,
840
-                    __LINE__
841
-                );
842
-            }
843
-        }
844
-        return false;
845
-    }
846
-
847
-
848
-    /**
849
-     *    get_config
850
-     *
851
-     * @access    public
852
-     * @param    string $section
853
-     * @param    string $name
854
-     * @param    string $config_class
855
-     * @return    mixed EE_Config_Base | NULL
856
-     */
857
-    public function get_config($section = '', $name = '', $config_class = '')
858
-    {
859
-        // ensure config class is set to something
860
-        $config_class = $this->_set_config_class($config_class, $name);
861
-        // run tests 1-4, 6 and 7 to verify that all params have been set
862
-        if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
863
-            return null;
864
-        }
865
-        // now test if the requested config object exists, but suppress errors
866
-        if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
867
-            // config already exists, so pass it back
868
-            return $this->{$section}->{$name};
869
-        }
870
-        // load config option from db if it exists
871
-        $config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
872
-        // verify the newly retrieved config object, but suppress errors
873
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
874
-            // config is good, so set it and pass it back
875
-            $this->{$section}->{$name} = $config_obj;
876
-            return $this->{$section}->{$name};
877
-        }
878
-        // oops! $config_obj is not already set and does not exist in the db, so create a new one
879
-        $config_obj = $this->set_config($section, $name, $config_class);
880
-        // verify the newly created config object
881
-        if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
882
-            return $this->{$section}->{$name};
883
-        } else {
884
-            EE_Error::add_error(
885
-                sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
886
-                __FILE__,
887
-                __FUNCTION__,
888
-                __LINE__
889
-            );
890
-        }
891
-        return null;
892
-    }
893
-
894
-
895
-    /**
896
-     *    get_config_option
897
-     *
898
-     * @access    public
899
-     * @param    string $config_option_name
900
-     * @return    mixed EE_Config_Base | FALSE
901
-     */
902
-    public function get_config_option($config_option_name = '')
903
-    {
904
-        // retrieve the wp-option for this config class.
905
-        $config_option = maybe_unserialize(get_option($config_option_name, array()));
906
-        if (empty($config_option)) {
907
-            EE_Config::log($config_option_name . '-NOT-FOUND');
908
-        }
909
-        return $config_option;
910
-    }
911
-
912
-
913
-    /**
914
-     * log
915
-     *
916
-     * @param string $config_option_name
917
-     */
918
-    public static function log($config_option_name = '')
919
-    {
920
-        if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
921
-            $config_log = get_option(EE_Config::LOG_NAME, array());
922
-            // copy incoming $_REQUEST and sanitize it so we can save it
923
-            $_request = $_REQUEST;
924
-            array_walk_recursive($_request, 'sanitize_text_field');
925
-            $config_log[ (string) microtime(true) ] = array(
926
-                'config_name' => $config_option_name,
927
-                'request'     => $_request,
928
-            );
929
-            update_option(EE_Config::LOG_NAME, $config_log);
930
-        }
931
-    }
932
-
933
-
934
-    /**
935
-     * trim_log
936
-     * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
937
-     */
938
-    public static function trim_log()
939
-    {
940
-        if (! EE_Config::logging_enabled()) {
941
-            return;
942
-        }
943
-        $config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
944
-        $log_length = count($config_log);
945
-        if ($log_length > EE_Config::LOG_LENGTH) {
946
-            ksort($config_log);
947
-            $config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
948
-            update_option(EE_Config::LOG_NAME, $config_log);
949
-        }
950
-    }
951
-
952
-
953
-    /**
954
-     *    get_page_for_posts
955
-     *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
956
-     *    wp-option "page_for_posts", or "posts" if no page is selected
957
-     *
958
-     * @access    public
959
-     * @return    string
960
-     */
961
-    public static function get_page_for_posts()
962
-    {
963
-        $page_for_posts = get_option('page_for_posts');
964
-        if (! $page_for_posts) {
965
-            return 'posts';
966
-        }
967
-        /** @type WPDB $wpdb */
968
-        global $wpdb;
969
-        $SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
970
-        return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
971
-    }
972
-
973
-
974
-    /**
975
-     *    register_shortcodes_and_modules.
976
-     *    At this point, it's too early to tell if we're maintenance mode or not.
977
-     *    In fact, this is where we give modules a chance to let core know they exist
978
-     *    so they can help trigger maintenance mode if it's needed
979
-     *
980
-     * @access    public
981
-     * @return    void
982
-     */
983
-    public function register_shortcodes_and_modules()
984
-    {
985
-        // allow modules to set hooks for the rest of the system
986
-        EE_Registry::instance()->modules = $this->_register_modules();
987
-    }
988
-
989
-
990
-    /**
991
-     *    initialize_shortcodes_and_modules
992
-     *    meaning they can start adding their hooks to get stuff done
993
-     *
994
-     * @access    public
995
-     * @return    void
996
-     */
997
-    public function initialize_shortcodes_and_modules()
998
-    {
999
-        // allow modules to set hooks for the rest of the system
1000
-        $this->_initialize_modules();
1001
-    }
1002
-
1003
-
1004
-    /**
1005
-     *    widgets_init
1006
-     *
1007
-     * @access private
1008
-     * @return void
1009
-     */
1010
-    public function widgets_init()
1011
-    {
1012
-        // only init widgets on admin pages when not in complete maintenance, and
1013
-        // on frontend when not in any maintenance mode
1014
-        if (! EE_Maintenance_Mode::instance()->level()
1015
-            || (
1016
-                is_admin()
1017
-                && EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1018
-            )
1019
-        ) {
1020
-            // grab list of installed widgets
1021
-            $widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1022
-            // filter list of modules to register
1023
-            $widgets_to_register = apply_filters(
1024
-                'FHEE__EE_Config__register_widgets__widgets_to_register',
1025
-                $widgets_to_register
1026
-            );
1027
-            if (! empty($widgets_to_register)) {
1028
-                // cycle thru widget folders
1029
-                foreach ($widgets_to_register as $widget_path) {
1030
-                    // add to list of installed widget modules
1031
-                    EE_Config::register_ee_widget($widget_path);
1032
-                }
1033
-            }
1034
-            // filter list of installed modules
1035
-            EE_Registry::instance()->widgets = apply_filters(
1036
-                'FHEE__EE_Config__register_widgets__installed_widgets',
1037
-                EE_Registry::instance()->widgets
1038
-            );
1039
-        }
1040
-    }
1041
-
1042
-
1043
-    /**
1044
-     *    register_ee_widget - makes core aware of this widget
1045
-     *
1046
-     * @access    public
1047
-     * @param    string $widget_path - full path up to and including widget folder
1048
-     * @return    void
1049
-     */
1050
-    public static function register_ee_widget($widget_path = null)
1051
-    {
1052
-        do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1053
-        $widget_ext = '.widget.php';
1054
-        // make all separators match
1055
-        $widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1056
-        // does the file path INCLUDE the actual file name as part of the path ?
1057
-        if (strpos($widget_path, $widget_ext) !== false) {
1058
-            // grab and shortcode file name from directory name and break apart at dots
1059
-            $file_name = explode('.', basename($widget_path));
1060
-            // take first segment from file name pieces and remove class prefix if it exists
1061
-            $widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1062
-            // sanitize shortcode directory name
1063
-            $widget = sanitize_key($widget);
1064
-            // now we need to rebuild the shortcode path
1065
-            $widget_path = explode(DS, $widget_path);
1066
-            // remove last segment
1067
-            array_pop($widget_path);
1068
-            // glue it back together
1069
-            $widget_path = implode(DS, $widget_path);
1070
-        } else {
1071
-            // grab and sanitize widget directory name
1072
-            $widget = sanitize_key(basename($widget_path));
1073
-        }
1074
-        // create classname from widget directory name
1075
-        $widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1076
-        // add class prefix
1077
-        $widget_class = 'EEW_' . $widget;
1078
-        // does the widget exist ?
1079
-        if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1080
-            $msg = sprintf(
1081
-                __(
1082
-                    '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',
1083
-                    'event_espresso'
1084
-                ),
1085
-                $widget_class,
1086
-                $widget_path . DS . $widget_class . $widget_ext
1087
-            );
1088
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1089
-            return;
1090
-        }
1091
-        // load the widget class file
1092
-        require_once($widget_path . DS . $widget_class . $widget_ext);
1093
-        // verify that class exists
1094
-        if (! class_exists($widget_class)) {
1095
-            $msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1096
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1097
-            return;
1098
-        }
1099
-        register_widget($widget_class);
1100
-        // add to array of registered widgets
1101
-        EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1102
-    }
1103
-
1104
-
1105
-    /**
1106
-     *        _register_modules
1107
-     *
1108
-     * @access private
1109
-     * @return array
1110
-     */
1111
-    private function _register_modules()
1112
-    {
1113
-        // grab list of installed modules
1114
-        $modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1115
-        // filter list of modules to register
1116
-        $modules_to_register = apply_filters(
1117
-            'FHEE__EE_Config__register_modules__modules_to_register',
1118
-            $modules_to_register
1119
-        );
1120
-        if (! empty($modules_to_register)) {
1121
-            // loop through folders
1122
-            foreach ($modules_to_register as $module_path) {
1123
-                /**TEMPORARILY EXCLUDE gateways from modules for time being**/
1124
-                if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1125
-                    && $module_path !== EE_MODULES . 'gateways'
1126
-                ) {
1127
-                    // add to list of installed modules
1128
-                    EE_Config::register_module($module_path);
1129
-                }
1130
-            }
1131
-        }
1132
-        // filter list of installed modules
1133
-        return apply_filters(
1134
-            'FHEE__EE_Config___register_modules__installed_modules',
1135
-            EE_Registry::instance()->modules
1136
-        );
1137
-    }
1138
-
1139
-
1140
-    /**
1141
-     *    register_module - makes core aware of this module
1142
-     *
1143
-     * @access    public
1144
-     * @param    string $module_path - full path up to and including module folder
1145
-     * @return    bool
1146
-     */
1147
-    public static function register_module($module_path = null)
1148
-    {
1149
-        do_action('AHEE__EE_Config__register_module__begin', $module_path);
1150
-        $module_ext = '.module.php';
1151
-        // make all separators match
1152
-        $module_path = str_replace(array('\\', '/'), DS, $module_path);
1153
-        // does the file path INCLUDE the actual file name as part of the path ?
1154
-        if (strpos($module_path, $module_ext) !== false) {
1155
-            // grab and shortcode file name from directory name and break apart at dots
1156
-            $module_file = explode('.', basename($module_path));
1157
-            // now we need to rebuild the shortcode path
1158
-            $module_path = explode(DS, $module_path);
1159
-            // remove last segment
1160
-            array_pop($module_path);
1161
-            // glue it back together
1162
-            $module_path = implode(DS, $module_path) . DS;
1163
-            // take first segment from file name pieces and sanitize it
1164
-            $module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1165
-            // ensure class prefix is added
1166
-            $module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1167
-        } else {
1168
-            // we need to generate the filename based off of the folder name
1169
-            // grab and sanitize module name
1170
-            $module = strtolower(basename($module_path));
1171
-            $module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1172
-            // like trailingslashit()
1173
-            $module_path = rtrim($module_path, DS) . DS;
1174
-            // create classname from module directory name
1175
-            $module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1176
-            // add class prefix
1177
-            $module_class = 'EED_' . $module;
1178
-        }
1179
-        // does the module exist ?
1180
-        if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1181
-            $msg = sprintf(
1182
-                __(
1183
-                    'The requested %s module file could not be found or is not readable due to file permissions.',
1184
-                    'event_espresso'
1185
-                ),
1186
-                $module
1187
-            );
1188
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1189
-            return false;
1190
-        }
1191
-        // load the module class file
1192
-        require_once($module_path . $module_class . $module_ext);
1193
-        // verify that class exists
1194
-        if (! class_exists($module_class)) {
1195
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1196
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1197
-            return false;
1198
-        }
1199
-        // add to array of registered modules
1200
-        EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1201
-        do_action(
1202
-            'AHEE__EE_Config__register_module__complete',
1203
-            $module_class,
1204
-            EE_Registry::instance()->modules->{$module_class}
1205
-        );
1206
-        return true;
1207
-    }
1208
-
1209
-
1210
-    /**
1211
-     *    _initialize_modules
1212
-     *    allow modules to set hooks for the rest of the system
1213
-     *
1214
-     * @access private
1215
-     * @return void
1216
-     */
1217
-    private function _initialize_modules()
1218
-    {
1219
-        // cycle thru shortcode folders
1220
-        foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1221
-            // fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1222
-            // which set hooks ?
1223
-            if (is_admin()) {
1224
-                // fire immediately
1225
-                call_user_func(array($module_class, 'set_hooks_admin'));
1226
-            } else {
1227
-                // delay until other systems are online
1228
-                add_action(
1229
-                    'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1230
-                    array($module_class, 'set_hooks')
1231
-                );
1232
-            }
1233
-        }
1234
-    }
1235
-
1236
-
1237
-    /**
1238
-     *    register_route - adds module method routes to route_map
1239
-     *
1240
-     * @access    public
1241
-     * @param    string $route       - "pretty" public alias for module method
1242
-     * @param    string $module      - module name (classname without EED_ prefix)
1243
-     * @param    string $method_name - the actual module method to be routed to
1244
-     * @param    string $key         - url param key indicating a route is being called
1245
-     * @return    bool
1246
-     */
1247
-    public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1248
-    {
1249
-        do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1250
-        $module = str_replace('EED_', '', $module);
1251
-        $module_class = 'EED_' . $module;
1252
-        if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1253
-            $msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1254
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1255
-            return false;
1256
-        }
1257
-        if (empty($route)) {
1258
-            $msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1259
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1260
-            return false;
1261
-        }
1262
-        if (! method_exists('EED_' . $module, $method_name)) {
1263
-            $msg = sprintf(
1264
-                __('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1265
-                $route
1266
-            );
1267
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1268
-            return false;
1269
-        }
1270
-        EE_Config::$_module_route_map[ $key ][ $route ] = array('EED_' . $module, $method_name);
1271
-        return true;
1272
-    }
1273
-
1274
-
1275
-    /**
1276
-     *    get_route - get module method route
1277
-     *
1278
-     * @access    public
1279
-     * @param    string $route - "pretty" public alias for module method
1280
-     * @param    string $key   - url param key indicating a route is being called
1281
-     * @return    string
1282
-     */
1283
-    public static function get_route($route = null, $key = 'ee')
1284
-    {
1285
-        do_action('AHEE__EE_Config__get_route__begin', $route);
1286
-        $route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1287
-        if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1288
-            return EE_Config::$_module_route_map[ $key ][ $route ];
1289
-        }
1290
-        return null;
1291
-    }
1292
-
1293
-
1294
-    /**
1295
-     *    get_routes - get ALL module method routes
1296
-     *
1297
-     * @access    public
1298
-     * @return    array
1299
-     */
1300
-    public static function get_routes()
1301
-    {
1302
-        return EE_Config::$_module_route_map;
1303
-    }
1304
-
1305
-
1306
-    /**
1307
-     *    register_forward - allows modules to forward request to another module for further processing
1308
-     *
1309
-     * @access    public
1310
-     * @param    string       $route   - "pretty" public alias for module method
1311
-     * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1312
-     *                                 class, allows different forwards to be served based on status
1313
-     * @param    array|string $forward - function name or array( class, method )
1314
-     * @param    string       $key     - url param key indicating a route is being called
1315
-     * @return    bool
1316
-     */
1317
-    public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1318
-    {
1319
-        do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1320
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1321
-            $msg = sprintf(
1322
-                __('The module route %s for this forward has not been registered.', 'event_espresso'),
1323
-                $route
1324
-            );
1325
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1326
-            return false;
1327
-        }
1328
-        if (empty($forward)) {
1329
-            $msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1330
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1331
-            return false;
1332
-        }
1333
-        if (is_array($forward)) {
1334
-            if (! isset($forward[1])) {
1335
-                $msg = sprintf(
1336
-                    __('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1337
-                    $route
1338
-                );
1339
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1340
-                return false;
1341
-            }
1342
-            if (! method_exists($forward[0], $forward[1])) {
1343
-                $msg = sprintf(
1344
-                    __('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1345
-                    $forward[1],
1346
-                    $route
1347
-                );
1348
-                EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1349
-                return false;
1350
-            }
1351
-        } elseif (! function_exists($forward)) {
1352
-            $msg = sprintf(
1353
-                __('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1354
-                $forward,
1355
-                $route
1356
-            );
1357
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1358
-            return false;
1359
-        }
1360
-        EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1361
-        return true;
1362
-    }
1363
-
1364
-
1365
-    /**
1366
-     *    get_forward - get forwarding route
1367
-     *
1368
-     * @access    public
1369
-     * @param    string  $route  - "pretty" public alias for module method
1370
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1371
-     *                           allows different forwards to be served based on status
1372
-     * @param    string  $key    - url param key indicating a route is being called
1373
-     * @return    string
1374
-     */
1375
-    public static function get_forward($route = null, $status = 0, $key = 'ee')
1376
-    {
1377
-        do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1378
-        if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1379
-            return apply_filters(
1380
-                'FHEE__EE_Config__get_forward',
1381
-                EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1382
-                $route,
1383
-                $status
1384
-            );
1385
-        }
1386
-        return null;
1387
-    }
1388
-
1389
-
1390
-    /**
1391
-     *    register_forward - allows modules to specify different view templates for different method routes and status
1392
-     *    results
1393
-     *
1394
-     * @access    public
1395
-     * @param    string  $route  - "pretty" public alias for module method
1396
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1397
-     *                           allows different views to be served based on status
1398
-     * @param    string  $view
1399
-     * @param    string  $key    - url param key indicating a route is being called
1400
-     * @return    bool
1401
-     */
1402
-    public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1403
-    {
1404
-        do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1405
-        if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1406
-            $msg = sprintf(
1407
-                __('The module route %s for this view has not been registered.', 'event_espresso'),
1408
-                $route
1409
-            );
1410
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1411
-            return false;
1412
-        }
1413
-        if (! is_readable($view)) {
1414
-            $msg = sprintf(
1415
-                __(
1416
-                    'The %s view file could not be found or is not readable due to file permissions.',
1417
-                    'event_espresso'
1418
-                ),
1419
-                $view
1420
-            );
1421
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1422
-            return false;
1423
-        }
1424
-        EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1425
-        return true;
1426
-    }
1427
-
1428
-
1429
-    /**
1430
-     *    get_view - get view for route and status
1431
-     *
1432
-     * @access    public
1433
-     * @param    string  $route  - "pretty" public alias for module method
1434
-     * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1435
-     *                           allows different views to be served based on status
1436
-     * @param    string  $key    - url param key indicating a route is being called
1437
-     * @return    string
1438
-     */
1439
-    public static function get_view($route = null, $status = 0, $key = 'ee')
1440
-    {
1441
-        do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1442
-        if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1443
-            return apply_filters(
1444
-                'FHEE__EE_Config__get_view',
1445
-                EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1446
-                $route,
1447
-                $status
1448
-            );
1449
-        }
1450
-        return null;
1451
-    }
1452
-
1453
-
1454
-    public function update_addon_option_names()
1455
-    {
1456
-        update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1457
-    }
1458
-
1459
-
1460
-    public function shutdown()
1461
-    {
1462
-        $this->update_addon_option_names();
1463
-    }
1464
-
1465
-
1466
-    /**
1467
-     * @return LegacyShortcodesManager
1468
-     */
1469
-    public static function getLegacyShortcodesManager()
1470
-    {
1471
-
1472
-        if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1473
-            EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1474
-                EE_Registry::instance()
1475
-            );
1476
-        }
1477
-        return EE_Config::instance()->legacy_shortcodes_manager;
1478
-    }
1479
-
1480
-
1481
-    /**
1482
-     * register_shortcode - makes core aware of this shortcode
1483
-     *
1484
-     * @deprecated 4.9.26
1485
-     * @param    string $shortcode_path - full path up to and including shortcode folder
1486
-     * @return    bool
1487
-     */
1488
-    public static function register_shortcode($shortcode_path = null)
1489
-    {
1490
-        EE_Error::doing_it_wrong(
1491
-            __METHOD__,
1492
-            __(
1493
-                '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.',
1494
-                'event_espresso'
1495
-            ),
1496
-            '4.9.26'
1497
-        );
1498
-        return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1499
-    }
1500
-}
1501
-
1502
-/**
1503
- * Base class used for config classes. These classes should generally not have
1504
- * magic functions in use, except we'll allow them to magically set and get stuff...
1505
- * basically, they should just be well-defined stdClasses
1506
- */
1507
-class EE_Config_Base
1508
-{
1509
-
1510
-    /**
1511
-     * Utility function for escaping the value of a property and returning.
1512
-     *
1513
-     * @param string $property property name (checks to see if exists).
1514
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1515
-     * @throws \EE_Error
1516
-     */
1517
-    public function get_pretty($property)
1518
-    {
1519
-        if (! property_exists($this, $property)) {
1520
-            throw new EE_Error(
1521
-                sprintf(
1522
-                    __(
1523
-                        '%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1524
-                        'event_espresso'
1525
-                    ),
1526
-                    get_class($this),
1527
-                    $property
1528
-                )
1529
-            );
1530
-        }
1531
-        // just handling escaping of strings for now.
1532
-        if (is_string($this->{$property})) {
1533
-            return stripslashes($this->{$property});
1534
-        }
1535
-        return $this->{$property};
1536
-    }
1537
-
1538
-
1539
-    public function populate()
1540
-    {
1541
-        // grab defaults via a new instance of this class.
1542
-        $class_name = get_class($this);
1543
-        $defaults = new $class_name;
1544
-        // loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1545
-        // default from our $defaults object.
1546
-        foreach (get_object_vars($defaults) as $property => $value) {
1547
-            if ($this->{$property} === null) {
1548
-                $this->{$property} = $value;
1549
-            }
1550
-        }
1551
-        // cleanup
1552
-        unset($defaults);
1553
-    }
1554
-
1555
-
1556
-    /**
1557
-     *        __isset
1558
-     *
1559
-     * @param $a
1560
-     * @return bool
1561
-     */
1562
-    public function __isset($a)
1563
-    {
1564
-        return false;
1565
-    }
1566
-
1567
-
1568
-    /**
1569
-     *        __unset
1570
-     *
1571
-     * @param $a
1572
-     * @return bool
1573
-     */
1574
-    public function __unset($a)
1575
-    {
1576
-        return false;
1577
-    }
1578
-
1579
-
1580
-    /**
1581
-     *        __clone
1582
-     */
1583
-    public function __clone()
1584
-    {
1585
-    }
1586
-
1587
-
1588
-    /**
1589
-     *        __wakeup
1590
-     */
1591
-    public function __wakeup()
1592
-    {
1593
-    }
1594
-
1595
-
1596
-    /**
1597
-     *        __destruct
1598
-     */
1599
-    public function __destruct()
1600
-    {
1601
-    }
1602
-}
1603
-
1604
-/**
1605
- * Class for defining what's in the EE_Config relating to registration settings
1606
- */
1607
-class EE_Core_Config extends EE_Config_Base
1608
-{
1609
-
1610
-    const OPTION_NAME_UXIP = 'ee_ueip_optin';
1611
-
1612
-
1613
-    public $current_blog_id;
1614
-
1615
-    public $ee_ueip_optin;
1616
-
1617
-    public $ee_ueip_has_notified;
1618
-
1619
-    /**
1620
-     * Not to be confused with the 4 critical page variables (See
1621
-     * get_critical_pages_array()), this is just an array of wp posts that have EE
1622
-     * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1623
-     * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1624
-     *
1625
-     * @var array
1626
-     */
1627
-    public $post_shortcodes;
1628
-
1629
-    public $module_route_map;
1630
-
1631
-    public $module_forward_map;
1632
-
1633
-    public $module_view_map;
1634
-
1635
-    /**
1636
-     * The next 4 vars are the IDs of critical EE pages.
1637
-     *
1638
-     * @var int
1639
-     */
1640
-    public $reg_page_id;
1641
-
1642
-    public $txn_page_id;
1643
-
1644
-    public $thank_you_page_id;
1645
-
1646
-    public $cancel_page_id;
1647
-
1648
-    /**
1649
-     * The next 4 vars are the URLs of critical EE pages.
1650
-     *
1651
-     * @var int
1652
-     */
1653
-    public $reg_page_url;
1654
-
1655
-    public $txn_page_url;
1656
-
1657
-    public $thank_you_page_url;
1658
-
1659
-    public $cancel_page_url;
1660
-
1661
-    /**
1662
-     * The next vars relate to the custom slugs for EE CPT routes
1663
-     */
1664
-    public $event_cpt_slug;
1665
-
1666
-    /**
1667
-     * This caches the _ee_ueip_option in case this config is reset in the same
1668
-     * request across blog switches in a multisite context.
1669
-     * Avoids extra queries to the db for this option.
1670
-     *
1671
-     * @var bool
1672
-     */
1673
-    public static $ee_ueip_option;
1674
-
1675
-
1676
-    /**
1677
-     *    class constructor
1678
-     *
1679
-     * @access    public
1680
-     */
1681
-    public function __construct()
1682
-    {
1683
-        // set default organization settings
1684
-        $this->current_blog_id = get_current_blog_id();
1685
-        $this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1686
-        $this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1687
-        $this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1688
-        $this->post_shortcodes = array();
1689
-        $this->module_route_map = array();
1690
-        $this->module_forward_map = array();
1691
-        $this->module_view_map = array();
1692
-        // critical EE page IDs
1693
-        $this->reg_page_id = 0;
1694
-        $this->txn_page_id = 0;
1695
-        $this->thank_you_page_id = 0;
1696
-        $this->cancel_page_id = 0;
1697
-        // critical EE page URLs
1698
-        $this->reg_page_url = '';
1699
-        $this->txn_page_url = '';
1700
-        $this->thank_you_page_url = '';
1701
-        $this->cancel_page_url = '';
1702
-        // cpt slugs
1703
-        $this->event_cpt_slug = __('events', 'event_espresso');
1704
-        // ueip constant check
1705
-        if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1706
-            $this->ee_ueip_optin = false;
1707
-            $this->ee_ueip_has_notified = true;
1708
-        }
1709
-    }
1710
-
1711
-
1712
-    /**
1713
-     * @return array
1714
-     */
1715
-    public function get_critical_pages_array()
1716
-    {
1717
-        return array(
1718
-            $this->reg_page_id,
1719
-            $this->txn_page_id,
1720
-            $this->thank_you_page_id,
1721
-            $this->cancel_page_id,
1722
-        );
1723
-    }
1724
-
1725
-
1726
-    /**
1727
-     * @return array
1728
-     */
1729
-    public function get_critical_pages_shortcodes_array()
1730
-    {
1731
-        return array(
1732
-            $this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1733
-            $this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1734
-            $this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1735
-            $this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1736
-        );
1737
-    }
1738
-
1739
-
1740
-    /**
1741
-     *  gets/returns URL for EE reg_page
1742
-     *
1743
-     * @access    public
1744
-     * @return    string
1745
-     */
1746
-    public function reg_page_url()
1747
-    {
1748
-        if (! $this->reg_page_url) {
1749
-            $this->reg_page_url = add_query_arg(
1750
-                array('uts' => time()),
1751
-                get_permalink($this->reg_page_id)
1752
-            ) . '#checkout';
1753
-        }
1754
-        return $this->reg_page_url;
1755
-    }
1756
-
1757
-
1758
-    /**
1759
-     *  gets/returns URL for EE txn_page
1760
-     *
1761
-     * @param array $query_args like what gets passed to
1762
-     *                          add_query_arg() as the first argument
1763
-     * @access    public
1764
-     * @return    string
1765
-     */
1766
-    public function txn_page_url($query_args = array())
1767
-    {
1768
-        if (! $this->txn_page_url) {
1769
-            $this->txn_page_url = get_permalink($this->txn_page_id);
1770
-        }
1771
-        if ($query_args) {
1772
-            return add_query_arg($query_args, $this->txn_page_url);
1773
-        } else {
1774
-            return $this->txn_page_url;
1775
-        }
1776
-    }
1777
-
1778
-
1779
-    /**
1780
-     *  gets/returns URL for EE thank_you_page
1781
-     *
1782
-     * @param array $query_args like what gets passed to
1783
-     *                          add_query_arg() as the first argument
1784
-     * @access    public
1785
-     * @return    string
1786
-     */
1787
-    public function thank_you_page_url($query_args = array())
1788
-    {
1789
-        if (! $this->thank_you_page_url) {
1790
-            $this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1791
-        }
1792
-        if ($query_args) {
1793
-            return add_query_arg($query_args, $this->thank_you_page_url);
1794
-        } else {
1795
-            return $this->thank_you_page_url;
1796
-        }
1797
-    }
1798
-
1799
-
1800
-    /**
1801
-     *  gets/returns URL for EE cancel_page
1802
-     *
1803
-     * @access    public
1804
-     * @return    string
1805
-     */
1806
-    public function cancel_page_url()
1807
-    {
1808
-        if (! $this->cancel_page_url) {
1809
-            $this->cancel_page_url = get_permalink($this->cancel_page_id);
1810
-        }
1811
-        return $this->cancel_page_url;
1812
-    }
1813
-
1814
-
1815
-    /**
1816
-     * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1817
-     *
1818
-     * @since 4.7.5
1819
-     */
1820
-    protected function _reset_urls()
1821
-    {
1822
-        $this->reg_page_url = '';
1823
-        $this->txn_page_url = '';
1824
-        $this->cancel_page_url = '';
1825
-        $this->thank_you_page_url = '';
1826
-    }
1827
-
1828
-
1829
-    /**
1830
-     * Used to return what the optin value is set for the EE User Experience Program.
1831
-     * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1832
-     * on the main site only.
1833
-     *
1834
-     * @return bool
1835
-     */
1836
-    protected function _get_main_ee_ueip_optin()
1837
-    {
1838
-        // if this is the main site then we can just bypass our direct query.
1839
-        if (is_main_site()) {
1840
-            return get_option(self::OPTION_NAME_UXIP, false);
1841
-        }
1842
-        // is this already cached for this request?  If so use it.
1843
-        if (EE_Core_Config::$ee_ueip_option !== null) {
1844
-            return EE_Core_Config::$ee_ueip_option;
1845
-        }
1846
-        global $wpdb;
1847
-        $current_network_main_site = is_multisite() ? get_current_site() : null;
1848
-        $current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1849
-        $option = self::OPTION_NAME_UXIP;
1850
-        // set correct table for query
1851
-        $table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1852
-        // rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1853
-        // get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1854
-        // re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1855
-        // this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1856
-        // for the purpose of caching.
1857
-        $pre = apply_filters('pre_option_' . $option, false, $option);
1858
-        if (false !== $pre) {
1859
-            EE_Core_Config::$ee_ueip_option = $pre;
1860
-            return EE_Core_Config::$ee_ueip_option;
1861
-        }
1862
-        $row = $wpdb->get_row(
1863
-            $wpdb->prepare(
1864
-                "SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1865
-                $option
1866
-            )
1867
-        );
1868
-        if (is_object($row)) {
1869
-            $value = $row->option_value;
1870
-        } else { // option does not exist so use default.
1871
-            EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1872
-            return EE_Core_Config::$ee_ueip_option;
1873
-        }
1874
-        EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1875
-        return EE_Core_Config::$ee_ueip_option;
1876
-    }
1877
-
1878
-
1879
-    /**
1880
-     * Utility function for escaping the value of a property and returning.
1881
-     *
1882
-     * @param string $property property name (checks to see if exists).
1883
-     * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1884
-     * @throws \EE_Error
1885
-     */
1886
-    public function get_pretty($property)
1887
-    {
1888
-        if ($property === self::OPTION_NAME_UXIP) {
1889
-            return $this->ee_ueip_optin ? 'yes' : 'no';
1890
-        }
1891
-        return parent::get_pretty($property);
1892
-    }
1893
-
1894
-
1895
-    /**
1896
-     * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1897
-     * on the object.
1898
-     *
1899
-     * @return array
1900
-     */
1901
-    public function __sleep()
1902
-    {
1903
-        // reset all url properties
1904
-        $this->_reset_urls();
1905
-        // return what to save to db
1906
-        return array_keys(get_object_vars($this));
1907
-    }
1908
-}
1909
-
1910
-/**
1911
- * Config class for storing info on the Organization
1912
- */
1913
-class EE_Organization_Config extends EE_Config_Base
1914
-{
1915
-
1916
-    /**
1917
-     * @var string $name
1918
-     * eg EE4.1
1919
-     */
1920
-    public $name;
1921
-
1922
-    /**
1923
-     * @var string $address_1
1924
-     * eg 123 Onna Road
1925
-     */
1926
-    public $address_1 = '';
1927
-
1928
-    /**
1929
-     * @var string $address_2
1930
-     * eg PO Box 123
1931
-     */
1932
-    public $address_2 = '';
1933
-
1934
-    /**
1935
-     * @var string $city
1936
-     * eg Inna City
1937
-     */
1938
-    public $city = '';
1939
-
1940
-    /**
1941
-     * @var int $STA_ID
1942
-     * eg 4
1943
-     */
1944
-    public $STA_ID = 0;
1945
-
1946
-    /**
1947
-     * @var string $CNT_ISO
1948
-     * eg US
1949
-     */
1950
-    public $CNT_ISO = '';
1951
-
1952
-    /**
1953
-     * @var string $zip
1954
-     * eg 12345  or V1A 2B3
1955
-     */
1956
-    public $zip = '';
1957
-
1958
-    /**
1959
-     * @var string $email
1960
-     * eg [email protected]
1961
-     */
1962
-    public $email;
1963
-
1964
-    /**
1965
-     * @var string $phone
1966
-     * eg. 111-111-1111
1967
-     */
1968
-    public $phone = '';
1969
-
1970
-    /**
1971
-     * @var string $vat
1972
-     * VAT/Tax Number
1973
-     */
1974
-    public $vat = '';
1975
-
1976
-    /**
1977
-     * @var string $logo_url
1978
-     * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1979
-     */
1980
-    public $logo_url = '';
1981
-
1982
-    /**
1983
-     * The below are all various properties for holding links to organization social network profiles
1984
-     *
1985
-     * @var string
1986
-     */
1987
-    /**
1988
-     * facebook (facebook.com/profile.name)
1989
-     *
1990
-     * @var string
1991
-     */
1992
-    public $facebook = '';
1993
-
1994
-    /**
1995
-     * twitter (twitter.com/twitter_handle)
1996
-     *
1997
-     * @var string
1998
-     */
1999
-    public $twitter = '';
2000
-
2001
-    /**
2002
-     * linkedin (linkedin.com/in/profile_name)
2003
-     *
2004
-     * @var string
2005
-     */
2006
-    public $linkedin = '';
2007
-
2008
-    /**
2009
-     * pinterest (www.pinterest.com/profile_name)
2010
-     *
2011
-     * @var string
2012
-     */
2013
-    public $pinterest = '';
2014
-
2015
-    /**
2016
-     * google+ (google.com/+profileName)
2017
-     *
2018
-     * @var string
2019
-     */
2020
-    public $google = '';
2021
-
2022
-    /**
2023
-     * instagram (instagram.com/handle)
2024
-     *
2025
-     * @var string
2026
-     */
2027
-    public $instagram = '';
2028
-
2029
-
2030
-    /**
2031
-     *    class constructor
2032
-     *
2033
-     * @access    public
2034
-     */
2035
-    public function __construct()
2036
-    {
2037
-        // set default organization settings
2038
-        // decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2039
-        $this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2040
-        $this->email = get_bloginfo('admin_email');
2041
-    }
2042
-}
2043
-
2044
-/**
2045
- * Class for defining what's in the EE_Config relating to currency
2046
- */
2047
-class EE_Currency_Config extends EE_Config_Base
2048
-{
2049
-
2050
-    /**
2051
-     * @var string $code
2052
-     * eg 'US'
2053
-     */
2054
-    public $code;
2055
-
2056
-    /**
2057
-     * @var string $name
2058
-     * eg 'Dollar'
2059
-     */
2060
-    public $name;
2061
-
2062
-    /**
2063
-     * plural name
2064
-     *
2065
-     * @var string $plural
2066
-     * eg 'Dollars'
2067
-     */
2068
-    public $plural;
2069
-
2070
-    /**
2071
-     * currency sign
2072
-     *
2073
-     * @var string $sign
2074
-     * eg '$'
2075
-     */
2076
-    public $sign;
2077
-
2078
-    /**
2079
-     * Whether the currency sign should come before the number or not
2080
-     *
2081
-     * @var boolean $sign_b4
2082
-     */
2083
-    public $sign_b4;
2084
-
2085
-    /**
2086
-     * How many digits should come after the decimal place
2087
-     *
2088
-     * @var int $dec_plc
2089
-     */
2090
-    public $dec_plc;
2091
-
2092
-    /**
2093
-     * Symbol to use for decimal mark
2094
-     *
2095
-     * @var string $dec_mrk
2096
-     * eg '.'
2097
-     */
2098
-    public $dec_mrk;
2099
-
2100
-    /**
2101
-     * Symbol to use for thousands
2102
-     *
2103
-     * @var string $thsnds
2104
-     * eg ','
2105
-     */
2106
-    public $thsnds;
2107
-
2108
-
2109
-    /**
2110
-     *    class constructor
2111
-     *
2112
-     * @access    public
2113
-     * @param string $CNT_ISO
2114
-     * @throws \EE_Error
2115
-     */
2116
-    public function __construct($CNT_ISO = '')
2117
-    {
2118
-        /** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2119
-        $table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2120
-        // get country code from organization settings or use default
2121
-        $ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2122
-                   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2123
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
2124
-            : '';
2125
-        // but override if requested
2126
-        $CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2127
-        // 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
2128
-        if (! empty($CNT_ISO)
2129
-            && EE_Maintenance_Mode::instance()->models_can_query()
2130
-            && $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2131
-        ) {
2132
-            // retrieve the country settings from the db, just in case they have been customized
2133
-            $country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2134
-            if ($country instanceof EE_Country) {
2135
-                $this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2136
-                $this->name = $country->currency_name_single();    // Dollar
2137
-                $this->plural = $country->currency_name_plural();    // Dollars
2138
-                $this->sign = $country->currency_sign();            // currency sign: $
2139
-                $this->sign_b4 = $country->currency_sign_before(
2140
-                );        // currency sign before or after: $TRUE  or  FALSE$
2141
-                $this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2142
-                $this->dec_mrk = $country->currency_decimal_mark(
2143
-                );    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2144
-                $this->thsnds = $country->currency_thousands_separator(
2145
-                );    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2146
-            }
2147
-        }
2148
-        // fallback to hardcoded defaults, in case the above failed
2149
-        if (empty($this->code)) {
2150
-            // set default currency settings
2151
-            $this->code = 'USD';    // currency code: USD, CAD, EUR
2152
-            $this->name = __('Dollar', 'event_espresso');    // Dollar
2153
-            $this->plural = __('Dollars', 'event_espresso');    // Dollars
2154
-            $this->sign = '$';    // currency sign: $
2155
-            $this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2156
-            $this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2157
-            $this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2158
-            $this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2159
-        }
2160
-    }
2161
-}
2162
-
2163
-/**
2164
- * Class for defining what's in the EE_Config relating to registration settings
2165
- */
2166
-class EE_Registration_Config extends EE_Config_Base
2167
-{
2168
-
2169
-    /**
2170
-     * Default registration status
2171
-     *
2172
-     * @var string $default_STS_ID
2173
-     * eg 'RPP'
2174
-     */
2175
-    public $default_STS_ID;
2176
-
2177
-    /**
2178
-     * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2179
-     * registrations)
2180
-     *
2181
-     * @var int
2182
-     */
2183
-    public $default_maximum_number_of_tickets;
2184
-
2185
-    /**
2186
-     * level of validation to apply to email addresses
2187
-     *
2188
-     * @var string $email_validation_level
2189
-     * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2190
-     */
2191
-    public $email_validation_level;
2192
-
2193
-    /**
2194
-     *    whether or not to show alternate payment options during the reg process if payment status is pending
2195
-     *
2196
-     * @var boolean $show_pending_payment_options
2197
-     */
2198
-    public $show_pending_payment_options;
2199
-
2200
-    /**
2201
-     * Whether to skip the registration confirmation page
2202
-     *
2203
-     * @var boolean $skip_reg_confirmation
2204
-     */
2205
-    public $skip_reg_confirmation;
2206
-
2207
-    /**
2208
-     * an array of SPCO reg steps where:
2209
-     *        the keys denotes the reg step order
2210
-     *        each element consists of an array with the following elements:
2211
-     *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2212
-     *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2213
-     *            "slug" => the URL param used to trigger the reg step
2214
-     *
2215
-     * @var array $reg_steps
2216
-     */
2217
-    public $reg_steps;
2218
-
2219
-    /**
2220
-     * Whether registration confirmation should be the last page of SPCO
2221
-     *
2222
-     * @var boolean $reg_confirmation_last
2223
-     */
2224
-    public $reg_confirmation_last;
2225
-
2226
-    /**
2227
-     * Whether or not to enable the EE Bot Trap
2228
-     *
2229
-     * @var boolean $use_bot_trap
2230
-     */
2231
-    public $use_bot_trap;
2232
-
2233
-    /**
2234
-     * Whether or not to encrypt some data sent by the EE Bot Trap
2235
-     *
2236
-     * @var boolean $use_encryption
2237
-     */
2238
-    public $use_encryption;
2239
-
2240
-    /**
2241
-     * Whether or not to use ReCaptcha
2242
-     *
2243
-     * @var boolean $use_captcha
2244
-     */
2245
-    public $use_captcha;
2246
-
2247
-    /**
2248
-     * ReCaptcha Theme
2249
-     *
2250
-     * @var string $recaptcha_theme
2251
-     *    options: 'dark', 'light', 'invisible'
2252
-     */
2253
-    public $recaptcha_theme;
2254
-
2255
-    /**
2256
-     * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2257
-     *
2258
-     * @var string $recaptcha_badge
2259
-     *    options: 'bottomright', 'bottomleft', 'inline'
2260
-     */
2261
-    public $recaptcha_badge;
17
+	const OPTION_NAME = 'ee_config';
18
+
19
+	const LOG_NAME = 'ee_config_log';
20
+
21
+	const LOG_LENGTH = 100;
22
+
23
+	const ADDON_OPTION_NAMES = 'ee_config_option_names';
24
+
25
+	/**
26
+	 *    instance of the EE_Config object
27
+	 *
28
+	 * @var    EE_Config $_instance
29
+	 * @access    private
30
+	 */
31
+	private static $_instance;
32
+
33
+	/**
34
+	 * @var boolean $_logging_enabled
35
+	 */
36
+	private static $_logging_enabled = false;
37
+
38
+	/**
39
+	 * @var LegacyShortcodesManager $legacy_shortcodes_manager
40
+	 */
41
+	private $legacy_shortcodes_manager;
42
+
43
+	/**
44
+	 * An StdClass whose property names are addon slugs,
45
+	 * and values are their config classes
46
+	 *
47
+	 * @var StdClass
48
+	 */
49
+	public $addons;
50
+
51
+	/**
52
+	 * @var EE_Admin_Config
53
+	 */
54
+	public $admin;
55
+
56
+	/**
57
+	 * @var EE_Core_Config
58
+	 */
59
+	public $core;
60
+
61
+	/**
62
+	 * @var EE_Currency_Config
63
+	 */
64
+	public $currency;
65
+
66
+	/**
67
+	 * @var EE_Organization_Config
68
+	 */
69
+	public $organization;
70
+
71
+	/**
72
+	 * @var EE_Registration_Config
73
+	 */
74
+	public $registration;
75
+
76
+	/**
77
+	 * @var EE_Template_Config
78
+	 */
79
+	public $template_settings;
80
+
81
+	/**
82
+	 * Holds EE environment values.
83
+	 *
84
+	 * @var EE_Environment_Config
85
+	 */
86
+	public $environment;
87
+
88
+	/**
89
+	 * settings pertaining to Google maps
90
+	 *
91
+	 * @var EE_Map_Config
92
+	 */
93
+	public $map_settings;
94
+
95
+	/**
96
+	 * settings pertaining to Taxes
97
+	 *
98
+	 * @var EE_Tax_Config
99
+	 */
100
+	public $tax_settings;
101
+
102
+	/**
103
+	 * Settings pertaining to global messages settings.
104
+	 *
105
+	 * @var EE_Messages_Config
106
+	 */
107
+	public $messages;
108
+
109
+	/**
110
+	 * @deprecated
111
+	 * @var EE_Gateway_Config
112
+	 */
113
+	public $gateway;
114
+
115
+	/**
116
+	 * @var    array $_addon_option_names
117
+	 * @access    private
118
+	 */
119
+	private $_addon_option_names = array();
120
+
121
+	/**
122
+	 * @var    array $_module_route_map
123
+	 * @access    private
124
+	 */
125
+	private static $_module_route_map = array();
126
+
127
+	/**
128
+	 * @var    array $_module_forward_map
129
+	 * @access    private
130
+	 */
131
+	private static $_module_forward_map = array();
132
+
133
+	/**
134
+	 * @var    array $_module_view_map
135
+	 * @access    private
136
+	 */
137
+	private static $_module_view_map = array();
138
+
139
+
140
+	/**
141
+	 * @singleton method used to instantiate class object
142
+	 * @access    public
143
+	 * @return EE_Config instance
144
+	 */
145
+	public static function instance()
146
+	{
147
+		// check if class object is instantiated, and instantiated properly
148
+		if (! self::$_instance instanceof EE_Config) {
149
+			self::$_instance = new self();
150
+		}
151
+		return self::$_instance;
152
+	}
153
+
154
+
155
+	/**
156
+	 * Resets the config
157
+	 *
158
+	 * @param bool    $hard_reset    if TRUE, sets EE_CONFig back to its original settings in the database. If FALSE
159
+	 *                               (default) leaves the database alone, and merely resets the EE_Config object to
160
+	 *                               reflect its state in the database
161
+	 * @param boolean $reinstantiate if TRUE (default) call instance() and return it. Otherwise, just leave
162
+	 *                               $_instance as NULL. Useful in case you want to forget about the old instance on
163
+	 *                               EE_Config, but might not be ready to instantiate EE_Config currently (eg if the
164
+	 *                               site was put into maintenance mode)
165
+	 * @return EE_Config
166
+	 */
167
+	public static function reset($hard_reset = false, $reinstantiate = true)
168
+	{
169
+		if (self::$_instance instanceof EE_Config) {
170
+			if ($hard_reset) {
171
+				self::$_instance->legacy_shortcodes_manager = null;
172
+				self::$_instance->_addon_option_names = array();
173
+				self::$_instance->_initialize_config();
174
+				self::$_instance->update_espresso_config();
175
+			}
176
+			self::$_instance->update_addon_option_names();
177
+		}
178
+		self::$_instance = null;
179
+		// we don't need to reset the static properties imo because those should
180
+		// only change when a module is added or removed. Currently we don't
181
+		// support removing a module during a request when it previously existed
182
+		if ($reinstantiate) {
183
+			return self::instance();
184
+		} else {
185
+			return null;
186
+		}
187
+	}
188
+
189
+
190
+	/**
191
+	 *    class constructor
192
+	 *
193
+	 * @access    private
194
+	 */
195
+	private function __construct()
196
+	{
197
+		do_action('AHEE__EE_Config__construct__begin', $this);
198
+		EE_Config::$_logging_enabled = apply_filters('FHEE__EE_Config___construct__logging_enabled', false);
199
+		// setup empty config classes
200
+		$this->_initialize_config();
201
+		// load existing EE site settings
202
+		$this->_load_core_config();
203
+		// confirm everything loaded correctly and set filtered defaults if not
204
+		$this->_verify_config();
205
+		//  register shortcodes and modules
206
+		add_action(
207
+			'AHEE__EE_System__register_shortcodes_modules_and_widgets',
208
+			array($this, 'register_shortcodes_and_modules'),
209
+			999
210
+		);
211
+		//  initialize shortcodes and modules
212
+		add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'initialize_shortcodes_and_modules'));
213
+		// register widgets
214
+		add_action('widgets_init', array($this, 'widgets_init'), 10);
215
+		// shutdown
216
+		add_action('shutdown', array($this, 'shutdown'), 10);
217
+		// construct__end hook
218
+		do_action('AHEE__EE_Config__construct__end', $this);
219
+		// hardcoded hack
220
+		$this->template_settings->current_espresso_theme = 'Espresso_Arabica_2014';
221
+	}
222
+
223
+
224
+	/**
225
+	 * @return boolean
226
+	 */
227
+	public static function logging_enabled()
228
+	{
229
+		return self::$_logging_enabled;
230
+	}
231
+
232
+
233
+	/**
234
+	 * use to get the current theme if needed from static context
235
+	 *
236
+	 * @return string current theme set.
237
+	 */
238
+	public static function get_current_theme()
239
+	{
240
+		return isset(self::$_instance->template_settings->current_espresso_theme)
241
+			? self::$_instance->template_settings->current_espresso_theme : 'Espresso_Arabica_2014';
242
+	}
243
+
244
+
245
+	/**
246
+	 *        _initialize_config
247
+	 *
248
+	 * @access private
249
+	 * @return void
250
+	 */
251
+	private function _initialize_config()
252
+	{
253
+		EE_Config::trim_log();
254
+		// set defaults
255
+		$this->_addon_option_names = get_option(EE_Config::ADDON_OPTION_NAMES, array());
256
+		$this->addons = new stdClass();
257
+		// set _module_route_map
258
+		EE_Config::$_module_route_map = array();
259
+		// set _module_forward_map
260
+		EE_Config::$_module_forward_map = array();
261
+		// set _module_view_map
262
+		EE_Config::$_module_view_map = array();
263
+	}
264
+
265
+
266
+	/**
267
+	 *        load core plugin configuration
268
+	 *
269
+	 * @access private
270
+	 * @return void
271
+	 */
272
+	private function _load_core_config()
273
+	{
274
+		// load_core_config__start hook
275
+		do_action('AHEE__EE_Config___load_core_config__start', $this);
276
+		$espresso_config = $this->get_espresso_config();
277
+		foreach ($espresso_config as $config => $settings) {
278
+			// load_core_config__start hook
279
+			$settings = apply_filters(
280
+				'FHEE__EE_Config___load_core_config__config_settings',
281
+				$settings,
282
+				$config,
283
+				$this
284
+			);
285
+			if (is_object($settings) && property_exists($this, $config)) {
286
+				$this->{$config} = apply_filters('FHEE__EE_Config___load_core_config__' . $config, $settings);
287
+				// call configs populate method to ensure any defaults are set for empty values.
288
+				if (method_exists($settings, 'populate')) {
289
+					$this->{$config}->populate();
290
+				}
291
+				if (method_exists($settings, 'do_hooks')) {
292
+					$this->{$config}->do_hooks();
293
+				}
294
+			}
295
+		}
296
+		if (apply_filters('FHEE__EE_Config___load_core_config__update_espresso_config', false)) {
297
+			$this->update_espresso_config();
298
+		}
299
+		// load_core_config__end hook
300
+		do_action('AHEE__EE_Config___load_core_config__end', $this);
301
+	}
302
+
303
+
304
+	/**
305
+	 *    _verify_config
306
+	 *
307
+	 * @access    protected
308
+	 * @return    void
309
+	 */
310
+	protected function _verify_config()
311
+	{
312
+		$this->core = $this->core instanceof EE_Core_Config
313
+			? $this->core
314
+			: new EE_Core_Config();
315
+		$this->core = apply_filters('FHEE__EE_Config___initialize_config__core', $this->core);
316
+		$this->organization = $this->organization instanceof EE_Organization_Config
317
+			? $this->organization
318
+			: new EE_Organization_Config();
319
+		$this->organization = apply_filters(
320
+			'FHEE__EE_Config___initialize_config__organization',
321
+			$this->organization
322
+		);
323
+		$this->currency = $this->currency instanceof EE_Currency_Config
324
+			? $this->currency
325
+			: new EE_Currency_Config();
326
+		$this->currency = apply_filters('FHEE__EE_Config___initialize_config__currency', $this->currency);
327
+		$this->registration = $this->registration instanceof EE_Registration_Config
328
+			? $this->registration
329
+			: new EE_Registration_Config();
330
+		$this->registration = apply_filters(
331
+			'FHEE__EE_Config___initialize_config__registration',
332
+			$this->registration
333
+		);
334
+		$this->admin = $this->admin instanceof EE_Admin_Config
335
+			? $this->admin
336
+			: new EE_Admin_Config();
337
+		$this->admin = apply_filters('FHEE__EE_Config___initialize_config__admin', $this->admin);
338
+		$this->template_settings = $this->template_settings instanceof EE_Template_Config
339
+			? $this->template_settings
340
+			: new EE_Template_Config();
341
+		$this->template_settings = apply_filters(
342
+			'FHEE__EE_Config___initialize_config__template_settings',
343
+			$this->template_settings
344
+		);
345
+		$this->map_settings = $this->map_settings instanceof EE_Map_Config
346
+			? $this->map_settings
347
+			: new EE_Map_Config();
348
+		$this->map_settings = apply_filters(
349
+			'FHEE__EE_Config___initialize_config__map_settings',
350
+			$this->map_settings
351
+		);
352
+		$this->environment = $this->environment instanceof EE_Environment_Config
353
+			? $this->environment
354
+			: new EE_Environment_Config();
355
+		$this->environment = apply_filters(
356
+			'FHEE__EE_Config___initialize_config__environment',
357
+			$this->environment
358
+		);
359
+		$this->tax_settings = $this->tax_settings instanceof EE_Tax_Config
360
+			? $this->tax_settings
361
+			: new EE_Tax_Config();
362
+		$this->tax_settings = apply_filters(
363
+			'FHEE__EE_Config___initialize_config__tax_settings',
364
+			$this->tax_settings
365
+		);
366
+		$this->messages = apply_filters('FHEE__EE_Config__initialize_config__messages', $this->messages);
367
+		$this->messages = $this->messages instanceof EE_Messages_Config
368
+			? $this->messages
369
+			: new EE_Messages_Config();
370
+		$this->gateway = $this->gateway instanceof EE_Gateway_Config
371
+			? $this->gateway
372
+			: new EE_Gateway_Config();
373
+		$this->gateway = apply_filters('FHEE__EE_Config___initialize_config__gateway', $this->gateway);
374
+		$this->legacy_shortcodes_manager = null;
375
+	}
376
+
377
+
378
+	/**
379
+	 *    get_espresso_config
380
+	 *
381
+	 * @access    public
382
+	 * @return    array of espresso config stuff
383
+	 */
384
+	public function get_espresso_config()
385
+	{
386
+		// grab espresso configuration
387
+		return apply_filters(
388
+			'FHEE__EE_Config__get_espresso_config__CFG',
389
+			get_option(EE_Config::OPTION_NAME, array())
390
+		);
391
+	}
392
+
393
+
394
+	/**
395
+	 *    double_check_config_comparison
396
+	 *
397
+	 * @access    public
398
+	 * @param string $option
399
+	 * @param        $old_value
400
+	 * @param        $value
401
+	 */
402
+	public function double_check_config_comparison($option = '', $old_value, $value)
403
+	{
404
+		// make sure we're checking the ee config
405
+		if ($option === EE_Config::OPTION_NAME) {
406
+			// run a loose comparison of the old value against the new value for type and properties,
407
+			// but NOT exact instance like WP update_option does (ie: NOT type safe comparison)
408
+			if ($value != $old_value) {
409
+				// if they are NOT the same, then remove the hook,
410
+				// which means the subsequent update results will be based solely on the update query results
411
+				// the reason we do this is because, as stated above,
412
+				// WP update_option performs an exact instance comparison (===) on any update values passed to it
413
+				// this happens PRIOR to serialization and any subsequent update.
414
+				// If values are found to match their previous old value,
415
+				// then WP bails before performing any update.
416
+				// Since we are passing the EE_Config object, it is comparing the EXACT instance of the saved version
417
+				// it just pulled from the db, with the one being passed to it (which will not match).
418
+				// HOWEVER, once the object is serialized and passed off to MySQL to update,
419
+				// MySQL MAY ALSO NOT perform the update because
420
+				// the string it sees in the db looks the same as the new one it has been passed!!!
421
+				// This results in the query returning an "affected rows" value of ZERO,
422
+				// which gets returned immediately by WP update_option and looks like an error.
423
+				remove_action('update_option', array($this, 'check_config_updated'));
424
+			}
425
+		}
426
+	}
427
+
428
+
429
+	/**
430
+	 *    update_espresso_config
431
+	 *
432
+	 * @access   public
433
+	 */
434
+	protected function _reset_espresso_addon_config()
435
+	{
436
+		$this->_addon_option_names = array();
437
+		foreach ($this->addons as $addon_name => $addon_config_obj) {
438
+			$addon_config_obj = maybe_unserialize($addon_config_obj);
439
+			if ($addon_config_obj instanceof EE_Config_Base) {
440
+				$this->update_config('addons', $addon_name, $addon_config_obj, false);
441
+			}
442
+			$this->addons->{$addon_name} = null;
443
+		}
444
+	}
445
+
446
+
447
+	/**
448
+	 *    update_espresso_config
449
+	 *
450
+	 * @access   public
451
+	 * @param   bool $add_success
452
+	 * @param   bool $add_error
453
+	 * @return   bool
454
+	 */
455
+	public function update_espresso_config($add_success = false, $add_error = true)
456
+	{
457
+		// don't allow config updates during WP heartbeats
458
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
459
+			return false;
460
+		}
461
+		// commented out the following re: https://events.codebasehq.com/projects/event-espresso/tickets/8197
462
+		// $clone = clone( self::$_instance );
463
+		// self::$_instance = NULL;
464
+		do_action('AHEE__EE_Config__update_espresso_config__begin', $this);
465
+		$this->_reset_espresso_addon_config();
466
+		// hook into update_option because that happens AFTER the ( $value === $old_value ) conditional
467
+		// but BEFORE the actual update occurs
468
+		add_action('update_option', array($this, 'double_check_config_comparison'), 1, 3);
469
+		// don't want to persist legacy_shortcodes_manager, but don't want to lose it either
470
+		$legacy_shortcodes_manager = $this->legacy_shortcodes_manager;
471
+		$this->legacy_shortcodes_manager = null;
472
+		// now update "ee_config"
473
+		$saved = update_option(EE_Config::OPTION_NAME, $this);
474
+		$this->legacy_shortcodes_manager = $legacy_shortcodes_manager;
475
+		EE_Config::log(EE_Config::OPTION_NAME);
476
+		// if not saved... check if the hook we just added still exists;
477
+		// if it does, it means one of two things:
478
+		// that update_option bailed at the($value === $old_value) conditional,
479
+		// or...
480
+		// the db update query returned 0 rows affected
481
+		// (probably because the data  value was the same from it's perspective)
482
+		// so the existence of the hook means that a negative result from update_option is NOT an error,
483
+		// but just means no update occurred, so don't display an error to the user.
484
+		// BUT... if update_option returns FALSE, AND the hook is missing,
485
+		// then it means that something truly went wrong
486
+		$saved = ! $saved ? has_action('update_option', array($this, 'double_check_config_comparison')) : $saved;
487
+		// remove our action since we don't want it in the system anymore
488
+		remove_action('update_option', array($this, 'double_check_config_comparison'), 1);
489
+		do_action('AHEE__EE_Config__update_espresso_config__end', $this, $saved);
490
+		// self::$_instance = $clone;
491
+		// unset( $clone );
492
+		// if config remains the same or was updated successfully
493
+		if ($saved) {
494
+			if ($add_success) {
495
+				EE_Error::add_success(
496
+					__('The Event Espresso Configuration Settings have been successfully updated.', 'event_espresso'),
497
+					__FILE__,
498
+					__FUNCTION__,
499
+					__LINE__
500
+				);
501
+			}
502
+			return true;
503
+		} else {
504
+			if ($add_error) {
505
+				EE_Error::add_error(
506
+					__('The Event Espresso Configuration Settings were not updated.', 'event_espresso'),
507
+					__FILE__,
508
+					__FUNCTION__,
509
+					__LINE__
510
+				);
511
+			}
512
+			return false;
513
+		}
514
+	}
515
+
516
+
517
+	/**
518
+	 *    _verify_config_params
519
+	 *
520
+	 * @access    private
521
+	 * @param    string         $section
522
+	 * @param    string         $name
523
+	 * @param    string         $config_class
524
+	 * @param    EE_Config_Base $config_obj
525
+	 * @param    array          $tests_to_run
526
+	 * @param    bool           $display_errors
527
+	 * @return    bool    TRUE on success, FALSE on fail
528
+	 */
529
+	private function _verify_config_params(
530
+		$section = '',
531
+		$name = '',
532
+		$config_class = '',
533
+		$config_obj = null,
534
+		$tests_to_run = array(1, 2, 3, 4, 5, 6, 7, 8),
535
+		$display_errors = true
536
+	) {
537
+		try {
538
+			foreach ($tests_to_run as $test) {
539
+				switch ($test) {
540
+					// TEST #1 : check that section was set
541
+					case 1:
542
+						if (empty($section)) {
543
+							if ($display_errors) {
544
+								throw new EE_Error(
545
+									sprintf(
546
+										__(
547
+											'No configuration section has been provided while attempting to save "%s".',
548
+											'event_espresso'
549
+										),
550
+										$config_class
551
+									)
552
+								);
553
+							}
554
+							return false;
555
+						}
556
+						break;
557
+					// TEST #2 : check that settings section exists
558
+					case 2:
559
+						if (! isset($this->{$section})) {
560
+							if ($display_errors) {
561
+								throw new EE_Error(
562
+									sprintf(
563
+										__('The "%s" configuration section does not exist.', 'event_espresso'),
564
+										$section
565
+									)
566
+								);
567
+							}
568
+							return false;
569
+						}
570
+						break;
571
+					// TEST #3 : check that section is the proper format
572
+					case 3:
573
+						if (! ($this->{$section} instanceof EE_Config_Base || $this->{$section} instanceof stdClass)
574
+						) {
575
+							if ($display_errors) {
576
+								throw new EE_Error(
577
+									sprintf(
578
+										__(
579
+											'The "%s" configuration settings have not been formatted correctly.',
580
+											'event_espresso'
581
+										),
582
+										$section
583
+									)
584
+								);
585
+							}
586
+							return false;
587
+						}
588
+						break;
589
+					// TEST #4 : check that config section name has been set
590
+					case 4:
591
+						if (empty($name)) {
592
+							if ($display_errors) {
593
+								throw new EE_Error(
594
+									__(
595
+										'No name has been provided for the specific configuration section.',
596
+										'event_espresso'
597
+									)
598
+								);
599
+							}
600
+							return false;
601
+						}
602
+						break;
603
+					// TEST #5 : check that a config class name has been set
604
+					case 5:
605
+						if (empty($config_class)) {
606
+							if ($display_errors) {
607
+								throw new EE_Error(
608
+									__(
609
+										'No class name has been provided for the specific configuration section.',
610
+										'event_espresso'
611
+									)
612
+								);
613
+							}
614
+							return false;
615
+						}
616
+						break;
617
+					// TEST #6 : verify config class is accessible
618
+					case 6:
619
+						if (! class_exists($config_class)) {
620
+							if ($display_errors) {
621
+								throw new EE_Error(
622
+									sprintf(
623
+										__(
624
+											'The "%s" class does not exist. Please ensure that an autoloader has been set for it.',
625
+											'event_espresso'
626
+										),
627
+										$config_class
628
+									)
629
+								);
630
+							}
631
+							return false;
632
+						}
633
+						break;
634
+					// TEST #7 : check that config has even been set
635
+					case 7:
636
+						if (! isset($this->{$section}->{$name})) {
637
+							if ($display_errors) {
638
+								throw new EE_Error(
639
+									sprintf(
640
+										__('No configuration has been set for "%1$s->%2$s".', 'event_espresso'),
641
+										$section,
642
+										$name
643
+									)
644
+								);
645
+							}
646
+							return false;
647
+						} else {
648
+							// and make sure it's not serialized
649
+							$this->{$section}->{$name} = maybe_unserialize($this->{$section}->{$name});
650
+						}
651
+						break;
652
+					// TEST #8 : check that config is the requested type
653
+					case 8:
654
+						if (! $this->{$section}->{$name} instanceof $config_class) {
655
+							if ($display_errors) {
656
+								throw new EE_Error(
657
+									sprintf(
658
+										__(
659
+											'The configuration for "%1$s->%2$s" is not of the "%3$s" class.',
660
+											'event_espresso'
661
+										),
662
+										$section,
663
+										$name,
664
+										$config_class
665
+									)
666
+								);
667
+							}
668
+							return false;
669
+						}
670
+						break;
671
+					// TEST #9 : verify config object
672
+					case 9:
673
+						if (! $config_obj instanceof EE_Config_Base) {
674
+							if ($display_errors) {
675
+								throw new EE_Error(
676
+									sprintf(
677
+										__('The "%s" class is not an instance of EE_Config_Base.', 'event_espresso'),
678
+										print_r($config_obj, true)
679
+									)
680
+								);
681
+							}
682
+							return false;
683
+						}
684
+						break;
685
+				}
686
+			}
687
+		} catch (EE_Error $e) {
688
+			$e->get_error();
689
+		}
690
+		// you have successfully run the gauntlet
691
+		return true;
692
+	}
693
+
694
+
695
+	/**
696
+	 *    _generate_config_option_name
697
+	 *
698
+	 * @access        protected
699
+	 * @param        string $section
700
+	 * @param        string $name
701
+	 * @return        string
702
+	 */
703
+	private function _generate_config_option_name($section = '', $name = '')
704
+	{
705
+		return 'ee_config-' . strtolower($section . '-' . str_replace(array('EE_', 'EED_'), '', $name));
706
+	}
707
+
708
+
709
+	/**
710
+	 *    _set_config_class
711
+	 * ensures that a config class is set, either from a passed config class or one generated from the config name
712
+	 *
713
+	 * @access    private
714
+	 * @param    string $config_class
715
+	 * @param    string $name
716
+	 * @return    string
717
+	 */
718
+	private function _set_config_class($config_class = '', $name = '')
719
+	{
720
+		return ! empty($config_class)
721
+			? $config_class
722
+			: str_replace(' ', '_', ucwords(str_replace('_', ' ', $name))) . '_Config';
723
+	}
724
+
725
+
726
+	/**
727
+	 *    set_config
728
+	 *
729
+	 * @access    protected
730
+	 * @param    string         $section
731
+	 * @param    string         $name
732
+	 * @param    string         $config_class
733
+	 * @param    EE_Config_Base $config_obj
734
+	 * @return    EE_Config_Base
735
+	 */
736
+	public function set_config($section = '', $name = '', $config_class = '', EE_Config_Base $config_obj = null)
737
+	{
738
+		// ensure config class is set to something
739
+		$config_class = $this->_set_config_class($config_class, $name);
740
+		// run tests 1-4, 6, and 7 to verify all config params are set and valid
741
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
742
+			return null;
743
+		}
744
+		$config_option_name = $this->_generate_config_option_name($section, $name);
745
+		// if the config option name hasn't been added yet to the list of option names we're tracking, then do so now
746
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
747
+			$this->_addon_option_names[ $config_option_name ] = $config_class;
748
+			$this->update_addon_option_names();
749
+		}
750
+		// verify the incoming config object but suppress errors
751
+		if (! $this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
752
+			$config_obj = new $config_class();
753
+		}
754
+		if (get_option($config_option_name)) {
755
+			EE_Config::log($config_option_name);
756
+			update_option($config_option_name, $config_obj);
757
+			$this->{$section}->{$name} = $config_obj;
758
+			return $this->{$section}->{$name};
759
+		} else {
760
+			// create a wp-option for this config
761
+			if (add_option($config_option_name, $config_obj, '', 'no')) {
762
+				$this->{$section}->{$name} = maybe_unserialize($config_obj);
763
+				return $this->{$section}->{$name};
764
+			} else {
765
+				EE_Error::add_error(
766
+					sprintf(__('The "%s" could not be saved to the database.', 'event_espresso'), $config_class),
767
+					__FILE__,
768
+					__FUNCTION__,
769
+					__LINE__
770
+				);
771
+				return null;
772
+			}
773
+		}
774
+	}
775
+
776
+
777
+	/**
778
+	 *    update_config
779
+	 * Important: the config object must ALREADY be set, otherwise this will produce an error.
780
+	 *
781
+	 * @access    public
782
+	 * @param    string                $section
783
+	 * @param    string                $name
784
+	 * @param    EE_Config_Base|string $config_obj
785
+	 * @param    bool                  $throw_errors
786
+	 * @return    bool
787
+	 */
788
+	public function update_config($section = '', $name = '', $config_obj = '', $throw_errors = true)
789
+	{
790
+		// don't allow config updates during WP heartbeats
791
+		if (\EE_Registry::instance()->REQ->get('action', '') === 'heartbeat') {
792
+			return false;
793
+		}
794
+		$config_obj = maybe_unserialize($config_obj);
795
+		// get class name of the incoming object
796
+		$config_class = get_class($config_obj);
797
+		// run tests 1-5 and 9 to verify config
798
+		if (! $this->_verify_config_params(
799
+			$section,
800
+			$name,
801
+			$config_class,
802
+			$config_obj,
803
+			array(1, 2, 3, 4, 7, 9)
804
+		)
805
+		) {
806
+			return false;
807
+		}
808
+		$config_option_name = $this->_generate_config_option_name($section, $name);
809
+		// check if config object has been added to db by seeing if config option name is in $this->_addon_option_names array
810
+		if (! isset($this->_addon_option_names[ $config_option_name ])) {
811
+			// save new config to db
812
+			if ($this->set_config($section, $name, $config_class, $config_obj)) {
813
+				return true;
814
+			}
815
+		} else {
816
+			// first check if the record already exists
817
+			$existing_config = get_option($config_option_name);
818
+			$config_obj = serialize($config_obj);
819
+			// just return if db record is already up to date (NOT type safe comparison)
820
+			if ($existing_config == $config_obj) {
821
+				$this->{$section}->{$name} = $config_obj;
822
+				return true;
823
+			} elseif (update_option($config_option_name, $config_obj)) {
824
+				EE_Config::log($config_option_name);
825
+				// update wp-option for this config class
826
+				$this->{$section}->{$name} = $config_obj;
827
+				return true;
828
+			} elseif ($throw_errors) {
829
+				EE_Error::add_error(
830
+					sprintf(
831
+						__(
832
+							'The "%1$s" object stored at"%2$s" was not successfully updated in the database.',
833
+							'event_espresso'
834
+						),
835
+						$config_class,
836
+						'EE_Config->' . $section . '->' . $name
837
+					),
838
+					__FILE__,
839
+					__FUNCTION__,
840
+					__LINE__
841
+				);
842
+			}
843
+		}
844
+		return false;
845
+	}
846
+
847
+
848
+	/**
849
+	 *    get_config
850
+	 *
851
+	 * @access    public
852
+	 * @param    string $section
853
+	 * @param    string $name
854
+	 * @param    string $config_class
855
+	 * @return    mixed EE_Config_Base | NULL
856
+	 */
857
+	public function get_config($section = '', $name = '', $config_class = '')
858
+	{
859
+		// ensure config class is set to something
860
+		$config_class = $this->_set_config_class($config_class, $name);
861
+		// run tests 1-4, 6 and 7 to verify that all params have been set
862
+		if (! $this->_verify_config_params($section, $name, $config_class, null, array(1, 2, 3, 4, 5, 6))) {
863
+			return null;
864
+		}
865
+		// now test if the requested config object exists, but suppress errors
866
+		if ($this->_verify_config_params($section, $name, $config_class, null, array(7, 8), false)) {
867
+			// config already exists, so pass it back
868
+			return $this->{$section}->{$name};
869
+		}
870
+		// load config option from db if it exists
871
+		$config_obj = $this->get_config_option($this->_generate_config_option_name($section, $name));
872
+		// verify the newly retrieved config object, but suppress errors
873
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9), false)) {
874
+			// config is good, so set it and pass it back
875
+			$this->{$section}->{$name} = $config_obj;
876
+			return $this->{$section}->{$name};
877
+		}
878
+		// oops! $config_obj is not already set and does not exist in the db, so create a new one
879
+		$config_obj = $this->set_config($section, $name, $config_class);
880
+		// verify the newly created config object
881
+		if ($this->_verify_config_params($section, $name, $config_class, $config_obj, array(9))) {
882
+			return $this->{$section}->{$name};
883
+		} else {
884
+			EE_Error::add_error(
885
+				sprintf(__('The "%s" could not be retrieved from the database.', 'event_espresso'), $config_class),
886
+				__FILE__,
887
+				__FUNCTION__,
888
+				__LINE__
889
+			);
890
+		}
891
+		return null;
892
+	}
893
+
894
+
895
+	/**
896
+	 *    get_config_option
897
+	 *
898
+	 * @access    public
899
+	 * @param    string $config_option_name
900
+	 * @return    mixed EE_Config_Base | FALSE
901
+	 */
902
+	public function get_config_option($config_option_name = '')
903
+	{
904
+		// retrieve the wp-option for this config class.
905
+		$config_option = maybe_unserialize(get_option($config_option_name, array()));
906
+		if (empty($config_option)) {
907
+			EE_Config::log($config_option_name . '-NOT-FOUND');
908
+		}
909
+		return $config_option;
910
+	}
911
+
912
+
913
+	/**
914
+	 * log
915
+	 *
916
+	 * @param string $config_option_name
917
+	 */
918
+	public static function log($config_option_name = '')
919
+	{
920
+		if (EE_Config::logging_enabled() && ! empty($config_option_name)) {
921
+			$config_log = get_option(EE_Config::LOG_NAME, array());
922
+			// copy incoming $_REQUEST and sanitize it so we can save it
923
+			$_request = $_REQUEST;
924
+			array_walk_recursive($_request, 'sanitize_text_field');
925
+			$config_log[ (string) microtime(true) ] = array(
926
+				'config_name' => $config_option_name,
927
+				'request'     => $_request,
928
+			);
929
+			update_option(EE_Config::LOG_NAME, $config_log);
930
+		}
931
+	}
932
+
933
+
934
+	/**
935
+	 * trim_log
936
+	 * reduces the size of the config log to the length specified by EE_Config::LOG_LENGTH
937
+	 */
938
+	public static function trim_log()
939
+	{
940
+		if (! EE_Config::logging_enabled()) {
941
+			return;
942
+		}
943
+		$config_log = maybe_unserialize(get_option(EE_Config::LOG_NAME, array()));
944
+		$log_length = count($config_log);
945
+		if ($log_length > EE_Config::LOG_LENGTH) {
946
+			ksort($config_log);
947
+			$config_log = array_slice($config_log, $log_length - EE_Config::LOG_LENGTH, null, true);
948
+			update_option(EE_Config::LOG_NAME, $config_log);
949
+		}
950
+	}
951
+
952
+
953
+	/**
954
+	 *    get_page_for_posts
955
+	 *    if the wp-option "show_on_front" is set to "page", then this is the post_name for the post set in the
956
+	 *    wp-option "page_for_posts", or "posts" if no page is selected
957
+	 *
958
+	 * @access    public
959
+	 * @return    string
960
+	 */
961
+	public static function get_page_for_posts()
962
+	{
963
+		$page_for_posts = get_option('page_for_posts');
964
+		if (! $page_for_posts) {
965
+			return 'posts';
966
+		}
967
+		/** @type WPDB $wpdb */
968
+		global $wpdb;
969
+		$SQL = "SELECT post_name from $wpdb->posts WHERE post_type='posts' OR post_type='page' AND post_status='publish' AND ID=%d";
970
+		return $wpdb->get_var($wpdb->prepare($SQL, $page_for_posts));
971
+	}
972
+
973
+
974
+	/**
975
+	 *    register_shortcodes_and_modules.
976
+	 *    At this point, it's too early to tell if we're maintenance mode or not.
977
+	 *    In fact, this is where we give modules a chance to let core know they exist
978
+	 *    so they can help trigger maintenance mode if it's needed
979
+	 *
980
+	 * @access    public
981
+	 * @return    void
982
+	 */
983
+	public function register_shortcodes_and_modules()
984
+	{
985
+		// allow modules to set hooks for the rest of the system
986
+		EE_Registry::instance()->modules = $this->_register_modules();
987
+	}
988
+
989
+
990
+	/**
991
+	 *    initialize_shortcodes_and_modules
992
+	 *    meaning they can start adding their hooks to get stuff done
993
+	 *
994
+	 * @access    public
995
+	 * @return    void
996
+	 */
997
+	public function initialize_shortcodes_and_modules()
998
+	{
999
+		// allow modules to set hooks for the rest of the system
1000
+		$this->_initialize_modules();
1001
+	}
1002
+
1003
+
1004
+	/**
1005
+	 *    widgets_init
1006
+	 *
1007
+	 * @access private
1008
+	 * @return void
1009
+	 */
1010
+	public function widgets_init()
1011
+	{
1012
+		// only init widgets on admin pages when not in complete maintenance, and
1013
+		// on frontend when not in any maintenance mode
1014
+		if (! EE_Maintenance_Mode::instance()->level()
1015
+			|| (
1016
+				is_admin()
1017
+				&& EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance
1018
+			)
1019
+		) {
1020
+			// grab list of installed widgets
1021
+			$widgets_to_register = glob(EE_WIDGETS . '*', GLOB_ONLYDIR);
1022
+			// filter list of modules to register
1023
+			$widgets_to_register = apply_filters(
1024
+				'FHEE__EE_Config__register_widgets__widgets_to_register',
1025
+				$widgets_to_register
1026
+			);
1027
+			if (! empty($widgets_to_register)) {
1028
+				// cycle thru widget folders
1029
+				foreach ($widgets_to_register as $widget_path) {
1030
+					// add to list of installed widget modules
1031
+					EE_Config::register_ee_widget($widget_path);
1032
+				}
1033
+			}
1034
+			// filter list of installed modules
1035
+			EE_Registry::instance()->widgets = apply_filters(
1036
+				'FHEE__EE_Config__register_widgets__installed_widgets',
1037
+				EE_Registry::instance()->widgets
1038
+			);
1039
+		}
1040
+	}
1041
+
1042
+
1043
+	/**
1044
+	 *    register_ee_widget - makes core aware of this widget
1045
+	 *
1046
+	 * @access    public
1047
+	 * @param    string $widget_path - full path up to and including widget folder
1048
+	 * @return    void
1049
+	 */
1050
+	public static function register_ee_widget($widget_path = null)
1051
+	{
1052
+		do_action('AHEE__EE_Config__register_widget__begin', $widget_path);
1053
+		$widget_ext = '.widget.php';
1054
+		// make all separators match
1055
+		$widget_path = rtrim(str_replace('\\', DS, $widget_path), DS);
1056
+		// does the file path INCLUDE the actual file name as part of the path ?
1057
+		if (strpos($widget_path, $widget_ext) !== false) {
1058
+			// grab and shortcode file name from directory name and break apart at dots
1059
+			$file_name = explode('.', basename($widget_path));
1060
+			// take first segment from file name pieces and remove class prefix if it exists
1061
+			$widget = strpos($file_name[0], 'EEW_') === 0 ? substr($file_name[0], 4) : $file_name[0];
1062
+			// sanitize shortcode directory name
1063
+			$widget = sanitize_key($widget);
1064
+			// now we need to rebuild the shortcode path
1065
+			$widget_path = explode(DS, $widget_path);
1066
+			// remove last segment
1067
+			array_pop($widget_path);
1068
+			// glue it back together
1069
+			$widget_path = implode(DS, $widget_path);
1070
+		} else {
1071
+			// grab and sanitize widget directory name
1072
+			$widget = sanitize_key(basename($widget_path));
1073
+		}
1074
+		// create classname from widget directory name
1075
+		$widget = str_replace(' ', '_', ucwords(str_replace('_', ' ', $widget)));
1076
+		// add class prefix
1077
+		$widget_class = 'EEW_' . $widget;
1078
+		// does the widget exist ?
1079
+		if (! is_readable($widget_path . DS . $widget_class . $widget_ext)) {
1080
+			$msg = sprintf(
1081
+				__(
1082
+					'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',
1083
+					'event_espresso'
1084
+				),
1085
+				$widget_class,
1086
+				$widget_path . DS . $widget_class . $widget_ext
1087
+			);
1088
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1089
+			return;
1090
+		}
1091
+		// load the widget class file
1092
+		require_once($widget_path . DS . $widget_class . $widget_ext);
1093
+		// verify that class exists
1094
+		if (! class_exists($widget_class)) {
1095
+			$msg = sprintf(__('The requested %s widget class does not exist.', 'event_espresso'), $widget_class);
1096
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1097
+			return;
1098
+		}
1099
+		register_widget($widget_class);
1100
+		// add to array of registered widgets
1101
+		EE_Registry::instance()->widgets->{$widget_class} = $widget_path . DS . $widget_class . $widget_ext;
1102
+	}
1103
+
1104
+
1105
+	/**
1106
+	 *        _register_modules
1107
+	 *
1108
+	 * @access private
1109
+	 * @return array
1110
+	 */
1111
+	private function _register_modules()
1112
+	{
1113
+		// grab list of installed modules
1114
+		$modules_to_register = glob(EE_MODULES . '*', GLOB_ONLYDIR);
1115
+		// filter list of modules to register
1116
+		$modules_to_register = apply_filters(
1117
+			'FHEE__EE_Config__register_modules__modules_to_register',
1118
+			$modules_to_register
1119
+		);
1120
+		if (! empty($modules_to_register)) {
1121
+			// loop through folders
1122
+			foreach ($modules_to_register as $module_path) {
1123
+				/**TEMPORARILY EXCLUDE gateways from modules for time being**/
1124
+				if ($module_path !== EE_MODULES . 'zzz-copy-this-module-template'
1125
+					&& $module_path !== EE_MODULES . 'gateways'
1126
+				) {
1127
+					// add to list of installed modules
1128
+					EE_Config::register_module($module_path);
1129
+				}
1130
+			}
1131
+		}
1132
+		// filter list of installed modules
1133
+		return apply_filters(
1134
+			'FHEE__EE_Config___register_modules__installed_modules',
1135
+			EE_Registry::instance()->modules
1136
+		);
1137
+	}
1138
+
1139
+
1140
+	/**
1141
+	 *    register_module - makes core aware of this module
1142
+	 *
1143
+	 * @access    public
1144
+	 * @param    string $module_path - full path up to and including module folder
1145
+	 * @return    bool
1146
+	 */
1147
+	public static function register_module($module_path = null)
1148
+	{
1149
+		do_action('AHEE__EE_Config__register_module__begin', $module_path);
1150
+		$module_ext = '.module.php';
1151
+		// make all separators match
1152
+		$module_path = str_replace(array('\\', '/'), DS, $module_path);
1153
+		// does the file path INCLUDE the actual file name as part of the path ?
1154
+		if (strpos($module_path, $module_ext) !== false) {
1155
+			// grab and shortcode file name from directory name and break apart at dots
1156
+			$module_file = explode('.', basename($module_path));
1157
+			// now we need to rebuild the shortcode path
1158
+			$module_path = explode(DS, $module_path);
1159
+			// remove last segment
1160
+			array_pop($module_path);
1161
+			// glue it back together
1162
+			$module_path = implode(DS, $module_path) . DS;
1163
+			// take first segment from file name pieces and sanitize it
1164
+			$module = preg_replace('/[^a-zA-Z0-9_\-]/', '', $module_file[0]);
1165
+			// ensure class prefix is added
1166
+			$module_class = strpos($module, 'EED_') !== 0 ? 'EED_' . $module : $module;
1167
+		} else {
1168
+			// we need to generate the filename based off of the folder name
1169
+			// grab and sanitize module name
1170
+			$module = strtolower(basename($module_path));
1171
+			$module = preg_replace('/[^a-z0-9_\-]/', '', $module);
1172
+			// like trailingslashit()
1173
+			$module_path = rtrim($module_path, DS) . DS;
1174
+			// create classname from module directory name
1175
+			$module = str_replace(' ', '_', ucwords(str_replace('_', ' ', $module)));
1176
+			// add class prefix
1177
+			$module_class = 'EED_' . $module;
1178
+		}
1179
+		// does the module exist ?
1180
+		if (! is_readable($module_path . DS . $module_class . $module_ext)) {
1181
+			$msg = sprintf(
1182
+				__(
1183
+					'The requested %s module file could not be found or is not readable due to file permissions.',
1184
+					'event_espresso'
1185
+				),
1186
+				$module
1187
+			);
1188
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1189
+			return false;
1190
+		}
1191
+		// load the module class file
1192
+		require_once($module_path . $module_class . $module_ext);
1193
+		// verify that class exists
1194
+		if (! class_exists($module_class)) {
1195
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
1196
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1197
+			return false;
1198
+		}
1199
+		// add to array of registered modules
1200
+		EE_Registry::instance()->modules->{$module_class} = $module_path . $module_class . $module_ext;
1201
+		do_action(
1202
+			'AHEE__EE_Config__register_module__complete',
1203
+			$module_class,
1204
+			EE_Registry::instance()->modules->{$module_class}
1205
+		);
1206
+		return true;
1207
+	}
1208
+
1209
+
1210
+	/**
1211
+	 *    _initialize_modules
1212
+	 *    allow modules to set hooks for the rest of the system
1213
+	 *
1214
+	 * @access private
1215
+	 * @return void
1216
+	 */
1217
+	private function _initialize_modules()
1218
+	{
1219
+		// cycle thru shortcode folders
1220
+		foreach (EE_Registry::instance()->modules as $module_class => $module_path) {
1221
+			// fire the shortcode class's set_hooks methods in case it needs to hook into other parts of the system
1222
+			// which set hooks ?
1223
+			if (is_admin()) {
1224
+				// fire immediately
1225
+				call_user_func(array($module_class, 'set_hooks_admin'));
1226
+			} else {
1227
+				// delay until other systems are online
1228
+				add_action(
1229
+					'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
1230
+					array($module_class, 'set_hooks')
1231
+				);
1232
+			}
1233
+		}
1234
+	}
1235
+
1236
+
1237
+	/**
1238
+	 *    register_route - adds module method routes to route_map
1239
+	 *
1240
+	 * @access    public
1241
+	 * @param    string $route       - "pretty" public alias for module method
1242
+	 * @param    string $module      - module name (classname without EED_ prefix)
1243
+	 * @param    string $method_name - the actual module method to be routed to
1244
+	 * @param    string $key         - url param key indicating a route is being called
1245
+	 * @return    bool
1246
+	 */
1247
+	public static function register_route($route = null, $module = null, $method_name = null, $key = 'ee')
1248
+	{
1249
+		do_action('AHEE__EE_Config__register_route__begin', $route, $module, $method_name);
1250
+		$module = str_replace('EED_', '', $module);
1251
+		$module_class = 'EED_' . $module;
1252
+		if (! isset(EE_Registry::instance()->modules->{$module_class})) {
1253
+			$msg = sprintf(__('The module %s has not been registered.', 'event_espresso'), $module);
1254
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1255
+			return false;
1256
+		}
1257
+		if (empty($route)) {
1258
+			$msg = sprintf(__('No route has been supplied.', 'event_espresso'), $route);
1259
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1260
+			return false;
1261
+		}
1262
+		if (! method_exists('EED_' . $module, $method_name)) {
1263
+			$msg = sprintf(
1264
+				__('A valid class method for the %s route has not been supplied.', 'event_espresso'),
1265
+				$route
1266
+			);
1267
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1268
+			return false;
1269
+		}
1270
+		EE_Config::$_module_route_map[ $key ][ $route ] = array('EED_' . $module, $method_name);
1271
+		return true;
1272
+	}
1273
+
1274
+
1275
+	/**
1276
+	 *    get_route - get module method route
1277
+	 *
1278
+	 * @access    public
1279
+	 * @param    string $route - "pretty" public alias for module method
1280
+	 * @param    string $key   - url param key indicating a route is being called
1281
+	 * @return    string
1282
+	 */
1283
+	public static function get_route($route = null, $key = 'ee')
1284
+	{
1285
+		do_action('AHEE__EE_Config__get_route__begin', $route);
1286
+		$route = (string) apply_filters('FHEE__EE_Config__get_route', $route);
1287
+		if (isset(EE_Config::$_module_route_map[ $key ][ $route ])) {
1288
+			return EE_Config::$_module_route_map[ $key ][ $route ];
1289
+		}
1290
+		return null;
1291
+	}
1292
+
1293
+
1294
+	/**
1295
+	 *    get_routes - get ALL module method routes
1296
+	 *
1297
+	 * @access    public
1298
+	 * @return    array
1299
+	 */
1300
+	public static function get_routes()
1301
+	{
1302
+		return EE_Config::$_module_route_map;
1303
+	}
1304
+
1305
+
1306
+	/**
1307
+	 *    register_forward - allows modules to forward request to another module for further processing
1308
+	 *
1309
+	 * @access    public
1310
+	 * @param    string       $route   - "pretty" public alias for module method
1311
+	 * @param    integer      $status  - integer value corresponding  to status constant strings set in module parent
1312
+	 *                                 class, allows different forwards to be served based on status
1313
+	 * @param    array|string $forward - function name or array( class, method )
1314
+	 * @param    string       $key     - url param key indicating a route is being called
1315
+	 * @return    bool
1316
+	 */
1317
+	public static function register_forward($route = null, $status = 0, $forward = null, $key = 'ee')
1318
+	{
1319
+		do_action('AHEE__EE_Config__register_forward', $route, $status, $forward);
1320
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1321
+			$msg = sprintf(
1322
+				__('The module route %s for this forward has not been registered.', 'event_espresso'),
1323
+				$route
1324
+			);
1325
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1326
+			return false;
1327
+		}
1328
+		if (empty($forward)) {
1329
+			$msg = sprintf(__('No forwarding route has been supplied.', 'event_espresso'), $route);
1330
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1331
+			return false;
1332
+		}
1333
+		if (is_array($forward)) {
1334
+			if (! isset($forward[1])) {
1335
+				$msg = sprintf(
1336
+					__('A class method for the %s forwarding route has not been supplied.', 'event_espresso'),
1337
+					$route
1338
+				);
1339
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1340
+				return false;
1341
+			}
1342
+			if (! method_exists($forward[0], $forward[1])) {
1343
+				$msg = sprintf(
1344
+					__('The class method %s for the %s forwarding route is in invalid.', 'event_espresso'),
1345
+					$forward[1],
1346
+					$route
1347
+				);
1348
+				EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1349
+				return false;
1350
+			}
1351
+		} elseif (! function_exists($forward)) {
1352
+			$msg = sprintf(
1353
+				__('The function %s for the %s forwarding route is in invalid.', 'event_espresso'),
1354
+				$forward,
1355
+				$route
1356
+			);
1357
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1358
+			return false;
1359
+		}
1360
+		EE_Config::$_module_forward_map[ $key ][ $route ][ absint($status) ] = $forward;
1361
+		return true;
1362
+	}
1363
+
1364
+
1365
+	/**
1366
+	 *    get_forward - get forwarding route
1367
+	 *
1368
+	 * @access    public
1369
+	 * @param    string  $route  - "pretty" public alias for module method
1370
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1371
+	 *                           allows different forwards to be served based on status
1372
+	 * @param    string  $key    - url param key indicating a route is being called
1373
+	 * @return    string
1374
+	 */
1375
+	public static function get_forward($route = null, $status = 0, $key = 'ee')
1376
+	{
1377
+		do_action('AHEE__EE_Config__get_forward__begin', $route, $status);
1378
+		if (isset(EE_Config::$_module_forward_map[ $key ][ $route ][ $status ])) {
1379
+			return apply_filters(
1380
+				'FHEE__EE_Config__get_forward',
1381
+				EE_Config::$_module_forward_map[ $key ][ $route ][ $status ],
1382
+				$route,
1383
+				$status
1384
+			);
1385
+		}
1386
+		return null;
1387
+	}
1388
+
1389
+
1390
+	/**
1391
+	 *    register_forward - allows modules to specify different view templates for different method routes and status
1392
+	 *    results
1393
+	 *
1394
+	 * @access    public
1395
+	 * @param    string  $route  - "pretty" public alias for module method
1396
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1397
+	 *                           allows different views to be served based on status
1398
+	 * @param    string  $view
1399
+	 * @param    string  $key    - url param key indicating a route is being called
1400
+	 * @return    bool
1401
+	 */
1402
+	public static function register_view($route = null, $status = 0, $view = null, $key = 'ee')
1403
+	{
1404
+		do_action('AHEE__EE_Config__register_view__begin', $route, $status, $view);
1405
+		if (! isset(EE_Config::$_module_route_map[ $key ][ $route ]) || empty($route)) {
1406
+			$msg = sprintf(
1407
+				__('The module route %s for this view has not been registered.', 'event_espresso'),
1408
+				$route
1409
+			);
1410
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1411
+			return false;
1412
+		}
1413
+		if (! is_readable($view)) {
1414
+			$msg = sprintf(
1415
+				__(
1416
+					'The %s view file could not be found or is not readable due to file permissions.',
1417
+					'event_espresso'
1418
+				),
1419
+				$view
1420
+			);
1421
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
1422
+			return false;
1423
+		}
1424
+		EE_Config::$_module_view_map[ $key ][ $route ][ absint($status) ] = $view;
1425
+		return true;
1426
+	}
1427
+
1428
+
1429
+	/**
1430
+	 *    get_view - get view for route and status
1431
+	 *
1432
+	 * @access    public
1433
+	 * @param    string  $route  - "pretty" public alias for module method
1434
+	 * @param    integer $status - integer value corresponding  to status constant strings set in module parent class,
1435
+	 *                           allows different views to be served based on status
1436
+	 * @param    string  $key    - url param key indicating a route is being called
1437
+	 * @return    string
1438
+	 */
1439
+	public static function get_view($route = null, $status = 0, $key = 'ee')
1440
+	{
1441
+		do_action('AHEE__EE_Config__get_view__begin', $route, $status);
1442
+		if (isset(EE_Config::$_module_view_map[ $key ][ $route ][ $status ])) {
1443
+			return apply_filters(
1444
+				'FHEE__EE_Config__get_view',
1445
+				EE_Config::$_module_view_map[ $key ][ $route ][ $status ],
1446
+				$route,
1447
+				$status
1448
+			);
1449
+		}
1450
+		return null;
1451
+	}
1452
+
1453
+
1454
+	public function update_addon_option_names()
1455
+	{
1456
+		update_option(EE_Config::ADDON_OPTION_NAMES, $this->_addon_option_names);
1457
+	}
1458
+
1459
+
1460
+	public function shutdown()
1461
+	{
1462
+		$this->update_addon_option_names();
1463
+	}
1464
+
1465
+
1466
+	/**
1467
+	 * @return LegacyShortcodesManager
1468
+	 */
1469
+	public static function getLegacyShortcodesManager()
1470
+	{
1471
+
1472
+		if (! EE_Config::instance()->legacy_shortcodes_manager instanceof LegacyShortcodesManager) {
1473
+			EE_Config::instance()->legacy_shortcodes_manager = new LegacyShortcodesManager(
1474
+				EE_Registry::instance()
1475
+			);
1476
+		}
1477
+		return EE_Config::instance()->legacy_shortcodes_manager;
1478
+	}
1479
+
1480
+
1481
+	/**
1482
+	 * register_shortcode - makes core aware of this shortcode
1483
+	 *
1484
+	 * @deprecated 4.9.26
1485
+	 * @param    string $shortcode_path - full path up to and including shortcode folder
1486
+	 * @return    bool
1487
+	 */
1488
+	public static function register_shortcode($shortcode_path = null)
1489
+	{
1490
+		EE_Error::doing_it_wrong(
1491
+			__METHOD__,
1492
+			__(
1493
+				'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.',
1494
+				'event_espresso'
1495
+			),
1496
+			'4.9.26'
1497
+		);
1498
+		return EE_Config::instance()->getLegacyShortcodesManager()->registerShortcode($shortcode_path);
1499
+	}
1500
+}
2262 1501
 
2263
-    /**
2264
-     * ReCaptcha Type
2265
-     *
2266
-     * @var string $recaptcha_type
2267
-     *    options: 'audio', 'image'
2268
-     */
2269
-    public $recaptcha_type;
1502
+/**
1503
+ * Base class used for config classes. These classes should generally not have
1504
+ * magic functions in use, except we'll allow them to magically set and get stuff...
1505
+ * basically, they should just be well-defined stdClasses
1506
+ */
1507
+class EE_Config_Base
1508
+{
2270 1509
 
2271
-    /**
2272
-     * ReCaptcha language
2273
-     *
2274
-     * @var string $recaptcha_language
2275
-     * eg 'en'
2276
-     */
2277
-    public $recaptcha_language;
1510
+	/**
1511
+	 * Utility function for escaping the value of a property and returning.
1512
+	 *
1513
+	 * @param string $property property name (checks to see if exists).
1514
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1515
+	 * @throws \EE_Error
1516
+	 */
1517
+	public function get_pretty($property)
1518
+	{
1519
+		if (! property_exists($this, $property)) {
1520
+			throw new EE_Error(
1521
+				sprintf(
1522
+					__(
1523
+						'%1$s::get_pretty() has been called with the property %2$s which does not exist on the %1$s config class.',
1524
+						'event_espresso'
1525
+					),
1526
+					get_class($this),
1527
+					$property
1528
+				)
1529
+			);
1530
+		}
1531
+		// just handling escaping of strings for now.
1532
+		if (is_string($this->{$property})) {
1533
+			return stripslashes($this->{$property});
1534
+		}
1535
+		return $this->{$property};
1536
+	}
1537
+
1538
+
1539
+	public function populate()
1540
+	{
1541
+		// grab defaults via a new instance of this class.
1542
+		$class_name = get_class($this);
1543
+		$defaults = new $class_name;
1544
+		// loop through the properties for this class and see if they are set.  If they are NOT, then grab the
1545
+		// default from our $defaults object.
1546
+		foreach (get_object_vars($defaults) as $property => $value) {
1547
+			if ($this->{$property} === null) {
1548
+				$this->{$property} = $value;
1549
+			}
1550
+		}
1551
+		// cleanup
1552
+		unset($defaults);
1553
+	}
1554
+
1555
+
1556
+	/**
1557
+	 *        __isset
1558
+	 *
1559
+	 * @param $a
1560
+	 * @return bool
1561
+	 */
1562
+	public function __isset($a)
1563
+	{
1564
+		return false;
1565
+	}
1566
+
1567
+
1568
+	/**
1569
+	 *        __unset
1570
+	 *
1571
+	 * @param $a
1572
+	 * @return bool
1573
+	 */
1574
+	public function __unset($a)
1575
+	{
1576
+		return false;
1577
+	}
1578
+
1579
+
1580
+	/**
1581
+	 *        __clone
1582
+	 */
1583
+	public function __clone()
1584
+	{
1585
+	}
1586
+
1587
+
1588
+	/**
1589
+	 *        __wakeup
1590
+	 */
1591
+	public function __wakeup()
1592
+	{
1593
+	}
1594
+
1595
+
1596
+	/**
1597
+	 *        __destruct
1598
+	 */
1599
+	public function __destruct()
1600
+	{
1601
+	}
1602
+}
2278 1603
 
2279
-    /**
2280
-     * ReCaptcha public key
2281
-     *
2282
-     * @var string $recaptcha_publickey
2283
-     */
2284
-    public $recaptcha_publickey;
1604
+/**
1605
+ * Class for defining what's in the EE_Config relating to registration settings
1606
+ */
1607
+class EE_Core_Config extends EE_Config_Base
1608
+{
2285 1609
 
2286
-    /**
2287
-     * ReCaptcha private key
2288
-     *
2289
-     * @var string $recaptcha_privatekey
2290
-     */
2291
-    public $recaptcha_privatekey;
1610
+	const OPTION_NAME_UXIP = 'ee_ueip_optin';
1611
+
1612
+
1613
+	public $current_blog_id;
1614
+
1615
+	public $ee_ueip_optin;
1616
+
1617
+	public $ee_ueip_has_notified;
1618
+
1619
+	/**
1620
+	 * Not to be confused with the 4 critical page variables (See
1621
+	 * get_critical_pages_array()), this is just an array of wp posts that have EE
1622
+	 * shortcodes in them. Keys are slugs, values are arrays with only 1 element: where the key is the shortcode
1623
+	 * in the page, and the value is the page's ID. The key 'posts' is basically a duplicate of this same array.
1624
+	 *
1625
+	 * @var array
1626
+	 */
1627
+	public $post_shortcodes;
1628
+
1629
+	public $module_route_map;
1630
+
1631
+	public $module_forward_map;
1632
+
1633
+	public $module_view_map;
1634
+
1635
+	/**
1636
+	 * The next 4 vars are the IDs of critical EE pages.
1637
+	 *
1638
+	 * @var int
1639
+	 */
1640
+	public $reg_page_id;
1641
+
1642
+	public $txn_page_id;
1643
+
1644
+	public $thank_you_page_id;
1645
+
1646
+	public $cancel_page_id;
1647
+
1648
+	/**
1649
+	 * The next 4 vars are the URLs of critical EE pages.
1650
+	 *
1651
+	 * @var int
1652
+	 */
1653
+	public $reg_page_url;
1654
+
1655
+	public $txn_page_url;
1656
+
1657
+	public $thank_you_page_url;
1658
+
1659
+	public $cancel_page_url;
1660
+
1661
+	/**
1662
+	 * The next vars relate to the custom slugs for EE CPT routes
1663
+	 */
1664
+	public $event_cpt_slug;
1665
+
1666
+	/**
1667
+	 * This caches the _ee_ueip_option in case this config is reset in the same
1668
+	 * request across blog switches in a multisite context.
1669
+	 * Avoids extra queries to the db for this option.
1670
+	 *
1671
+	 * @var bool
1672
+	 */
1673
+	public static $ee_ueip_option;
1674
+
1675
+
1676
+	/**
1677
+	 *    class constructor
1678
+	 *
1679
+	 * @access    public
1680
+	 */
1681
+	public function __construct()
1682
+	{
1683
+		// set default organization settings
1684
+		$this->current_blog_id = get_current_blog_id();
1685
+		$this->current_blog_id = $this->current_blog_id === null ? 1 : $this->current_blog_id;
1686
+		$this->ee_ueip_optin = $this->_get_main_ee_ueip_optin();
1687
+		$this->ee_ueip_has_notified = is_main_site() ? get_option('ee_ueip_has_notified', false) : true;
1688
+		$this->post_shortcodes = array();
1689
+		$this->module_route_map = array();
1690
+		$this->module_forward_map = array();
1691
+		$this->module_view_map = array();
1692
+		// critical EE page IDs
1693
+		$this->reg_page_id = 0;
1694
+		$this->txn_page_id = 0;
1695
+		$this->thank_you_page_id = 0;
1696
+		$this->cancel_page_id = 0;
1697
+		// critical EE page URLs
1698
+		$this->reg_page_url = '';
1699
+		$this->txn_page_url = '';
1700
+		$this->thank_you_page_url = '';
1701
+		$this->cancel_page_url = '';
1702
+		// cpt slugs
1703
+		$this->event_cpt_slug = __('events', 'event_espresso');
1704
+		// ueip constant check
1705
+		if (defined('EE_DISABLE_UXIP') && EE_DISABLE_UXIP) {
1706
+			$this->ee_ueip_optin = false;
1707
+			$this->ee_ueip_has_notified = true;
1708
+		}
1709
+	}
1710
+
1711
+
1712
+	/**
1713
+	 * @return array
1714
+	 */
1715
+	public function get_critical_pages_array()
1716
+	{
1717
+		return array(
1718
+			$this->reg_page_id,
1719
+			$this->txn_page_id,
1720
+			$this->thank_you_page_id,
1721
+			$this->cancel_page_id,
1722
+		);
1723
+	}
1724
+
1725
+
1726
+	/**
1727
+	 * @return array
1728
+	 */
1729
+	public function get_critical_pages_shortcodes_array()
1730
+	{
1731
+		return array(
1732
+			$this->reg_page_id       => 'ESPRESSO_CHECKOUT',
1733
+			$this->txn_page_id       => 'ESPRESSO_TXN_PAGE',
1734
+			$this->thank_you_page_id => 'ESPRESSO_THANK_YOU',
1735
+			$this->cancel_page_id    => 'ESPRESSO_CANCELLED',
1736
+		);
1737
+	}
1738
+
1739
+
1740
+	/**
1741
+	 *  gets/returns URL for EE reg_page
1742
+	 *
1743
+	 * @access    public
1744
+	 * @return    string
1745
+	 */
1746
+	public function reg_page_url()
1747
+	{
1748
+		if (! $this->reg_page_url) {
1749
+			$this->reg_page_url = add_query_arg(
1750
+				array('uts' => time()),
1751
+				get_permalink($this->reg_page_id)
1752
+			) . '#checkout';
1753
+		}
1754
+		return $this->reg_page_url;
1755
+	}
1756
+
1757
+
1758
+	/**
1759
+	 *  gets/returns URL for EE txn_page
1760
+	 *
1761
+	 * @param array $query_args like what gets passed to
1762
+	 *                          add_query_arg() as the first argument
1763
+	 * @access    public
1764
+	 * @return    string
1765
+	 */
1766
+	public function txn_page_url($query_args = array())
1767
+	{
1768
+		if (! $this->txn_page_url) {
1769
+			$this->txn_page_url = get_permalink($this->txn_page_id);
1770
+		}
1771
+		if ($query_args) {
1772
+			return add_query_arg($query_args, $this->txn_page_url);
1773
+		} else {
1774
+			return $this->txn_page_url;
1775
+		}
1776
+	}
1777
+
1778
+
1779
+	/**
1780
+	 *  gets/returns URL for EE thank_you_page
1781
+	 *
1782
+	 * @param array $query_args like what gets passed to
1783
+	 *                          add_query_arg() as the first argument
1784
+	 * @access    public
1785
+	 * @return    string
1786
+	 */
1787
+	public function thank_you_page_url($query_args = array())
1788
+	{
1789
+		if (! $this->thank_you_page_url) {
1790
+			$this->thank_you_page_url = get_permalink($this->thank_you_page_id);
1791
+		}
1792
+		if ($query_args) {
1793
+			return add_query_arg($query_args, $this->thank_you_page_url);
1794
+		} else {
1795
+			return $this->thank_you_page_url;
1796
+		}
1797
+	}
1798
+
1799
+
1800
+	/**
1801
+	 *  gets/returns URL for EE cancel_page
1802
+	 *
1803
+	 * @access    public
1804
+	 * @return    string
1805
+	 */
1806
+	public function cancel_page_url()
1807
+	{
1808
+		if (! $this->cancel_page_url) {
1809
+			$this->cancel_page_url = get_permalink($this->cancel_page_id);
1810
+		}
1811
+		return $this->cancel_page_url;
1812
+	}
1813
+
1814
+
1815
+	/**
1816
+	 * Resets all critical page urls to their original state.  Used primarily by the __sleep() magic method currently.
1817
+	 *
1818
+	 * @since 4.7.5
1819
+	 */
1820
+	protected function _reset_urls()
1821
+	{
1822
+		$this->reg_page_url = '';
1823
+		$this->txn_page_url = '';
1824
+		$this->cancel_page_url = '';
1825
+		$this->thank_you_page_url = '';
1826
+	}
1827
+
1828
+
1829
+	/**
1830
+	 * Used to return what the optin value is set for the EE User Experience Program.
1831
+	 * This accounts for multisite and this value being requested for a subsite.  In multisite, the value is set
1832
+	 * on the main site only.
1833
+	 *
1834
+	 * @return bool
1835
+	 */
1836
+	protected function _get_main_ee_ueip_optin()
1837
+	{
1838
+		// if this is the main site then we can just bypass our direct query.
1839
+		if (is_main_site()) {
1840
+			return get_option(self::OPTION_NAME_UXIP, false);
1841
+		}
1842
+		// is this already cached for this request?  If so use it.
1843
+		if (EE_Core_Config::$ee_ueip_option !== null) {
1844
+			return EE_Core_Config::$ee_ueip_option;
1845
+		}
1846
+		global $wpdb;
1847
+		$current_network_main_site = is_multisite() ? get_current_site() : null;
1848
+		$current_main_site_id = ! empty($current_network_main_site) ? $current_network_main_site->blog_id : 1;
1849
+		$option = self::OPTION_NAME_UXIP;
1850
+		// set correct table for query
1851
+		$table_name = $wpdb->get_blog_prefix($current_main_site_id) . 'options';
1852
+		// rather than getting blog option for the $current_main_site_id, we do a direct $wpdb query because
1853
+		// get_blog_option() does a switch_to_blog an that could cause infinite recursion because EE_Core_Config might be
1854
+		// re-constructed on the blog switch.  Note, we are still executing any core wp filters on this option retrieval.
1855
+		// this bit of code is basically a direct copy of get_option without any caching because we are NOT switched to the blog
1856
+		// for the purpose of caching.
1857
+		$pre = apply_filters('pre_option_' . $option, false, $option);
1858
+		if (false !== $pre) {
1859
+			EE_Core_Config::$ee_ueip_option = $pre;
1860
+			return EE_Core_Config::$ee_ueip_option;
1861
+		}
1862
+		$row = $wpdb->get_row(
1863
+			$wpdb->prepare(
1864
+				"SELECT option_value FROM $table_name WHERE option_name = %s LIMIT 1",
1865
+				$option
1866
+			)
1867
+		);
1868
+		if (is_object($row)) {
1869
+			$value = $row->option_value;
1870
+		} else { // option does not exist so use default.
1871
+			EE_Core_Config::$ee_ueip_option =  apply_filters('default_option_' . $option, false, $option);
1872
+			return EE_Core_Config::$ee_ueip_option;
1873
+		}
1874
+		EE_Core_Config::$ee_ueip_option = apply_filters('option_' . $option, maybe_unserialize($value), $option);
1875
+		return EE_Core_Config::$ee_ueip_option;
1876
+	}
1877
+
1878
+
1879
+	/**
1880
+	 * Utility function for escaping the value of a property and returning.
1881
+	 *
1882
+	 * @param string $property property name (checks to see if exists).
1883
+	 * @return mixed if a detected type found return the escaped value, otherwise just the raw value is returned.
1884
+	 * @throws \EE_Error
1885
+	 */
1886
+	public function get_pretty($property)
1887
+	{
1888
+		if ($property === self::OPTION_NAME_UXIP) {
1889
+			return $this->ee_ueip_optin ? 'yes' : 'no';
1890
+		}
1891
+		return parent::get_pretty($property);
1892
+	}
1893
+
1894
+
1895
+	/**
1896
+	 * Currently used to ensure critical page urls have initial values saved to the db instead of any current set values
1897
+	 * on the object.
1898
+	 *
1899
+	 * @return array
1900
+	 */
1901
+	public function __sleep()
1902
+	{
1903
+		// reset all url properties
1904
+		$this->_reset_urls();
1905
+		// return what to save to db
1906
+		return array_keys(get_object_vars($this));
1907
+	}
1908
+}
2292 1909
 
2293
-    /**
2294
-     * array of form names protected by ReCaptcha
2295
-     *
2296
-     * @var array $recaptcha_protected_forms
2297
-     */
2298
-    public $recaptcha_protected_forms;
1910
+/**
1911
+ * Config class for storing info on the Organization
1912
+ */
1913
+class EE_Organization_Config extends EE_Config_Base
1914
+{
2299 1915
 
2300
-    /**
2301
-     * ReCaptcha width
2302
-     *
2303
-     * @var int $recaptcha_width
2304
-     * @deprecated
2305
-     */
2306
-    public $recaptcha_width;
1916
+	/**
1917
+	 * @var string $name
1918
+	 * eg EE4.1
1919
+	 */
1920
+	public $name;
1921
+
1922
+	/**
1923
+	 * @var string $address_1
1924
+	 * eg 123 Onna Road
1925
+	 */
1926
+	public $address_1 = '';
1927
+
1928
+	/**
1929
+	 * @var string $address_2
1930
+	 * eg PO Box 123
1931
+	 */
1932
+	public $address_2 = '';
1933
+
1934
+	/**
1935
+	 * @var string $city
1936
+	 * eg Inna City
1937
+	 */
1938
+	public $city = '';
1939
+
1940
+	/**
1941
+	 * @var int $STA_ID
1942
+	 * eg 4
1943
+	 */
1944
+	public $STA_ID = 0;
1945
+
1946
+	/**
1947
+	 * @var string $CNT_ISO
1948
+	 * eg US
1949
+	 */
1950
+	public $CNT_ISO = '';
1951
+
1952
+	/**
1953
+	 * @var string $zip
1954
+	 * eg 12345  or V1A 2B3
1955
+	 */
1956
+	public $zip = '';
1957
+
1958
+	/**
1959
+	 * @var string $email
1960
+	 * eg [email protected]
1961
+	 */
1962
+	public $email;
1963
+
1964
+	/**
1965
+	 * @var string $phone
1966
+	 * eg. 111-111-1111
1967
+	 */
1968
+	public $phone = '';
1969
+
1970
+	/**
1971
+	 * @var string $vat
1972
+	 * VAT/Tax Number
1973
+	 */
1974
+	public $vat = '';
1975
+
1976
+	/**
1977
+	 * @var string $logo_url
1978
+	 * eg http://www.somedomain.com/wp-content/uploads/kittehs.jpg
1979
+	 */
1980
+	public $logo_url = '';
1981
+
1982
+	/**
1983
+	 * The below are all various properties for holding links to organization social network profiles
1984
+	 *
1985
+	 * @var string
1986
+	 */
1987
+	/**
1988
+	 * facebook (facebook.com/profile.name)
1989
+	 *
1990
+	 * @var string
1991
+	 */
1992
+	public $facebook = '';
1993
+
1994
+	/**
1995
+	 * twitter (twitter.com/twitter_handle)
1996
+	 *
1997
+	 * @var string
1998
+	 */
1999
+	public $twitter = '';
2000
+
2001
+	/**
2002
+	 * linkedin (linkedin.com/in/profile_name)
2003
+	 *
2004
+	 * @var string
2005
+	 */
2006
+	public $linkedin = '';
2007
+
2008
+	/**
2009
+	 * pinterest (www.pinterest.com/profile_name)
2010
+	 *
2011
+	 * @var string
2012
+	 */
2013
+	public $pinterest = '';
2014
+
2015
+	/**
2016
+	 * google+ (google.com/+profileName)
2017
+	 *
2018
+	 * @var string
2019
+	 */
2020
+	public $google = '';
2021
+
2022
+	/**
2023
+	 * instagram (instagram.com/handle)
2024
+	 *
2025
+	 * @var string
2026
+	 */
2027
+	public $instagram = '';
2028
+
2029
+
2030
+	/**
2031
+	 *    class constructor
2032
+	 *
2033
+	 * @access    public
2034
+	 */
2035
+	public function __construct()
2036
+	{
2037
+		// set default organization settings
2038
+		// decode HTML entities from the WP blogname, because it's stored in the DB with HTML entities encoded
2039
+		$this->name = wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES);
2040
+		$this->email = get_bloginfo('admin_email');
2041
+	}
2042
+}
2307 2043
 
2308
-    /**
2309
-     * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2310
-     *
2311
-     * @var boolean $track_invalid_checkout_access
2312
-     */
2313
-    protected $track_invalid_checkout_access = true;
2044
+/**
2045
+ * Class for defining what's in the EE_Config relating to currency
2046
+ */
2047
+class EE_Currency_Config extends EE_Config_Base
2048
+{
2314 2049
 
2315
-    /**
2316
-     * Whether or not to show the privacy policy consent checkbox
2317
-     *
2318
-     * @var bool
2319
-     */
2320
-    public $consent_checkbox_enabled;
2050
+	/**
2051
+	 * @var string $code
2052
+	 * eg 'US'
2053
+	 */
2054
+	public $code;
2055
+
2056
+	/**
2057
+	 * @var string $name
2058
+	 * eg 'Dollar'
2059
+	 */
2060
+	public $name;
2061
+
2062
+	/**
2063
+	 * plural name
2064
+	 *
2065
+	 * @var string $plural
2066
+	 * eg 'Dollars'
2067
+	 */
2068
+	public $plural;
2069
+
2070
+	/**
2071
+	 * currency sign
2072
+	 *
2073
+	 * @var string $sign
2074
+	 * eg '$'
2075
+	 */
2076
+	public $sign;
2077
+
2078
+	/**
2079
+	 * Whether the currency sign should come before the number or not
2080
+	 *
2081
+	 * @var boolean $sign_b4
2082
+	 */
2083
+	public $sign_b4;
2084
+
2085
+	/**
2086
+	 * How many digits should come after the decimal place
2087
+	 *
2088
+	 * @var int $dec_plc
2089
+	 */
2090
+	public $dec_plc;
2091
+
2092
+	/**
2093
+	 * Symbol to use for decimal mark
2094
+	 *
2095
+	 * @var string $dec_mrk
2096
+	 * eg '.'
2097
+	 */
2098
+	public $dec_mrk;
2099
+
2100
+	/**
2101
+	 * Symbol to use for thousands
2102
+	 *
2103
+	 * @var string $thsnds
2104
+	 * eg ','
2105
+	 */
2106
+	public $thsnds;
2107
+
2108
+
2109
+	/**
2110
+	 *    class constructor
2111
+	 *
2112
+	 * @access    public
2113
+	 * @param string $CNT_ISO
2114
+	 * @throws \EE_Error
2115
+	 */
2116
+	public function __construct($CNT_ISO = '')
2117
+	{
2118
+		/** @var \EventEspresso\core\services\database\TableAnalysis $table_analysis */
2119
+		$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
2120
+		// get country code from organization settings or use default
2121
+		$ORG_CNT = isset(EE_Registry::instance()->CFG->organization)
2122
+				   && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config
2123
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
2124
+			: '';
2125
+		// but override if requested
2126
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : $ORG_CNT;
2127
+		// 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
2128
+		if (! empty($CNT_ISO)
2129
+			&& EE_Maintenance_Mode::instance()->models_can_query()
2130
+			&& $table_analysis->tableExists(EE_Registry::instance()->load_model('Country')->table())
2131
+		) {
2132
+			// retrieve the country settings from the db, just in case they have been customized
2133
+			$country = EE_Registry::instance()->load_model('Country')->get_one_by_ID($CNT_ISO);
2134
+			if ($country instanceof EE_Country) {
2135
+				$this->code = $country->currency_code();    // currency code: USD, CAD, EUR
2136
+				$this->name = $country->currency_name_single();    // Dollar
2137
+				$this->plural = $country->currency_name_plural();    // Dollars
2138
+				$this->sign = $country->currency_sign();            // currency sign: $
2139
+				$this->sign_b4 = $country->currency_sign_before(
2140
+				);        // currency sign before or after: $TRUE  or  FALSE$
2141
+				$this->dec_plc = $country->currency_decimal_places();    // decimal places: 2 = 0.00  3 = 0.000
2142
+				$this->dec_mrk = $country->currency_decimal_mark(
2143
+				);    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2144
+				$this->thsnds = $country->currency_thousands_separator(
2145
+				);    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2146
+			}
2147
+		}
2148
+		// fallback to hardcoded defaults, in case the above failed
2149
+		if (empty($this->code)) {
2150
+			// set default currency settings
2151
+			$this->code = 'USD';    // currency code: USD, CAD, EUR
2152
+			$this->name = __('Dollar', 'event_espresso');    // Dollar
2153
+			$this->plural = __('Dollars', 'event_espresso');    // Dollars
2154
+			$this->sign = '$';    // currency sign: $
2155
+			$this->sign_b4 = true;    // currency sign before or after: $TRUE  or  FALSE$
2156
+			$this->dec_plc = 2;    // decimal places: 2 = 0.00  3 = 0.000
2157
+			$this->dec_mrk = '.';    // decimal mark: (comma) ',' = 0,01   or (decimal) '.' = 0.01
2158
+			$this->thsnds = ',';    // thousands separator: (comma) ',' = 1,000   or (decimal) '.' = 1.000
2159
+		}
2160
+	}
2161
+}
2321 2162
 
2322
-    /**
2323
-     * Label text to show on the checkbox
2324
-     *
2325
-     * @var string
2326
-     */
2327
-    public $consent_checkbox_label_text;
2163
+/**
2164
+ * Class for defining what's in the EE_Config relating to registration settings
2165
+ */
2166
+class EE_Registration_Config extends EE_Config_Base
2167
+{
2328 2168
 
2329
-    /*
2169
+	/**
2170
+	 * Default registration status
2171
+	 *
2172
+	 * @var string $default_STS_ID
2173
+	 * eg 'RPP'
2174
+	 */
2175
+	public $default_STS_ID;
2176
+
2177
+	/**
2178
+	 * For new events, this will be the default value for the maximum number of tickets (equivalent to maximum number of
2179
+	 * registrations)
2180
+	 *
2181
+	 * @var int
2182
+	 */
2183
+	public $default_maximum_number_of_tickets;
2184
+
2185
+	/**
2186
+	 * level of validation to apply to email addresses
2187
+	 *
2188
+	 * @var string $email_validation_level
2189
+	 * options: 'basic', 'wp_default', 'i18n', 'i18n_dns'
2190
+	 */
2191
+	public $email_validation_level;
2192
+
2193
+	/**
2194
+	 *    whether or not to show alternate payment options during the reg process if payment status is pending
2195
+	 *
2196
+	 * @var boolean $show_pending_payment_options
2197
+	 */
2198
+	public $show_pending_payment_options;
2199
+
2200
+	/**
2201
+	 * Whether to skip the registration confirmation page
2202
+	 *
2203
+	 * @var boolean $skip_reg_confirmation
2204
+	 */
2205
+	public $skip_reg_confirmation;
2206
+
2207
+	/**
2208
+	 * an array of SPCO reg steps where:
2209
+	 *        the keys denotes the reg step order
2210
+	 *        each element consists of an array with the following elements:
2211
+	 *            "file_path" => the file path to the EE_SPCO_Reg_Step class
2212
+	 *            "class_name" => the specific EE_SPCO_Reg_Step child class name
2213
+	 *            "slug" => the URL param used to trigger the reg step
2214
+	 *
2215
+	 * @var array $reg_steps
2216
+	 */
2217
+	public $reg_steps;
2218
+
2219
+	/**
2220
+	 * Whether registration confirmation should be the last page of SPCO
2221
+	 *
2222
+	 * @var boolean $reg_confirmation_last
2223
+	 */
2224
+	public $reg_confirmation_last;
2225
+
2226
+	/**
2227
+	 * Whether or not to enable the EE Bot Trap
2228
+	 *
2229
+	 * @var boolean $use_bot_trap
2230
+	 */
2231
+	public $use_bot_trap;
2232
+
2233
+	/**
2234
+	 * Whether or not to encrypt some data sent by the EE Bot Trap
2235
+	 *
2236
+	 * @var boolean $use_encryption
2237
+	 */
2238
+	public $use_encryption;
2239
+
2240
+	/**
2241
+	 * Whether or not to use ReCaptcha
2242
+	 *
2243
+	 * @var boolean $use_captcha
2244
+	 */
2245
+	public $use_captcha;
2246
+
2247
+	/**
2248
+	 * ReCaptcha Theme
2249
+	 *
2250
+	 * @var string $recaptcha_theme
2251
+	 *    options: 'dark', 'light', 'invisible'
2252
+	 */
2253
+	public $recaptcha_theme;
2254
+
2255
+	/**
2256
+	 * ReCaptcha Badge - determines the position of the reCAPTCHA badge if using Invisible ReCaptcha.
2257
+	 *
2258
+	 * @var string $recaptcha_badge
2259
+	 *    options: 'bottomright', 'bottomleft', 'inline'
2260
+	 */
2261
+	public $recaptcha_badge;
2262
+
2263
+	/**
2264
+	 * ReCaptcha Type
2265
+	 *
2266
+	 * @var string $recaptcha_type
2267
+	 *    options: 'audio', 'image'
2268
+	 */
2269
+	public $recaptcha_type;
2270
+
2271
+	/**
2272
+	 * ReCaptcha language
2273
+	 *
2274
+	 * @var string $recaptcha_language
2275
+	 * eg 'en'
2276
+	 */
2277
+	public $recaptcha_language;
2278
+
2279
+	/**
2280
+	 * ReCaptcha public key
2281
+	 *
2282
+	 * @var string $recaptcha_publickey
2283
+	 */
2284
+	public $recaptcha_publickey;
2285
+
2286
+	/**
2287
+	 * ReCaptcha private key
2288
+	 *
2289
+	 * @var string $recaptcha_privatekey
2290
+	 */
2291
+	public $recaptcha_privatekey;
2292
+
2293
+	/**
2294
+	 * array of form names protected by ReCaptcha
2295
+	 *
2296
+	 * @var array $recaptcha_protected_forms
2297
+	 */
2298
+	public $recaptcha_protected_forms;
2299
+
2300
+	/**
2301
+	 * ReCaptcha width
2302
+	 *
2303
+	 * @var int $recaptcha_width
2304
+	 * @deprecated
2305
+	 */
2306
+	public $recaptcha_width;
2307
+
2308
+	/**
2309
+	 * Whether or not invalid attempts to directly access the registration checkout page should be tracked.
2310
+	 *
2311
+	 * @var boolean $track_invalid_checkout_access
2312
+	 */
2313
+	protected $track_invalid_checkout_access = true;
2314
+
2315
+	/**
2316
+	 * Whether or not to show the privacy policy consent checkbox
2317
+	 *
2318
+	 * @var bool
2319
+	 */
2320
+	public $consent_checkbox_enabled;
2321
+
2322
+	/**
2323
+	 * Label text to show on the checkbox
2324
+	 *
2325
+	 * @var string
2326
+	 */
2327
+	public $consent_checkbox_label_text;
2328
+
2329
+	/*
2330 2330
      * String describing how long to keep payment logs. Passed into DateTime constructor
2331 2331
      * @var string
2332 2332
      */
2333
-    public $gateway_log_lifespan = '1 week';
2334
-
2335
-
2336
-    /**
2337
-     *    class constructor
2338
-     *
2339
-     * @access    public
2340
-     */
2341
-    public function __construct()
2342
-    {
2343
-        // set default registration settings
2344
-        $this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2345
-        $this->email_validation_level = 'wp_default';
2346
-        $this->show_pending_payment_options = true;
2347
-        $this->skip_reg_confirmation = true;
2348
-        $this->reg_steps = array();
2349
-        $this->reg_confirmation_last = false;
2350
-        $this->use_bot_trap = true;
2351
-        $this->use_encryption = true;
2352
-        $this->use_captcha = false;
2353
-        $this->recaptcha_theme = 'light';
2354
-        $this->recaptcha_badge = 'bottomleft';
2355
-        $this->recaptcha_type = 'image';
2356
-        $this->recaptcha_language = 'en';
2357
-        $this->recaptcha_publickey = null;
2358
-        $this->recaptcha_privatekey = null;
2359
-        $this->recaptcha_protected_forms = array();
2360
-        $this->recaptcha_width = 500;
2361
-        $this->default_maximum_number_of_tickets = 10;
2362
-        $this->consent_checkbox_enabled = false;
2363
-        $this->consent_checkbox_label_text = '';
2364
-        $this->gateway_log_lifespan = '7 days';
2365
-    }
2366
-
2367
-
2368
-    /**
2369
-     * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2370
-     *
2371
-     * @since 4.8.8.rc.019
2372
-     */
2373
-    public function do_hooks()
2374
-    {
2375
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2376
-        add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2377
-        add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2378
-    }
2379
-
2380
-
2381
-    /**
2382
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2383
-     * EVT_default_registration_status field matches the config setting for default_STS_ID.
2384
-     */
2385
-    public function set_default_reg_status_on_EEM_Event()
2386
-    {
2387
-        EEM_Event::set_default_reg_status($this->default_STS_ID);
2388
-    }
2389
-
2390
-
2391
-    /**
2392
-     * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2393
-     * for Events matches the config setting for default_maximum_number_of_tickets
2394
-     */
2395
-    public function set_default_max_ticket_on_EEM_Event()
2396
-    {
2397
-        EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2398
-    }
2399
-
2400
-
2401
-    /**
2402
-     * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2403
-     * constructed because that happens before we can get the privacy policy page's permalink.
2404
-     *
2405
-     * @throws InvalidArgumentException
2406
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2407
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2408
-     */
2409
-    public function setDefaultCheckboxLabelText()
2410
-    {
2411
-        if ($this->getConsentCheckboxLabelText() === null
2412
-            || $this->getConsentCheckboxLabelText() === '') {
2413
-            $opening_a_tag = '';
2414
-            $closing_a_tag = '';
2415
-            if (function_exists('get_privacy_policy_url')) {
2416
-                $privacy_page_url = get_privacy_policy_url();
2417
-                if (! empty($privacy_page_url)) {
2418
-                    $opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2419
-                    $closing_a_tag = '</a>';
2420
-                }
2421
-            }
2422
-            $loader = LoaderFactory::getLoader();
2423
-            $org_config = $loader->getShared('EE_Organization_Config');
2424
-            /**
2425
-             * @var $org_config EE_Organization_Config
2426
-             */
2427
-
2428
-            $this->setConsentCheckboxLabelText(
2429
-                sprintf(
2430
-                    esc_html__(
2431
-                        'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2432
-                        'event_espresso'
2433
-                    ),
2434
-                    $org_config->name,
2435
-                    $opening_a_tag,
2436
-                    $closing_a_tag
2437
-                )
2438
-            );
2439
-        }
2440
-    }
2441
-
2442
-
2443
-    /**
2444
-     * @return boolean
2445
-     */
2446
-    public function track_invalid_checkout_access()
2447
-    {
2448
-        return $this->track_invalid_checkout_access;
2449
-    }
2450
-
2451
-
2452
-    /**
2453
-     * @param boolean $track_invalid_checkout_access
2454
-     */
2455
-    public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2456
-    {
2457
-        $this->track_invalid_checkout_access = filter_var(
2458
-            $track_invalid_checkout_access,
2459
-            FILTER_VALIDATE_BOOLEAN
2460
-        );
2461
-    }
2462
-
2463
-
2464
-    /**
2465
-     * Gets the options to make availalbe for the gateway log lifespan
2466
-     * @return array
2467
-     */
2468
-    public function gatewayLogLifespanOptions()
2469
-    {
2470
-        return (array) apply_filters(
2471
-            'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2472
-            array(
2473
-                '1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2474
-                '1 day' => esc_html__('1 Day', 'event_espresso'),
2475
-                '7 days' => esc_html__('7 Days', 'event_espresso'),
2476
-                '14 days' => esc_html__('14 Days', 'event_espresso'),
2477
-                '30 days' => esc_html__('30 Days', 'event_espresso')
2478
-            )
2479
-        );
2480
-    }
2481
-
2482
-
2483
-    /**
2484
-     * @return bool
2485
-     */
2486
-    public function isConsentCheckboxEnabled()
2487
-    {
2488
-        return $this->consent_checkbox_enabled;
2489
-    }
2490
-
2491
-
2492
-    /**
2493
-     * @param bool $consent_checkbox_enabled
2494
-     */
2495
-    public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2496
-    {
2497
-        $this->consent_checkbox_enabled = filter_var(
2498
-            $consent_checkbox_enabled,
2499
-            FILTER_VALIDATE_BOOLEAN
2500
-        );
2501
-    }
2502
-
2503
-
2504
-    /**
2505
-     * @return string
2506
-     */
2507
-    public function getConsentCheckboxLabelText()
2508
-    {
2509
-        return $this->consent_checkbox_label_text;
2510
-    }
2511
-
2512
-
2513
-    /**
2514
-     * @param string $consent_checkbox_label_text
2515
-     */
2516
-    public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2517
-    {
2518
-        $this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2519
-    }
2333
+	public $gateway_log_lifespan = '1 week';
2334
+
2335
+
2336
+	/**
2337
+	 *    class constructor
2338
+	 *
2339
+	 * @access    public
2340
+	 */
2341
+	public function __construct()
2342
+	{
2343
+		// set default registration settings
2344
+		$this->default_STS_ID = EEM_Registration::status_id_pending_payment;
2345
+		$this->email_validation_level = 'wp_default';
2346
+		$this->show_pending_payment_options = true;
2347
+		$this->skip_reg_confirmation = true;
2348
+		$this->reg_steps = array();
2349
+		$this->reg_confirmation_last = false;
2350
+		$this->use_bot_trap = true;
2351
+		$this->use_encryption = true;
2352
+		$this->use_captcha = false;
2353
+		$this->recaptcha_theme = 'light';
2354
+		$this->recaptcha_badge = 'bottomleft';
2355
+		$this->recaptcha_type = 'image';
2356
+		$this->recaptcha_language = 'en';
2357
+		$this->recaptcha_publickey = null;
2358
+		$this->recaptcha_privatekey = null;
2359
+		$this->recaptcha_protected_forms = array();
2360
+		$this->recaptcha_width = 500;
2361
+		$this->default_maximum_number_of_tickets = 10;
2362
+		$this->consent_checkbox_enabled = false;
2363
+		$this->consent_checkbox_label_text = '';
2364
+		$this->gateway_log_lifespan = '7 days';
2365
+	}
2366
+
2367
+
2368
+	/**
2369
+	 * This is called by the config loader and hooks are initialized AFTER the config has been populated.
2370
+	 *
2371
+	 * @since 4.8.8.rc.019
2372
+	 */
2373
+	public function do_hooks()
2374
+	{
2375
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_reg_status_on_EEM_Event'));
2376
+		add_action('AHEE__EE_Config___load_core_config__end', array($this, 'set_default_max_ticket_on_EEM_Event'));
2377
+		add_action('setup_theme', array($this, 'setDefaultCheckboxLabelText'));
2378
+	}
2379
+
2380
+
2381
+	/**
2382
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the
2383
+	 * EVT_default_registration_status field matches the config setting for default_STS_ID.
2384
+	 */
2385
+	public function set_default_reg_status_on_EEM_Event()
2386
+	{
2387
+		EEM_Event::set_default_reg_status($this->default_STS_ID);
2388
+	}
2389
+
2390
+
2391
+	/**
2392
+	 * Hooked into `AHEE__EE_Config___load_core_config__end` to ensure the default for the EVT_additional_limit field
2393
+	 * for Events matches the config setting for default_maximum_number_of_tickets
2394
+	 */
2395
+	public function set_default_max_ticket_on_EEM_Event()
2396
+	{
2397
+		EEM_Event::set_default_additional_limit($this->default_maximum_number_of_tickets);
2398
+	}
2399
+
2400
+
2401
+	/**
2402
+	 * Sets the default consent checkbox text. This needs to be done a bit later than when EE_Registration_Config is
2403
+	 * constructed because that happens before we can get the privacy policy page's permalink.
2404
+	 *
2405
+	 * @throws InvalidArgumentException
2406
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
2407
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
2408
+	 */
2409
+	public function setDefaultCheckboxLabelText()
2410
+	{
2411
+		if ($this->getConsentCheckboxLabelText() === null
2412
+			|| $this->getConsentCheckboxLabelText() === '') {
2413
+			$opening_a_tag = '';
2414
+			$closing_a_tag = '';
2415
+			if (function_exists('get_privacy_policy_url')) {
2416
+				$privacy_page_url = get_privacy_policy_url();
2417
+				if (! empty($privacy_page_url)) {
2418
+					$opening_a_tag = '<a href="' . $privacy_page_url . '" target="_blank">';
2419
+					$closing_a_tag = '</a>';
2420
+				}
2421
+			}
2422
+			$loader = LoaderFactory::getLoader();
2423
+			$org_config = $loader->getShared('EE_Organization_Config');
2424
+			/**
2425
+			 * @var $org_config EE_Organization_Config
2426
+			 */
2427
+
2428
+			$this->setConsentCheckboxLabelText(
2429
+				sprintf(
2430
+					esc_html__(
2431
+						'I consent to %1$s storing and using my personal information, according to their %2$sprivacy policy%3$s.',
2432
+						'event_espresso'
2433
+					),
2434
+					$org_config->name,
2435
+					$opening_a_tag,
2436
+					$closing_a_tag
2437
+				)
2438
+			);
2439
+		}
2440
+	}
2441
+
2442
+
2443
+	/**
2444
+	 * @return boolean
2445
+	 */
2446
+	public function track_invalid_checkout_access()
2447
+	{
2448
+		return $this->track_invalid_checkout_access;
2449
+	}
2450
+
2451
+
2452
+	/**
2453
+	 * @param boolean $track_invalid_checkout_access
2454
+	 */
2455
+	public function set_track_invalid_checkout_access($track_invalid_checkout_access)
2456
+	{
2457
+		$this->track_invalid_checkout_access = filter_var(
2458
+			$track_invalid_checkout_access,
2459
+			FILTER_VALIDATE_BOOLEAN
2460
+		);
2461
+	}
2462
+
2463
+
2464
+	/**
2465
+	 * Gets the options to make availalbe for the gateway log lifespan
2466
+	 * @return array
2467
+	 */
2468
+	public function gatewayLogLifespanOptions()
2469
+	{
2470
+		return (array) apply_filters(
2471
+			'FHEE_EE_Admin_Config__gatewayLogLifespanOptions',
2472
+			array(
2473
+				'1 second' => esc_html__('Don\'t Log At All', 'event_espresso'),
2474
+				'1 day' => esc_html__('1 Day', 'event_espresso'),
2475
+				'7 days' => esc_html__('7 Days', 'event_espresso'),
2476
+				'14 days' => esc_html__('14 Days', 'event_espresso'),
2477
+				'30 days' => esc_html__('30 Days', 'event_espresso')
2478
+			)
2479
+		);
2480
+	}
2481
+
2482
+
2483
+	/**
2484
+	 * @return bool
2485
+	 */
2486
+	public function isConsentCheckboxEnabled()
2487
+	{
2488
+		return $this->consent_checkbox_enabled;
2489
+	}
2490
+
2491
+
2492
+	/**
2493
+	 * @param bool $consent_checkbox_enabled
2494
+	 */
2495
+	public function setConsentCheckboxEnabled($consent_checkbox_enabled)
2496
+	{
2497
+		$this->consent_checkbox_enabled = filter_var(
2498
+			$consent_checkbox_enabled,
2499
+			FILTER_VALIDATE_BOOLEAN
2500
+		);
2501
+	}
2502
+
2503
+
2504
+	/**
2505
+	 * @return string
2506
+	 */
2507
+	public function getConsentCheckboxLabelText()
2508
+	{
2509
+		return $this->consent_checkbox_label_text;
2510
+	}
2511
+
2512
+
2513
+	/**
2514
+	 * @param string $consent_checkbox_label_text
2515
+	 */
2516
+	public function setConsentCheckboxLabelText($consent_checkbox_label_text)
2517
+	{
2518
+		$this->consent_checkbox_label_text = (string) $consent_checkbox_label_text;
2519
+	}
2520 2520
 }
2521 2521
 
2522 2522
 /**
@@ -2525,154 +2525,154 @@  discard block
 block discarded – undo
2525 2525
 class EE_Admin_Config extends EE_Config_Base
2526 2526
 {
2527 2527
 
2528
-    /**
2529
-     * @var boolean $use_personnel_manager
2530
-     */
2531
-    public $use_personnel_manager;
2532
-
2533
-    /**
2534
-     * @var boolean $use_dashboard_widget
2535
-     */
2536
-    public $use_dashboard_widget;
2537
-
2538
-    /**
2539
-     * @var int $events_in_dashboard
2540
-     */
2541
-    public $events_in_dashboard;
2542
-
2543
-    /**
2544
-     * @var boolean $use_event_timezones
2545
-     */
2546
-    public $use_event_timezones;
2547
-
2548
-    /**
2549
-     * @var boolean $use_full_logging
2550
-     */
2551
-    public $use_full_logging;
2552
-
2553
-    /**
2554
-     * @var string $log_file_name
2555
-     */
2556
-    public $log_file_name;
2557
-
2558
-    /**
2559
-     * @var string $debug_file_name
2560
-     */
2561
-    public $debug_file_name;
2562
-
2563
-    /**
2564
-     * @var boolean $use_remote_logging
2565
-     */
2566
-    public $use_remote_logging;
2567
-
2568
-    /**
2569
-     * @var string $remote_logging_url
2570
-     */
2571
-    public $remote_logging_url;
2572
-
2573
-    /**
2574
-     * @var boolean $show_reg_footer
2575
-     */
2576
-    public $show_reg_footer;
2577
-
2578
-    /**
2579
-     * @var string $affiliate_id
2580
-     */
2581
-    public $affiliate_id;
2582
-
2583
-    /**
2584
-     * help tours on or off (global setting)
2585
-     *
2586
-     * @var boolean
2587
-     */
2588
-    public $help_tour_activation;
2589
-
2590
-    /**
2591
-     * adds extra layer of encoding to session data to prevent serialization errors
2592
-     * but is incompatible with some server configuration errors
2593
-     * if you get "500 internal server errors" during registration, try turning this on
2594
-     * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2595
-     *
2596
-     * @var boolean $encode_session_data
2597
-     */
2598
-    private $encode_session_data = false;
2599
-
2600
-
2601
-    /**
2602
-     *    class constructor
2603
-     *
2604
-     * @access    public
2605
-     */
2606
-    public function __construct()
2607
-    {
2608
-        // set default general admin settings
2609
-        $this->use_personnel_manager = true;
2610
-        $this->use_dashboard_widget = true;
2611
-        $this->events_in_dashboard = 30;
2612
-        $this->use_event_timezones = false;
2613
-        $this->use_full_logging = false;
2614
-        $this->use_remote_logging = false;
2615
-        $this->remote_logging_url = null;
2616
-        $this->show_reg_footer = true;
2617
-        $this->affiliate_id = 'default';
2618
-        $this->help_tour_activation = true;
2619
-        $this->encode_session_data = false;
2620
-    }
2621
-
2622
-
2623
-    /**
2624
-     * @param bool $reset
2625
-     * @return string
2626
-     */
2627
-    public function log_file_name($reset = false)
2628
-    {
2629
-        if (empty($this->log_file_name) || $reset) {
2630
-            $this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2631
-            EE_Config::instance()->update_espresso_config(false, false);
2632
-        }
2633
-        return $this->log_file_name;
2634
-    }
2635
-
2636
-
2637
-    /**
2638
-     * @param bool $reset
2639
-     * @return string
2640
-     */
2641
-    public function debug_file_name($reset = false)
2642
-    {
2643
-        if (empty($this->debug_file_name) || $reset) {
2644
-            $this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2645
-            EE_Config::instance()->update_espresso_config(false, false);
2646
-        }
2647
-        return $this->debug_file_name;
2648
-    }
2649
-
2650
-
2651
-    /**
2652
-     * @return string
2653
-     */
2654
-    public function affiliate_id()
2655
-    {
2656
-        return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2657
-    }
2658
-
2659
-
2660
-    /**
2661
-     * @return boolean
2662
-     */
2663
-    public function encode_session_data()
2664
-    {
2665
-        return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2666
-    }
2667
-
2668
-
2669
-    /**
2670
-     * @param boolean $encode_session_data
2671
-     */
2672
-    public function set_encode_session_data($encode_session_data)
2673
-    {
2674
-        $this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2675
-    }
2528
+	/**
2529
+	 * @var boolean $use_personnel_manager
2530
+	 */
2531
+	public $use_personnel_manager;
2532
+
2533
+	/**
2534
+	 * @var boolean $use_dashboard_widget
2535
+	 */
2536
+	public $use_dashboard_widget;
2537
+
2538
+	/**
2539
+	 * @var int $events_in_dashboard
2540
+	 */
2541
+	public $events_in_dashboard;
2542
+
2543
+	/**
2544
+	 * @var boolean $use_event_timezones
2545
+	 */
2546
+	public $use_event_timezones;
2547
+
2548
+	/**
2549
+	 * @var boolean $use_full_logging
2550
+	 */
2551
+	public $use_full_logging;
2552
+
2553
+	/**
2554
+	 * @var string $log_file_name
2555
+	 */
2556
+	public $log_file_name;
2557
+
2558
+	/**
2559
+	 * @var string $debug_file_name
2560
+	 */
2561
+	public $debug_file_name;
2562
+
2563
+	/**
2564
+	 * @var boolean $use_remote_logging
2565
+	 */
2566
+	public $use_remote_logging;
2567
+
2568
+	/**
2569
+	 * @var string $remote_logging_url
2570
+	 */
2571
+	public $remote_logging_url;
2572
+
2573
+	/**
2574
+	 * @var boolean $show_reg_footer
2575
+	 */
2576
+	public $show_reg_footer;
2577
+
2578
+	/**
2579
+	 * @var string $affiliate_id
2580
+	 */
2581
+	public $affiliate_id;
2582
+
2583
+	/**
2584
+	 * help tours on or off (global setting)
2585
+	 *
2586
+	 * @var boolean
2587
+	 */
2588
+	public $help_tour_activation;
2589
+
2590
+	/**
2591
+	 * adds extra layer of encoding to session data to prevent serialization errors
2592
+	 * but is incompatible with some server configuration errors
2593
+	 * if you get "500 internal server errors" during registration, try turning this on
2594
+	 * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off
2595
+	 *
2596
+	 * @var boolean $encode_session_data
2597
+	 */
2598
+	private $encode_session_data = false;
2599
+
2600
+
2601
+	/**
2602
+	 *    class constructor
2603
+	 *
2604
+	 * @access    public
2605
+	 */
2606
+	public function __construct()
2607
+	{
2608
+		// set default general admin settings
2609
+		$this->use_personnel_manager = true;
2610
+		$this->use_dashboard_widget = true;
2611
+		$this->events_in_dashboard = 30;
2612
+		$this->use_event_timezones = false;
2613
+		$this->use_full_logging = false;
2614
+		$this->use_remote_logging = false;
2615
+		$this->remote_logging_url = null;
2616
+		$this->show_reg_footer = true;
2617
+		$this->affiliate_id = 'default';
2618
+		$this->help_tour_activation = true;
2619
+		$this->encode_session_data = false;
2620
+	}
2621
+
2622
+
2623
+	/**
2624
+	 * @param bool $reset
2625
+	 * @return string
2626
+	 */
2627
+	public function log_file_name($reset = false)
2628
+	{
2629
+		if (empty($this->log_file_name) || $reset) {
2630
+			$this->log_file_name = sanitize_key('espresso_log_' . md5(uniqid('', true))) . '.txt';
2631
+			EE_Config::instance()->update_espresso_config(false, false);
2632
+		}
2633
+		return $this->log_file_name;
2634
+	}
2635
+
2636
+
2637
+	/**
2638
+	 * @param bool $reset
2639
+	 * @return string
2640
+	 */
2641
+	public function debug_file_name($reset = false)
2642
+	{
2643
+		if (empty($this->debug_file_name) || $reset) {
2644
+			$this->debug_file_name = sanitize_key('espresso_debug_' . md5(uniqid('', true))) . '.txt';
2645
+			EE_Config::instance()->update_espresso_config(false, false);
2646
+		}
2647
+		return $this->debug_file_name;
2648
+	}
2649
+
2650
+
2651
+	/**
2652
+	 * @return string
2653
+	 */
2654
+	public function affiliate_id()
2655
+	{
2656
+		return ! empty($this->affiliate_id) ? $this->affiliate_id : 'default';
2657
+	}
2658
+
2659
+
2660
+	/**
2661
+	 * @return boolean
2662
+	 */
2663
+	public function encode_session_data()
2664
+	{
2665
+		return filter_var($this->encode_session_data, FILTER_VALIDATE_BOOLEAN);
2666
+	}
2667
+
2668
+
2669
+	/**
2670
+	 * @param boolean $encode_session_data
2671
+	 */
2672
+	public function set_encode_session_data($encode_session_data)
2673
+	{
2674
+		$this->encode_session_data = filter_var($encode_session_data, FILTER_VALIDATE_BOOLEAN);
2675
+	}
2676 2676
 }
2677 2677
 
2678 2678
 /**
@@ -2681,70 +2681,70 @@  discard block
 block discarded – undo
2681 2681
 class EE_Template_Config extends EE_Config_Base
2682 2682
 {
2683 2683
 
2684
-    /**
2685
-     * @var boolean $enable_default_style
2686
-     */
2687
-    public $enable_default_style;
2688
-
2689
-    /**
2690
-     * @var string $custom_style_sheet
2691
-     */
2692
-    public $custom_style_sheet;
2693
-
2694
-    /**
2695
-     * @var boolean $display_address_in_regform
2696
-     */
2697
-    public $display_address_in_regform;
2698
-
2699
-    /**
2700
-     * @var int $display_description_on_multi_reg_page
2701
-     */
2702
-    public $display_description_on_multi_reg_page;
2703
-
2704
-    /**
2705
-     * @var boolean $use_custom_templates
2706
-     */
2707
-    public $use_custom_templates;
2708
-
2709
-    /**
2710
-     * @var string $current_espresso_theme
2711
-     */
2712
-    public $current_espresso_theme;
2713
-
2714
-    /**
2715
-     * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2716
-     */
2717
-    public $EED_Ticket_Selector;
2718
-
2719
-    /**
2720
-     * @var EE_Event_Single_Config $EED_Event_Single
2721
-     */
2722
-    public $EED_Event_Single;
2723
-
2724
-    /**
2725
-     * @var EE_Events_Archive_Config $EED_Events_Archive
2726
-     */
2727
-    public $EED_Events_Archive;
2728
-
2729
-
2730
-    /**
2731
-     *    class constructor
2732
-     *
2733
-     * @access    public
2734
-     */
2735
-    public function __construct()
2736
-    {
2737
-        // set default template settings
2738
-        $this->enable_default_style = true;
2739
-        $this->custom_style_sheet = null;
2740
-        $this->display_address_in_regform = true;
2741
-        $this->display_description_on_multi_reg_page = false;
2742
-        $this->use_custom_templates = false;
2743
-        $this->current_espresso_theme = 'Espresso_Arabica_2014';
2744
-        $this->EED_Event_Single = null;
2745
-        $this->EED_Events_Archive = null;
2746
-        $this->EED_Ticket_Selector = null;
2747
-    }
2684
+	/**
2685
+	 * @var boolean $enable_default_style
2686
+	 */
2687
+	public $enable_default_style;
2688
+
2689
+	/**
2690
+	 * @var string $custom_style_sheet
2691
+	 */
2692
+	public $custom_style_sheet;
2693
+
2694
+	/**
2695
+	 * @var boolean $display_address_in_regform
2696
+	 */
2697
+	public $display_address_in_regform;
2698
+
2699
+	/**
2700
+	 * @var int $display_description_on_multi_reg_page
2701
+	 */
2702
+	public $display_description_on_multi_reg_page;
2703
+
2704
+	/**
2705
+	 * @var boolean $use_custom_templates
2706
+	 */
2707
+	public $use_custom_templates;
2708
+
2709
+	/**
2710
+	 * @var string $current_espresso_theme
2711
+	 */
2712
+	public $current_espresso_theme;
2713
+
2714
+	/**
2715
+	 * @var EE_Ticket_Selector_Config $EED_Ticket_Selector
2716
+	 */
2717
+	public $EED_Ticket_Selector;
2718
+
2719
+	/**
2720
+	 * @var EE_Event_Single_Config $EED_Event_Single
2721
+	 */
2722
+	public $EED_Event_Single;
2723
+
2724
+	/**
2725
+	 * @var EE_Events_Archive_Config $EED_Events_Archive
2726
+	 */
2727
+	public $EED_Events_Archive;
2728
+
2729
+
2730
+	/**
2731
+	 *    class constructor
2732
+	 *
2733
+	 * @access    public
2734
+	 */
2735
+	public function __construct()
2736
+	{
2737
+		// set default template settings
2738
+		$this->enable_default_style = true;
2739
+		$this->custom_style_sheet = null;
2740
+		$this->display_address_in_regform = true;
2741
+		$this->display_description_on_multi_reg_page = false;
2742
+		$this->use_custom_templates = false;
2743
+		$this->current_espresso_theme = 'Espresso_Arabica_2014';
2744
+		$this->EED_Event_Single = null;
2745
+		$this->EED_Events_Archive = null;
2746
+		$this->EED_Ticket_Selector = null;
2747
+	}
2748 2748
 }
2749 2749
 
2750 2750
 /**
@@ -2753,114 +2753,114 @@  discard block
 block discarded – undo
2753 2753
 class EE_Map_Config extends EE_Config_Base
2754 2754
 {
2755 2755
 
2756
-    /**
2757
-     * @var boolean $use_google_maps
2758
-     */
2759
-    public $use_google_maps;
2760
-
2761
-    /**
2762
-     * @var string $api_key
2763
-     */
2764
-    public $google_map_api_key;
2765
-
2766
-    /**
2767
-     * @var int $event_details_map_width
2768
-     */
2769
-    public $event_details_map_width;
2770
-
2771
-    /**
2772
-     * @var int $event_details_map_height
2773
-     */
2774
-    public $event_details_map_height;
2775
-
2776
-    /**
2777
-     * @var int $event_details_map_zoom
2778
-     */
2779
-    public $event_details_map_zoom;
2780
-
2781
-    /**
2782
-     * @var boolean $event_details_display_nav
2783
-     */
2784
-    public $event_details_display_nav;
2785
-
2786
-    /**
2787
-     * @var boolean $event_details_nav_size
2788
-     */
2789
-    public $event_details_nav_size;
2790
-
2791
-    /**
2792
-     * @var string $event_details_control_type
2793
-     */
2794
-    public $event_details_control_type;
2795
-
2796
-    /**
2797
-     * @var string $event_details_map_align
2798
-     */
2799
-    public $event_details_map_align;
2800
-
2801
-    /**
2802
-     * @var int $event_list_map_width
2803
-     */
2804
-    public $event_list_map_width;
2805
-
2806
-    /**
2807
-     * @var int $event_list_map_height
2808
-     */
2809
-    public $event_list_map_height;
2810
-
2811
-    /**
2812
-     * @var int $event_list_map_zoom
2813
-     */
2814
-    public $event_list_map_zoom;
2815
-
2816
-    /**
2817
-     * @var boolean $event_list_display_nav
2818
-     */
2819
-    public $event_list_display_nav;
2820
-
2821
-    /**
2822
-     * @var boolean $event_list_nav_size
2823
-     */
2824
-    public $event_list_nav_size;
2825
-
2826
-    /**
2827
-     * @var string $event_list_control_type
2828
-     */
2829
-    public $event_list_control_type;
2830
-
2831
-    /**
2832
-     * @var string $event_list_map_align
2833
-     */
2834
-    public $event_list_map_align;
2835
-
2836
-
2837
-    /**
2838
-     *    class constructor
2839
-     *
2840
-     * @access    public
2841
-     */
2842
-    public function __construct()
2843
-    {
2844
-        // set default map settings
2845
-        $this->use_google_maps = true;
2846
-        $this->google_map_api_key = '';
2847
-        // for event details pages (reg page)
2848
-        $this->event_details_map_width = 585;            // ee_map_width_single
2849
-        $this->event_details_map_height = 362;            // ee_map_height_single
2850
-        $this->event_details_map_zoom = 14;            // ee_map_zoom_single
2851
-        $this->event_details_display_nav = true;            // ee_map_nav_display_single
2852
-        $this->event_details_nav_size = false;            // ee_map_nav_size_single
2853
-        $this->event_details_control_type = 'default';        // ee_map_type_control_single
2854
-        $this->event_details_map_align = 'center';            // ee_map_align_single
2855
-        // for event list pages
2856
-        $this->event_list_map_width = 300;            // ee_map_width
2857
-        $this->event_list_map_height = 185;        // ee_map_height
2858
-        $this->event_list_map_zoom = 12;            // ee_map_zoom
2859
-        $this->event_list_display_nav = false;        // ee_map_nav_display
2860
-        $this->event_list_nav_size = true;            // ee_map_nav_size
2861
-        $this->event_list_control_type = 'dropdown';        // ee_map_type_control
2862
-        $this->event_list_map_align = 'center';            // ee_map_align
2863
-    }
2756
+	/**
2757
+	 * @var boolean $use_google_maps
2758
+	 */
2759
+	public $use_google_maps;
2760
+
2761
+	/**
2762
+	 * @var string $api_key
2763
+	 */
2764
+	public $google_map_api_key;
2765
+
2766
+	/**
2767
+	 * @var int $event_details_map_width
2768
+	 */
2769
+	public $event_details_map_width;
2770
+
2771
+	/**
2772
+	 * @var int $event_details_map_height
2773
+	 */
2774
+	public $event_details_map_height;
2775
+
2776
+	/**
2777
+	 * @var int $event_details_map_zoom
2778
+	 */
2779
+	public $event_details_map_zoom;
2780
+
2781
+	/**
2782
+	 * @var boolean $event_details_display_nav
2783
+	 */
2784
+	public $event_details_display_nav;
2785
+
2786
+	/**
2787
+	 * @var boolean $event_details_nav_size
2788
+	 */
2789
+	public $event_details_nav_size;
2790
+
2791
+	/**
2792
+	 * @var string $event_details_control_type
2793
+	 */
2794
+	public $event_details_control_type;
2795
+
2796
+	/**
2797
+	 * @var string $event_details_map_align
2798
+	 */
2799
+	public $event_details_map_align;
2800
+
2801
+	/**
2802
+	 * @var int $event_list_map_width
2803
+	 */
2804
+	public $event_list_map_width;
2805
+
2806
+	/**
2807
+	 * @var int $event_list_map_height
2808
+	 */
2809
+	public $event_list_map_height;
2810
+
2811
+	/**
2812
+	 * @var int $event_list_map_zoom
2813
+	 */
2814
+	public $event_list_map_zoom;
2815
+
2816
+	/**
2817
+	 * @var boolean $event_list_display_nav
2818
+	 */
2819
+	public $event_list_display_nav;
2820
+
2821
+	/**
2822
+	 * @var boolean $event_list_nav_size
2823
+	 */
2824
+	public $event_list_nav_size;
2825
+
2826
+	/**
2827
+	 * @var string $event_list_control_type
2828
+	 */
2829
+	public $event_list_control_type;
2830
+
2831
+	/**
2832
+	 * @var string $event_list_map_align
2833
+	 */
2834
+	public $event_list_map_align;
2835
+
2836
+
2837
+	/**
2838
+	 *    class constructor
2839
+	 *
2840
+	 * @access    public
2841
+	 */
2842
+	public function __construct()
2843
+	{
2844
+		// set default map settings
2845
+		$this->use_google_maps = true;
2846
+		$this->google_map_api_key = '';
2847
+		// for event details pages (reg page)
2848
+		$this->event_details_map_width = 585;            // ee_map_width_single
2849
+		$this->event_details_map_height = 362;            // ee_map_height_single
2850
+		$this->event_details_map_zoom = 14;            // ee_map_zoom_single
2851
+		$this->event_details_display_nav = true;            // ee_map_nav_display_single
2852
+		$this->event_details_nav_size = false;            // ee_map_nav_size_single
2853
+		$this->event_details_control_type = 'default';        // ee_map_type_control_single
2854
+		$this->event_details_map_align = 'center';            // ee_map_align_single
2855
+		// for event list pages
2856
+		$this->event_list_map_width = 300;            // ee_map_width
2857
+		$this->event_list_map_height = 185;        // ee_map_height
2858
+		$this->event_list_map_zoom = 12;            // ee_map_zoom
2859
+		$this->event_list_display_nav = false;        // ee_map_nav_display
2860
+		$this->event_list_nav_size = true;            // ee_map_nav_size
2861
+		$this->event_list_control_type = 'dropdown';        // ee_map_type_control
2862
+		$this->event_list_map_align = 'center';            // ee_map_align
2863
+	}
2864 2864
 }
2865 2865
 
2866 2866
 /**
@@ -2869,46 +2869,46 @@  discard block
 block discarded – undo
2869 2869
 class EE_Events_Archive_Config extends EE_Config_Base
2870 2870
 {
2871 2871
 
2872
-    public $display_status_banner;
2872
+	public $display_status_banner;
2873 2873
 
2874
-    public $display_description;
2874
+	public $display_description;
2875 2875
 
2876
-    public $display_ticket_selector;
2876
+	public $display_ticket_selector;
2877 2877
 
2878
-    public $display_datetimes;
2878
+	public $display_datetimes;
2879 2879
 
2880
-    public $display_venue;
2880
+	public $display_venue;
2881 2881
 
2882
-    public $display_expired_events;
2882
+	public $display_expired_events;
2883 2883
 
2884
-    public $use_sortable_display_order;
2884
+	public $use_sortable_display_order;
2885 2885
 
2886
-    public $display_order_tickets;
2886
+	public $display_order_tickets;
2887 2887
 
2888
-    public $display_order_datetimes;
2888
+	public $display_order_datetimes;
2889 2889
 
2890
-    public $display_order_event;
2890
+	public $display_order_event;
2891 2891
 
2892
-    public $display_order_venue;
2892
+	public $display_order_venue;
2893 2893
 
2894 2894
 
2895
-    /**
2896
-     *    class constructor
2897
-     */
2898
-    public function __construct()
2899
-    {
2900
-        $this->display_status_banner = 0;
2901
-        $this->display_description = 1;
2902
-        $this->display_ticket_selector = 0;
2903
-        $this->display_datetimes = 1;
2904
-        $this->display_venue = 0;
2905
-        $this->display_expired_events = 0;
2906
-        $this->use_sortable_display_order = false;
2907
-        $this->display_order_tickets = 100;
2908
-        $this->display_order_datetimes = 110;
2909
-        $this->display_order_event = 120;
2910
-        $this->display_order_venue = 130;
2911
-    }
2895
+	/**
2896
+	 *    class constructor
2897
+	 */
2898
+	public function __construct()
2899
+	{
2900
+		$this->display_status_banner = 0;
2901
+		$this->display_description = 1;
2902
+		$this->display_ticket_selector = 0;
2903
+		$this->display_datetimes = 1;
2904
+		$this->display_venue = 0;
2905
+		$this->display_expired_events = 0;
2906
+		$this->use_sortable_display_order = false;
2907
+		$this->display_order_tickets = 100;
2908
+		$this->display_order_datetimes = 110;
2909
+		$this->display_order_event = 120;
2910
+		$this->display_order_venue = 130;
2911
+	}
2912 2912
 }
2913 2913
 
2914 2914
 /**
@@ -2917,34 +2917,34 @@  discard block
 block discarded – undo
2917 2917
 class EE_Event_Single_Config extends EE_Config_Base
2918 2918
 {
2919 2919
 
2920
-    public $display_status_banner_single;
2920
+	public $display_status_banner_single;
2921 2921
 
2922
-    public $display_venue;
2922
+	public $display_venue;
2923 2923
 
2924
-    public $use_sortable_display_order;
2924
+	public $use_sortable_display_order;
2925 2925
 
2926
-    public $display_order_tickets;
2926
+	public $display_order_tickets;
2927 2927
 
2928
-    public $display_order_datetimes;
2928
+	public $display_order_datetimes;
2929 2929
 
2930
-    public $display_order_event;
2930
+	public $display_order_event;
2931 2931
 
2932
-    public $display_order_venue;
2932
+	public $display_order_venue;
2933 2933
 
2934 2934
 
2935
-    /**
2936
-     *    class constructor
2937
-     */
2938
-    public function __construct()
2939
-    {
2940
-        $this->display_status_banner_single = 0;
2941
-        $this->display_venue = 1;
2942
-        $this->use_sortable_display_order = false;
2943
-        $this->display_order_tickets = 100;
2944
-        $this->display_order_datetimes = 110;
2945
-        $this->display_order_event = 120;
2946
-        $this->display_order_venue = 130;
2947
-    }
2935
+	/**
2936
+	 *    class constructor
2937
+	 */
2938
+	public function __construct()
2939
+	{
2940
+		$this->display_status_banner_single = 0;
2941
+		$this->display_venue = 1;
2942
+		$this->use_sortable_display_order = false;
2943
+		$this->display_order_tickets = 100;
2944
+		$this->display_order_datetimes = 110;
2945
+		$this->display_order_event = 120;
2946
+		$this->display_order_venue = 130;
2947
+	}
2948 2948
 }
2949 2949
 
2950 2950
 /**
@@ -2953,172 +2953,172 @@  discard block
 block discarded – undo
2953 2953
 class EE_Ticket_Selector_Config extends EE_Config_Base
2954 2954
 {
2955 2955
 
2956
-    /**
2957
-     * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2958
-     */
2959
-    const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2960
-
2961
-    /**
2962
-     * constant to indicate that a datetime selector should only be shown for ticket selectors
2963
-     * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2964
-     */
2965
-    const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2966
-
2967
-    /**
2968
-     * @var boolean $show_ticket_sale_columns
2969
-     */
2970
-    public $show_ticket_sale_columns;
2971
-
2972
-    /**
2973
-     * @var boolean $show_ticket_details
2974
-     */
2975
-    public $show_ticket_details;
2976
-
2977
-    /**
2978
-     * @var boolean $show_expired_tickets
2979
-     */
2980
-    public $show_expired_tickets;
2981
-
2982
-    /**
2983
-     * whether or not to display a dropdown box populated with event datetimes
2984
-     * that toggles which tickets are displayed for a ticket selector.
2985
-     * uses one of the *_DATETIME_SELECTOR constants defined above
2986
-     *
2987
-     * @var string $show_datetime_selector
2988
-     */
2989
-    private $show_datetime_selector = 'no_datetime_selector';
2990
-
2991
-    /**
2992
-     * the number of datetimes an event has to have before conditionally displaying a datetime selector
2993
-     *
2994
-     * @var int $datetime_selector_threshold
2995
-     */
2996
-    private $datetime_selector_threshold = 3;
2997
-
2998
-    /**
2999
-     * determines the maximum number of "checked" dates in the date and time filter
3000
-     *
3001
-     * @var int $datetime_selector_checked
3002
-     */
3003
-    private $datetime_selector_max_checked = 10;
3004
-
3005
-
3006
-    /**
3007
-     *    class constructor
3008
-     */
3009
-    public function __construct()
3010
-    {
3011
-        $this->show_ticket_sale_columns = true;
3012
-        $this->show_ticket_details = true;
3013
-        $this->show_expired_tickets = true;
3014
-        $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3015
-        $this->datetime_selector_threshold = 3;
3016
-        $this->datetime_selector_max_checked = 10;
3017
-    }
3018
-
3019
-
3020
-    /**
3021
-     * returns true if a datetime selector should be displayed
3022
-     *
3023
-     * @param array $datetimes
3024
-     * @return bool
3025
-     */
3026
-    public function showDatetimeSelector(array $datetimes)
3027
-    {
3028
-        // if the settings are NOT: don't show OR below threshold, THEN active = true
3029
-        return ! (
3030
-            $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3031
-            || (
3032
-                $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3033
-                && count($datetimes) < $this->getDatetimeSelectorThreshold()
3034
-            )
3035
-        );
3036
-    }
3037
-
3038
-
3039
-    /**
3040
-     * @return string
3041
-     */
3042
-    public function getShowDatetimeSelector()
3043
-    {
3044
-        return $this->show_datetime_selector;
3045
-    }
3046
-
3047
-
3048
-    /**
3049
-     * @param bool $keys_only
3050
-     * @return array
3051
-     */
3052
-    public function getShowDatetimeSelectorOptions($keys_only = true)
3053
-    {
3054
-        return $keys_only
3055
-            ? array(
3056
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3057
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3058
-            )
3059
-            : array(
3060
-                \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3061
-                    'Do not show date & time filter',
3062
-                    'event_espresso'
3063
-                ),
3064
-                \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3065
-                    'Maybe show date & time filter',
3066
-                    'event_espresso'
3067
-                ),
3068
-            );
3069
-    }
3070
-
3071
-
3072
-    /**
3073
-     * @param string $show_datetime_selector
3074
-     */
3075
-    public function setShowDatetimeSelector($show_datetime_selector)
3076
-    {
3077
-        $this->show_datetime_selector = in_array(
3078
-            $show_datetime_selector,
3079
-            $this->getShowDatetimeSelectorOptions(),
3080
-            true
3081
-        )
3082
-            ? $show_datetime_selector
3083
-            : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3084
-    }
3085
-
3086
-
3087
-    /**
3088
-     * @return int
3089
-     */
3090
-    public function getDatetimeSelectorThreshold()
3091
-    {
3092
-        return $this->datetime_selector_threshold;
3093
-    }
3094
-
3095
-
3096
-    /**
3097
-     * @param int $datetime_selector_threshold
3098
-     */
3099
-    public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3100
-    {
3101
-        $datetime_selector_threshold = absint($datetime_selector_threshold);
3102
-        $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3103
-    }
3104
-
3105
-
3106
-    /**
3107
-     * @return int
3108
-     */
3109
-    public function getDatetimeSelectorMaxChecked()
3110
-    {
3111
-        return $this->datetime_selector_max_checked;
3112
-    }
3113
-
3114
-
3115
-    /**
3116
-     * @param int $datetime_selector_max_checked
3117
-     */
3118
-    public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3119
-    {
3120
-        $this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3121
-    }
2956
+	/**
2957
+	 * constant to indicate that a datetime selector should NEVER be shown for ticket selectors
2958
+	 */
2959
+	const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector';
2960
+
2961
+	/**
2962
+	 * constant to indicate that a datetime selector should only be shown for ticket selectors
2963
+	 * when the number of datetimes for the event matches the value set for $datetime_selector_threshold
2964
+	 */
2965
+	const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector';
2966
+
2967
+	/**
2968
+	 * @var boolean $show_ticket_sale_columns
2969
+	 */
2970
+	public $show_ticket_sale_columns;
2971
+
2972
+	/**
2973
+	 * @var boolean $show_ticket_details
2974
+	 */
2975
+	public $show_ticket_details;
2976
+
2977
+	/**
2978
+	 * @var boolean $show_expired_tickets
2979
+	 */
2980
+	public $show_expired_tickets;
2981
+
2982
+	/**
2983
+	 * whether or not to display a dropdown box populated with event datetimes
2984
+	 * that toggles which tickets are displayed for a ticket selector.
2985
+	 * uses one of the *_DATETIME_SELECTOR constants defined above
2986
+	 *
2987
+	 * @var string $show_datetime_selector
2988
+	 */
2989
+	private $show_datetime_selector = 'no_datetime_selector';
2990
+
2991
+	/**
2992
+	 * the number of datetimes an event has to have before conditionally displaying a datetime selector
2993
+	 *
2994
+	 * @var int $datetime_selector_threshold
2995
+	 */
2996
+	private $datetime_selector_threshold = 3;
2997
+
2998
+	/**
2999
+	 * determines the maximum number of "checked" dates in the date and time filter
3000
+	 *
3001
+	 * @var int $datetime_selector_checked
3002
+	 */
3003
+	private $datetime_selector_max_checked = 10;
3004
+
3005
+
3006
+	/**
3007
+	 *    class constructor
3008
+	 */
3009
+	public function __construct()
3010
+	{
3011
+		$this->show_ticket_sale_columns = true;
3012
+		$this->show_ticket_details = true;
3013
+		$this->show_expired_tickets = true;
3014
+		$this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3015
+		$this->datetime_selector_threshold = 3;
3016
+		$this->datetime_selector_max_checked = 10;
3017
+	}
3018
+
3019
+
3020
+	/**
3021
+	 * returns true if a datetime selector should be displayed
3022
+	 *
3023
+	 * @param array $datetimes
3024
+	 * @return bool
3025
+	 */
3026
+	public function showDatetimeSelector(array $datetimes)
3027
+	{
3028
+		// if the settings are NOT: don't show OR below threshold, THEN active = true
3029
+		return ! (
3030
+			$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR
3031
+			|| (
3032
+				$this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR
3033
+				&& count($datetimes) < $this->getDatetimeSelectorThreshold()
3034
+			)
3035
+		);
3036
+	}
3037
+
3038
+
3039
+	/**
3040
+	 * @return string
3041
+	 */
3042
+	public function getShowDatetimeSelector()
3043
+	{
3044
+		return $this->show_datetime_selector;
3045
+	}
3046
+
3047
+
3048
+	/**
3049
+	 * @param bool $keys_only
3050
+	 * @return array
3051
+	 */
3052
+	public function getShowDatetimeSelectorOptions($keys_only = true)
3053
+	{
3054
+		return $keys_only
3055
+			? array(
3056
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR,
3057
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR,
3058
+			)
3059
+			: array(
3060
+				\EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__(
3061
+					'Do not show date & time filter',
3062
+					'event_espresso'
3063
+				),
3064
+				\EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR  => esc_html__(
3065
+					'Maybe show date & time filter',
3066
+					'event_espresso'
3067
+				),
3068
+			);
3069
+	}
3070
+
3071
+
3072
+	/**
3073
+	 * @param string $show_datetime_selector
3074
+	 */
3075
+	public function setShowDatetimeSelector($show_datetime_selector)
3076
+	{
3077
+		$this->show_datetime_selector = in_array(
3078
+			$show_datetime_selector,
3079
+			$this->getShowDatetimeSelectorOptions(),
3080
+			true
3081
+		)
3082
+			? $show_datetime_selector
3083
+			: \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR;
3084
+	}
3085
+
3086
+
3087
+	/**
3088
+	 * @return int
3089
+	 */
3090
+	public function getDatetimeSelectorThreshold()
3091
+	{
3092
+		return $this->datetime_selector_threshold;
3093
+	}
3094
+
3095
+
3096
+	/**
3097
+	 * @param int $datetime_selector_threshold
3098
+	 */
3099
+	public function setDatetimeSelectorThreshold($datetime_selector_threshold)
3100
+	{
3101
+		$datetime_selector_threshold = absint($datetime_selector_threshold);
3102
+		$this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3;
3103
+	}
3104
+
3105
+
3106
+	/**
3107
+	 * @return int
3108
+	 */
3109
+	public function getDatetimeSelectorMaxChecked()
3110
+	{
3111
+		return $this->datetime_selector_max_checked;
3112
+	}
3113
+
3114
+
3115
+	/**
3116
+	 * @param int $datetime_selector_max_checked
3117
+	 */
3118
+	public function setDatetimeSelectorMaxChecked($datetime_selector_max_checked)
3119
+	{
3120
+		$this->datetime_selector_max_checked = absint($datetime_selector_max_checked);
3121
+	}
3122 3122
 }
3123 3123
 
3124 3124
 /**
@@ -3131,81 +3131,81 @@  discard block
 block discarded – undo
3131 3131
 class EE_Environment_Config extends EE_Config_Base
3132 3132
 {
3133 3133
 
3134
-    /**
3135
-     * Hold any php environment variables that we want to track.
3136
-     *
3137
-     * @var stdClass;
3138
-     */
3139
-    public $php;
3140
-
3141
-
3142
-    /**
3143
-     *    constructor
3144
-     */
3145
-    public function __construct()
3146
-    {
3147
-        $this->php = new stdClass();
3148
-        $this->_set_php_values();
3149
-    }
3150
-
3151
-
3152
-    /**
3153
-     * This sets the php environment variables.
3154
-     *
3155
-     * @since 4.4.0
3156
-     * @return void
3157
-     */
3158
-    protected function _set_php_values()
3159
-    {
3160
-        $this->php->max_input_vars = ini_get('max_input_vars');
3161
-        $this->php->version = phpversion();
3162
-    }
3163
-
3164
-
3165
-    /**
3166
-     * helper method for determining whether input_count is
3167
-     * reaching the potential maximum the server can handle
3168
-     * according to max_input_vars
3169
-     *
3170
-     * @param int   $input_count the count of input vars.
3171
-     * @return array {
3172
-     *                           An array that represents whether available space and if no available space the error
3173
-     *                           message.
3174
-     * @type bool   $has_space   whether more inputs can be added.
3175
-     * @type string $msg         Any message to be displayed.
3176
-     *                           }
3177
-     */
3178
-    public function max_input_vars_limit_check($input_count = 0)
3179
-    {
3180
-        if (! empty($this->php->max_input_vars)
3181
-            && ($input_count >= $this->php->max_input_vars)
3182
-            && (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3183
-        ) {
3184
-            return sprintf(
3185
-                __(
3186
-                    'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3187
-                    'event_espresso'
3188
-                ),
3189
-                '<br>',
3190
-                $input_count,
3191
-                $this->php->max_input_vars
3192
-            );
3193
-        } else {
3194
-            return '';
3195
-        }
3196
-    }
3197
-
3198
-
3199
-    /**
3200
-     * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3201
-     *
3202
-     * @since 4.4.1
3203
-     * @return void
3204
-     */
3205
-    public function recheck_values()
3206
-    {
3207
-        $this->_set_php_values();
3208
-    }
3134
+	/**
3135
+	 * Hold any php environment variables that we want to track.
3136
+	 *
3137
+	 * @var stdClass;
3138
+	 */
3139
+	public $php;
3140
+
3141
+
3142
+	/**
3143
+	 *    constructor
3144
+	 */
3145
+	public function __construct()
3146
+	{
3147
+		$this->php = new stdClass();
3148
+		$this->_set_php_values();
3149
+	}
3150
+
3151
+
3152
+	/**
3153
+	 * This sets the php environment variables.
3154
+	 *
3155
+	 * @since 4.4.0
3156
+	 * @return void
3157
+	 */
3158
+	protected function _set_php_values()
3159
+	{
3160
+		$this->php->max_input_vars = ini_get('max_input_vars');
3161
+		$this->php->version = phpversion();
3162
+	}
3163
+
3164
+
3165
+	/**
3166
+	 * helper method for determining whether input_count is
3167
+	 * reaching the potential maximum the server can handle
3168
+	 * according to max_input_vars
3169
+	 *
3170
+	 * @param int   $input_count the count of input vars.
3171
+	 * @return array {
3172
+	 *                           An array that represents whether available space and if no available space the error
3173
+	 *                           message.
3174
+	 * @type bool   $has_space   whether more inputs can be added.
3175
+	 * @type string $msg         Any message to be displayed.
3176
+	 *                           }
3177
+	 */
3178
+	public function max_input_vars_limit_check($input_count = 0)
3179
+	{
3180
+		if (! empty($this->php->max_input_vars)
3181
+			&& ($input_count >= $this->php->max_input_vars)
3182
+			&& (PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9)
3183
+		) {
3184
+			return sprintf(
3185
+				__(
3186
+					'The maximum number of inputs on this page has been exceeded.  You cannot add anymore items (i.e. tickets, datetimes, custom fields) on this page because of your servers PHP "max_input_vars" setting.%1$sThere are %2$d inputs and the maximum amount currently allowed by your server is %3$d.',
3187
+					'event_espresso'
3188
+				),
3189
+				'<br>',
3190
+				$input_count,
3191
+				$this->php->max_input_vars
3192
+			);
3193
+		} else {
3194
+			return '';
3195
+		}
3196
+	}
3197
+
3198
+
3199
+	/**
3200
+	 * The purpose of this method is just to force rechecking php values so if they've changed, they get updated.
3201
+	 *
3202
+	 * @since 4.4.1
3203
+	 * @return void
3204
+	 */
3205
+	public function recheck_values()
3206
+	{
3207
+		$this->_set_php_values();
3208
+	}
3209 3209
 }
3210 3210
 
3211 3211
 /**
@@ -3218,21 +3218,21 @@  discard block
 block discarded – undo
3218 3218
 class EE_Tax_Config extends EE_Config_Base
3219 3219
 {
3220 3220
 
3221
-    /*
3221
+	/*
3222 3222
      * flag to indicate whether or not to display ticket prices with the taxes included
3223 3223
      *
3224 3224
      * @var boolean $prices_displayed_including_taxes
3225 3225
      */
3226
-    public $prices_displayed_including_taxes;
3226
+	public $prices_displayed_including_taxes;
3227 3227
 
3228 3228
 
3229
-    /**
3230
-     *    class constructor
3231
-     */
3232
-    public function __construct()
3233
-    {
3234
-        $this->prices_displayed_including_taxes = true;
3235
-    }
3229
+	/**
3230
+	 *    class constructor
3231
+	 */
3232
+	public function __construct()
3233
+	{
3234
+		$this->prices_displayed_including_taxes = true;
3235
+	}
3236 3236
 }
3237 3237
 
3238 3238
 /**
@@ -3246,19 +3246,19 @@  discard block
 block discarded – undo
3246 3246
 class EE_Messages_Config extends EE_Config_Base
3247 3247
 {
3248 3248
 
3249
-    /**
3250
-     * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3251
-     * A value of 0 represents never deleting.  Default is 0.
3252
-     *
3253
-     * @var integer
3254
-     */
3255
-    public $delete_threshold;
3249
+	/**
3250
+	 * This is an integer representing the deletion threshold in months for when old messages will get deleted.
3251
+	 * A value of 0 represents never deleting.  Default is 0.
3252
+	 *
3253
+	 * @var integer
3254
+	 */
3255
+	public $delete_threshold;
3256 3256
 
3257 3257
 
3258
-    public function __construct()
3259
-    {
3260
-        $this->delete_threshold = 0;
3261
-    }
3258
+	public function __construct()
3259
+	{
3260
+		$this->delete_threshold = 0;
3261
+	}
3262 3262
 }
3263 3263
 
3264 3264
 /**
@@ -3269,31 +3269,31 @@  discard block
 block discarded – undo
3269 3269
 class EE_Gateway_Config extends EE_Config_Base
3270 3270
 {
3271 3271
 
3272
-    /**
3273
-     * Array with keys that are payment gateways slugs, and values are arrays
3274
-     * with any config info the gateway wants to store
3275
-     *
3276
-     * @var array
3277
-     */
3278
-    public $payment_settings;
3279
-
3280
-    /**
3281
-     * Where keys are gateway slugs, and values are booleans indicating whether or not
3282
-     * the gateway is stored in the uploads directory
3283
-     *
3284
-     * @var array
3285
-     */
3286
-    public $active_gateways;
3287
-
3288
-
3289
-    /**
3290
-     *    class constructor
3291
-     *
3292
-     * @deprecated
3293
-     */
3294
-    public function __construct()
3295
-    {
3296
-        $this->payment_settings = array();
3297
-        $this->active_gateways = array('Invoice' => false);
3298
-    }
3272
+	/**
3273
+	 * Array with keys that are payment gateways slugs, and values are arrays
3274
+	 * with any config info the gateway wants to store
3275
+	 *
3276
+	 * @var array
3277
+	 */
3278
+	public $payment_settings;
3279
+
3280
+	/**
3281
+	 * Where keys are gateway slugs, and values are booleans indicating whether or not
3282
+	 * the gateway is stored in the uploads directory
3283
+	 *
3284
+	 * @var array
3285
+	 */
3286
+	public $active_gateways;
3287
+
3288
+
3289
+	/**
3290
+	 *    class constructor
3291
+	 *
3292
+	 * @deprecated
3293
+	 */
3294
+	public function __construct()
3295
+	{
3296
+		$this->payment_settings = array();
3297
+		$this->active_gateways = array('Invoice' => false);
3298
+	}
3299 3299
 }
Please login to merge, or discard this patch.
entities/route_match/specifications/frontend/EspressoBlockRenderer.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -15,21 +15,21 @@
 block discarded – undo
15 15
 class EspressoBlockRenderer extends RouteMatchSpecification
16 16
 {
17 17
 
18
-    /**
19
-     * returns true if current request matches specification
20
-     *
21
-     * @since $VID:$
22
-     * @return boolean
23
-     */
24
-    public function isMatchingRoute()
25
-    {
26
-        return strpos(
27
-            $this->request->requestUri(),
28
-            'wp-json/wp/v2/block-renderer/eventespresso'
29
-        ) !== false
30
-            || strpos(
31
-                $this->request->requestUri(),
32
-                'wp-json/gutenberg/v2/block-renderer/eventespresso'
33
-            ) !== false;
34
-    }
18
+	/**
19
+	 * returns true if current request matches specification
20
+	 *
21
+	 * @since $VID:$
22
+	 * @return boolean
23
+	 */
24
+	public function isMatchingRoute()
25
+	{
26
+		return strpos(
27
+			$this->request->requestUri(),
28
+			'wp-json/wp/v2/block-renderer/eventespresso'
29
+		) !== false
30
+			|| strpos(
31
+				$this->request->requestUri(),
32
+				'wp-json/gutenberg/v2/block-renderer/eventespresso'
33
+			) !== false;
34
+	}
35 35
 }
Please login to merge, or discard this patch.