Completed
Branch fix/pue-feature-flag (92fc4a)
by
unknown
18:20 queued 15:56
created
core/admin/EE_Admin.core.php 2 patches
Indentation   +986 added lines, -986 removed lines patch added patch discarded remove patch
@@ -20,990 +20,990 @@
 block discarded – undo
20 20
  */
21 21
 final class EE_Admin implements InterminableInterface
22 22
 {
23
-    /**
24
-     * @var EE_Admin $_instance
25
-     */
26
-    private static $_instance;
27
-
28
-    /**
29
-     * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
30
-     */
31
-    private $persistent_admin_notice_manager;
32
-
33
-    /**
34
-     * @var LoaderInterface
35
-     */
36
-    protected $loader;
37
-
38
-    /**
39
-     * @var RequestInterface
40
-     */
41
-    protected $request;
42
-
43
-
44
-    /**
45
-     * @param RequestInterface $request
46
-     * @singleton method used to instantiate class object
47
-     * @return EE_Admin
48
-     * @throws EE_Error
49
-     */
50
-    public static function instance(RequestInterface $request = null)
51
-    {
52
-        // check if class object is instantiated
53
-        if (! self::$_instance instanceof EE_Admin) {
54
-            self::$_instance = new self($request);
55
-        }
56
-        return self::$_instance;
57
-    }
58
-
59
-
60
-    /**
61
-     * @return EE_Admin
62
-     * @throws EE_Error
63
-     */
64
-    public static function reset()
65
-    {
66
-        self::$_instance = null;
67
-        $request         = LoaderFactory::getLoader()->getShared(RequestInterface::class);
68
-        return self::instance($request);
69
-    }
70
-
71
-
72
-    /**
73
-     * @param RequestInterface $request
74
-     * @throws EE_Error
75
-     * @throws InvalidDataTypeException
76
-     * @throws InvalidInterfaceException
77
-     * @throws InvalidArgumentException
78
-     */
79
-    protected function __construct(RequestInterface $request)
80
-    {
81
-        $this->request = $request;
82
-        $this->loader = LoaderFactory::getLoader();
83
-        // define global EE_Admin constants
84
-        $this->_define_all_constants();
85
-        // set autoloaders for our admin page classes based on included path information
86
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
87
-        // admin hooks
88
-        add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2);
89
-        add_action('AHEE__EE_System__initialize_last', [$this, 'init']);
90
-        add_action('AHEE__EE_Admin_Page__route_admin_request', [$this, 'route_admin_request'], 100, 2);
91
-        add_action('wp_loaded', [$this, 'wp_loaded'], 100);
92
-        add_action('admin_init', [$this, 'admin_init'], 100);
93
-        add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts'], 20);
94
-        add_action('admin_notices', [$this, 'display_admin_notices'], 10);
95
-        add_action('network_admin_notices', [$this, 'display_admin_notices'], 10);
96
-        add_filter('pre_update_option', [$this, 'check_for_invalid_datetime_formats'], 100, 2);
97
-        add_filter('admin_footer_text', [$this, 'espresso_admin_footer']);
98
-        add_action('load-plugins.php', [$this, 'hookIntoWpPluginsPage']);
99
-        add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2);
100
-        add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2);
101
-        // reset Environment config (we only do this on admin page loads);
102
-        EE_Registry::instance()->CFG->environment->recheck_values();
103
-        do_action('AHEE__EE_Admin__loaded');
104
-    }
105
-
106
-
107
-    /**
108
-     * _define_all_constants
109
-     * define constants that are set globally for all admin pages
110
-     *
111
-     * @return void
112
-     */
113
-    private function _define_all_constants()
114
-    {
115
-        if (! defined('EE_ADMIN_URL')) {
116
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
117
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
118
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/');
119
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
120
-            define('WP_AJAX_URL', admin_url('admin-ajax.php'));
121
-        }
122
-    }
123
-
124
-
125
-    /**
126
-     * filter_plugin_actions - adds links to the Plugins page listing
127
-     *
128
-     * @param array  $links
129
-     * @param string $plugin
130
-     * @return    array
131
-     */
132
-    public function filter_plugin_actions($links, $plugin)
133
-    {
134
-        // set $main_file in stone
135
-        static $main_file;
136
-        // if $main_file is not set yet
137
-        if (! $main_file) {
138
-            $main_file = EE_PLUGIN_BASENAME;
139
-        }
140
-        if ($plugin === $main_file) {
141
-            // compare current plugin to this one
142
-            if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
143
-                $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
144
-                                    . ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
145
-                                    . esc_html__('Maintenance Mode Active', 'event_espresso')
146
-                                    . '</a>';
147
-                array_unshift($links, $maintenance_link);
148
-            } else {
149
-                $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
150
-                                     . esc_html__('Settings', 'event_espresso')
151
-                                     . '</a>';
152
-                $events_link       = '<a href="admin.php?page=espresso_events">'
153
-                                     . esc_html__('Events', 'event_espresso')
154
-                                     . '</a>';
155
-                // add before other links
156
-                array_unshift($links, $org_settings_link, $events_link);
157
-            }
158
-        }
159
-        return $links;
160
-    }
161
-
162
-
163
-    /**
164
-     * @deprecated 4.10.14.p
165
-     */
166
-    public function get_request()
167
-    {
168
-    }
169
-
170
-
171
-    /**
172
-     * hide_admin_pages_except_maintenance_mode
173
-     *
174
-     * @param array $admin_page_folder_names
175
-     * @return array
176
-     */
177
-    public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = [])
178
-    {
179
-        return [
180
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance/',
181
-            'about'       => EE_ADMIN_PAGES . 'about/',
182
-            'support'     => EE_ADMIN_PAGES . 'support/',
183
-        ];
184
-    }
185
-
186
-
187
-    /**
188
-     * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
189
-     * EE_Front_Controller's init phases have run
190
-     *
191
-     * @return void
192
-     * @throws EE_Error
193
-     * @throws InvalidArgumentException
194
-     * @throws InvalidDataTypeException
195
-     * @throws InvalidInterfaceException
196
-     * @throws ReflectionException
197
-     * @throws ServiceNotFoundException
198
-     */
199
-    public function init()
200
-    {
201
-        // only enable most of the EE_Admin IF we're not in full maintenance mode
202
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
203
-            $this->initModelsReady();
204
-        }
205
-        // run the admin page factory but ONLY if:
206
-        // - it is a regular non ajax admin request
207
-        // - we are doing an ee admin ajax request
208
-        if ($this->request->isAdmin() || $this->request->isAdminAjax()) {
209
-            // this loads the controller for the admin pages which will setup routing etc
210
-            $this->loader->getShared('EE_Admin_Page_Loader', [$this->loader]);
211
-        }
212
-        if ($this->request->isAdminAjax()) {
213
-            return;
214
-        }
215
-        add_filter('content_save_pre', [$this, 'its_eSpresso'], 10, 1);
216
-        // make sure our CPTs and custom taxonomy metaboxes get shown for first time users
217
-        add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10);
218
-        add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10);
219
-        // exclude EE critical pages from all nav menus and wp_list_pages
220
-        add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu'], 10);
221
-    }
222
-
223
-
224
-    /**
225
-     * Gets the loader (and if it wasn't previously set, sets it)
226
-     *
227
-     * @return LoaderInterface
228
-     * @throws InvalidArgumentException
229
-     * @throws InvalidDataTypeException
230
-     * @throws InvalidInterfaceException
231
-     */
232
-    protected function getLoader()
233
-    {
234
-        return $this->loader;
235
-    }
236
-
237
-
238
-    /**
239
-     * Method that's fired on admin requests (including admin ajax) but only when the models are usable
240
-     * (ie, the site isn't in maintenance mode)
241
-     *
242
-     * @return void
243
-     * @throws EE_Error
244
-     * @since 4.9.63.p
245
-     */
246
-    protected function initModelsReady()
247
-    {
248
-        // ok so we want to enable the entire admin
249
-        $this->persistent_admin_notice_manager = $this->loader->getShared(
250
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
251
-        );
252
-        $this->persistent_admin_notice_manager->setReturnUrl(
253
-            EE_Admin_Page::add_query_args_and_nonce(
254
-                [
255
-                    'page'   => $this->request->getRequestParam('page'),
256
-                    'action' => $this->request->getRequestParam('action'),
257
-                ],
258
-                EE_ADMIN_URL
259
-            )
260
-        );
261
-        $this->maybeSetDatetimeWarningNotice();
262
-        // at a glance dashboard widget
263
-        add_filter('dashboard_glance_items', [$this, 'dashboard_glance_items'], 10);
264
-        // filter for get_edit_post_link used on comments for custom post types
265
-        add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 2);
266
-    }
267
-
268
-
269
-    /**
270
-     *    get_persistent_admin_notices
271
-     *
272
-     * @access    public
273
-     * @return void
274
-     * @throws EE_Error
275
-     * @throws InvalidArgumentException
276
-     * @throws InvalidDataTypeException
277
-     * @throws InvalidInterfaceException
278
-     */
279
-    public function maybeSetDatetimeWarningNotice()
280
-    {
281
-        // add dismissible notice for datetime changes.  Only valid if site does not have a timezone_string set.
282
-        // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
283
-        // with this.  But after enough time (indeterminate at this point) we can just remove this notice.
284
-        // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
285
-        if (
286
-            apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
287
-            && ! get_option('timezone_string')
288
-            && EEM_Event::instance()->count() > 0
289
-        ) {
290
-            new PersistentAdminNotice(
291
-                'datetime_fix_notice',
292
-                sprintf(
293
-                    esc_html__(
294
-                        '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
295
-                        'event_espresso'
296
-                    ),
297
-                    '<strong>',
298
-                    '</strong>',
299
-                    '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
300
-                    '</a>',
301
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
302
-                        [
303
-                            'page'   => 'espresso_maintenance_settings',
304
-                            'action' => 'datetime_tools',
305
-                        ],
306
-                        admin_url('admin.php')
307
-                    ) . '">'
308
-                ),
309
-                false,
310
-                'manage_options',
311
-                'datetime_fix_persistent_notice'
312
-            );
313
-        }
314
-    }
315
-
316
-
317
-    /**
318
-     * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
319
-     * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
320
-     * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
321
-     * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
322
-     * normal property on the post_type object.  It's found ONLY in this particular context.
323
-     *
324
-     * @param WP_Post $post_type WP post type object
325
-     * @return WP_Post
326
-     * @throws InvalidArgumentException
327
-     * @throws InvalidDataTypeException
328
-     * @throws InvalidInterfaceException
329
-     */
330
-    public function remove_pages_from_nav_menu($post_type)
331
-    {
332
-        // if this isn't the "pages" post type let's get out
333
-        if ($post_type->name !== 'page') {
334
-            return $post_type;
335
-        }
336
-        $critical_pages            = EE_Registry::instance()->CFG->core->get_critical_pages_array();
337
-        $post_type->_default_query = [
338
-            'post__not_in' => $critical_pages,
339
-        ];
340
-        return $post_type;
341
-    }
342
-
343
-
344
-    /**
345
-     * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
346
-     * metaboxes get shown as well
347
-     *
348
-     * @return void
349
-     */
350
-    public function enable_hidden_ee_nav_menu_metaboxes()
351
-    {
352
-        global $wp_meta_boxes, $pagenow;
353
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
354
-            return;
355
-        }
356
-        $user = wp_get_current_user();
357
-        // has this been done yet?
358
-        if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
359
-            return;
360
-        }
361
-
362
-        $hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
363
-        $initial_meta_boxes = apply_filters(
364
-            'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
365
-            [
366
-                'nav-menu-theme-locations',
367
-                'add-page',
368
-                'add-custom-links',
369
-                'add-category',
370
-                'add-espresso_events',
371
-                'add-espresso_venues',
372
-                'add-espresso_event_categories',
373
-                'add-espresso_venue_categories',
374
-                'add-post-type-post',
375
-                'add-post-type-page',
376
-            ]
377
-        );
378
-
379
-        if (is_array($hidden_meta_boxes)) {
380
-            foreach ($hidden_meta_boxes as $key => $meta_box_id) {
381
-                if (in_array($meta_box_id, $initial_meta_boxes, true)) {
382
-                    unset($hidden_meta_boxes[ $key ]);
383
-                }
384
-            }
385
-        }
386
-        update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
387
-        update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
388
-    }
389
-
390
-
391
-    /**
392
-     * This method simply registers custom nav menu boxes for "nav_menus.php route"
393
-     * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
394
-     *
395
-     * @return void
396
-     * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
397
-     *         addons etc.
398
-     */
399
-    public function register_custom_nav_menu_boxes()
400
-    {
401
-        add_meta_box(
402
-            'add-extra-nav-menu-pages',
403
-            esc_html__('Event Espresso Pages', 'event_espresso'),
404
-            [$this, 'ee_cpt_archive_pages'],
405
-            'nav-menus',
406
-            'side',
407
-            'core'
408
-        );
409
-    }
410
-
411
-
412
-    /**
413
-     * Use this to edit the post link for our cpts so that the edit link points to the correct page.
414
-     *
415
-     * @param string $link the original link generated by wp
416
-     * @param int    $id   post id
417
-     * @return string  the (maybe) modified link
418
-     * @since   4.3.0
419
-     */
420
-    public function modify_edit_post_link($link, $id)
421
-    {
422
-        if (! $post = get_post($id)) {
423
-            return $link;
424
-        }
425
-        if ($post->post_type === 'espresso_attendees') {
426
-            $query_args = [
427
-                'action' => 'edit_attendee',
428
-                'post'   => $id,
429
-            ];
430
-            return EEH_URL::add_query_args_and_nonce(
431
-                $query_args,
432
-                admin_url('admin.php?page=espresso_registrations')
433
-            );
434
-        }
435
-        return $link;
436
-    }
437
-
438
-
439
-    public function ee_cpt_archive_pages()
440
-    {
441
-        global $nav_menu_selected_id;
442
-        $removed_args = [
443
-            'action',
444
-            'customlink-tab',
445
-            'edit-menu-item',
446
-            'menu-item',
447
-            'page-tab',
448
-            '_wpnonce',
449
-        ];
450
-        $nav_tab_link = $nav_menu_selected_id
451
-            ? esc_url(
452
-                add_query_arg(
453
-                    'extra-nav-menu-pages-tab',
454
-                    'event-archives',
455
-                    remove_query_arg($removed_args)
456
-                )
457
-            )
458
-            : '';
459
-        $select_all_link = esc_url(
460
-            add_query_arg(
461
-                [
462
-                    'extra-nav-menu-pages-tab' => 'event-archives',
463
-                    'selectall'                => 1,
464
-                ],
465
-                remove_query_arg($removed_args)
466
-            )
467
-        );
468
-        $pages = $this->_get_extra_nav_menu_pages_items();
469
-        $args['walker'] = new Walker_Nav_Menu_Checklist(false);
470
-        ;
471
-        $nav_menu_pages_items = walk_nav_menu_tree(
472
-            array_map(
473
-                [$this, '_setup_extra_nav_menu_pages_items'],
474
-                $pages
475
-            ),
476
-            0,
477
-            (object) $args
478
-        );
479
-
480
-        EEH_Template::display_template(
481
-            EE_ADMIN_TEMPLATE . 'cpt_archive_page.template.php',
482
-            [
483
-                $nav_menu_pages_items,
484
-                $nav_tab_link,
485
-                $select_all_link,
486
-            ]
487
-        );
488
-    }
489
-
490
-
491
-    /**
492
-     * Returns an array of event archive nav items.
493
-     *
494
-     * @return array
495
-     * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
496
-     *        method we use for getting the extra nav menu items
497
-     */
498
-    private function _get_extra_nav_menu_pages_items()
499
-    {
500
-        $menuitems[] = [
501
-            'title'       => esc_html__('Event List', 'event_espresso'),
502
-            'url'         => get_post_type_archive_link('espresso_events'),
503
-            'description' => esc_html__('Archive page for all events.', 'event_espresso'),
504
-        ];
505
-        return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
506
-    }
507
-
508
-
509
-    /**
510
-     * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
511
-     * the properties and converts it to the menu item object.
512
-     *
513
-     * @param $menu_item_values
514
-     * @return stdClass
515
-     * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
516
-     */
517
-    private function _setup_extra_nav_menu_pages_items($menu_item_values)
518
-    {
519
-        $menu_item = new stdClass();
520
-        $keys      = [
521
-            'ID'               => 0,
522
-            'db_id'            => 0,
523
-            'menu_item_parent' => 0,
524
-            'object_id'        => -1,
525
-            'post_parent'      => 0,
526
-            'type'             => 'custom',
527
-            'object'           => '',
528
-            'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
529
-            'title'            => '',
530
-            'url'              => '',
531
-            'target'           => '',
532
-            'attr_title'       => '',
533
-            'description'      => '',
534
-            'classes'          => [],
535
-            'xfn'              => '',
536
-        ];
537
-
538
-        foreach ($keys as $key => $value) {
539
-            $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
540
-        }
541
-        return $menu_item;
542
-    }
543
-
544
-
545
-    /**
546
-     * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
547
-     * EE_Admin_Page route is called.
548
-     *
549
-     * @return void
550
-     */
551
-    public function route_admin_request()
552
-    {
553
-    }
554
-
555
-
556
-    /**
557
-     * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
558
-     *
559
-     * @return void
560
-     */
561
-    public function wp_loaded()
562
-    {
563
-    }
564
-
565
-
566
-    /**
567
-     * admin_init
568
-     *
569
-     * @return void
570
-     * @throws InvalidArgumentException
571
-     * @throws InvalidDataTypeException
572
-     * @throws InvalidInterfaceException
573
-     */
574
-    public function admin_init()
575
-    {
576
-        /**
577
-         * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
578
-         * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
579
-         * - check if doing post processing.
580
-         * - check if doing post processing of one of EE CPTs
581
-         * - instantiate the corresponding EE CPT model for the post_type being processed.
582
-         */
583
-        $action    = $this->request->getRequestParam('action');
584
-        $post_type = $this->request->getRequestParam('post_type');
585
-        if ($post_type && $action === 'editpost') {
586
-            /** @var CustomPostTypeDefinitions $custom_post_types */
587
-            $custom_post_types = $this->loader->getShared(CustomPostTypeDefinitions::class);
588
-            $custom_post_types->getCustomPostTypeModels($post_type);
589
-        }
590
-
591
-
592
-        /**
593
-         * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
594
-         * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
595
-         * Pages" tab in the EE General Settings Admin page.
596
-         * This is for user-proofing.
597
-         */
598
-        add_filter('wp_dropdown_pages', [$this, 'modify_dropdown_pages']);
599
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
600
-            $this->adminInitModelsReady();
601
-        }
602
-    }
603
-
604
-
605
-    /**
606
-     * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode)
607
-     */
608
-    protected function adminInitModelsReady()
609
-    {
610
-        if (function_exists('wp_add_privacy_policy_content')) {
611
-            $this->loader->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager');
612
-        }
613
-    }
614
-
615
-
616
-    /**
617
-     * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
618
-     *
619
-     * @param string $output Current output.
620
-     * @return string
621
-     * @throws InvalidArgumentException
622
-     * @throws InvalidDataTypeException
623
-     * @throws InvalidInterfaceException
624
-     */
625
-    public function modify_dropdown_pages($output)
626
-    {
627
-        // get critical pages
628
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
629
-
630
-        // split current output by line break for easier parsing.
631
-        $split_output = explode("\n", $output);
632
-
633
-        // loop through to remove any critical pages from the array.
634
-        foreach ($critical_pages as $page_id) {
635
-            $needle = 'value="' . $page_id . '"';
636
-            foreach ($split_output as $key => $haystack) {
637
-                if (strpos($haystack, $needle) !== false) {
638
-                    unset($split_output[ $key ]);
639
-                }
640
-            }
641
-        }
642
-        // replace output with the new contents
643
-        return implode("\n", $split_output);
644
-    }
645
-
646
-
647
-    /**
648
-     * enqueue all admin scripts that need loaded for admin pages
649
-     *
650
-     * @return void
651
-     */
652
-    public function enqueue_admin_scripts()
653
-    {
654
-        // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
655
-        // Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
656
-        // calls.
657
-        wp_enqueue_script(
658
-            'ee-inject-wp',
659
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
660
-            ['jquery'],
661
-            EVENT_ESPRESSO_VERSION,
662
-            true
663
-        );
664
-    }
665
-
666
-
667
-    /**
668
-     * display_admin_notices
669
-     *
670
-     * @return void
671
-     */
672
-    public function display_admin_notices()
673
-    {
674
-        echo EE_Error::get_notices(); // already escaped
675
-    }
676
-
677
-
678
-    /**
679
-     * @param array $elements
680
-     * @return array
681
-     * @throws EE_Error
682
-     * @throws InvalidArgumentException
683
-     * @throws InvalidDataTypeException
684
-     * @throws InvalidInterfaceException
685
-     */
686
-    public function dashboard_glance_items($elements)
687
-    {
688
-        $elements                        = is_array($elements) ? $elements : [$elements];
689
-        $events                          = EEM_Event::instance()->count();
690
-        $items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
691
-            ['page' => 'espresso_events'],
692
-            admin_url('admin.php')
693
-        );
694
-        $items['events']['text']         = sprintf(
695
-            esc_html(
696
-                _n('%s Event', '%s Events', $events, 'event_espresso')
697
-            ),
698
-            number_format_i18n($events)
699
-        );
700
-        $items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
701
-        $registrations                   = EEM_Registration::instance()->count(
702
-            [
703
-                [
704
-                    'STS_ID' => ['!=', EEM_Registration::status_id_incomplete],
705
-                ],
706
-            ]
707
-        );
708
-        $items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
709
-            ['page' => 'espresso_registrations'],
710
-            admin_url('admin.php')
711
-        );
712
-        $items['registrations']['text']  = sprintf(
713
-            esc_html(
714
-                _n('%s Registration', '%s Registrations', $registrations, 'event_espresso')
715
-            ),
716
-            number_format_i18n($registrations)
717
-        );
718
-        $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
719
-
720
-        $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
721
-
722
-        foreach ($items as $type => $item_properties) {
723
-            $elements[] = sprintf(
724
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
725
-                $item_properties['url'],
726
-                $item_properties['title'],
727
-                $item_properties['text']
728
-            );
729
-        }
730
-        return $elements;
731
-    }
732
-
733
-
734
-    /**
735
-     * check_for_invalid_datetime_formats
736
-     * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
737
-     * their selected format can be parsed by PHP
738
-     *
739
-     * @param    $value
740
-     * @param    $option
741
-     * @return    string
742
-     */
743
-    public function check_for_invalid_datetime_formats($value, $option)
744
-    {
745
-        // check for date_format or time_format
746
-        switch ($option) {
747
-            case 'date_format':
748
-                $date_time_format = $value . ' ' . get_option('time_format');
749
-                break;
750
-            case 'time_format':
751
-                $date_time_format = get_option('date_format') . ' ' . $value;
752
-                break;
753
-            default:
754
-                $date_time_format = false;
755
-        }
756
-        // do we have a date_time format to check ?
757
-        if ($date_time_format) {
758
-            $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
759
-
760
-            if (is_array($error_msg)) {
761
-                $msg = '<p>'
762
-                       . sprintf(
763
-                           esc_html__(
764
-                               'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
765
-                               'event_espresso'
766
-                           ),
767
-                           date($date_time_format),
768
-                           $date_time_format
769
-                       )
770
-                       . '</p><p><ul>';
771
-
772
-
773
-                foreach ($error_msg as $error) {
774
-                    $msg .= '<li>' . $error . '</li>';
775
-                }
776
-
777
-                $msg .= '</ul></p><p>'
778
-                        . sprintf(
779
-                            esc_html__(
780
-                                '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
781
-                                'event_espresso'
782
-                            ),
783
-                            '<span style="color:#D54E21;">',
784
-                            '</span>'
785
-                        )
786
-                        . '</p>';
787
-
788
-                // trigger WP settings error
789
-                add_settings_error(
790
-                    'date_format',
791
-                    'date_format',
792
-                    $msg
793
-                );
794
-
795
-                // set format to something valid
796
-                switch ($option) {
797
-                    case 'date_format':
798
-                        $value = 'F j, Y';
799
-                        break;
800
-                    case 'time_format':
801
-                        $value = 'g:i a';
802
-                        break;
803
-                }
804
-            }
805
-        }
806
-        return $value;
807
-    }
808
-
809
-
810
-    /**
811
-     * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
812
-     *
813
-     * @param $content
814
-     * @return    string
815
-     */
816
-    public function its_eSpresso($content)
817
-    {
818
-        return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
819
-    }
820
-
821
-
822
-    /**
823
-     * espresso_admin_footer
824
-     *
825
-     * @return    string
826
-     */
827
-    public function espresso_admin_footer()
828
-    {
829
-        return EEH_Template::powered_by_event_espresso('aln-cntr', '', ['utm_content' => 'admin_footer']);
830
-    }
831
-
832
-
833
-    /**
834
-     * static method for registering ee admin page.
835
-     * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
836
-     *
837
-     * @param       $page_basename
838
-     * @param       $page_path
839
-     * @param array $config
840
-     * @return void
841
-     * @throws EE_Error
842
-     * @see        EE_Register_Admin_Page::register()
843
-     * @since      4.3.0
844
-     * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
845
-     */
846
-    public static function register_ee_admin_page($page_basename, $page_path, $config = [])
847
-    {
848
-        EE_Error::doing_it_wrong(
849
-            __METHOD__,
850
-            sprintf(
851
-                esc_html__(
852
-                    'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
853
-                    'event_espresso'
854
-                ),
855
-                $page_basename
856
-            ),
857
-            '4.3'
858
-        );
859
-        if (class_exists('EE_Register_Admin_Page')) {
860
-            $config['page_path'] = $page_path;
861
-        }
862
-        EE_Register_Admin_Page::register($page_basename, $config);
863
-    }
864
-
865
-
866
-    /**
867
-     * @param int     $post_ID
868
-     * @param WP_Post $post
869
-     * @return void
870
-     * @deprecated 4.8.41
871
-     */
872
-    public static function parse_post_content_on_save($post_ID, $post)
873
-    {
874
-        EE_Error::doing_it_wrong(
875
-            __METHOD__,
876
-            esc_html__('Usage is deprecated', 'event_espresso'),
877
-            '4.8.41'
878
-        );
879
-    }
880
-
881
-
882
-    /**
883
-     * @param  $option
884
-     * @param  $old_value
885
-     * @param  $value
886
-     * @return void
887
-     * @deprecated 4.8.41
888
-     */
889
-    public function reset_page_for_posts_on_change($option, $old_value, $value)
890
-    {
891
-        EE_Error::doing_it_wrong(
892
-            __METHOD__,
893
-            esc_html__('Usage is deprecated', 'event_espresso'),
894
-            '4.8.41'
895
-        );
896
-    }
897
-
898
-
899
-    /**
900
-     * @return void
901
-     * @deprecated 4.9.27
902
-     */
903
-    public function get_persistent_admin_notices()
904
-    {
905
-        EE_Error::doing_it_wrong(
906
-            __METHOD__,
907
-            sprintf(
908
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
909
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
910
-            ),
911
-            '4.9.27'
912
-        );
913
-    }
914
-
915
-
916
-    /**
917
-     * @throws InvalidInterfaceException
918
-     * @throws InvalidDataTypeException
919
-     * @throws DomainException
920
-     * @deprecated 4.9.27
921
-     */
922
-    public function dismiss_ee_nag_notice_callback()
923
-    {
924
-        EE_Error::doing_it_wrong(
925
-            __METHOD__,
926
-            sprintf(
927
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
928
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
929
-            ),
930
-            '4.9.27'
931
-        );
932
-        $this->persistent_admin_notice_manager->dismissNotice();
933
-    }
934
-
935
-
936
-    /**
937
-     * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
938
-     *
939
-     * @throws InvalidArgumentException
940
-     * @throws InvalidDataTypeException
941
-     * @throws InvalidInterfaceException
942
-     */
943
-    public function hookIntoWpPluginsPage()
944
-    {
945
-        $this->loader->getShared('EventEspresso\core\domain\services\admin\ExitModal');
946
-        $this->loader
947
-             ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
948
-             ->decafUpsells();
949
-    }
950
-
951
-
952
-    /**
953
-     * Hooks into the "post states" filter in a wp post type list table.
954
-     *
955
-     * @param array   $post_states
956
-     * @param WP_Post $post
957
-     * @return array
958
-     * @throws InvalidArgumentException
959
-     * @throws InvalidDataTypeException
960
-     * @throws InvalidInterfaceException
961
-     */
962
-    public function displayStateForCriticalPages($post_states, $post)
963
-    {
964
-        $post_states = (array) $post_states;
965
-        if (! $post instanceof WP_Post || $post->post_type !== 'page') {
966
-            return $post_states;
967
-        }
968
-        /** @var EE_Core_Config $config */
969
-        $config = $this->loader->getShared('EE_Config')->core;
970
-        if (in_array($post->ID, $config->get_critical_pages_array(), true)) {
971
-            $post_states[] = sprintf(
972
-            /* Translators: Using company name - Event Espresso Critical Page */
973
-                esc_html__('%s Critical Page', 'event_espresso'),
974
-                'Event Espresso'
975
-            );
976
-        }
977
-        return $post_states;
978
-    }
979
-
980
-
981
-    /**
982
-     * Show documentation links on the plugins page
983
-     *
984
-     * @param mixed $meta Plugin Row Meta
985
-     * @param mixed $file Plugin Base file
986
-     * @return array
987
-     */
988
-    public function addLinksToPluginRowMeta($meta, $file)
989
-    {
990
-        if (EE_PLUGIN_BASENAME === $file) {
991
-            $row_meta = [
992
-                'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"'
993
-                          . ' aria-label="'
994
-                          . esc_attr__('View Event Espresso documentation', 'event_espresso')
995
-                          . '">'
996
-                          . esc_html__('Docs', 'event_espresso')
997
-                          . '</a>',
998
-                'api'  => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"'
999
-                          . ' aria-label="'
1000
-                          . esc_attr__('View Event Espresso API docs', 'event_espresso')
1001
-                          . '">'
1002
-                          . esc_html__('API docs', 'event_espresso')
1003
-                          . '</a>',
1004
-            ];
1005
-            return array_merge($meta, $row_meta);
1006
-        }
1007
-        return (array) $meta;
1008
-    }
23
+	/**
24
+	 * @var EE_Admin $_instance
25
+	 */
26
+	private static $_instance;
27
+
28
+	/**
29
+	 * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
30
+	 */
31
+	private $persistent_admin_notice_manager;
32
+
33
+	/**
34
+	 * @var LoaderInterface
35
+	 */
36
+	protected $loader;
37
+
38
+	/**
39
+	 * @var RequestInterface
40
+	 */
41
+	protected $request;
42
+
43
+
44
+	/**
45
+	 * @param RequestInterface $request
46
+	 * @singleton method used to instantiate class object
47
+	 * @return EE_Admin
48
+	 * @throws EE_Error
49
+	 */
50
+	public static function instance(RequestInterface $request = null)
51
+	{
52
+		// check if class object is instantiated
53
+		if (! self::$_instance instanceof EE_Admin) {
54
+			self::$_instance = new self($request);
55
+		}
56
+		return self::$_instance;
57
+	}
58
+
59
+
60
+	/**
61
+	 * @return EE_Admin
62
+	 * @throws EE_Error
63
+	 */
64
+	public static function reset()
65
+	{
66
+		self::$_instance = null;
67
+		$request         = LoaderFactory::getLoader()->getShared(RequestInterface::class);
68
+		return self::instance($request);
69
+	}
70
+
71
+
72
+	/**
73
+	 * @param RequestInterface $request
74
+	 * @throws EE_Error
75
+	 * @throws InvalidDataTypeException
76
+	 * @throws InvalidInterfaceException
77
+	 * @throws InvalidArgumentException
78
+	 */
79
+	protected function __construct(RequestInterface $request)
80
+	{
81
+		$this->request = $request;
82
+		$this->loader = LoaderFactory::getLoader();
83
+		// define global EE_Admin constants
84
+		$this->_define_all_constants();
85
+		// set autoloaders for our admin page classes based on included path information
86
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
87
+		// admin hooks
88
+		add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2);
89
+		add_action('AHEE__EE_System__initialize_last', [$this, 'init']);
90
+		add_action('AHEE__EE_Admin_Page__route_admin_request', [$this, 'route_admin_request'], 100, 2);
91
+		add_action('wp_loaded', [$this, 'wp_loaded'], 100);
92
+		add_action('admin_init', [$this, 'admin_init'], 100);
93
+		add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts'], 20);
94
+		add_action('admin_notices', [$this, 'display_admin_notices'], 10);
95
+		add_action('network_admin_notices', [$this, 'display_admin_notices'], 10);
96
+		add_filter('pre_update_option', [$this, 'check_for_invalid_datetime_formats'], 100, 2);
97
+		add_filter('admin_footer_text', [$this, 'espresso_admin_footer']);
98
+		add_action('load-plugins.php', [$this, 'hookIntoWpPluginsPage']);
99
+		add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2);
100
+		add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2);
101
+		// reset Environment config (we only do this on admin page loads);
102
+		EE_Registry::instance()->CFG->environment->recheck_values();
103
+		do_action('AHEE__EE_Admin__loaded');
104
+	}
105
+
106
+
107
+	/**
108
+	 * _define_all_constants
109
+	 * define constants that are set globally for all admin pages
110
+	 *
111
+	 * @return void
112
+	 */
113
+	private function _define_all_constants()
114
+	{
115
+		if (! defined('EE_ADMIN_URL')) {
116
+			define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
117
+			define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
118
+			define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/');
119
+			define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
120
+			define('WP_AJAX_URL', admin_url('admin-ajax.php'));
121
+		}
122
+	}
123
+
124
+
125
+	/**
126
+	 * filter_plugin_actions - adds links to the Plugins page listing
127
+	 *
128
+	 * @param array  $links
129
+	 * @param string $plugin
130
+	 * @return    array
131
+	 */
132
+	public function filter_plugin_actions($links, $plugin)
133
+	{
134
+		// set $main_file in stone
135
+		static $main_file;
136
+		// if $main_file is not set yet
137
+		if (! $main_file) {
138
+			$main_file = EE_PLUGIN_BASENAME;
139
+		}
140
+		if ($plugin === $main_file) {
141
+			// compare current plugin to this one
142
+			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
143
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
144
+									. ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
145
+									. esc_html__('Maintenance Mode Active', 'event_espresso')
146
+									. '</a>';
147
+				array_unshift($links, $maintenance_link);
148
+			} else {
149
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
150
+									 . esc_html__('Settings', 'event_espresso')
151
+									 . '</a>';
152
+				$events_link       = '<a href="admin.php?page=espresso_events">'
153
+									 . esc_html__('Events', 'event_espresso')
154
+									 . '</a>';
155
+				// add before other links
156
+				array_unshift($links, $org_settings_link, $events_link);
157
+			}
158
+		}
159
+		return $links;
160
+	}
161
+
162
+
163
+	/**
164
+	 * @deprecated 4.10.14.p
165
+	 */
166
+	public function get_request()
167
+	{
168
+	}
169
+
170
+
171
+	/**
172
+	 * hide_admin_pages_except_maintenance_mode
173
+	 *
174
+	 * @param array $admin_page_folder_names
175
+	 * @return array
176
+	 */
177
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = [])
178
+	{
179
+		return [
180
+			'maintenance' => EE_ADMIN_PAGES . 'maintenance/',
181
+			'about'       => EE_ADMIN_PAGES . 'about/',
182
+			'support'     => EE_ADMIN_PAGES . 'support/',
183
+		];
184
+	}
185
+
186
+
187
+	/**
188
+	 * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
189
+	 * EE_Front_Controller's init phases have run
190
+	 *
191
+	 * @return void
192
+	 * @throws EE_Error
193
+	 * @throws InvalidArgumentException
194
+	 * @throws InvalidDataTypeException
195
+	 * @throws InvalidInterfaceException
196
+	 * @throws ReflectionException
197
+	 * @throws ServiceNotFoundException
198
+	 */
199
+	public function init()
200
+	{
201
+		// only enable most of the EE_Admin IF we're not in full maintenance mode
202
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
203
+			$this->initModelsReady();
204
+		}
205
+		// run the admin page factory but ONLY if:
206
+		// - it is a regular non ajax admin request
207
+		// - we are doing an ee admin ajax request
208
+		if ($this->request->isAdmin() || $this->request->isAdminAjax()) {
209
+			// this loads the controller for the admin pages which will setup routing etc
210
+			$this->loader->getShared('EE_Admin_Page_Loader', [$this->loader]);
211
+		}
212
+		if ($this->request->isAdminAjax()) {
213
+			return;
214
+		}
215
+		add_filter('content_save_pre', [$this, 'its_eSpresso'], 10, 1);
216
+		// make sure our CPTs and custom taxonomy metaboxes get shown for first time users
217
+		add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10);
218
+		add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10);
219
+		// exclude EE critical pages from all nav menus and wp_list_pages
220
+		add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu'], 10);
221
+	}
222
+
223
+
224
+	/**
225
+	 * Gets the loader (and if it wasn't previously set, sets it)
226
+	 *
227
+	 * @return LoaderInterface
228
+	 * @throws InvalidArgumentException
229
+	 * @throws InvalidDataTypeException
230
+	 * @throws InvalidInterfaceException
231
+	 */
232
+	protected function getLoader()
233
+	{
234
+		return $this->loader;
235
+	}
236
+
237
+
238
+	/**
239
+	 * Method that's fired on admin requests (including admin ajax) but only when the models are usable
240
+	 * (ie, the site isn't in maintenance mode)
241
+	 *
242
+	 * @return void
243
+	 * @throws EE_Error
244
+	 * @since 4.9.63.p
245
+	 */
246
+	protected function initModelsReady()
247
+	{
248
+		// ok so we want to enable the entire admin
249
+		$this->persistent_admin_notice_manager = $this->loader->getShared(
250
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
251
+		);
252
+		$this->persistent_admin_notice_manager->setReturnUrl(
253
+			EE_Admin_Page::add_query_args_and_nonce(
254
+				[
255
+					'page'   => $this->request->getRequestParam('page'),
256
+					'action' => $this->request->getRequestParam('action'),
257
+				],
258
+				EE_ADMIN_URL
259
+			)
260
+		);
261
+		$this->maybeSetDatetimeWarningNotice();
262
+		// at a glance dashboard widget
263
+		add_filter('dashboard_glance_items', [$this, 'dashboard_glance_items'], 10);
264
+		// filter for get_edit_post_link used on comments for custom post types
265
+		add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 2);
266
+	}
267
+
268
+
269
+	/**
270
+	 *    get_persistent_admin_notices
271
+	 *
272
+	 * @access    public
273
+	 * @return void
274
+	 * @throws EE_Error
275
+	 * @throws InvalidArgumentException
276
+	 * @throws InvalidDataTypeException
277
+	 * @throws InvalidInterfaceException
278
+	 */
279
+	public function maybeSetDatetimeWarningNotice()
280
+	{
281
+		// add dismissible notice for datetime changes.  Only valid if site does not have a timezone_string set.
282
+		// @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
283
+		// with this.  But after enough time (indeterminate at this point) we can just remove this notice.
284
+		// this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
285
+		if (
286
+			apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
287
+			&& ! get_option('timezone_string')
288
+			&& EEM_Event::instance()->count() > 0
289
+		) {
290
+			new PersistentAdminNotice(
291
+				'datetime_fix_notice',
292
+				sprintf(
293
+					esc_html__(
294
+						'%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times.  Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.',
295
+						'event_espresso'
296
+					),
297
+					'<strong>',
298
+					'</strong>',
299
+					'<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
300
+					'</a>',
301
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
302
+						[
303
+							'page'   => 'espresso_maintenance_settings',
304
+							'action' => 'datetime_tools',
305
+						],
306
+						admin_url('admin.php')
307
+					) . '">'
308
+				),
309
+				false,
310
+				'manage_options',
311
+				'datetime_fix_persistent_notice'
312
+			);
313
+		}
314
+	}
315
+
316
+
317
+	/**
318
+	 * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
319
+	 * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
320
+	 * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
321
+	 * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
322
+	 * normal property on the post_type object.  It's found ONLY in this particular context.
323
+	 *
324
+	 * @param WP_Post $post_type WP post type object
325
+	 * @return WP_Post
326
+	 * @throws InvalidArgumentException
327
+	 * @throws InvalidDataTypeException
328
+	 * @throws InvalidInterfaceException
329
+	 */
330
+	public function remove_pages_from_nav_menu($post_type)
331
+	{
332
+		// if this isn't the "pages" post type let's get out
333
+		if ($post_type->name !== 'page') {
334
+			return $post_type;
335
+		}
336
+		$critical_pages            = EE_Registry::instance()->CFG->core->get_critical_pages_array();
337
+		$post_type->_default_query = [
338
+			'post__not_in' => $critical_pages,
339
+		];
340
+		return $post_type;
341
+	}
342
+
343
+
344
+	/**
345
+	 * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
346
+	 * metaboxes get shown as well
347
+	 *
348
+	 * @return void
349
+	 */
350
+	public function enable_hidden_ee_nav_menu_metaboxes()
351
+	{
352
+		global $wp_meta_boxes, $pagenow;
353
+		if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
354
+			return;
355
+		}
356
+		$user = wp_get_current_user();
357
+		// has this been done yet?
358
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
359
+			return;
360
+		}
361
+
362
+		$hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
363
+		$initial_meta_boxes = apply_filters(
364
+			'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
365
+			[
366
+				'nav-menu-theme-locations',
367
+				'add-page',
368
+				'add-custom-links',
369
+				'add-category',
370
+				'add-espresso_events',
371
+				'add-espresso_venues',
372
+				'add-espresso_event_categories',
373
+				'add-espresso_venue_categories',
374
+				'add-post-type-post',
375
+				'add-post-type-page',
376
+			]
377
+		);
378
+
379
+		if (is_array($hidden_meta_boxes)) {
380
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
381
+				if (in_array($meta_box_id, $initial_meta_boxes, true)) {
382
+					unset($hidden_meta_boxes[ $key ]);
383
+				}
384
+			}
385
+		}
386
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
387
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
388
+	}
389
+
390
+
391
+	/**
392
+	 * This method simply registers custom nav menu boxes for "nav_menus.php route"
393
+	 * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
394
+	 *
395
+	 * @return void
396
+	 * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
397
+	 *         addons etc.
398
+	 */
399
+	public function register_custom_nav_menu_boxes()
400
+	{
401
+		add_meta_box(
402
+			'add-extra-nav-menu-pages',
403
+			esc_html__('Event Espresso Pages', 'event_espresso'),
404
+			[$this, 'ee_cpt_archive_pages'],
405
+			'nav-menus',
406
+			'side',
407
+			'core'
408
+		);
409
+	}
410
+
411
+
412
+	/**
413
+	 * Use this to edit the post link for our cpts so that the edit link points to the correct page.
414
+	 *
415
+	 * @param string $link the original link generated by wp
416
+	 * @param int    $id   post id
417
+	 * @return string  the (maybe) modified link
418
+	 * @since   4.3.0
419
+	 */
420
+	public function modify_edit_post_link($link, $id)
421
+	{
422
+		if (! $post = get_post($id)) {
423
+			return $link;
424
+		}
425
+		if ($post->post_type === 'espresso_attendees') {
426
+			$query_args = [
427
+				'action' => 'edit_attendee',
428
+				'post'   => $id,
429
+			];
430
+			return EEH_URL::add_query_args_and_nonce(
431
+				$query_args,
432
+				admin_url('admin.php?page=espresso_registrations')
433
+			);
434
+		}
435
+		return $link;
436
+	}
437
+
438
+
439
+	public function ee_cpt_archive_pages()
440
+	{
441
+		global $nav_menu_selected_id;
442
+		$removed_args = [
443
+			'action',
444
+			'customlink-tab',
445
+			'edit-menu-item',
446
+			'menu-item',
447
+			'page-tab',
448
+			'_wpnonce',
449
+		];
450
+		$nav_tab_link = $nav_menu_selected_id
451
+			? esc_url(
452
+				add_query_arg(
453
+					'extra-nav-menu-pages-tab',
454
+					'event-archives',
455
+					remove_query_arg($removed_args)
456
+				)
457
+			)
458
+			: '';
459
+		$select_all_link = esc_url(
460
+			add_query_arg(
461
+				[
462
+					'extra-nav-menu-pages-tab' => 'event-archives',
463
+					'selectall'                => 1,
464
+				],
465
+				remove_query_arg($removed_args)
466
+			)
467
+		);
468
+		$pages = $this->_get_extra_nav_menu_pages_items();
469
+		$args['walker'] = new Walker_Nav_Menu_Checklist(false);
470
+		;
471
+		$nav_menu_pages_items = walk_nav_menu_tree(
472
+			array_map(
473
+				[$this, '_setup_extra_nav_menu_pages_items'],
474
+				$pages
475
+			),
476
+			0,
477
+			(object) $args
478
+		);
479
+
480
+		EEH_Template::display_template(
481
+			EE_ADMIN_TEMPLATE . 'cpt_archive_page.template.php',
482
+			[
483
+				$nav_menu_pages_items,
484
+				$nav_tab_link,
485
+				$select_all_link,
486
+			]
487
+		);
488
+	}
489
+
490
+
491
+	/**
492
+	 * Returns an array of event archive nav items.
493
+	 *
494
+	 * @return array
495
+	 * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
496
+	 *        method we use for getting the extra nav menu items
497
+	 */
498
+	private function _get_extra_nav_menu_pages_items()
499
+	{
500
+		$menuitems[] = [
501
+			'title'       => esc_html__('Event List', 'event_espresso'),
502
+			'url'         => get_post_type_archive_link('espresso_events'),
503
+			'description' => esc_html__('Archive page for all events.', 'event_espresso'),
504
+		];
505
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
506
+	}
507
+
508
+
509
+	/**
510
+	 * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
511
+	 * the properties and converts it to the menu item object.
512
+	 *
513
+	 * @param $menu_item_values
514
+	 * @return stdClass
515
+	 * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
516
+	 */
517
+	private function _setup_extra_nav_menu_pages_items($menu_item_values)
518
+	{
519
+		$menu_item = new stdClass();
520
+		$keys      = [
521
+			'ID'               => 0,
522
+			'db_id'            => 0,
523
+			'menu_item_parent' => 0,
524
+			'object_id'        => -1,
525
+			'post_parent'      => 0,
526
+			'type'             => 'custom',
527
+			'object'           => '',
528
+			'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
529
+			'title'            => '',
530
+			'url'              => '',
531
+			'target'           => '',
532
+			'attr_title'       => '',
533
+			'description'      => '',
534
+			'classes'          => [],
535
+			'xfn'              => '',
536
+		];
537
+
538
+		foreach ($keys as $key => $value) {
539
+			$menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
540
+		}
541
+		return $menu_item;
542
+	}
543
+
544
+
545
+	/**
546
+	 * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
547
+	 * EE_Admin_Page route is called.
548
+	 *
549
+	 * @return void
550
+	 */
551
+	public function route_admin_request()
552
+	{
553
+	}
554
+
555
+
556
+	/**
557
+	 * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
558
+	 *
559
+	 * @return void
560
+	 */
561
+	public function wp_loaded()
562
+	{
563
+	}
564
+
565
+
566
+	/**
567
+	 * admin_init
568
+	 *
569
+	 * @return void
570
+	 * @throws InvalidArgumentException
571
+	 * @throws InvalidDataTypeException
572
+	 * @throws InvalidInterfaceException
573
+	 */
574
+	public function admin_init()
575
+	{
576
+		/**
577
+		 * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
578
+		 * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
579
+		 * - check if doing post processing.
580
+		 * - check if doing post processing of one of EE CPTs
581
+		 * - instantiate the corresponding EE CPT model for the post_type being processed.
582
+		 */
583
+		$action    = $this->request->getRequestParam('action');
584
+		$post_type = $this->request->getRequestParam('post_type');
585
+		if ($post_type && $action === 'editpost') {
586
+			/** @var CustomPostTypeDefinitions $custom_post_types */
587
+			$custom_post_types = $this->loader->getShared(CustomPostTypeDefinitions::class);
588
+			$custom_post_types->getCustomPostTypeModels($post_type);
589
+		}
590
+
591
+
592
+		/**
593
+		 * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
594
+		 * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
595
+		 * Pages" tab in the EE General Settings Admin page.
596
+		 * This is for user-proofing.
597
+		 */
598
+		add_filter('wp_dropdown_pages', [$this, 'modify_dropdown_pages']);
599
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
600
+			$this->adminInitModelsReady();
601
+		}
602
+	}
603
+
604
+
605
+	/**
606
+	 * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode)
607
+	 */
608
+	protected function adminInitModelsReady()
609
+	{
610
+		if (function_exists('wp_add_privacy_policy_content')) {
611
+			$this->loader->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager');
612
+		}
613
+	}
614
+
615
+
616
+	/**
617
+	 * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
618
+	 *
619
+	 * @param string $output Current output.
620
+	 * @return string
621
+	 * @throws InvalidArgumentException
622
+	 * @throws InvalidDataTypeException
623
+	 * @throws InvalidInterfaceException
624
+	 */
625
+	public function modify_dropdown_pages($output)
626
+	{
627
+		// get critical pages
628
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
629
+
630
+		// split current output by line break for easier parsing.
631
+		$split_output = explode("\n", $output);
632
+
633
+		// loop through to remove any critical pages from the array.
634
+		foreach ($critical_pages as $page_id) {
635
+			$needle = 'value="' . $page_id . '"';
636
+			foreach ($split_output as $key => $haystack) {
637
+				if (strpos($haystack, $needle) !== false) {
638
+					unset($split_output[ $key ]);
639
+				}
640
+			}
641
+		}
642
+		// replace output with the new contents
643
+		return implode("\n", $split_output);
644
+	}
645
+
646
+
647
+	/**
648
+	 * enqueue all admin scripts that need loaded for admin pages
649
+	 *
650
+	 * @return void
651
+	 */
652
+	public function enqueue_admin_scripts()
653
+	{
654
+		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
655
+		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
656
+		// calls.
657
+		wp_enqueue_script(
658
+			'ee-inject-wp',
659
+			EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
660
+			['jquery'],
661
+			EVENT_ESPRESSO_VERSION,
662
+			true
663
+		);
664
+	}
665
+
666
+
667
+	/**
668
+	 * display_admin_notices
669
+	 *
670
+	 * @return void
671
+	 */
672
+	public function display_admin_notices()
673
+	{
674
+		echo EE_Error::get_notices(); // already escaped
675
+	}
676
+
677
+
678
+	/**
679
+	 * @param array $elements
680
+	 * @return array
681
+	 * @throws EE_Error
682
+	 * @throws InvalidArgumentException
683
+	 * @throws InvalidDataTypeException
684
+	 * @throws InvalidInterfaceException
685
+	 */
686
+	public function dashboard_glance_items($elements)
687
+	{
688
+		$elements                        = is_array($elements) ? $elements : [$elements];
689
+		$events                          = EEM_Event::instance()->count();
690
+		$items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
691
+			['page' => 'espresso_events'],
692
+			admin_url('admin.php')
693
+		);
694
+		$items['events']['text']         = sprintf(
695
+			esc_html(
696
+				_n('%s Event', '%s Events', $events, 'event_espresso')
697
+			),
698
+			number_format_i18n($events)
699
+		);
700
+		$items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
701
+		$registrations                   = EEM_Registration::instance()->count(
702
+			[
703
+				[
704
+					'STS_ID' => ['!=', EEM_Registration::status_id_incomplete],
705
+				],
706
+			]
707
+		);
708
+		$items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
709
+			['page' => 'espresso_registrations'],
710
+			admin_url('admin.php')
711
+		);
712
+		$items['registrations']['text']  = sprintf(
713
+			esc_html(
714
+				_n('%s Registration', '%s Registrations', $registrations, 'event_espresso')
715
+			),
716
+			number_format_i18n($registrations)
717
+		);
718
+		$items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
719
+
720
+		$items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
721
+
722
+		foreach ($items as $type => $item_properties) {
723
+			$elements[] = sprintf(
724
+				'<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
725
+				$item_properties['url'],
726
+				$item_properties['title'],
727
+				$item_properties['text']
728
+			);
729
+		}
730
+		return $elements;
731
+	}
732
+
733
+
734
+	/**
735
+	 * check_for_invalid_datetime_formats
736
+	 * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
737
+	 * their selected format can be parsed by PHP
738
+	 *
739
+	 * @param    $value
740
+	 * @param    $option
741
+	 * @return    string
742
+	 */
743
+	public function check_for_invalid_datetime_formats($value, $option)
744
+	{
745
+		// check for date_format or time_format
746
+		switch ($option) {
747
+			case 'date_format':
748
+				$date_time_format = $value . ' ' . get_option('time_format');
749
+				break;
750
+			case 'time_format':
751
+				$date_time_format = get_option('date_format') . ' ' . $value;
752
+				break;
753
+			default:
754
+				$date_time_format = false;
755
+		}
756
+		// do we have a date_time format to check ?
757
+		if ($date_time_format) {
758
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
759
+
760
+			if (is_array($error_msg)) {
761
+				$msg = '<p>'
762
+					   . sprintf(
763
+						   esc_html__(
764
+							   'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
765
+							   'event_espresso'
766
+						   ),
767
+						   date($date_time_format),
768
+						   $date_time_format
769
+					   )
770
+					   . '</p><p><ul>';
771
+
772
+
773
+				foreach ($error_msg as $error) {
774
+					$msg .= '<li>' . $error . '</li>';
775
+				}
776
+
777
+				$msg .= '</ul></p><p>'
778
+						. sprintf(
779
+							esc_html__(
780
+								'%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
781
+								'event_espresso'
782
+							),
783
+							'<span style="color:#D54E21;">',
784
+							'</span>'
785
+						)
786
+						. '</p>';
787
+
788
+				// trigger WP settings error
789
+				add_settings_error(
790
+					'date_format',
791
+					'date_format',
792
+					$msg
793
+				);
794
+
795
+				// set format to something valid
796
+				switch ($option) {
797
+					case 'date_format':
798
+						$value = 'F j, Y';
799
+						break;
800
+					case 'time_format':
801
+						$value = 'g:i a';
802
+						break;
803
+				}
804
+			}
805
+		}
806
+		return $value;
807
+	}
808
+
809
+
810
+	/**
811
+	 * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
812
+	 *
813
+	 * @param $content
814
+	 * @return    string
815
+	 */
816
+	public function its_eSpresso($content)
817
+	{
818
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
819
+	}
820
+
821
+
822
+	/**
823
+	 * espresso_admin_footer
824
+	 *
825
+	 * @return    string
826
+	 */
827
+	public function espresso_admin_footer()
828
+	{
829
+		return EEH_Template::powered_by_event_espresso('aln-cntr', '', ['utm_content' => 'admin_footer']);
830
+	}
831
+
832
+
833
+	/**
834
+	 * static method for registering ee admin page.
835
+	 * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
836
+	 *
837
+	 * @param       $page_basename
838
+	 * @param       $page_path
839
+	 * @param array $config
840
+	 * @return void
841
+	 * @throws EE_Error
842
+	 * @see        EE_Register_Admin_Page::register()
843
+	 * @since      4.3.0
844
+	 * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
845
+	 */
846
+	public static function register_ee_admin_page($page_basename, $page_path, $config = [])
847
+	{
848
+		EE_Error::doing_it_wrong(
849
+			__METHOD__,
850
+			sprintf(
851
+				esc_html__(
852
+					'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
853
+					'event_espresso'
854
+				),
855
+				$page_basename
856
+			),
857
+			'4.3'
858
+		);
859
+		if (class_exists('EE_Register_Admin_Page')) {
860
+			$config['page_path'] = $page_path;
861
+		}
862
+		EE_Register_Admin_Page::register($page_basename, $config);
863
+	}
864
+
865
+
866
+	/**
867
+	 * @param int     $post_ID
868
+	 * @param WP_Post $post
869
+	 * @return void
870
+	 * @deprecated 4.8.41
871
+	 */
872
+	public static function parse_post_content_on_save($post_ID, $post)
873
+	{
874
+		EE_Error::doing_it_wrong(
875
+			__METHOD__,
876
+			esc_html__('Usage is deprecated', 'event_espresso'),
877
+			'4.8.41'
878
+		);
879
+	}
880
+
881
+
882
+	/**
883
+	 * @param  $option
884
+	 * @param  $old_value
885
+	 * @param  $value
886
+	 * @return void
887
+	 * @deprecated 4.8.41
888
+	 */
889
+	public function reset_page_for_posts_on_change($option, $old_value, $value)
890
+	{
891
+		EE_Error::doing_it_wrong(
892
+			__METHOD__,
893
+			esc_html__('Usage is deprecated', 'event_espresso'),
894
+			'4.8.41'
895
+		);
896
+	}
897
+
898
+
899
+	/**
900
+	 * @return void
901
+	 * @deprecated 4.9.27
902
+	 */
903
+	public function get_persistent_admin_notices()
904
+	{
905
+		EE_Error::doing_it_wrong(
906
+			__METHOD__,
907
+			sprintf(
908
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
909
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
910
+			),
911
+			'4.9.27'
912
+		);
913
+	}
914
+
915
+
916
+	/**
917
+	 * @throws InvalidInterfaceException
918
+	 * @throws InvalidDataTypeException
919
+	 * @throws DomainException
920
+	 * @deprecated 4.9.27
921
+	 */
922
+	public function dismiss_ee_nag_notice_callback()
923
+	{
924
+		EE_Error::doing_it_wrong(
925
+			__METHOD__,
926
+			sprintf(
927
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
928
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
929
+			),
930
+			'4.9.27'
931
+		);
932
+		$this->persistent_admin_notice_manager->dismissNotice();
933
+	}
934
+
935
+
936
+	/**
937
+	 * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
938
+	 *
939
+	 * @throws InvalidArgumentException
940
+	 * @throws InvalidDataTypeException
941
+	 * @throws InvalidInterfaceException
942
+	 */
943
+	public function hookIntoWpPluginsPage()
944
+	{
945
+		$this->loader->getShared('EventEspresso\core\domain\services\admin\ExitModal');
946
+		$this->loader
947
+			 ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
948
+			 ->decafUpsells();
949
+	}
950
+
951
+
952
+	/**
953
+	 * Hooks into the "post states" filter in a wp post type list table.
954
+	 *
955
+	 * @param array   $post_states
956
+	 * @param WP_Post $post
957
+	 * @return array
958
+	 * @throws InvalidArgumentException
959
+	 * @throws InvalidDataTypeException
960
+	 * @throws InvalidInterfaceException
961
+	 */
962
+	public function displayStateForCriticalPages($post_states, $post)
963
+	{
964
+		$post_states = (array) $post_states;
965
+		if (! $post instanceof WP_Post || $post->post_type !== 'page') {
966
+			return $post_states;
967
+		}
968
+		/** @var EE_Core_Config $config */
969
+		$config = $this->loader->getShared('EE_Config')->core;
970
+		if (in_array($post->ID, $config->get_critical_pages_array(), true)) {
971
+			$post_states[] = sprintf(
972
+			/* Translators: Using company name - Event Espresso Critical Page */
973
+				esc_html__('%s Critical Page', 'event_espresso'),
974
+				'Event Espresso'
975
+			);
976
+		}
977
+		return $post_states;
978
+	}
979
+
980
+
981
+	/**
982
+	 * Show documentation links on the plugins page
983
+	 *
984
+	 * @param mixed $meta Plugin Row Meta
985
+	 * @param mixed $file Plugin Base file
986
+	 * @return array
987
+	 */
988
+	public function addLinksToPluginRowMeta($meta, $file)
989
+	{
990
+		if (EE_PLUGIN_BASENAME === $file) {
991
+			$row_meta = [
992
+				'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"'
993
+						  . ' aria-label="'
994
+						  . esc_attr__('View Event Espresso documentation', 'event_espresso')
995
+						  . '">'
996
+						  . esc_html__('Docs', 'event_espresso')
997
+						  . '</a>',
998
+				'api'  => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"'
999
+						  . ' aria-label="'
1000
+						  . esc_attr__('View Event Espresso API docs', 'event_espresso')
1001
+						  . '">'
1002
+						  . esc_html__('API docs', 'event_espresso')
1003
+						  . '</a>',
1004
+			];
1005
+			return array_merge($meta, $row_meta);
1006
+		}
1007
+		return (array) $meta;
1008
+	}
1009 1009
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public static function instance(RequestInterface $request = null)
51 51
     {
52 52
         // check if class object is instantiated
53
-        if (! self::$_instance instanceof EE_Admin) {
53
+        if ( ! self::$_instance instanceof EE_Admin) {
54 54
             self::$_instance = new self($request);
55 55
         }
56 56
         return self::$_instance;
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
      */
113 113
     private function _define_all_constants()
114 114
     {
115
-        if (! defined('EE_ADMIN_URL')) {
116
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
117
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
118
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/');
119
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
115
+        if ( ! defined('EE_ADMIN_URL')) {
116
+            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/');
117
+            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/');
118
+            define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates/');
119
+            define('WP_ADMIN_PATH', ABSPATH.'wp-admin/');
120 120
             define('WP_AJAX_URL', admin_url('admin-ajax.php'));
121 121
         }
122 122
     }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         // set $main_file in stone
135 135
         static $main_file;
136 136
         // if $main_file is not set yet
137
-        if (! $main_file) {
137
+        if ( ! $main_file) {
138 138
             $main_file = EE_PLUGIN_BASENAME;
139 139
         }
140 140
         if ($plugin === $main_file) {
@@ -177,9 +177,9 @@  discard block
 block discarded – undo
177 177
     public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = [])
178 178
     {
179 179
         return [
180
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance/',
181
-            'about'       => EE_ADMIN_PAGES . 'about/',
182
-            'support'     => EE_ADMIN_PAGES . 'support/',
180
+            'maintenance' => EE_ADMIN_PAGES.'maintenance/',
181
+            'about'       => EE_ADMIN_PAGES.'about/',
182
+            'support'     => EE_ADMIN_PAGES.'support/',
183 183
         ];
184 184
     }
185 185
 
@@ -298,13 +298,13 @@  discard block
 block discarded – undo
298 298
                     '</strong>',
299 299
                     '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
300 300
                     '</a>',
301
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
301
+                    '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
302 302
                         [
303 303
                             'page'   => 'espresso_maintenance_settings',
304 304
                             'action' => 'datetime_tools',
305 305
                         ],
306 306
                         admin_url('admin.php')
307
-                    ) . '">'
307
+                    ).'">'
308 308
                 ),
309 309
                 false,
310 310
                 'manage_options',
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     public function enable_hidden_ee_nav_menu_metaboxes()
351 351
     {
352 352
         global $wp_meta_boxes, $pagenow;
353
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
353
+        if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
354 354
             return;
355 355
         }
356 356
         $user = wp_get_current_user();
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
         if (is_array($hidden_meta_boxes)) {
380 380
             foreach ($hidden_meta_boxes as $key => $meta_box_id) {
381 381
                 if (in_array($meta_box_id, $initial_meta_boxes, true)) {
382
-                    unset($hidden_meta_boxes[ $key ]);
382
+                    unset($hidden_meta_boxes[$key]);
383 383
                 }
384 384
             }
385 385
         }
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
      */
420 420
     public function modify_edit_post_link($link, $id)
421 421
     {
422
-        if (! $post = get_post($id)) {
422
+        if ( ! $post = get_post($id)) {
423 423
             return $link;
424 424
         }
425 425
         if ($post->post_type === 'espresso_attendees') {
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
         );
479 479
 
480 480
         EEH_Template::display_template(
481
-            EE_ADMIN_TEMPLATE . 'cpt_archive_page.template.php',
481
+            EE_ADMIN_TEMPLATE.'cpt_archive_page.template.php',
482 482
             [
483 483
                 $nav_menu_pages_items,
484 484
                 $nav_tab_link,
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
         ];
537 537
 
538 538
         foreach ($keys as $key => $value) {
539
-            $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
539
+            $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
540 540
         }
541 541
         return $menu_item;
542 542
     }
@@ -632,10 +632,10 @@  discard block
 block discarded – undo
632 632
 
633 633
         // loop through to remove any critical pages from the array.
634 634
         foreach ($critical_pages as $page_id) {
635
-            $needle = 'value="' . $page_id . '"';
635
+            $needle = 'value="'.$page_id.'"';
636 636
             foreach ($split_output as $key => $haystack) {
637 637
                 if (strpos($haystack, $needle) !== false) {
638
-                    unset($split_output[ $key ]);
638
+                    unset($split_output[$key]);
639 639
                 }
640 640
             }
641 641
         }
@@ -656,7 +656,7 @@  discard block
 block discarded – undo
656 656
         // calls.
657 657
         wp_enqueue_script(
658 658
             'ee-inject-wp',
659
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
659
+            EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js',
660 660
             ['jquery'],
661 661
             EVENT_ESPRESSO_VERSION,
662 662
             true
@@ -691,7 +691,7 @@  discard block
 block discarded – undo
691 691
             ['page' => 'espresso_events'],
692 692
             admin_url('admin.php')
693 693
         );
694
-        $items['events']['text']         = sprintf(
694
+        $items['events']['text'] = sprintf(
695 695
             esc_html(
696 696
                 _n('%s Event', '%s Events', $events, 'event_espresso')
697 697
             ),
@@ -705,11 +705,11 @@  discard block
 block discarded – undo
705 705
                 ],
706 706
             ]
707 707
         );
708
-        $items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
708
+        $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(
709 709
             ['page' => 'espresso_registrations'],
710 710
             admin_url('admin.php')
711 711
         );
712
-        $items['registrations']['text']  = sprintf(
712
+        $items['registrations']['text'] = sprintf(
713 713
             esc_html(
714 714
                 _n('%s Registration', '%s Registrations', $registrations, 'event_espresso')
715 715
             ),
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 
722 722
         foreach ($items as $type => $item_properties) {
723 723
             $elements[] = sprintf(
724
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
724
+                '<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>',
725 725
                 $item_properties['url'],
726 726
                 $item_properties['title'],
727 727
                 $item_properties['text']
@@ -745,10 +745,10 @@  discard block
 block discarded – undo
745 745
         // check for date_format or time_format
746 746
         switch ($option) {
747 747
             case 'date_format':
748
-                $date_time_format = $value . ' ' . get_option('time_format');
748
+                $date_time_format = $value.' '.get_option('time_format');
749 749
                 break;
750 750
             case 'time_format':
751
-                $date_time_format = get_option('date_format') . ' ' . $value;
751
+                $date_time_format = get_option('date_format').' '.$value;
752 752
                 break;
753 753
             default:
754 754
                 $date_time_format = false;
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 
772 772
 
773 773
                 foreach ($error_msg as $error) {
774
-                    $msg .= '<li>' . $error . '</li>';
774
+                    $msg .= '<li>'.$error.'</li>';
775 775
                 }
776 776
 
777 777
                 $msg .= '</ul></p><p>'
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
     public function displayStateForCriticalPages($post_states, $post)
963 963
     {
964 964
         $post_states = (array) $post_states;
965
-        if (! $post instanceof WP_Post || $post->post_type !== 'page') {
965
+        if ( ! $post instanceof WP_Post || $post->post_type !== 'page') {
966 966
             return $post_states;
967 967
         }
968 968
         /** @var EE_Core_Config $config */
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +4104 added lines, -4104 removed lines patch added patch discarded remove patch
@@ -18,4180 +18,4180 @@
 block discarded – undo
18 18
  */
19 19
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
20 20
 {
21
-    /**
22
-     * @var LoaderInterface
23
-     */
24
-    protected $loader;
21
+	/**
22
+	 * @var LoaderInterface
23
+	 */
24
+	protected $loader;
25 25
 
26
-    /**
27
-     * @var RequestInterface
28
-     */
29
-    protected $request;
26
+	/**
27
+	 * @var RequestInterface
28
+	 */
29
+	protected $request;
30 30
 
31
-    // set in _init_page_props()
32
-    public $page_slug;
31
+	// set in _init_page_props()
32
+	public $page_slug;
33 33
 
34
-    public $page_label;
34
+	public $page_label;
35 35
 
36
-    public $page_folder;
36
+	public $page_folder;
37 37
 
38
-    // set in define_page_props()
39
-    protected $_admin_base_url;
38
+	// set in define_page_props()
39
+	protected $_admin_base_url;
40 40
 
41
-    protected $_admin_base_path;
41
+	protected $_admin_base_path;
42 42
 
43
-    protected $_admin_page_title;
43
+	protected $_admin_page_title;
44 44
 
45
-    protected $_labels;
45
+	protected $_labels;
46 46
 
47 47
 
48
-    // set early within EE_Admin_Init
49
-    protected $_wp_page_slug;
48
+	// set early within EE_Admin_Init
49
+	protected $_wp_page_slug;
50 50
 
51
-    // navtabs
52
-    protected $_nav_tabs;
51
+	// navtabs
52
+	protected $_nav_tabs;
53 53
 
54
-    protected $_default_nav_tab_name;
54
+	protected $_default_nav_tab_name;
55 55
 
56 56
 
57
-    // template variables (used by templates)
58
-    protected $_template_path;
57
+	// template variables (used by templates)
58
+	protected $_template_path;
59 59
 
60
-    protected $_column_template_path;
60
+	protected $_column_template_path;
61 61
 
62
-    /**
63
-     * @var array $_template_args
64
-     */
65
-    protected $_template_args = [];
62
+	/**
63
+	 * @var array $_template_args
64
+	 */
65
+	protected $_template_args = [];
66 66
 
67
-    /**
68
-     * this will hold the list table object for a given view.
69
-     *
70
-     * @var EE_Admin_List_Table $_list_table_object
71
-     */
72
-    protected $_list_table_object;
67
+	/**
68
+	 * this will hold the list table object for a given view.
69
+	 *
70
+	 * @var EE_Admin_List_Table $_list_table_object
71
+	 */
72
+	protected $_list_table_object;
73 73
 
74
-    // bools
75
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
74
+	// bools
75
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
76 76
 
77
-    protected $_routing;
77
+	protected $_routing;
78 78
 
79
-    // list table args
80
-    protected $_view;
79
+	// list table args
80
+	protected $_view;
81 81
 
82
-    protected $_views;
82
+	protected $_views;
83 83
 
84 84
 
85
-    // action => method pairs used for routing incoming requests
86
-    protected $_page_routes;
85
+	// action => method pairs used for routing incoming requests
86
+	protected $_page_routes;
87 87
 
88
-    /**
89
-     * @var array $_page_config
90
-     */
91
-    protected $_page_config;
88
+	/**
89
+	 * @var array $_page_config
90
+	 */
91
+	protected $_page_config;
92 92
 
93
-    /**
94
-     * the current page route and route config
95
-     *
96
-     * @var string $_route
97
-     */
98
-    protected $_route;
93
+	/**
94
+	 * the current page route and route config
95
+	 *
96
+	 * @var string $_route
97
+	 */
98
+	protected $_route;
99 99
 
100
-    /**
101
-     * @var string $_cpt_route
102
-     */
103
-    protected $_cpt_route;
100
+	/**
101
+	 * @var string $_cpt_route
102
+	 */
103
+	protected $_cpt_route;
104 104
 
105
-    /**
106
-     * @var array $_route_config
107
-     */
108
-    protected $_route_config;
105
+	/**
106
+	 * @var array $_route_config
107
+	 */
108
+	protected $_route_config;
109 109
 
110
-    /**
111
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
112
-     * actions.
113
-     *
114
-     * @since 4.6.x
115
-     * @var array.
116
-     */
117
-    protected $_default_route_query_args;
118
-
119
-    // set via request page and action args.
120
-    protected $_current_page;
121
-
122
-    protected $_current_view;
123
-
124
-    protected $_current_page_view_url;
125
-
126
-    /**
127
-     * unprocessed value for the 'action' request param (default '')
128
-     *
129
-     * @var string
130
-     */
131
-    protected $raw_req_action = '';
132
-
133
-    /**
134
-     * unprocessed value for the 'page' request param (default '')
135
-     *
136
-     * @var string
137
-     */
138
-    protected $raw_req_page = '';
139
-
140
-    /**
141
-     * sanitized request action (and nonce)
142
-     *
143
-     * @var string
144
-     */
145
-    protected $_req_action = '';
146
-
147
-    /**
148
-     * sanitized request action nonce
149
-     *
150
-     * @var string
151
-     */
152
-    protected $_req_nonce = '';
153
-
154
-    /**
155
-     * @var string
156
-     */
157
-    protected $_search_btn_label = '';
158
-
159
-    /**
160
-     * @var string
161
-     */
162
-    protected $_search_box_callback = '';
163
-
164
-    /**
165
-     * @var WP_Screen
166
-     */
167
-    protected $_current_screen;
168
-
169
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
170
-    protected $_hook_obj;
171
-
172
-    // for holding incoming request data
173
-    protected $_req_data = [];
174
-
175
-    // yes / no array for admin form fields
176
-    protected $_yes_no_values = [];
177
-
178
-    // some default things shared by all child classes
179
-    protected $_default_espresso_metaboxes;
180
-
181
-    /**
182
-     * @var EE_Registry
183
-     */
184
-    protected $EE = null;
185
-
186
-
187
-    /**
188
-     * This is just a property that flags whether the given route is a caffeinated route or not.
189
-     *
190
-     * @var boolean
191
-     */
192
-    protected $_is_caf = false;
193
-
194
-
195
-    /**
196
-     * @Constructor
197
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
198
-     * @throws EE_Error
199
-     * @throws InvalidArgumentException
200
-     * @throws ReflectionException
201
-     * @throws InvalidDataTypeException
202
-     * @throws InvalidInterfaceException
203
-     */
204
-    public function __construct($routing = true)
205
-    {
206
-        $this->loader  = LoaderFactory::getLoader();
207
-        $this->request = $this->loader->getShared(RequestInterface::class);
208
-        $this->_routing = $routing;
209
-
210
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
211
-            $this->_is_caf = true;
212
-        }
213
-        $this->_yes_no_values = [
214
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
215
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
216
-        ];
217
-        // set the _req_data property.
218
-        $this->_req_data = $this->request->requestParams();
219
-        // set initial page props (child method)
220
-        $this->_init_page_props();
221
-        // set global defaults
222
-        $this->_set_defaults();
223
-        // set early because incoming requests could be ajax related and we need to register those hooks.
224
-        $this->_global_ajax_hooks();
225
-        $this->_ajax_hooks();
226
-        // other_page_hooks have to be early too.
227
-        $this->_do_other_page_hooks();
228
-        // set up page dependencies
229
-        $this->_before_page_setup();
230
-        $this->_page_setup();
231
-        // die();
232
-    }
233
-
234
-
235
-    /**
236
-     * _init_page_props
237
-     * Child classes use to set at least the following properties:
238
-     * $page_slug.
239
-     * $page_label.
240
-     *
241
-     * @abstract
242
-     * @return void
243
-     */
244
-    abstract protected function _init_page_props();
245
-
246
-
247
-    /**
248
-     * _ajax_hooks
249
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
250
-     * Note: within the ajax callback methods.
251
-     *
252
-     * @abstract
253
-     * @return void
254
-     */
255
-    abstract protected function _ajax_hooks();
256
-
257
-
258
-    /**
259
-     * _define_page_props
260
-     * child classes define page properties in here.  Must include at least:
261
-     * $_admin_base_url = base_url for all admin pages
262
-     * $_admin_page_title = default admin_page_title for admin pages
263
-     * $_labels = array of default labels for various automatically generated elements:
264
-     *    array(
265
-     *        'buttons' => array(
266
-     *            'add' => esc_html__('label for add new button'),
267
-     *            'edit' => esc_html__('label for edit button'),
268
-     *            'delete' => esc_html__('label for delete button')
269
-     *            )
270
-     *        )
271
-     *
272
-     * @abstract
273
-     * @return void
274
-     */
275
-    abstract protected function _define_page_props();
276
-
277
-
278
-    /**
279
-     * _set_page_routes
280
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
281
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
282
-     * have a 'default' route. Here's the format
283
-     * $this->_page_routes = array(
284
-     *        'default' => array(
285
-     *            'func' => '_default_method_handling_route',
286
-     *            'args' => array('array','of','args'),
287
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
288
-     *            ajax request, backend processing)
289
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
290
-     *            headers route after.  The string you enter here should match the defined route reference for a
291
-     *            headers sent route.
292
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
293
-     *            this route.
294
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
295
-     *            checks).
296
-     *        ),
297
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
298
-     *        handling method.
299
-     *        )
300
-     * )
301
-     *
302
-     * @abstract
303
-     * @return void
304
-     */
305
-    abstract protected function _set_page_routes();
306
-
307
-
308
-    /**
309
-     * _set_page_config
310
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
311
-     * array corresponds to the page_route for the loaded page. Format:
312
-     * $this->_page_config = array(
313
-     *        'default' => array(
314
-     *            'labels' => array(
315
-     *                'buttons' => array(
316
-     *                    'add' => esc_html__('label for adding item'),
317
-     *                    'edit' => esc_html__('label for editing item'),
318
-     *                    'delete' => esc_html__('label for deleting item')
319
-     *                ),
320
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
321
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
322
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
323
-     *            _define_page_props() method
324
-     *            'nav' => array(
325
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
326
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
327
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
328
-     *                'order' => 10, //required to indicate tab position.
329
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
330
-     *                displayed then add this parameter.
331
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
332
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
333
-     *            metaboxes set for eventespresso admin pages.
334
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
335
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
336
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
337
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
338
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
339
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
340
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
341
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
342
-     *            want to display.
343
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
344
-     *                'tab_id' => array(
345
-     *                    'title' => 'tab_title',
346
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
347
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
348
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
349
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
350
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
351
-     *                    attempt to use the callback which should match the name of a method in the class
352
-     *                    ),
353
-     *                'tab2_id' => array(
354
-     *                    'title' => 'tab2 title',
355
-     *                    'filename' => 'file_name_2'
356
-     *                    'callback' => 'callback_method_for_content',
357
-     *                 ),
358
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
359
-     *            help tab area on an admin page. @return void
360
-     *
361
-     * @abstract
362
-     */
363
-    abstract protected function _set_page_config();
364
-
365
-
366
-    /**
367
-     * _add_screen_options
368
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
369
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
370
-     * to a particular view.
371
-     *
372
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
373
-     *         see also WP_Screen object documents...
374
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
375
-     * @abstract
376
-     * @return void
377
-     */
378
-    abstract protected function _add_screen_options();
379
-
380
-
381
-    /**
382
-     * _add_feature_pointers
383
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
384
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
385
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
386
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
387
-     * extended) also see:
388
-     *
389
-     * @link   http://eamann.com/tech/wordpress-portland/
390
-     * @abstract
391
-     * @return void
392
-     */
393
-    abstract protected function _add_feature_pointers();
394
-
395
-
396
-    /**
397
-     * load_scripts_styles
398
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
399
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
400
-     * scripts/styles per view by putting them in a dynamic function in this format
401
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
402
-     *
403
-     * @abstract
404
-     * @return void
405
-     */
406
-    abstract public function load_scripts_styles();
407
-
408
-
409
-    /**
410
-     * admin_init
411
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
412
-     * all pages/views loaded by child class.
413
-     *
414
-     * @abstract
415
-     * @return void
416
-     */
417
-    abstract public function admin_init();
418
-
419
-
420
-    /**
421
-     * admin_notices
422
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
423
-     * all pages/views loaded by child class.
424
-     *
425
-     * @abstract
426
-     * @return void
427
-     */
428
-    abstract public function admin_notices();
429
-
430
-
431
-    /**
432
-     * admin_footer_scripts
433
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
434
-     * will apply to all pages/views loaded by child class.
435
-     *
436
-     * @return void
437
-     */
438
-    abstract public function admin_footer_scripts();
439
-
440
-
441
-    /**
442
-     * admin_footer
443
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
444
-     * apply to all pages/views loaded by child class.
445
-     *
446
-     * @return void
447
-     */
448
-    public function admin_footer()
449
-    {
450
-    }
451
-
452
-
453
-    /**
454
-     * _global_ajax_hooks
455
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
456
-     * Note: within the ajax callback methods.
457
-     *
458
-     * @abstract
459
-     * @return void
460
-     */
461
-    protected function _global_ajax_hooks()
462
-    {
463
-        // for lazy loading of metabox content
464
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
465
-    }
466
-
467
-
468
-    public function ajax_metabox_content()
469
-    {
470
-        $content_id  = $this->request->getRequestParam('contentid', '');
471
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
472
-        self::cached_rss_display($content_id, $content_url);
473
-        wp_die();
474
-    }
475
-
476
-
477
-    /**
478
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
479
-     *
480
-     * @return void
481
-     */
482
-    protected function _before_page_setup()
483
-    {
484
-        // default is to do nothing
485
-    }
486
-
487
-
488
-    /**
489
-     * Makes sure any things that need to be loaded early get handled.
490
-     * We also escape early here if the page requested doesn't match the object.
491
-     *
492
-     * @final
493
-     * @return void
494
-     * @throws EE_Error
495
-     * @throws InvalidArgumentException
496
-     * @throws ReflectionException
497
-     * @throws InvalidDataTypeException
498
-     * @throws InvalidInterfaceException
499
-     */
500
-    final protected function _page_setup()
501
-    {
502
-        // requires?
503
-        // admin_init stuff - global - we're setting this REALLY early
504
-        // so if EE_Admin pages have to hook into other WP pages they can.
505
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
506
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
507
-        // next verify if we need to load anything...
508
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
509
-        $this->_current_page = $this->request->getRequestParam('current_page', $this->_current_page, 'key');
510
-
511
-        $this->page_folder   = strtolower(
512
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
513
-        );
514
-        global $ee_menu_slugs;
515
-        $ee_menu_slugs = (array) $ee_menu_slugs;
516
-        if (
517
-            ! $this->request->isAjax()
518
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
519
-        ) {
520
-            return;
521
-        }
522
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
523
-        // we need to copy the action from the second to the first
524
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
525
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
526
-        $action     = $action !== '-1' ? $action : $action2;
527
-        $req_action = $action !== '-1' ? $action : 'default';
528
-
529
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
530
-        // then let's use the route as the action.
531
-        // This covers cases where we're coming in from a list table that isn't on the default route.
532
-        $route = $this->request->getRequestParam('route');
533
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
534
-            ? $route
535
-            : $req_action;
536
-
537
-        $this->_current_view = $this->_req_action;
538
-        $this->_req_nonce    = $this->_req_action . '_nonce';
539
-        $this->_define_page_props();
540
-        $this->_current_page_view_url = add_query_arg(
541
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
542
-            $this->_admin_base_url
543
-        );
544
-        // default things
545
-        $this->_default_espresso_metaboxes = [
546
-            '_espresso_news_post_box',
547
-            '_espresso_links_post_box',
548
-            '_espresso_ratings_request',
549
-            '_espresso_sponsors_post_box',
550
-        ];
551
-        // set page configs
552
-        $this->_set_page_routes();
553
-        $this->_set_page_config();
554
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
555
-        if ($this->request->requestParamIsSet('wp_referer')) {
556
-            $wp_referer = $this->request->getRequestParam('wp_referer');
557
-            if ($wp_referer) {
558
-                $this->_default_route_query_args['wp_referer'] = $wp_referer;
559
-            }
560
-        }
561
-        // for caffeinated and other extended functionality.
562
-        //  If there is a _extend_page_config method
563
-        // then let's run that to modify the all the various page configuration arrays
564
-        if (method_exists($this, '_extend_page_config')) {
565
-            $this->_extend_page_config();
566
-        }
567
-        // for CPT and other extended functionality.
568
-        // If there is an _extend_page_config_for_cpt
569
-        // then let's run that to modify all the various page configuration arrays.
570
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
571
-            $this->_extend_page_config_for_cpt();
572
-        }
573
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
574
-        $this->_page_routes = apply_filters(
575
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
576
-            $this->_page_routes,
577
-            $this
578
-        );
579
-        $this->_page_config = apply_filters(
580
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
581
-            $this->_page_config,
582
-            $this
583
-        );
584
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
585
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
586
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
587
-            add_action(
588
-                'AHEE__EE_Admin_Page__route_admin_request',
589
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
590
-                10,
591
-                2
592
-            );
593
-        }
594
-        // next route only if routing enabled
595
-        if ($this->_routing && ! $this->request->isAjax()) {
596
-            $this->_verify_routes();
597
-            // next let's just check user_access and kill if no access
598
-            $this->check_user_access();
599
-            if ($this->_is_UI_request) {
600
-                // admin_init stuff - global, all views for this page class, specific view
601
-                add_action('admin_init', [$this, 'admin_init'], 10);
602
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
603
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
604
-                }
605
-            } else {
606
-                // hijack regular WP loading and route admin request immediately
607
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
608
-                $this->route_admin_request();
609
-            }
610
-        }
611
-    }
612
-
613
-
614
-    /**
615
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
616
-     *
617
-     * @return void
618
-     * @throws EE_Error
619
-     */
620
-    private function _do_other_page_hooks()
621
-    {
622
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
623
-        foreach ($registered_pages as $page) {
624
-            // now let's setup the file name and class that should be present
625
-            $classname = str_replace('.class.php', '', $page);
626
-            // autoloaders should take care of loading file
627
-            if (! class_exists($classname)) {
628
-                $error_msg[] = sprintf(
629
-                    esc_html__(
630
-                        'Something went wrong with loading the %s admin hooks page.',
631
-                        'event_espresso'
632
-                    ),
633
-                    $page
634
-                );
635
-                $error_msg[] = $error_msg[0]
636
-                               . "\r\n"
637
-                               . sprintf(
638
-                                   esc_html__(
639
-                                       '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',
640
-                                       'event_espresso'
641
-                                   ),
642
-                                   $page,
643
-                                   '<br />',
644
-                                   '<strong>' . $classname . '</strong>'
645
-                               );
646
-                throw new EE_Error(implode('||', $error_msg));
647
-            }
648
-            // notice we are passing the instance of this class to the hook object.
649
-            $this->loader->getShared($classname, [$this]);
650
-        }
651
-    }
652
-
653
-
654
-    /**
655
-     * @throws ReflectionException
656
-     * @throws EE_Error
657
-     */
658
-    public function load_page_dependencies()
659
-    {
660
-        try {
661
-            $this->_load_page_dependencies();
662
-        } catch (EE_Error $e) {
663
-            $e->get_error();
664
-        }
665
-    }
666
-
667
-
668
-    /**
669
-     * load_page_dependencies
670
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
671
-     *
672
-     * @return void
673
-     * @throws DomainException
674
-     * @throws EE_Error
675
-     * @throws InvalidArgumentException
676
-     * @throws InvalidDataTypeException
677
-     * @throws InvalidInterfaceException
678
-     */
679
-    protected function _load_page_dependencies()
680
-    {
681
-        // let's set the current_screen and screen options to override what WP set
682
-        $this->_current_screen = get_current_screen();
683
-        // load admin_notices - global, page class, and view specific
684
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
685
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
686
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
687
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
688
-        }
689
-        // load network admin_notices - global, page class, and view specific
690
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
691
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
692
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
693
-        }
694
-        // this will save any per_page screen options if they are present
695
-        $this->_set_per_page_screen_options();
696
-        // setup list table properties
697
-        $this->_set_list_table();
698
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
699
-        // However in some cases the metaboxes will need to be added within a route handling callback.
700
-        $this->_add_registered_meta_boxes();
701
-        $this->_add_screen_columns();
702
-        // add screen options - global, page child class, and view specific
703
-        $this->_add_global_screen_options();
704
-        $this->_add_screen_options();
705
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
706
-        if (method_exists($this, $add_screen_options)) {
707
-            $this->{$add_screen_options}();
708
-        }
709
-        // add help tab(s) - set via page_config and qtips.
710
-        $this->_add_help_tabs();
711
-        $this->_add_qtips();
712
-        // add feature_pointers - global, page child class, and view specific
713
-        $this->_add_feature_pointers();
714
-        $this->_add_global_feature_pointers();
715
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
716
-        if (method_exists($this, $add_feature_pointer)) {
717
-            $this->{$add_feature_pointer}();
718
-        }
719
-        // enqueue scripts/styles - global, page class, and view specific
720
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
721
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
722
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
723
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
724
-        }
725
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
726
-        // admin_print_footer_scripts - global, page child class, and view specific.
727
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
728
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
729
-        // is a good use case. Notice the late priority we're giving these
730
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
731
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
732
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
733
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
734
-        }
735
-        // admin footer scripts
736
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
737
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
738
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
739
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
740
-        }
741
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
742
-        // targeted hook
743
-        do_action(
744
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
745
-        );
746
-    }
747
-
748
-
749
-    /**
750
-     * _set_defaults
751
-     * This sets some global defaults for class properties.
752
-     */
753
-    private function _set_defaults()
754
-    {
755
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
756
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
757
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
758
-        $this->_page_config          = $this->_default_route_query_args = [];
759
-        $this->_default_nav_tab_name = 'overview';
760
-        // init template args
761
-        $this->_template_args = [
762
-            'admin_page_header'  => '',
763
-            'admin_page_content' => '',
764
-            'post_body_content'  => '',
765
-            'before_list_table'  => '',
766
-            'after_list_table'   => '',
767
-        ];
768
-    }
769
-
770
-
771
-    /**
772
-     * route_admin_request
773
-     *
774
-     * @return void
775
-     * @throws InvalidArgumentException
776
-     * @throws InvalidInterfaceException
777
-     * @throws InvalidDataTypeException
778
-     * @throws EE_Error
779
-     * @throws ReflectionException
780
-     * @see    _route_admin_request()
781
-     */
782
-    public function route_admin_request()
783
-    {
784
-        try {
785
-            $this->_route_admin_request();
786
-        } catch (EE_Error $e) {
787
-            $e->get_error();
788
-        }
789
-    }
790
-
791
-
792
-    public function set_wp_page_slug($wp_page_slug)
793
-    {
794
-        $this->_wp_page_slug = $wp_page_slug;
795
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
796
-        if (is_network_admin()) {
797
-            $this->_wp_page_slug .= '-network';
798
-        }
799
-    }
800
-
801
-
802
-    /**
803
-     * _verify_routes
804
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
805
-     * we know if we need to drop out.
806
-     *
807
-     * @return bool
808
-     * @throws EE_Error
809
-     */
810
-    protected function _verify_routes()
811
-    {
812
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
813
-        if (! $this->_current_page && ! $this->request->isAjax()) {
814
-            return false;
815
-        }
816
-        $this->_route = false;
817
-        // check that the page_routes array is not empty
818
-        if (empty($this->_page_routes)) {
819
-            // user error msg
820
-            $error_msg = sprintf(
821
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
822
-                $this->_admin_page_title
823
-            );
824
-            // developer error msg
825
-            $error_msg .= '||' . $error_msg
826
-                          . esc_html__(
827
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
828
-                              'event_espresso'
829
-                          );
830
-            throw new EE_Error($error_msg);
831
-        }
832
-        // and that the requested page route exists
833
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
834
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
835
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
836
-                ? $this->_page_config[ $this->_req_action ]
837
-                : [];
838
-        } else {
839
-            // user error msg
840
-            $error_msg = sprintf(
841
-                esc_html__(
842
-                    'The requested page route does not exist for the %s admin page.',
843
-                    'event_espresso'
844
-                ),
845
-                $this->_admin_page_title
846
-            );
847
-            // developer error msg
848
-            $error_msg .= '||' . $error_msg
849
-                          . sprintf(
850
-                              esc_html__(
851
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
852
-                                  'event_espresso'
853
-                              ),
854
-                              $this->_req_action
855
-                          );
856
-            throw new EE_Error($error_msg);
857
-        }
858
-        // and that a default route exists
859
-        if (! array_key_exists('default', $this->_page_routes)) {
860
-            // user error msg
861
-            $error_msg = sprintf(
862
-                esc_html__(
863
-                    'A default page route has not been set for the % admin page.',
864
-                    'event_espresso'
865
-                ),
866
-                $this->_admin_page_title
867
-            );
868
-            // developer error msg
869
-            $error_msg .= '||' . $error_msg
870
-                          . esc_html__(
871
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
872
-                              'event_espresso'
873
-                          );
874
-            throw new EE_Error($error_msg);
875
-        }
876
-        // first lets' catch if the UI request has EVER been set.
877
-        if ($this->_is_UI_request === null) {
878
-            // lets set if this is a UI request or not.
879
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
880
-            // wait a minute... we might have a noheader in the route array
881
-            $this->_is_UI_request = ! (
882
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
883
-            )
884
-                ? $this->_is_UI_request
885
-                : false;
886
-        }
887
-        $this->_set_current_labels();
888
-        return true;
889
-    }
890
-
891
-
892
-    /**
893
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
894
-     *
895
-     * @param string $route the route name we're verifying
896
-     * @return bool we'll throw an exception if this isn't a valid route.
897
-     * @throws EE_Error
898
-     */
899
-    protected function _verify_route($route)
900
-    {
901
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
902
-            return true;
903
-        }
904
-        // user error msg
905
-        $error_msg = sprintf(
906
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
907
-            $this->_admin_page_title
908
-        );
909
-        // developer error msg
910
-        $error_msg .= '||' . $error_msg
911
-                      . sprintf(
912
-                          esc_html__(
913
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
914
-                              'event_espresso'
915
-                          ),
916
-                          $route
917
-                      );
918
-        throw new EE_Error($error_msg);
919
-    }
920
-
921
-
922
-    /**
923
-     * perform nonce verification
924
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
925
-     * using this method (and save retyping!)
926
-     *
927
-     * @param string $nonce     The nonce sent
928
-     * @param string $nonce_ref The nonce reference string (name0)
929
-     * @return void
930
-     * @throws EE_Error
931
-     */
932
-    protected function _verify_nonce($nonce, $nonce_ref)
933
-    {
934
-        // verify nonce against expected value
935
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
936
-            // these are not the droids you are looking for !!!
937
-            $msg = sprintf(
938
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
939
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
940
-                '</a>'
941
-            );
942
-            if (WP_DEBUG) {
943
-                $msg .= "\n  ";
944
-                $msg .= sprintf(
945
-                    esc_html__(
946
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
947
-                        'event_espresso'
948
-                    ),
949
-                    __CLASS__
950
-                );
951
-            }
952
-            if (! $this->request->isAjax()) {
953
-                wp_die($msg);
954
-            }
955
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
956
-            $this->_return_json();
957
-        }
958
-    }
959
-
960
-
961
-    /**
962
-     * _route_admin_request()
963
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
964
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
965
-     * in the page routes and then will try to load the corresponding method.
966
-     *
967
-     * @return void
968
-     * @throws EE_Error
969
-     * @throws InvalidArgumentException
970
-     * @throws InvalidDataTypeException
971
-     * @throws InvalidInterfaceException
972
-     * @throws ReflectionException
973
-     */
974
-    protected function _route_admin_request()
975
-    {
976
-        if (! $this->_is_UI_request) {
977
-            $this->_verify_routes();
978
-        }
979
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
980
-        if ($this->_req_action !== 'default' && $nonce_check) {
981
-            // set nonce from post data
982
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
983
-            $this->_verify_nonce($nonce, $this->_req_nonce);
984
-        }
985
-        // set the nav_tabs array but ONLY if this is  UI_request
986
-        if ($this->_is_UI_request) {
987
-            $this->_set_nav_tabs();
988
-        }
989
-        // grab callback function
990
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
991
-        // check if callback has args
992
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
993
-        $error_msg = '';
994
-        // action right before calling route
995
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
996
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
997
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
998
-        }
999
-        // right before calling the route, let's clean the _wp_http_referer
1000
-        $this->request->unSetRequestParam('_wp_http_referer');
1001
-        $this->request->unSetServerParam('_wp_http_referer');
1002
-        $cleaner_request_uri = remove_query_arg(
1003
-            '_wp_http_referer',
1004
-            wp_unslash($this->request->getServerParam('REQUEST_URI'))
1005
-        );
1006
-        $this->request->setRequestParam('_wp_http_referer', $cleaner_request_uri);
1007
-        $this->request->setServerParam('REQUEST_URI', $cleaner_request_uri);
1008
-        if (! empty($func)) {
1009
-            if (is_array($func)) {
1010
-                [$class, $method] = $func;
1011
-            } elseif (strpos($func, '::') !== false) {
1012
-                [$class, $method] = explode('::', $func);
1013
-            } else {
1014
-                $class  = $this;
1015
-                $method = $func;
1016
-            }
1017
-            if (! (is_object($class) && $class === $this)) {
1018
-                // send along this admin page object for access by addons.
1019
-                $args['admin_page_object'] = $this;
1020
-            }
1021
-            if (
1022
-                // is it a method on a class that doesn't work?
1023
-                (
1024
-                    (
1025
-                        method_exists($class, $method)
1026
-                        && call_user_func_array([$class, $method], $args) === false
1027
-                    )
1028
-                    && (
1029
-                        // is it a standalone function that doesn't work?
1030
-                        function_exists($method)
1031
-                        && call_user_func_array(
1032
-                            $func,
1033
-                            array_merge(['admin_page_object' => $this], $args)
1034
-                        ) === false
1035
-                    )
1036
-                )
1037
-                || (
1038
-                    // is it neither a class method NOR a standalone function?
1039
-                    ! method_exists($class, $method)
1040
-                    && ! function_exists($method)
1041
-                )
1042
-            ) {
1043
-                // user error msg
1044
-                $error_msg = esc_html__(
1045
-                    'An error occurred. The  requested page route could not be found.',
1046
-                    'event_espresso'
1047
-                );
1048
-                // developer error msg
1049
-                $error_msg .= '||';
1050
-                $error_msg .= sprintf(
1051
-                    esc_html__(
1052
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1053
-                        'event_espresso'
1054
-                    ),
1055
-                    $method
1056
-                );
1057
-            }
1058
-            if (! empty($error_msg)) {
1059
-                throw new EE_Error($error_msg);
1060
-            }
1061
-        }
1062
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1063
-        // then we need to reset the routing properties to the new route.
1064
-        // 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.
1065
-        if (
1066
-            $this->_is_UI_request === false
1067
-            && is_array($this->_route)
1068
-            && ! empty($this->_route['headers_sent_route'])
1069
-        ) {
1070
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1071
-        }
1072
-    }
1073
-
1074
-
1075
-    /**
1076
-     * This method just allows the resetting of page properties in the case where a no headers
1077
-     * route redirects to a headers route in its route config.
1078
-     *
1079
-     * @param string $new_route New (non header) route to redirect to.
1080
-     * @return   void
1081
-     * @throws ReflectionException
1082
-     * @throws InvalidArgumentException
1083
-     * @throws InvalidInterfaceException
1084
-     * @throws InvalidDataTypeException
1085
-     * @throws EE_Error
1086
-     * @since   4.3.0
1087
-     */
1088
-    protected function _reset_routing_properties($new_route)
1089
-    {
1090
-        $this->_is_UI_request = true;
1091
-        // now we set the current route to whatever the headers_sent_route is set at
1092
-        $this->request->setRequestParam('action', $new_route);
1093
-        // rerun page setup
1094
-        $this->_page_setup();
1095
-    }
1096
-
1097
-
1098
-    /**
1099
-     * _add_query_arg
1100
-     * adds nonce to array of arguments then calls WP add_query_arg function
1101
-     *(internally just uses EEH_URL's function with the same name)
1102
-     *
1103
-     * @param array  $args
1104
-     * @param string $url
1105
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1106
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1107
-     *                                        Example usage: If the current page is:
1108
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1109
-     *                                        &action=default&event_id=20&month_range=March%202015
1110
-     *                                        &_wpnonce=5467821
1111
-     *                                        and you call:
1112
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1113
-     *                                        array(
1114
-     *                                        'action' => 'resend_something',
1115
-     *                                        'page=>espresso_registrations'
1116
-     *                                        ),
1117
-     *                                        $some_url,
1118
-     *                                        true
1119
-     *                                        );
1120
-     *                                        It will produce a url in this structure:
1121
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1122
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1123
-     *                                        month_range]=March%202015
1124
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1125
-     * @return string
1126
-     */
1127
-    public static function add_query_args_and_nonce(
1128
-        $args = [],
1129
-        $url = false,
1130
-        $sticky = false,
1131
-        $exclude_nonce = false
1132
-    ) {
1133
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1134
-        if ($sticky) {
1135
-            /** @var RequestInterface $request */
1136
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1137
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer'], true);
1138
-            foreach ($request->requestParams() as $key => $value) {
1139
-                // do not add nonces
1140
-                if (strpos($key, 'nonce') !== false) {
1141
-                    continue;
1142
-                }
1143
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1144
-            }
1145
-        }
1146
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1147
-    }
1148
-
1149
-
1150
-    /**
1151
-     * This returns a generated link that will load the related help tab.
1152
-     *
1153
-     * @param string $help_tab_id the id for the connected help tab
1154
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1155
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1156
-     * @return string              generated link
1157
-     * @uses EEH_Template::get_help_tab_link()
1158
-     */
1159
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1160
-    {
1161
-        return EEH_Template::get_help_tab_link(
1162
-            $help_tab_id,
1163
-            $this->page_slug,
1164
-            $this->_req_action,
1165
-            $icon_style,
1166
-            $help_text
1167
-        );
1168
-    }
1169
-
1170
-
1171
-    /**
1172
-     * _add_help_tabs
1173
-     * Note child classes define their help tabs within the page_config array.
1174
-     *
1175
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1176
-     * @return void
1177
-     * @throws DomainException
1178
-     * @throws EE_Error
1179
-     */
1180
-    protected function _add_help_tabs()
1181
-    {
1182
-        if (isset($this->_page_config[ $this->_req_action ])) {
1183
-            $config = $this->_page_config[ $this->_req_action ];
1184
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1185
-            if (is_array($config) && isset($config['help_sidebar'])) {
1186
-                // check that the callback given is valid
1187
-                if (! method_exists($this, $config['help_sidebar'])) {
1188
-                    throw new EE_Error(
1189
-                        sprintf(
1190
-                            esc_html__(
1191
-                                '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',
1192
-                                'event_espresso'
1193
-                            ),
1194
-                            $config['help_sidebar'],
1195
-                            get_class($this)
1196
-                        )
1197
-                    );
1198
-                }
1199
-                $content = apply_filters(
1200
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1201
-                    $this->{$config['help_sidebar']}()
1202
-                );
1203
-                $this->_current_screen->set_help_sidebar($content);
1204
-            }
1205
-            if (! isset($config['help_tabs'])) {
1206
-                return;
1207
-            } //no help tabs for this route
1208
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1209
-                // we're here so there ARE help tabs!
1210
-                // make sure we've got what we need
1211
-                if (! isset($cfg['title'])) {
1212
-                    throw new EE_Error(
1213
-                        esc_html__(
1214
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1215
-                            'event_espresso'
1216
-                        )
1217
-                    );
1218
-                }
1219
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1220
-                    throw new EE_Error(
1221
-                        esc_html__(
1222
-                            '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',
1223
-                            'event_espresso'
1224
-                        )
1225
-                    );
1226
-                }
1227
-                // first priority goes to content.
1228
-                if (! empty($cfg['content'])) {
1229
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1230
-                    // second priority goes to filename
1231
-                } elseif (! empty($cfg['filename'])) {
1232
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1233
-                    // 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)
1234
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1235
-                                                             . basename($this->_get_dir())
1236
-                                                             . '/help_tabs/'
1237
-                                                             . $cfg['filename']
1238
-                                                             . '.help_tab.php' : $file_path;
1239
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1240
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1241
-                        EE_Error::add_error(
1242
-                            sprintf(
1243
-                                esc_html__(
1244
-                                    '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',
1245
-                                    'event_espresso'
1246
-                                ),
1247
-                                $tab_id,
1248
-                                key($config),
1249
-                                $file_path
1250
-                            ),
1251
-                            __FILE__,
1252
-                            __FUNCTION__,
1253
-                            __LINE__
1254
-                        );
1255
-                        return;
1256
-                    }
1257
-                    $template_args['admin_page_obj'] = $this;
1258
-                    $content                         = EEH_Template::display_template(
1259
-                        $file_path,
1260
-                        $template_args,
1261
-                        true
1262
-                    );
1263
-                } else {
1264
-                    $content = '';
1265
-                }
1266
-                // check if callback is valid
1267
-                if (
1268
-                    empty($content)
1269
-                    && (
1270
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1271
-                    )
1272
-                ) {
1273
-                    EE_Error::add_error(
1274
-                        sprintf(
1275
-                            esc_html__(
1276
-                                '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.',
1277
-                                'event_espresso'
1278
-                            ),
1279
-                            $cfg['title']
1280
-                        ),
1281
-                        __FILE__,
1282
-                        __FUNCTION__,
1283
-                        __LINE__
1284
-                    );
1285
-                    return;
1286
-                }
1287
-                // setup config array for help tab method
1288
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1289
-                $_ht = [
1290
-                    'id'       => $id,
1291
-                    'title'    => $cfg['title'],
1292
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1293
-                    'content'  => $content,
1294
-                ];
1295
-                $this->_current_screen->add_help_tab($_ht);
1296
-            }
1297
-        }
1298
-    }
1299
-
1300
-
1301
-    /**
1302
-     * This simply sets up any qtips that have been defined in the page config
1303
-     *
1304
-     * @return void
1305
-     */
1306
-    protected function _add_qtips()
1307
-    {
1308
-        if (isset($this->_route_config['qtips'])) {
1309
-            $qtips = (array) $this->_route_config['qtips'];
1310
-            // load qtip loader
1311
-            $path = [
1312
-                $this->_get_dir() . '/qtips/',
1313
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1314
-            ];
1315
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1316
-        }
1317
-    }
1318
-
1319
-
1320
-    /**
1321
-     * _set_nav_tabs
1322
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1323
-     * wish to add additional tabs or modify accordingly.
1324
-     *
1325
-     * @return void
1326
-     * @throws InvalidArgumentException
1327
-     * @throws InvalidInterfaceException
1328
-     * @throws InvalidDataTypeException
1329
-     */
1330
-    protected function _set_nav_tabs()
1331
-    {
1332
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1333
-        $i = 0;
1334
-        foreach ($this->_page_config as $slug => $config) {
1335
-            if (! is_array($config) || empty($config['nav'])) {
1336
-                continue;
1337
-            }
1338
-            // no nav tab for this config
1339
-            // check for persistent flag
1340
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1341
-                // nav tab is only to appear when route requested.
1342
-                continue;
1343
-            }
1344
-            if (! $this->check_user_access($slug, true)) {
1345
-                // no nav tab because current user does not have access.
1346
-                continue;
1347
-            }
1348
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1349
-            $this->_nav_tabs[ $slug ] = [
1350
-                'url'       => isset($config['nav']['url'])
1351
-                    ? $config['nav']['url']
1352
-                    : self::add_query_args_and_nonce(
1353
-                        ['action' => $slug],
1354
-                        $this->_admin_base_url
1355
-                    ),
1356
-                'link_text' => isset($config['nav']['label'])
1357
-                    ? $config['nav']['label']
1358
-                    : ucwords(
1359
-                        str_replace('_', ' ', $slug)
1360
-                    ),
1361
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1362
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1363
-            ];
1364
-            $i++;
1365
-        }
1366
-        // if $this->_nav_tabs is empty then lets set the default
1367
-        if (empty($this->_nav_tabs)) {
1368
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1369
-                'url'       => $this->_admin_base_url,
1370
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1371
-                'css_class' => 'nav-tab-active',
1372
-                'order'     => 10,
1373
-            ];
1374
-        }
1375
-        // now let's sort the tabs according to order
1376
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1377
-    }
1378
-
1379
-
1380
-    /**
1381
-     * _set_current_labels
1382
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1383
-     * property array
1384
-     *
1385
-     * @return void
1386
-     */
1387
-    private function _set_current_labels()
1388
-    {
1389
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1390
-            foreach ($this->_route_config['labels'] as $label => $text) {
1391
-                if (is_array($text)) {
1392
-                    foreach ($text as $sublabel => $subtext) {
1393
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1394
-                    }
1395
-                } else {
1396
-                    $this->_labels[ $label ] = $text;
1397
-                }
1398
-            }
1399
-        }
1400
-    }
1401
-
1402
-
1403
-    /**
1404
-     *        verifies user access for this admin page
1405
-     *
1406
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1407
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1408
-     *                               return false if verify fail.
1409
-     * @return bool
1410
-     * @throws InvalidArgumentException
1411
-     * @throws InvalidDataTypeException
1412
-     * @throws InvalidInterfaceException
1413
-     */
1414
-    public function check_user_access($route_to_check = '', $verify_only = false)
1415
-    {
1416
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1417
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1418
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1419
-                          && is_array(
1420
-                              $this->_page_routes[ $route_to_check ]
1421
-                          )
1422
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1423
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1424
-        if (empty($capability) && empty($route_to_check)) {
1425
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1426
-                : $this->_route['capability'];
1427
-        } else {
1428
-            $capability = empty($capability) ? 'manage_options' : $capability;
1429
-        }
1430
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1431
-        if (
1432
-            ! $this->request->isAjax()
1433
-            && (
1434
-                ! function_exists('is_admin')
1435
-                || ! EE_Registry::instance()->CAP->current_user_can(
1436
-                    $capability,
1437
-                    $this->page_slug
1438
-                    . '_'
1439
-                    . $route_to_check,
1440
-                    $id
1441
-                )
1442
-            )
1443
-        ) {
1444
-            if ($verify_only) {
1445
-                return false;
1446
-            }
1447
-            if (is_user_logged_in()) {
1448
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1449
-            } else {
1450
-                return false;
1451
-            }
1452
-        }
1453
-        return true;
1454
-    }
1455
-
1456
-
1457
-    /**
1458
-     * admin_init_global
1459
-     * This runs all the code that we want executed within the WP admin_init hook.
1460
-     * This method executes for ALL EE Admin pages.
1461
-     *
1462
-     * @return void
1463
-     */
1464
-    public function admin_init_global()
1465
-    {
1466
-    }
1467
-
1468
-
1469
-    /**
1470
-     * wp_loaded_global
1471
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1472
-     * EE_Admin page and will execute on every EE Admin Page load
1473
-     *
1474
-     * @return void
1475
-     */
1476
-    public function wp_loaded()
1477
-    {
1478
-    }
1479
-
1480
-
1481
-    /**
1482
-     * admin_notices
1483
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1484
-     * ALL EE_Admin pages.
1485
-     *
1486
-     * @return void
1487
-     */
1488
-    public function admin_notices_global()
1489
-    {
1490
-        $this->_display_no_javascript_warning();
1491
-        $this->_display_espresso_notices();
1492
-    }
1493
-
1494
-
1495
-    public function network_admin_notices_global()
1496
-    {
1497
-        $this->_display_no_javascript_warning();
1498
-        $this->_display_espresso_notices();
1499
-    }
1500
-
1501
-
1502
-    /**
1503
-     * admin_footer_scripts_global
1504
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1505
-     * will apply on ALL EE_Admin pages.
1506
-     *
1507
-     * @return void
1508
-     */
1509
-    public function admin_footer_scripts_global()
1510
-    {
1511
-        $this->_add_admin_page_ajax_loading_img();
1512
-        $this->_add_admin_page_overlay();
1513
-        // if metaboxes are present we need to add the nonce field
1514
-        if (
1515
-            isset($this->_route_config['metaboxes'])
1516
-            || isset($this->_route_config['list_table'])
1517
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1518
-        ) {
1519
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1520
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1521
-        }
1522
-    }
1523
-
1524
-
1525
-    /**
1526
-     * admin_footer_global
1527
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1528
-     * ALL EE_Admin Pages.
1529
-     *
1530
-     * @return void
1531
-     */
1532
-    public function admin_footer_global()
1533
-    {
1534
-        // dialog container for dialog helper
1535
-        echo '
110
+	/**
111
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
112
+	 * actions.
113
+	 *
114
+	 * @since 4.6.x
115
+	 * @var array.
116
+	 */
117
+	protected $_default_route_query_args;
118
+
119
+	// set via request page and action args.
120
+	protected $_current_page;
121
+
122
+	protected $_current_view;
123
+
124
+	protected $_current_page_view_url;
125
+
126
+	/**
127
+	 * unprocessed value for the 'action' request param (default '')
128
+	 *
129
+	 * @var string
130
+	 */
131
+	protected $raw_req_action = '';
132
+
133
+	/**
134
+	 * unprocessed value for the 'page' request param (default '')
135
+	 *
136
+	 * @var string
137
+	 */
138
+	protected $raw_req_page = '';
139
+
140
+	/**
141
+	 * sanitized request action (and nonce)
142
+	 *
143
+	 * @var string
144
+	 */
145
+	protected $_req_action = '';
146
+
147
+	/**
148
+	 * sanitized request action nonce
149
+	 *
150
+	 * @var string
151
+	 */
152
+	protected $_req_nonce = '';
153
+
154
+	/**
155
+	 * @var string
156
+	 */
157
+	protected $_search_btn_label = '';
158
+
159
+	/**
160
+	 * @var string
161
+	 */
162
+	protected $_search_box_callback = '';
163
+
164
+	/**
165
+	 * @var WP_Screen
166
+	 */
167
+	protected $_current_screen;
168
+
169
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
170
+	protected $_hook_obj;
171
+
172
+	// for holding incoming request data
173
+	protected $_req_data = [];
174
+
175
+	// yes / no array for admin form fields
176
+	protected $_yes_no_values = [];
177
+
178
+	// some default things shared by all child classes
179
+	protected $_default_espresso_metaboxes;
180
+
181
+	/**
182
+	 * @var EE_Registry
183
+	 */
184
+	protected $EE = null;
185
+
186
+
187
+	/**
188
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
189
+	 *
190
+	 * @var boolean
191
+	 */
192
+	protected $_is_caf = false;
193
+
194
+
195
+	/**
196
+	 * @Constructor
197
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
198
+	 * @throws EE_Error
199
+	 * @throws InvalidArgumentException
200
+	 * @throws ReflectionException
201
+	 * @throws InvalidDataTypeException
202
+	 * @throws InvalidInterfaceException
203
+	 */
204
+	public function __construct($routing = true)
205
+	{
206
+		$this->loader  = LoaderFactory::getLoader();
207
+		$this->request = $this->loader->getShared(RequestInterface::class);
208
+		$this->_routing = $routing;
209
+
210
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
211
+			$this->_is_caf = true;
212
+		}
213
+		$this->_yes_no_values = [
214
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
215
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
216
+		];
217
+		// set the _req_data property.
218
+		$this->_req_data = $this->request->requestParams();
219
+		// set initial page props (child method)
220
+		$this->_init_page_props();
221
+		// set global defaults
222
+		$this->_set_defaults();
223
+		// set early because incoming requests could be ajax related and we need to register those hooks.
224
+		$this->_global_ajax_hooks();
225
+		$this->_ajax_hooks();
226
+		// other_page_hooks have to be early too.
227
+		$this->_do_other_page_hooks();
228
+		// set up page dependencies
229
+		$this->_before_page_setup();
230
+		$this->_page_setup();
231
+		// die();
232
+	}
233
+
234
+
235
+	/**
236
+	 * _init_page_props
237
+	 * Child classes use to set at least the following properties:
238
+	 * $page_slug.
239
+	 * $page_label.
240
+	 *
241
+	 * @abstract
242
+	 * @return void
243
+	 */
244
+	abstract protected function _init_page_props();
245
+
246
+
247
+	/**
248
+	 * _ajax_hooks
249
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
250
+	 * Note: within the ajax callback methods.
251
+	 *
252
+	 * @abstract
253
+	 * @return void
254
+	 */
255
+	abstract protected function _ajax_hooks();
256
+
257
+
258
+	/**
259
+	 * _define_page_props
260
+	 * child classes define page properties in here.  Must include at least:
261
+	 * $_admin_base_url = base_url for all admin pages
262
+	 * $_admin_page_title = default admin_page_title for admin pages
263
+	 * $_labels = array of default labels for various automatically generated elements:
264
+	 *    array(
265
+	 *        'buttons' => array(
266
+	 *            'add' => esc_html__('label for add new button'),
267
+	 *            'edit' => esc_html__('label for edit button'),
268
+	 *            'delete' => esc_html__('label for delete button')
269
+	 *            )
270
+	 *        )
271
+	 *
272
+	 * @abstract
273
+	 * @return void
274
+	 */
275
+	abstract protected function _define_page_props();
276
+
277
+
278
+	/**
279
+	 * _set_page_routes
280
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
281
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
282
+	 * have a 'default' route. Here's the format
283
+	 * $this->_page_routes = array(
284
+	 *        'default' => array(
285
+	 *            'func' => '_default_method_handling_route',
286
+	 *            'args' => array('array','of','args'),
287
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
288
+	 *            ajax request, backend processing)
289
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
290
+	 *            headers route after.  The string you enter here should match the defined route reference for a
291
+	 *            headers sent route.
292
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
293
+	 *            this route.
294
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
295
+	 *            checks).
296
+	 *        ),
297
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
298
+	 *        handling method.
299
+	 *        )
300
+	 * )
301
+	 *
302
+	 * @abstract
303
+	 * @return void
304
+	 */
305
+	abstract protected function _set_page_routes();
306
+
307
+
308
+	/**
309
+	 * _set_page_config
310
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
311
+	 * array corresponds to the page_route for the loaded page. Format:
312
+	 * $this->_page_config = array(
313
+	 *        'default' => array(
314
+	 *            'labels' => array(
315
+	 *                'buttons' => array(
316
+	 *                    'add' => esc_html__('label for adding item'),
317
+	 *                    'edit' => esc_html__('label for editing item'),
318
+	 *                    'delete' => esc_html__('label for deleting item')
319
+	 *                ),
320
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
321
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
322
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
323
+	 *            _define_page_props() method
324
+	 *            'nav' => array(
325
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
326
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
327
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
328
+	 *                'order' => 10, //required to indicate tab position.
329
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
330
+	 *                displayed then add this parameter.
331
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
332
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
333
+	 *            metaboxes set for eventespresso admin pages.
334
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
335
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
336
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
337
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
338
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
339
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
340
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
341
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
342
+	 *            want to display.
343
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
344
+	 *                'tab_id' => array(
345
+	 *                    'title' => 'tab_title',
346
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
347
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
348
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
349
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
350
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
351
+	 *                    attempt to use the callback which should match the name of a method in the class
352
+	 *                    ),
353
+	 *                'tab2_id' => array(
354
+	 *                    'title' => 'tab2 title',
355
+	 *                    'filename' => 'file_name_2'
356
+	 *                    'callback' => 'callback_method_for_content',
357
+	 *                 ),
358
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
359
+	 *            help tab area on an admin page. @return void
360
+	 *
361
+	 * @abstract
362
+	 */
363
+	abstract protected function _set_page_config();
364
+
365
+
366
+	/**
367
+	 * _add_screen_options
368
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
369
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
370
+	 * to a particular view.
371
+	 *
372
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
373
+	 *         see also WP_Screen object documents...
374
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
375
+	 * @abstract
376
+	 * @return void
377
+	 */
378
+	abstract protected function _add_screen_options();
379
+
380
+
381
+	/**
382
+	 * _add_feature_pointers
383
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
384
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
385
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
386
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
387
+	 * extended) also see:
388
+	 *
389
+	 * @link   http://eamann.com/tech/wordpress-portland/
390
+	 * @abstract
391
+	 * @return void
392
+	 */
393
+	abstract protected function _add_feature_pointers();
394
+
395
+
396
+	/**
397
+	 * load_scripts_styles
398
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
399
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
400
+	 * scripts/styles per view by putting them in a dynamic function in this format
401
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
402
+	 *
403
+	 * @abstract
404
+	 * @return void
405
+	 */
406
+	abstract public function load_scripts_styles();
407
+
408
+
409
+	/**
410
+	 * admin_init
411
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
412
+	 * all pages/views loaded by child class.
413
+	 *
414
+	 * @abstract
415
+	 * @return void
416
+	 */
417
+	abstract public function admin_init();
418
+
419
+
420
+	/**
421
+	 * admin_notices
422
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
423
+	 * all pages/views loaded by child class.
424
+	 *
425
+	 * @abstract
426
+	 * @return void
427
+	 */
428
+	abstract public function admin_notices();
429
+
430
+
431
+	/**
432
+	 * admin_footer_scripts
433
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
434
+	 * will apply to all pages/views loaded by child class.
435
+	 *
436
+	 * @return void
437
+	 */
438
+	abstract public function admin_footer_scripts();
439
+
440
+
441
+	/**
442
+	 * admin_footer
443
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
444
+	 * apply to all pages/views loaded by child class.
445
+	 *
446
+	 * @return void
447
+	 */
448
+	public function admin_footer()
449
+	{
450
+	}
451
+
452
+
453
+	/**
454
+	 * _global_ajax_hooks
455
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
456
+	 * Note: within the ajax callback methods.
457
+	 *
458
+	 * @abstract
459
+	 * @return void
460
+	 */
461
+	protected function _global_ajax_hooks()
462
+	{
463
+		// for lazy loading of metabox content
464
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
465
+	}
466
+
467
+
468
+	public function ajax_metabox_content()
469
+	{
470
+		$content_id  = $this->request->getRequestParam('contentid', '');
471
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
472
+		self::cached_rss_display($content_id, $content_url);
473
+		wp_die();
474
+	}
475
+
476
+
477
+	/**
478
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
479
+	 *
480
+	 * @return void
481
+	 */
482
+	protected function _before_page_setup()
483
+	{
484
+		// default is to do nothing
485
+	}
486
+
487
+
488
+	/**
489
+	 * Makes sure any things that need to be loaded early get handled.
490
+	 * We also escape early here if the page requested doesn't match the object.
491
+	 *
492
+	 * @final
493
+	 * @return void
494
+	 * @throws EE_Error
495
+	 * @throws InvalidArgumentException
496
+	 * @throws ReflectionException
497
+	 * @throws InvalidDataTypeException
498
+	 * @throws InvalidInterfaceException
499
+	 */
500
+	final protected function _page_setup()
501
+	{
502
+		// requires?
503
+		// admin_init stuff - global - we're setting this REALLY early
504
+		// so if EE_Admin pages have to hook into other WP pages they can.
505
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
506
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
507
+		// next verify if we need to load anything...
508
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
509
+		$this->_current_page = $this->request->getRequestParam('current_page', $this->_current_page, 'key');
510
+
511
+		$this->page_folder   = strtolower(
512
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
513
+		);
514
+		global $ee_menu_slugs;
515
+		$ee_menu_slugs = (array) $ee_menu_slugs;
516
+		if (
517
+			! $this->request->isAjax()
518
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
519
+		) {
520
+			return;
521
+		}
522
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
523
+		// we need to copy the action from the second to the first
524
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
525
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
526
+		$action     = $action !== '-1' ? $action : $action2;
527
+		$req_action = $action !== '-1' ? $action : 'default';
528
+
529
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
530
+		// then let's use the route as the action.
531
+		// This covers cases where we're coming in from a list table that isn't on the default route.
532
+		$route = $this->request->getRequestParam('route');
533
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
534
+			? $route
535
+			: $req_action;
536
+
537
+		$this->_current_view = $this->_req_action;
538
+		$this->_req_nonce    = $this->_req_action . '_nonce';
539
+		$this->_define_page_props();
540
+		$this->_current_page_view_url = add_query_arg(
541
+			['page' => $this->_current_page, 'action' => $this->_current_view],
542
+			$this->_admin_base_url
543
+		);
544
+		// default things
545
+		$this->_default_espresso_metaboxes = [
546
+			'_espresso_news_post_box',
547
+			'_espresso_links_post_box',
548
+			'_espresso_ratings_request',
549
+			'_espresso_sponsors_post_box',
550
+		];
551
+		// set page configs
552
+		$this->_set_page_routes();
553
+		$this->_set_page_config();
554
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
555
+		if ($this->request->requestParamIsSet('wp_referer')) {
556
+			$wp_referer = $this->request->getRequestParam('wp_referer');
557
+			if ($wp_referer) {
558
+				$this->_default_route_query_args['wp_referer'] = $wp_referer;
559
+			}
560
+		}
561
+		// for caffeinated and other extended functionality.
562
+		//  If there is a _extend_page_config method
563
+		// then let's run that to modify the all the various page configuration arrays
564
+		if (method_exists($this, '_extend_page_config')) {
565
+			$this->_extend_page_config();
566
+		}
567
+		// for CPT and other extended functionality.
568
+		// If there is an _extend_page_config_for_cpt
569
+		// then let's run that to modify all the various page configuration arrays.
570
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
571
+			$this->_extend_page_config_for_cpt();
572
+		}
573
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
574
+		$this->_page_routes = apply_filters(
575
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
576
+			$this->_page_routes,
577
+			$this
578
+		);
579
+		$this->_page_config = apply_filters(
580
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
581
+			$this->_page_config,
582
+			$this
583
+		);
584
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
585
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
586
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
587
+			add_action(
588
+				'AHEE__EE_Admin_Page__route_admin_request',
589
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
590
+				10,
591
+				2
592
+			);
593
+		}
594
+		// next route only if routing enabled
595
+		if ($this->_routing && ! $this->request->isAjax()) {
596
+			$this->_verify_routes();
597
+			// next let's just check user_access and kill if no access
598
+			$this->check_user_access();
599
+			if ($this->_is_UI_request) {
600
+				// admin_init stuff - global, all views for this page class, specific view
601
+				add_action('admin_init', [$this, 'admin_init'], 10);
602
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
603
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
604
+				}
605
+			} else {
606
+				// hijack regular WP loading and route admin request immediately
607
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
608
+				$this->route_admin_request();
609
+			}
610
+		}
611
+	}
612
+
613
+
614
+	/**
615
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
616
+	 *
617
+	 * @return void
618
+	 * @throws EE_Error
619
+	 */
620
+	private function _do_other_page_hooks()
621
+	{
622
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
623
+		foreach ($registered_pages as $page) {
624
+			// now let's setup the file name and class that should be present
625
+			$classname = str_replace('.class.php', '', $page);
626
+			// autoloaders should take care of loading file
627
+			if (! class_exists($classname)) {
628
+				$error_msg[] = sprintf(
629
+					esc_html__(
630
+						'Something went wrong with loading the %s admin hooks page.',
631
+						'event_espresso'
632
+					),
633
+					$page
634
+				);
635
+				$error_msg[] = $error_msg[0]
636
+							   . "\r\n"
637
+							   . sprintf(
638
+								   esc_html__(
639
+									   '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',
640
+									   'event_espresso'
641
+								   ),
642
+								   $page,
643
+								   '<br />',
644
+								   '<strong>' . $classname . '</strong>'
645
+							   );
646
+				throw new EE_Error(implode('||', $error_msg));
647
+			}
648
+			// notice we are passing the instance of this class to the hook object.
649
+			$this->loader->getShared($classname, [$this]);
650
+		}
651
+	}
652
+
653
+
654
+	/**
655
+	 * @throws ReflectionException
656
+	 * @throws EE_Error
657
+	 */
658
+	public function load_page_dependencies()
659
+	{
660
+		try {
661
+			$this->_load_page_dependencies();
662
+		} catch (EE_Error $e) {
663
+			$e->get_error();
664
+		}
665
+	}
666
+
667
+
668
+	/**
669
+	 * load_page_dependencies
670
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
671
+	 *
672
+	 * @return void
673
+	 * @throws DomainException
674
+	 * @throws EE_Error
675
+	 * @throws InvalidArgumentException
676
+	 * @throws InvalidDataTypeException
677
+	 * @throws InvalidInterfaceException
678
+	 */
679
+	protected function _load_page_dependencies()
680
+	{
681
+		// let's set the current_screen and screen options to override what WP set
682
+		$this->_current_screen = get_current_screen();
683
+		// load admin_notices - global, page class, and view specific
684
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
685
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
686
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
687
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
688
+		}
689
+		// load network admin_notices - global, page class, and view specific
690
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
691
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
692
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
693
+		}
694
+		// this will save any per_page screen options if they are present
695
+		$this->_set_per_page_screen_options();
696
+		// setup list table properties
697
+		$this->_set_list_table();
698
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
699
+		// However in some cases the metaboxes will need to be added within a route handling callback.
700
+		$this->_add_registered_meta_boxes();
701
+		$this->_add_screen_columns();
702
+		// add screen options - global, page child class, and view specific
703
+		$this->_add_global_screen_options();
704
+		$this->_add_screen_options();
705
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
706
+		if (method_exists($this, $add_screen_options)) {
707
+			$this->{$add_screen_options}();
708
+		}
709
+		// add help tab(s) - set via page_config and qtips.
710
+		$this->_add_help_tabs();
711
+		$this->_add_qtips();
712
+		// add feature_pointers - global, page child class, and view specific
713
+		$this->_add_feature_pointers();
714
+		$this->_add_global_feature_pointers();
715
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
716
+		if (method_exists($this, $add_feature_pointer)) {
717
+			$this->{$add_feature_pointer}();
718
+		}
719
+		// enqueue scripts/styles - global, page class, and view specific
720
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
721
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
722
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
723
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
724
+		}
725
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
726
+		// admin_print_footer_scripts - global, page child class, and view specific.
727
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
728
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
729
+		// is a good use case. Notice the late priority we're giving these
730
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
731
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
732
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
733
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
734
+		}
735
+		// admin footer scripts
736
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
737
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
738
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
739
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
740
+		}
741
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
742
+		// targeted hook
743
+		do_action(
744
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
745
+		);
746
+	}
747
+
748
+
749
+	/**
750
+	 * _set_defaults
751
+	 * This sets some global defaults for class properties.
752
+	 */
753
+	private function _set_defaults()
754
+	{
755
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
756
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
757
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
758
+		$this->_page_config          = $this->_default_route_query_args = [];
759
+		$this->_default_nav_tab_name = 'overview';
760
+		// init template args
761
+		$this->_template_args = [
762
+			'admin_page_header'  => '',
763
+			'admin_page_content' => '',
764
+			'post_body_content'  => '',
765
+			'before_list_table'  => '',
766
+			'after_list_table'   => '',
767
+		];
768
+	}
769
+
770
+
771
+	/**
772
+	 * route_admin_request
773
+	 *
774
+	 * @return void
775
+	 * @throws InvalidArgumentException
776
+	 * @throws InvalidInterfaceException
777
+	 * @throws InvalidDataTypeException
778
+	 * @throws EE_Error
779
+	 * @throws ReflectionException
780
+	 * @see    _route_admin_request()
781
+	 */
782
+	public function route_admin_request()
783
+	{
784
+		try {
785
+			$this->_route_admin_request();
786
+		} catch (EE_Error $e) {
787
+			$e->get_error();
788
+		}
789
+	}
790
+
791
+
792
+	public function set_wp_page_slug($wp_page_slug)
793
+	{
794
+		$this->_wp_page_slug = $wp_page_slug;
795
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
796
+		if (is_network_admin()) {
797
+			$this->_wp_page_slug .= '-network';
798
+		}
799
+	}
800
+
801
+
802
+	/**
803
+	 * _verify_routes
804
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
805
+	 * we know if we need to drop out.
806
+	 *
807
+	 * @return bool
808
+	 * @throws EE_Error
809
+	 */
810
+	protected function _verify_routes()
811
+	{
812
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
813
+		if (! $this->_current_page && ! $this->request->isAjax()) {
814
+			return false;
815
+		}
816
+		$this->_route = false;
817
+		// check that the page_routes array is not empty
818
+		if (empty($this->_page_routes)) {
819
+			// user error msg
820
+			$error_msg = sprintf(
821
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
822
+				$this->_admin_page_title
823
+			);
824
+			// developer error msg
825
+			$error_msg .= '||' . $error_msg
826
+						  . esc_html__(
827
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
828
+							  'event_espresso'
829
+						  );
830
+			throw new EE_Error($error_msg);
831
+		}
832
+		// and that the requested page route exists
833
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
834
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
835
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
836
+				? $this->_page_config[ $this->_req_action ]
837
+				: [];
838
+		} else {
839
+			// user error msg
840
+			$error_msg = sprintf(
841
+				esc_html__(
842
+					'The requested page route does not exist for the %s admin page.',
843
+					'event_espresso'
844
+				),
845
+				$this->_admin_page_title
846
+			);
847
+			// developer error msg
848
+			$error_msg .= '||' . $error_msg
849
+						  . sprintf(
850
+							  esc_html__(
851
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
852
+								  'event_espresso'
853
+							  ),
854
+							  $this->_req_action
855
+						  );
856
+			throw new EE_Error($error_msg);
857
+		}
858
+		// and that a default route exists
859
+		if (! array_key_exists('default', $this->_page_routes)) {
860
+			// user error msg
861
+			$error_msg = sprintf(
862
+				esc_html__(
863
+					'A default page route has not been set for the % admin page.',
864
+					'event_espresso'
865
+				),
866
+				$this->_admin_page_title
867
+			);
868
+			// developer error msg
869
+			$error_msg .= '||' . $error_msg
870
+						  . esc_html__(
871
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
872
+							  'event_espresso'
873
+						  );
874
+			throw new EE_Error($error_msg);
875
+		}
876
+		// first lets' catch if the UI request has EVER been set.
877
+		if ($this->_is_UI_request === null) {
878
+			// lets set if this is a UI request or not.
879
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
880
+			// wait a minute... we might have a noheader in the route array
881
+			$this->_is_UI_request = ! (
882
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
883
+			)
884
+				? $this->_is_UI_request
885
+				: false;
886
+		}
887
+		$this->_set_current_labels();
888
+		return true;
889
+	}
890
+
891
+
892
+	/**
893
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
894
+	 *
895
+	 * @param string $route the route name we're verifying
896
+	 * @return bool we'll throw an exception if this isn't a valid route.
897
+	 * @throws EE_Error
898
+	 */
899
+	protected function _verify_route($route)
900
+	{
901
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
902
+			return true;
903
+		}
904
+		// user error msg
905
+		$error_msg = sprintf(
906
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
907
+			$this->_admin_page_title
908
+		);
909
+		// developer error msg
910
+		$error_msg .= '||' . $error_msg
911
+					  . sprintf(
912
+						  esc_html__(
913
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
914
+							  'event_espresso'
915
+						  ),
916
+						  $route
917
+					  );
918
+		throw new EE_Error($error_msg);
919
+	}
920
+
921
+
922
+	/**
923
+	 * perform nonce verification
924
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
925
+	 * using this method (and save retyping!)
926
+	 *
927
+	 * @param string $nonce     The nonce sent
928
+	 * @param string $nonce_ref The nonce reference string (name0)
929
+	 * @return void
930
+	 * @throws EE_Error
931
+	 */
932
+	protected function _verify_nonce($nonce, $nonce_ref)
933
+	{
934
+		// verify nonce against expected value
935
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
936
+			// these are not the droids you are looking for !!!
937
+			$msg = sprintf(
938
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
939
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
940
+				'</a>'
941
+			);
942
+			if (WP_DEBUG) {
943
+				$msg .= "\n  ";
944
+				$msg .= sprintf(
945
+					esc_html__(
946
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
947
+						'event_espresso'
948
+					),
949
+					__CLASS__
950
+				);
951
+			}
952
+			if (! $this->request->isAjax()) {
953
+				wp_die($msg);
954
+			}
955
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
956
+			$this->_return_json();
957
+		}
958
+	}
959
+
960
+
961
+	/**
962
+	 * _route_admin_request()
963
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
964
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
965
+	 * in the page routes and then will try to load the corresponding method.
966
+	 *
967
+	 * @return void
968
+	 * @throws EE_Error
969
+	 * @throws InvalidArgumentException
970
+	 * @throws InvalidDataTypeException
971
+	 * @throws InvalidInterfaceException
972
+	 * @throws ReflectionException
973
+	 */
974
+	protected function _route_admin_request()
975
+	{
976
+		if (! $this->_is_UI_request) {
977
+			$this->_verify_routes();
978
+		}
979
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
980
+		if ($this->_req_action !== 'default' && $nonce_check) {
981
+			// set nonce from post data
982
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
983
+			$this->_verify_nonce($nonce, $this->_req_nonce);
984
+		}
985
+		// set the nav_tabs array but ONLY if this is  UI_request
986
+		if ($this->_is_UI_request) {
987
+			$this->_set_nav_tabs();
988
+		}
989
+		// grab callback function
990
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
991
+		// check if callback has args
992
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
993
+		$error_msg = '';
994
+		// action right before calling route
995
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
996
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
997
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
998
+		}
999
+		// right before calling the route, let's clean the _wp_http_referer
1000
+		$this->request->unSetRequestParam('_wp_http_referer');
1001
+		$this->request->unSetServerParam('_wp_http_referer');
1002
+		$cleaner_request_uri = remove_query_arg(
1003
+			'_wp_http_referer',
1004
+			wp_unslash($this->request->getServerParam('REQUEST_URI'))
1005
+		);
1006
+		$this->request->setRequestParam('_wp_http_referer', $cleaner_request_uri);
1007
+		$this->request->setServerParam('REQUEST_URI', $cleaner_request_uri);
1008
+		if (! empty($func)) {
1009
+			if (is_array($func)) {
1010
+				[$class, $method] = $func;
1011
+			} elseif (strpos($func, '::') !== false) {
1012
+				[$class, $method] = explode('::', $func);
1013
+			} else {
1014
+				$class  = $this;
1015
+				$method = $func;
1016
+			}
1017
+			if (! (is_object($class) && $class === $this)) {
1018
+				// send along this admin page object for access by addons.
1019
+				$args['admin_page_object'] = $this;
1020
+			}
1021
+			if (
1022
+				// is it a method on a class that doesn't work?
1023
+				(
1024
+					(
1025
+						method_exists($class, $method)
1026
+						&& call_user_func_array([$class, $method], $args) === false
1027
+					)
1028
+					&& (
1029
+						// is it a standalone function that doesn't work?
1030
+						function_exists($method)
1031
+						&& call_user_func_array(
1032
+							$func,
1033
+							array_merge(['admin_page_object' => $this], $args)
1034
+						) === false
1035
+					)
1036
+				)
1037
+				|| (
1038
+					// is it neither a class method NOR a standalone function?
1039
+					! method_exists($class, $method)
1040
+					&& ! function_exists($method)
1041
+				)
1042
+			) {
1043
+				// user error msg
1044
+				$error_msg = esc_html__(
1045
+					'An error occurred. The  requested page route could not be found.',
1046
+					'event_espresso'
1047
+				);
1048
+				// developer error msg
1049
+				$error_msg .= '||';
1050
+				$error_msg .= sprintf(
1051
+					esc_html__(
1052
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1053
+						'event_espresso'
1054
+					),
1055
+					$method
1056
+				);
1057
+			}
1058
+			if (! empty($error_msg)) {
1059
+				throw new EE_Error($error_msg);
1060
+			}
1061
+		}
1062
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1063
+		// then we need to reset the routing properties to the new route.
1064
+		// 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.
1065
+		if (
1066
+			$this->_is_UI_request === false
1067
+			&& is_array($this->_route)
1068
+			&& ! empty($this->_route['headers_sent_route'])
1069
+		) {
1070
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1071
+		}
1072
+	}
1073
+
1074
+
1075
+	/**
1076
+	 * This method just allows the resetting of page properties in the case where a no headers
1077
+	 * route redirects to a headers route in its route config.
1078
+	 *
1079
+	 * @param string $new_route New (non header) route to redirect to.
1080
+	 * @return   void
1081
+	 * @throws ReflectionException
1082
+	 * @throws InvalidArgumentException
1083
+	 * @throws InvalidInterfaceException
1084
+	 * @throws InvalidDataTypeException
1085
+	 * @throws EE_Error
1086
+	 * @since   4.3.0
1087
+	 */
1088
+	protected function _reset_routing_properties($new_route)
1089
+	{
1090
+		$this->_is_UI_request = true;
1091
+		// now we set the current route to whatever the headers_sent_route is set at
1092
+		$this->request->setRequestParam('action', $new_route);
1093
+		// rerun page setup
1094
+		$this->_page_setup();
1095
+	}
1096
+
1097
+
1098
+	/**
1099
+	 * _add_query_arg
1100
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1101
+	 *(internally just uses EEH_URL's function with the same name)
1102
+	 *
1103
+	 * @param array  $args
1104
+	 * @param string $url
1105
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1106
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1107
+	 *                                        Example usage: If the current page is:
1108
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1109
+	 *                                        &action=default&event_id=20&month_range=March%202015
1110
+	 *                                        &_wpnonce=5467821
1111
+	 *                                        and you call:
1112
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1113
+	 *                                        array(
1114
+	 *                                        'action' => 'resend_something',
1115
+	 *                                        'page=>espresso_registrations'
1116
+	 *                                        ),
1117
+	 *                                        $some_url,
1118
+	 *                                        true
1119
+	 *                                        );
1120
+	 *                                        It will produce a url in this structure:
1121
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1122
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1123
+	 *                                        month_range]=March%202015
1124
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1125
+	 * @return string
1126
+	 */
1127
+	public static function add_query_args_and_nonce(
1128
+		$args = [],
1129
+		$url = false,
1130
+		$sticky = false,
1131
+		$exclude_nonce = false
1132
+	) {
1133
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1134
+		if ($sticky) {
1135
+			/** @var RequestInterface $request */
1136
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1137
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer'], true);
1138
+			foreach ($request->requestParams() as $key => $value) {
1139
+				// do not add nonces
1140
+				if (strpos($key, 'nonce') !== false) {
1141
+					continue;
1142
+				}
1143
+				$args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1144
+			}
1145
+		}
1146
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1147
+	}
1148
+
1149
+
1150
+	/**
1151
+	 * This returns a generated link that will load the related help tab.
1152
+	 *
1153
+	 * @param string $help_tab_id the id for the connected help tab
1154
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1155
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1156
+	 * @return string              generated link
1157
+	 * @uses EEH_Template::get_help_tab_link()
1158
+	 */
1159
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1160
+	{
1161
+		return EEH_Template::get_help_tab_link(
1162
+			$help_tab_id,
1163
+			$this->page_slug,
1164
+			$this->_req_action,
1165
+			$icon_style,
1166
+			$help_text
1167
+		);
1168
+	}
1169
+
1170
+
1171
+	/**
1172
+	 * _add_help_tabs
1173
+	 * Note child classes define their help tabs within the page_config array.
1174
+	 *
1175
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1176
+	 * @return void
1177
+	 * @throws DomainException
1178
+	 * @throws EE_Error
1179
+	 */
1180
+	protected function _add_help_tabs()
1181
+	{
1182
+		if (isset($this->_page_config[ $this->_req_action ])) {
1183
+			$config = $this->_page_config[ $this->_req_action ];
1184
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1185
+			if (is_array($config) && isset($config['help_sidebar'])) {
1186
+				// check that the callback given is valid
1187
+				if (! method_exists($this, $config['help_sidebar'])) {
1188
+					throw new EE_Error(
1189
+						sprintf(
1190
+							esc_html__(
1191
+								'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',
1192
+								'event_espresso'
1193
+							),
1194
+							$config['help_sidebar'],
1195
+							get_class($this)
1196
+						)
1197
+					);
1198
+				}
1199
+				$content = apply_filters(
1200
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1201
+					$this->{$config['help_sidebar']}()
1202
+				);
1203
+				$this->_current_screen->set_help_sidebar($content);
1204
+			}
1205
+			if (! isset($config['help_tabs'])) {
1206
+				return;
1207
+			} //no help tabs for this route
1208
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1209
+				// we're here so there ARE help tabs!
1210
+				// make sure we've got what we need
1211
+				if (! isset($cfg['title'])) {
1212
+					throw new EE_Error(
1213
+						esc_html__(
1214
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1215
+							'event_espresso'
1216
+						)
1217
+					);
1218
+				}
1219
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1220
+					throw new EE_Error(
1221
+						esc_html__(
1222
+							'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',
1223
+							'event_espresso'
1224
+						)
1225
+					);
1226
+				}
1227
+				// first priority goes to content.
1228
+				if (! empty($cfg['content'])) {
1229
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1230
+					// second priority goes to filename
1231
+				} elseif (! empty($cfg['filename'])) {
1232
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1233
+					// 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)
1234
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1235
+															 . basename($this->_get_dir())
1236
+															 . '/help_tabs/'
1237
+															 . $cfg['filename']
1238
+															 . '.help_tab.php' : $file_path;
1239
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1240
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1241
+						EE_Error::add_error(
1242
+							sprintf(
1243
+								esc_html__(
1244
+									'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',
1245
+									'event_espresso'
1246
+								),
1247
+								$tab_id,
1248
+								key($config),
1249
+								$file_path
1250
+							),
1251
+							__FILE__,
1252
+							__FUNCTION__,
1253
+							__LINE__
1254
+						);
1255
+						return;
1256
+					}
1257
+					$template_args['admin_page_obj'] = $this;
1258
+					$content                         = EEH_Template::display_template(
1259
+						$file_path,
1260
+						$template_args,
1261
+						true
1262
+					);
1263
+				} else {
1264
+					$content = '';
1265
+				}
1266
+				// check if callback is valid
1267
+				if (
1268
+					empty($content)
1269
+					&& (
1270
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1271
+					)
1272
+				) {
1273
+					EE_Error::add_error(
1274
+						sprintf(
1275
+							esc_html__(
1276
+								'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.',
1277
+								'event_espresso'
1278
+							),
1279
+							$cfg['title']
1280
+						),
1281
+						__FILE__,
1282
+						__FUNCTION__,
1283
+						__LINE__
1284
+					);
1285
+					return;
1286
+				}
1287
+				// setup config array for help tab method
1288
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1289
+				$_ht = [
1290
+					'id'       => $id,
1291
+					'title'    => $cfg['title'],
1292
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1293
+					'content'  => $content,
1294
+				];
1295
+				$this->_current_screen->add_help_tab($_ht);
1296
+			}
1297
+		}
1298
+	}
1299
+
1300
+
1301
+	/**
1302
+	 * This simply sets up any qtips that have been defined in the page config
1303
+	 *
1304
+	 * @return void
1305
+	 */
1306
+	protected function _add_qtips()
1307
+	{
1308
+		if (isset($this->_route_config['qtips'])) {
1309
+			$qtips = (array) $this->_route_config['qtips'];
1310
+			// load qtip loader
1311
+			$path = [
1312
+				$this->_get_dir() . '/qtips/',
1313
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1314
+			];
1315
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1316
+		}
1317
+	}
1318
+
1319
+
1320
+	/**
1321
+	 * _set_nav_tabs
1322
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1323
+	 * wish to add additional tabs or modify accordingly.
1324
+	 *
1325
+	 * @return void
1326
+	 * @throws InvalidArgumentException
1327
+	 * @throws InvalidInterfaceException
1328
+	 * @throws InvalidDataTypeException
1329
+	 */
1330
+	protected function _set_nav_tabs()
1331
+	{
1332
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1333
+		$i = 0;
1334
+		foreach ($this->_page_config as $slug => $config) {
1335
+			if (! is_array($config) || empty($config['nav'])) {
1336
+				continue;
1337
+			}
1338
+			// no nav tab for this config
1339
+			// check for persistent flag
1340
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1341
+				// nav tab is only to appear when route requested.
1342
+				continue;
1343
+			}
1344
+			if (! $this->check_user_access($slug, true)) {
1345
+				// no nav tab because current user does not have access.
1346
+				continue;
1347
+			}
1348
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1349
+			$this->_nav_tabs[ $slug ] = [
1350
+				'url'       => isset($config['nav']['url'])
1351
+					? $config['nav']['url']
1352
+					: self::add_query_args_and_nonce(
1353
+						['action' => $slug],
1354
+						$this->_admin_base_url
1355
+					),
1356
+				'link_text' => isset($config['nav']['label'])
1357
+					? $config['nav']['label']
1358
+					: ucwords(
1359
+						str_replace('_', ' ', $slug)
1360
+					),
1361
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1362
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1363
+			];
1364
+			$i++;
1365
+		}
1366
+		// if $this->_nav_tabs is empty then lets set the default
1367
+		if (empty($this->_nav_tabs)) {
1368
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1369
+				'url'       => $this->_admin_base_url,
1370
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1371
+				'css_class' => 'nav-tab-active',
1372
+				'order'     => 10,
1373
+			];
1374
+		}
1375
+		// now let's sort the tabs according to order
1376
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1377
+	}
1378
+
1379
+
1380
+	/**
1381
+	 * _set_current_labels
1382
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1383
+	 * property array
1384
+	 *
1385
+	 * @return void
1386
+	 */
1387
+	private function _set_current_labels()
1388
+	{
1389
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1390
+			foreach ($this->_route_config['labels'] as $label => $text) {
1391
+				if (is_array($text)) {
1392
+					foreach ($text as $sublabel => $subtext) {
1393
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1394
+					}
1395
+				} else {
1396
+					$this->_labels[ $label ] = $text;
1397
+				}
1398
+			}
1399
+		}
1400
+	}
1401
+
1402
+
1403
+	/**
1404
+	 *        verifies user access for this admin page
1405
+	 *
1406
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1407
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1408
+	 *                               return false if verify fail.
1409
+	 * @return bool
1410
+	 * @throws InvalidArgumentException
1411
+	 * @throws InvalidDataTypeException
1412
+	 * @throws InvalidInterfaceException
1413
+	 */
1414
+	public function check_user_access($route_to_check = '', $verify_only = false)
1415
+	{
1416
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1417
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1418
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1419
+						  && is_array(
1420
+							  $this->_page_routes[ $route_to_check ]
1421
+						  )
1422
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1423
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1424
+		if (empty($capability) && empty($route_to_check)) {
1425
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1426
+				: $this->_route['capability'];
1427
+		} else {
1428
+			$capability = empty($capability) ? 'manage_options' : $capability;
1429
+		}
1430
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1431
+		if (
1432
+			! $this->request->isAjax()
1433
+			&& (
1434
+				! function_exists('is_admin')
1435
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1436
+					$capability,
1437
+					$this->page_slug
1438
+					. '_'
1439
+					. $route_to_check,
1440
+					$id
1441
+				)
1442
+			)
1443
+		) {
1444
+			if ($verify_only) {
1445
+				return false;
1446
+			}
1447
+			if (is_user_logged_in()) {
1448
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1449
+			} else {
1450
+				return false;
1451
+			}
1452
+		}
1453
+		return true;
1454
+	}
1455
+
1456
+
1457
+	/**
1458
+	 * admin_init_global
1459
+	 * This runs all the code that we want executed within the WP admin_init hook.
1460
+	 * This method executes for ALL EE Admin pages.
1461
+	 *
1462
+	 * @return void
1463
+	 */
1464
+	public function admin_init_global()
1465
+	{
1466
+	}
1467
+
1468
+
1469
+	/**
1470
+	 * wp_loaded_global
1471
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1472
+	 * EE_Admin page and will execute on every EE Admin Page load
1473
+	 *
1474
+	 * @return void
1475
+	 */
1476
+	public function wp_loaded()
1477
+	{
1478
+	}
1479
+
1480
+
1481
+	/**
1482
+	 * admin_notices
1483
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1484
+	 * ALL EE_Admin pages.
1485
+	 *
1486
+	 * @return void
1487
+	 */
1488
+	public function admin_notices_global()
1489
+	{
1490
+		$this->_display_no_javascript_warning();
1491
+		$this->_display_espresso_notices();
1492
+	}
1493
+
1494
+
1495
+	public function network_admin_notices_global()
1496
+	{
1497
+		$this->_display_no_javascript_warning();
1498
+		$this->_display_espresso_notices();
1499
+	}
1500
+
1501
+
1502
+	/**
1503
+	 * admin_footer_scripts_global
1504
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1505
+	 * will apply on ALL EE_Admin pages.
1506
+	 *
1507
+	 * @return void
1508
+	 */
1509
+	public function admin_footer_scripts_global()
1510
+	{
1511
+		$this->_add_admin_page_ajax_loading_img();
1512
+		$this->_add_admin_page_overlay();
1513
+		// if metaboxes are present we need to add the nonce field
1514
+		if (
1515
+			isset($this->_route_config['metaboxes'])
1516
+			|| isset($this->_route_config['list_table'])
1517
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1518
+		) {
1519
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1520
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1521
+		}
1522
+	}
1523
+
1524
+
1525
+	/**
1526
+	 * admin_footer_global
1527
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1528
+	 * ALL EE_Admin Pages.
1529
+	 *
1530
+	 * @return void
1531
+	 */
1532
+	public function admin_footer_global()
1533
+	{
1534
+		// dialog container for dialog helper
1535
+		echo '
1536 1536
         <div class="ee-admin-dialog-container auto-hide hidden">
1537 1537
             <div class="ee-notices"></div>
1538 1538
             <div class="ee-admin-dialog-container-inner-content"></div>
1539 1539
         </div>
1540 1540
         ';
1541 1541
 
1542
-        // current set timezone for timezone js
1543
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1544
-    }
1545
-
1546
-
1547
-    /**
1548
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1549
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1550
-     * help popups then in your templates or your content you set "triggers" for the content using the
1551
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1552
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1553
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1554
-     * for the
1555
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1556
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1557
-     *    'help_trigger_id' => array(
1558
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1559
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1560
-     *    )
1561
-     * );
1562
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1563
-     *
1564
-     * @param array $help_array
1565
-     * @param bool  $display
1566
-     * @return string content
1567
-     * @throws DomainException
1568
-     * @throws EE_Error
1569
-     */
1570
-    protected function _set_help_popup_content($help_array = [], $display = false)
1571
-    {
1572
-        $content    = '';
1573
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1574
-        // loop through the array and setup content
1575
-        foreach ($help_array as $trigger => $help) {
1576
-            // make sure the array is setup properly
1577
-            if (! isset($help['title']) || ! isset($help['content'])) {
1578
-                throw new EE_Error(
1579
-                    esc_html__(
1580
-                        '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',
1581
-                        'event_espresso'
1582
-                    )
1583
-                );
1584
-            }
1585
-            // we're good so let's setup the template vars and then assign parsed template content to our content.
1586
-            $template_args = [
1587
-                'help_popup_id'      => $trigger,
1588
-                'help_popup_title'   => $help['title'],
1589
-                'help_popup_content' => $help['content'],
1590
-            ];
1591
-            $content       .= EEH_Template::display_template(
1592
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1593
-                $template_args,
1594
-                true
1595
-            );
1596
-        }
1597
-        if ($display) {
1598
-            echo wp_kses($content, AllowedTags::getWithFormTags());
1599
-            return '';
1600
-        }
1601
-        return $content;
1602
-    }
1603
-
1604
-
1605
-    /**
1606
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1607
-     *
1608
-     * @return array properly formatted array for help popup content
1609
-     * @throws EE_Error
1610
-     */
1611
-    private function _get_help_content()
1612
-    {
1613
-        // what is the method we're looking for?
1614
-        $method_name = '_help_popup_content_' . $this->_req_action;
1615
-        // if method doesn't exist let's get out.
1616
-        if (! method_exists($this, $method_name)) {
1617
-            return [];
1618
-        }
1619
-        // k we're good to go let's retrieve the help array
1620
-        $help_array = call_user_func([$this, $method_name]);
1621
-        // make sure we've got an array!
1622
-        if (! is_array($help_array)) {
1623
-            throw new EE_Error(
1624
-                esc_html__(
1625
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1626
-                    'event_espresso'
1627
-                )
1628
-            );
1629
-        }
1630
-        return $help_array;
1631
-    }
1632
-
1633
-
1634
-    /**
1635
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1636
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1637
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1638
-     *
1639
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1640
-     * @param boolean $display    if false then we return the trigger string
1641
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1642
-     * @return string
1643
-     * @throws DomainException
1644
-     * @throws EE_Error
1645
-     */
1646
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1647
-    {
1648
-        if ($this->request->isAjax()) {
1649
-            return '';
1650
-        }
1651
-        // 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
1652
-        $help_array   = $this->_get_help_content();
1653
-        $help_content = '';
1654
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1655
-            $help_array[ $trigger_id ] = [
1656
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1657
-                'content' => esc_html__(
1658
-                    '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.)',
1659
-                    'event_espresso'
1660
-                ),
1661
-            ];
1662
-            $help_content              = $this->_set_help_popup_content($help_array);
1663
-        }
1664
-        // let's setup the trigger
1665
-        $content = '<a class="ee-dialog" href="?height='
1666
-                   . esc_attr($dimensions[0])
1667
-                   . '&width='
1668
-                   . esc_attr($dimensions[1])
1669
-                   . '&inlineId='
1670
-                   . esc_attr($trigger_id)
1671
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1672
-        $content .= $help_content;
1673
-        if ($display) {
1674
-            echo wp_kses($content, AllowedTags::getWithFormTags());
1675
-            return '';
1676
-        }
1677
-        return $content;
1678
-    }
1679
-
1680
-
1681
-    /**
1682
-     * _add_global_screen_options
1683
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1684
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1685
-     *
1686
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1687
-     *         see also WP_Screen object documents...
1688
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1689
-     * @abstract
1690
-     * @return void
1691
-     */
1692
-    private function _add_global_screen_options()
1693
-    {
1694
-    }
1695
-
1696
-
1697
-    /**
1698
-     * _add_global_feature_pointers
1699
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1700
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1701
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1702
-     *
1703
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1704
-     *         extended) also see:
1705
-     * @link   http://eamann.com/tech/wordpress-portland/
1706
-     * @abstract
1707
-     * @return void
1708
-     */
1709
-    private function _add_global_feature_pointers()
1710
-    {
1711
-    }
1712
-
1713
-
1714
-    /**
1715
-     * load_global_scripts_styles
1716
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1717
-     *
1718
-     * @return void
1719
-     */
1720
-    public function load_global_scripts_styles()
1721
-    {
1722
-        /** STYLES **/
1723
-        // add debugging styles
1724
-        if (WP_DEBUG) {
1725
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1726
-        }
1727
-        // register all styles
1728
-        wp_register_style(
1729
-            'espresso-ui-theme',
1730
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1731
-            [],
1732
-            EVENT_ESPRESSO_VERSION
1733
-        );
1734
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1735
-        // helpers styles
1736
-        wp_register_style(
1737
-            'ee-text-links',
1738
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1739
-            [],
1740
-            EVENT_ESPRESSO_VERSION
1741
-        );
1742
-        /** SCRIPTS **/
1743
-        // register all scripts
1744
-        wp_register_script(
1745
-            'ee-dialog',
1746
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1747
-            ['jquery', 'jquery-ui-draggable'],
1748
-            EVENT_ESPRESSO_VERSION,
1749
-            true
1750
-        );
1751
-        wp_register_script(
1752
-            'ee_admin_js',
1753
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1754
-            ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1755
-            EVENT_ESPRESSO_VERSION,
1756
-            true
1757
-        );
1758
-        wp_register_script(
1759
-            'jquery-ui-timepicker-addon',
1760
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1761
-            ['jquery-ui-datepicker', 'jquery-ui-slider'],
1762
-            EVENT_ESPRESSO_VERSION,
1763
-            true
1764
-        );
1765
-        // script for sorting tables
1766
-        wp_register_script(
1767
-            'espresso_ajax_table_sorting',
1768
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1769
-            ['ee_admin_js', 'jquery-ui-sortable'],
1770
-            EVENT_ESPRESSO_VERSION,
1771
-            true
1772
-        );
1773
-        // script for parsing uri's
1774
-        wp_register_script(
1775
-            'ee-parse-uri',
1776
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1777
-            [],
1778
-            EVENT_ESPRESSO_VERSION,
1779
-            true
1780
-        );
1781
-        // and parsing associative serialized form elements
1782
-        wp_register_script(
1783
-            'ee-serialize-full-array',
1784
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1785
-            ['jquery'],
1786
-            EVENT_ESPRESSO_VERSION,
1787
-            true
1788
-        );
1789
-        // helpers scripts
1790
-        wp_register_script(
1791
-            'ee-text-links',
1792
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1793
-            ['jquery'],
1794
-            EVENT_ESPRESSO_VERSION,
1795
-            true
1796
-        );
1797
-        wp_register_script(
1798
-            'ee-moment-core',
1799
-            EE_GLOBAL_ASSETS_URL . 'moment/moment-with-locales.min.js',
1800
-            [],
1801
-            EVENT_ESPRESSO_VERSION,
1802
-            true
1803
-        );
1804
-        wp_register_script(
1805
-            'ee-moment',
1806
-            EE_GLOBAL_ASSETS_URL . 'moment/moment-timezone-with-data.min.js',
1807
-            ['ee-moment-core'],
1808
-            EVENT_ESPRESSO_VERSION,
1809
-            true
1810
-        );
1811
-        wp_register_script(
1812
-            'ee-datepicker',
1813
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1814
-            ['jquery-ui-timepicker-addon', 'ee-moment'],
1815
-            EVENT_ESPRESSO_VERSION,
1816
-            true
1817
-        );
1818
-        // google charts
1819
-        wp_register_script(
1820
-            'google-charts',
1821
-            'https://www.gstatic.com/charts/loader.js',
1822
-            [],
1823
-            EVENT_ESPRESSO_VERSION
1824
-        );
1825
-        // ENQUEUE ALL BASICS BY DEFAULT
1826
-        wp_enqueue_style('ee-admin-css');
1827
-        wp_enqueue_script('ee_admin_js');
1828
-        wp_enqueue_script('ee-accounting');
1829
-        wp_enqueue_script('jquery-validate');
1830
-        // taking care of metaboxes
1831
-        if (
1832
-            empty($this->_cpt_route)
1833
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1834
-        ) {
1835
-            wp_enqueue_script('dashboard');
1836
-        }
1837
-        // LOCALIZED DATA
1838
-        // localize script for ajax lazy loading
1839
-        $lazy_loader_container_ids = apply_filters(
1840
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1841
-            ['espresso_news_post_box_content']
1842
-        );
1843
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1844
-        add_filter(
1845
-            'admin_body_class',
1846
-            function ($classes) {
1847
-                if (strpos($classes, 'espresso-admin') === false) {
1848
-                    $classes .= ' espresso-admin';
1849
-                }
1850
-                return $classes;
1851
-            }
1852
-        );
1853
-    }
1854
-
1855
-
1856
-    /**
1857
-     *        admin_footer_scripts_eei18n_js_strings
1858
-     *
1859
-     * @return        void
1860
-     */
1861
-    public function admin_footer_scripts_eei18n_js_strings()
1862
-    {
1863
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1864
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1865
-            __(
1866
-                '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!!!',
1867
-                'event_espresso'
1868
-            )
1869
-        );
1870
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1871
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1872
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1873
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1874
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1875
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1876
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1877
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1878
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1879
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1880
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1881
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1882
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1883
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1884
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1885
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1886
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1887
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1888
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1889
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1890
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1891
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1892
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1893
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1894
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1895
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1896
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1897
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1898
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1899
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1900
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1901
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1902
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1903
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1904
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1905
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1906
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1907
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1908
-    }
1909
-
1910
-
1911
-    /**
1912
-     *        load enhanced xdebug styles for ppl with failing eyesight
1913
-     *
1914
-     * @return        void
1915
-     */
1916
-    public function add_xdebug_style()
1917
-    {
1918
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1919
-    }
1920
-
1921
-
1922
-    /************************/
1923
-    /** LIST TABLE METHODS **/
1924
-    /************************/
1925
-    /**
1926
-     * this sets up the list table if the current view requires it.
1927
-     *
1928
-     * @return void
1929
-     * @throws EE_Error
1930
-     */
1931
-    protected function _set_list_table()
1932
-    {
1933
-        // first is this a list_table view?
1934
-        if (! isset($this->_route_config['list_table'])) {
1935
-            return;
1936
-        } //not a list_table view so get out.
1937
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
1938
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
1939
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1940
-            // user error msg
1941
-            $error_msg = esc_html__(
1942
-                'An error occurred. The requested list table views could not be found.',
1943
-                'event_espresso'
1944
-            );
1945
-            // developer error msg
1946
-            $error_msg .= '||'
1947
-                          . sprintf(
1948
-                              esc_html__(
1949
-                                  '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.',
1950
-                                  'event_espresso'
1951
-                              ),
1952
-                              $this->_req_action,
1953
-                              $list_table_view
1954
-                          );
1955
-            throw new EE_Error($error_msg);
1956
-        }
1957
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1958
-        $this->_views = apply_filters(
1959
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1960
-            $this->_views
1961
-        );
1962
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1963
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1964
-        $this->_set_list_table_view();
1965
-        $this->_set_list_table_object();
1966
-    }
1967
-
1968
-
1969
-    /**
1970
-     * set current view for List Table
1971
-     *
1972
-     * @return void
1973
-     */
1974
-    protected function _set_list_table_view()
1975
-    {
1976
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1977
-        $status = $this->request->getRequestParam('status', null, 'key');
1978
-        $this->_view = $status && array_key_exists($status, $this->_views)
1979
-            ? $status
1980
-            : $this->_view;
1981
-    }
1982
-
1983
-
1984
-    /**
1985
-     * _set_list_table_object
1986
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1987
-     *
1988
-     * @throws InvalidInterfaceException
1989
-     * @throws InvalidArgumentException
1990
-     * @throws InvalidDataTypeException
1991
-     * @throws EE_Error
1992
-     * @throws InvalidInterfaceException
1993
-     */
1994
-    protected function _set_list_table_object()
1995
-    {
1996
-        if (isset($this->_route_config['list_table'])) {
1997
-            if (! class_exists($this->_route_config['list_table'])) {
1998
-                throw new EE_Error(
1999
-                    sprintf(
2000
-                        esc_html__(
2001
-                            '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.',
2002
-                            'event_espresso'
2003
-                        ),
2004
-                        $this->_route_config['list_table'],
2005
-                        get_class($this)
2006
-                    )
2007
-                );
2008
-            }
2009
-            $this->_list_table_object = $this->loader->getShared(
2010
-                $this->_route_config['list_table'],
2011
-                [$this]
2012
-            );
2013
-        }
2014
-    }
2015
-
2016
-
2017
-    /**
2018
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2019
-     *
2020
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2021
-     *                                                    urls.  The array should be indexed by the view it is being
2022
-     *                                                    added to.
2023
-     * @return array
2024
-     */
2025
-    public function get_list_table_view_RLs($extra_query_args = [])
2026
-    {
2027
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2028
-        if (empty($this->_views)) {
2029
-            $this->_views = [];
2030
-        }
2031
-        // cycle thru views
2032
-        foreach ($this->_views as $key => $view) {
2033
-            $query_args = [];
2034
-            // check for current view
2035
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2036
-            $query_args['action']                        = $this->_req_action;
2037
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2038
-            $query_args['status']                        = $view['slug'];
2039
-            // merge any other arguments sent in.
2040
-            if (isset($extra_query_args[ $view['slug'] ])) {
2041
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2042
-            }
2043
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2044
-        }
2045
-        return $this->_views;
2046
-    }
2047
-
2048
-
2049
-    /**
2050
-     * _entries_per_page_dropdown
2051
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2052
-     *
2053
-     * @param int $max_entries total number of rows in the table
2054
-     * @return string
2055
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2056
-     *         WP does it.
2057
-     */
2058
-    protected function _entries_per_page_dropdown($max_entries = 0)
2059
-    {
2060
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2061
-        $values   = [10, 25, 50, 100];
2062
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2063
-        if ($max_entries) {
2064
-            $values[] = $max_entries;
2065
-            sort($values);
2066
-        }
2067
-        $entries_per_page_dropdown = '
1542
+		// current set timezone for timezone js
1543
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1544
+	}
1545
+
1546
+
1547
+	/**
1548
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1549
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1550
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1551
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1552
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1553
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1554
+	 * for the
1555
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1556
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1557
+	 *    'help_trigger_id' => array(
1558
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1559
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1560
+	 *    )
1561
+	 * );
1562
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1563
+	 *
1564
+	 * @param array $help_array
1565
+	 * @param bool  $display
1566
+	 * @return string content
1567
+	 * @throws DomainException
1568
+	 * @throws EE_Error
1569
+	 */
1570
+	protected function _set_help_popup_content($help_array = [], $display = false)
1571
+	{
1572
+		$content    = '';
1573
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1574
+		// loop through the array and setup content
1575
+		foreach ($help_array as $trigger => $help) {
1576
+			// make sure the array is setup properly
1577
+			if (! isset($help['title']) || ! isset($help['content'])) {
1578
+				throw new EE_Error(
1579
+					esc_html__(
1580
+						'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',
1581
+						'event_espresso'
1582
+					)
1583
+				);
1584
+			}
1585
+			// we're good so let's setup the template vars and then assign parsed template content to our content.
1586
+			$template_args = [
1587
+				'help_popup_id'      => $trigger,
1588
+				'help_popup_title'   => $help['title'],
1589
+				'help_popup_content' => $help['content'],
1590
+			];
1591
+			$content       .= EEH_Template::display_template(
1592
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1593
+				$template_args,
1594
+				true
1595
+			);
1596
+		}
1597
+		if ($display) {
1598
+			echo wp_kses($content, AllowedTags::getWithFormTags());
1599
+			return '';
1600
+		}
1601
+		return $content;
1602
+	}
1603
+
1604
+
1605
+	/**
1606
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1607
+	 *
1608
+	 * @return array properly formatted array for help popup content
1609
+	 * @throws EE_Error
1610
+	 */
1611
+	private function _get_help_content()
1612
+	{
1613
+		// what is the method we're looking for?
1614
+		$method_name = '_help_popup_content_' . $this->_req_action;
1615
+		// if method doesn't exist let's get out.
1616
+		if (! method_exists($this, $method_name)) {
1617
+			return [];
1618
+		}
1619
+		// k we're good to go let's retrieve the help array
1620
+		$help_array = call_user_func([$this, $method_name]);
1621
+		// make sure we've got an array!
1622
+		if (! is_array($help_array)) {
1623
+			throw new EE_Error(
1624
+				esc_html__(
1625
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1626
+					'event_espresso'
1627
+				)
1628
+			);
1629
+		}
1630
+		return $help_array;
1631
+	}
1632
+
1633
+
1634
+	/**
1635
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1636
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1637
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1638
+	 *
1639
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1640
+	 * @param boolean $display    if false then we return the trigger string
1641
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1642
+	 * @return string
1643
+	 * @throws DomainException
1644
+	 * @throws EE_Error
1645
+	 */
1646
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1647
+	{
1648
+		if ($this->request->isAjax()) {
1649
+			return '';
1650
+		}
1651
+		// 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
1652
+		$help_array   = $this->_get_help_content();
1653
+		$help_content = '';
1654
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1655
+			$help_array[ $trigger_id ] = [
1656
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1657
+				'content' => esc_html__(
1658
+					'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.)',
1659
+					'event_espresso'
1660
+				),
1661
+			];
1662
+			$help_content              = $this->_set_help_popup_content($help_array);
1663
+		}
1664
+		// let's setup the trigger
1665
+		$content = '<a class="ee-dialog" href="?height='
1666
+				   . esc_attr($dimensions[0])
1667
+				   . '&width='
1668
+				   . esc_attr($dimensions[1])
1669
+				   . '&inlineId='
1670
+				   . esc_attr($trigger_id)
1671
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1672
+		$content .= $help_content;
1673
+		if ($display) {
1674
+			echo wp_kses($content, AllowedTags::getWithFormTags());
1675
+			return '';
1676
+		}
1677
+		return $content;
1678
+	}
1679
+
1680
+
1681
+	/**
1682
+	 * _add_global_screen_options
1683
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1684
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1685
+	 *
1686
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1687
+	 *         see also WP_Screen object documents...
1688
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1689
+	 * @abstract
1690
+	 * @return void
1691
+	 */
1692
+	private function _add_global_screen_options()
1693
+	{
1694
+	}
1695
+
1696
+
1697
+	/**
1698
+	 * _add_global_feature_pointers
1699
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1700
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1701
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1702
+	 *
1703
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1704
+	 *         extended) also see:
1705
+	 * @link   http://eamann.com/tech/wordpress-portland/
1706
+	 * @abstract
1707
+	 * @return void
1708
+	 */
1709
+	private function _add_global_feature_pointers()
1710
+	{
1711
+	}
1712
+
1713
+
1714
+	/**
1715
+	 * load_global_scripts_styles
1716
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1717
+	 *
1718
+	 * @return void
1719
+	 */
1720
+	public function load_global_scripts_styles()
1721
+	{
1722
+		/** STYLES **/
1723
+		// add debugging styles
1724
+		if (WP_DEBUG) {
1725
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1726
+		}
1727
+		// register all styles
1728
+		wp_register_style(
1729
+			'espresso-ui-theme',
1730
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1731
+			[],
1732
+			EVENT_ESPRESSO_VERSION
1733
+		);
1734
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1735
+		// helpers styles
1736
+		wp_register_style(
1737
+			'ee-text-links',
1738
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1739
+			[],
1740
+			EVENT_ESPRESSO_VERSION
1741
+		);
1742
+		/** SCRIPTS **/
1743
+		// register all scripts
1744
+		wp_register_script(
1745
+			'ee-dialog',
1746
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1747
+			['jquery', 'jquery-ui-draggable'],
1748
+			EVENT_ESPRESSO_VERSION,
1749
+			true
1750
+		);
1751
+		wp_register_script(
1752
+			'ee_admin_js',
1753
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1754
+			['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1755
+			EVENT_ESPRESSO_VERSION,
1756
+			true
1757
+		);
1758
+		wp_register_script(
1759
+			'jquery-ui-timepicker-addon',
1760
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1761
+			['jquery-ui-datepicker', 'jquery-ui-slider'],
1762
+			EVENT_ESPRESSO_VERSION,
1763
+			true
1764
+		);
1765
+		// script for sorting tables
1766
+		wp_register_script(
1767
+			'espresso_ajax_table_sorting',
1768
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1769
+			['ee_admin_js', 'jquery-ui-sortable'],
1770
+			EVENT_ESPRESSO_VERSION,
1771
+			true
1772
+		);
1773
+		// script for parsing uri's
1774
+		wp_register_script(
1775
+			'ee-parse-uri',
1776
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1777
+			[],
1778
+			EVENT_ESPRESSO_VERSION,
1779
+			true
1780
+		);
1781
+		// and parsing associative serialized form elements
1782
+		wp_register_script(
1783
+			'ee-serialize-full-array',
1784
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1785
+			['jquery'],
1786
+			EVENT_ESPRESSO_VERSION,
1787
+			true
1788
+		);
1789
+		// helpers scripts
1790
+		wp_register_script(
1791
+			'ee-text-links',
1792
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1793
+			['jquery'],
1794
+			EVENT_ESPRESSO_VERSION,
1795
+			true
1796
+		);
1797
+		wp_register_script(
1798
+			'ee-moment-core',
1799
+			EE_GLOBAL_ASSETS_URL . 'moment/moment-with-locales.min.js',
1800
+			[],
1801
+			EVENT_ESPRESSO_VERSION,
1802
+			true
1803
+		);
1804
+		wp_register_script(
1805
+			'ee-moment',
1806
+			EE_GLOBAL_ASSETS_URL . 'moment/moment-timezone-with-data.min.js',
1807
+			['ee-moment-core'],
1808
+			EVENT_ESPRESSO_VERSION,
1809
+			true
1810
+		);
1811
+		wp_register_script(
1812
+			'ee-datepicker',
1813
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1814
+			['jquery-ui-timepicker-addon', 'ee-moment'],
1815
+			EVENT_ESPRESSO_VERSION,
1816
+			true
1817
+		);
1818
+		// google charts
1819
+		wp_register_script(
1820
+			'google-charts',
1821
+			'https://www.gstatic.com/charts/loader.js',
1822
+			[],
1823
+			EVENT_ESPRESSO_VERSION
1824
+		);
1825
+		// ENQUEUE ALL BASICS BY DEFAULT
1826
+		wp_enqueue_style('ee-admin-css');
1827
+		wp_enqueue_script('ee_admin_js');
1828
+		wp_enqueue_script('ee-accounting');
1829
+		wp_enqueue_script('jquery-validate');
1830
+		// taking care of metaboxes
1831
+		if (
1832
+			empty($this->_cpt_route)
1833
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1834
+		) {
1835
+			wp_enqueue_script('dashboard');
1836
+		}
1837
+		// LOCALIZED DATA
1838
+		// localize script for ajax lazy loading
1839
+		$lazy_loader_container_ids = apply_filters(
1840
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1841
+			['espresso_news_post_box_content']
1842
+		);
1843
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1844
+		add_filter(
1845
+			'admin_body_class',
1846
+			function ($classes) {
1847
+				if (strpos($classes, 'espresso-admin') === false) {
1848
+					$classes .= ' espresso-admin';
1849
+				}
1850
+				return $classes;
1851
+			}
1852
+		);
1853
+	}
1854
+
1855
+
1856
+	/**
1857
+	 *        admin_footer_scripts_eei18n_js_strings
1858
+	 *
1859
+	 * @return        void
1860
+	 */
1861
+	public function admin_footer_scripts_eei18n_js_strings()
1862
+	{
1863
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1864
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1865
+			__(
1866
+				'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!!!',
1867
+				'event_espresso'
1868
+			)
1869
+		);
1870
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1871
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1872
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1873
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1874
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1875
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1876
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1877
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1878
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1879
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1880
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1881
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1882
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1883
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1884
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1885
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1886
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1887
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1888
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1889
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1890
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1891
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1892
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1893
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1894
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1895
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1896
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1897
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1898
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1899
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1900
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1901
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1902
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1903
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1904
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1905
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1906
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1907
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1908
+	}
1909
+
1910
+
1911
+	/**
1912
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1913
+	 *
1914
+	 * @return        void
1915
+	 */
1916
+	public function add_xdebug_style()
1917
+	{
1918
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1919
+	}
1920
+
1921
+
1922
+	/************************/
1923
+	/** LIST TABLE METHODS **/
1924
+	/************************/
1925
+	/**
1926
+	 * this sets up the list table if the current view requires it.
1927
+	 *
1928
+	 * @return void
1929
+	 * @throws EE_Error
1930
+	 */
1931
+	protected function _set_list_table()
1932
+	{
1933
+		// first is this a list_table view?
1934
+		if (! isset($this->_route_config['list_table'])) {
1935
+			return;
1936
+		} //not a list_table view so get out.
1937
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
1938
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
1939
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1940
+			// user error msg
1941
+			$error_msg = esc_html__(
1942
+				'An error occurred. The requested list table views could not be found.',
1943
+				'event_espresso'
1944
+			);
1945
+			// developer error msg
1946
+			$error_msg .= '||'
1947
+						  . sprintf(
1948
+							  esc_html__(
1949
+								  '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.',
1950
+								  'event_espresso'
1951
+							  ),
1952
+							  $this->_req_action,
1953
+							  $list_table_view
1954
+						  );
1955
+			throw new EE_Error($error_msg);
1956
+		}
1957
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1958
+		$this->_views = apply_filters(
1959
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1960
+			$this->_views
1961
+		);
1962
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1963
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1964
+		$this->_set_list_table_view();
1965
+		$this->_set_list_table_object();
1966
+	}
1967
+
1968
+
1969
+	/**
1970
+	 * set current view for List Table
1971
+	 *
1972
+	 * @return void
1973
+	 */
1974
+	protected function _set_list_table_view()
1975
+	{
1976
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1977
+		$status = $this->request->getRequestParam('status', null, 'key');
1978
+		$this->_view = $status && array_key_exists($status, $this->_views)
1979
+			? $status
1980
+			: $this->_view;
1981
+	}
1982
+
1983
+
1984
+	/**
1985
+	 * _set_list_table_object
1986
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1987
+	 *
1988
+	 * @throws InvalidInterfaceException
1989
+	 * @throws InvalidArgumentException
1990
+	 * @throws InvalidDataTypeException
1991
+	 * @throws EE_Error
1992
+	 * @throws InvalidInterfaceException
1993
+	 */
1994
+	protected function _set_list_table_object()
1995
+	{
1996
+		if (isset($this->_route_config['list_table'])) {
1997
+			if (! class_exists($this->_route_config['list_table'])) {
1998
+				throw new EE_Error(
1999
+					sprintf(
2000
+						esc_html__(
2001
+							'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.',
2002
+							'event_espresso'
2003
+						),
2004
+						$this->_route_config['list_table'],
2005
+						get_class($this)
2006
+					)
2007
+				);
2008
+			}
2009
+			$this->_list_table_object = $this->loader->getShared(
2010
+				$this->_route_config['list_table'],
2011
+				[$this]
2012
+			);
2013
+		}
2014
+	}
2015
+
2016
+
2017
+	/**
2018
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2019
+	 *
2020
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2021
+	 *                                                    urls.  The array should be indexed by the view it is being
2022
+	 *                                                    added to.
2023
+	 * @return array
2024
+	 */
2025
+	public function get_list_table_view_RLs($extra_query_args = [])
2026
+	{
2027
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2028
+		if (empty($this->_views)) {
2029
+			$this->_views = [];
2030
+		}
2031
+		// cycle thru views
2032
+		foreach ($this->_views as $key => $view) {
2033
+			$query_args = [];
2034
+			// check for current view
2035
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2036
+			$query_args['action']                        = $this->_req_action;
2037
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2038
+			$query_args['status']                        = $view['slug'];
2039
+			// merge any other arguments sent in.
2040
+			if (isset($extra_query_args[ $view['slug'] ])) {
2041
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2042
+			}
2043
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2044
+		}
2045
+		return $this->_views;
2046
+	}
2047
+
2048
+
2049
+	/**
2050
+	 * _entries_per_page_dropdown
2051
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2052
+	 *
2053
+	 * @param int $max_entries total number of rows in the table
2054
+	 * @return string
2055
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2056
+	 *         WP does it.
2057
+	 */
2058
+	protected function _entries_per_page_dropdown($max_entries = 0)
2059
+	{
2060
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2061
+		$values   = [10, 25, 50, 100];
2062
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2063
+		if ($max_entries) {
2064
+			$values[] = $max_entries;
2065
+			sort($values);
2066
+		}
2067
+		$entries_per_page_dropdown = '
2068 2068
 			<div id="entries-per-page-dv" class="alignleft actions">
2069 2069
 				<label class="hide-if-no-js">
2070 2070
 					Show
2071 2071
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2072
-        foreach ($values as $value) {
2073
-            if ($value < $max_entries) {
2074
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2075
-                $entries_per_page_dropdown .= '
2072
+		foreach ($values as $value) {
2073
+			if ($value < $max_entries) {
2074
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2075
+				$entries_per_page_dropdown .= '
2076 2076
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2077
-            }
2078
-        }
2079
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2080
-        $entries_per_page_dropdown .= '
2077
+			}
2078
+		}
2079
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2080
+		$entries_per_page_dropdown .= '
2081 2081
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2082
-        $entries_per_page_dropdown .= '
2082
+		$entries_per_page_dropdown .= '
2083 2083
 					</select>
2084 2084
 					entries
2085 2085
 				</label>
2086 2086
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2087 2087
 			</div>
2088 2088
 		';
2089
-        return $entries_per_page_dropdown;
2090
-    }
2091
-
2092
-
2093
-    /**
2094
-     *        _set_search_attributes
2095
-     *
2096
-     * @return        void
2097
-     */
2098
-    public function _set_search_attributes()
2099
-    {
2100
-        $this->_template_args['search']['btn_label'] = sprintf(
2101
-            esc_html__('Search %s', 'event_espresso'),
2102
-            empty($this->_search_btn_label) ? $this->page_label
2103
-                : $this->_search_btn_label
2104
-        );
2105
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2106
-    }
2107
-
2108
-
2109
-
2110
-    /*** END LIST TABLE METHODS **/
2111
-
2112
-
2113
-    /**
2114
-     * _add_registered_metaboxes
2115
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2116
-     *
2117
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2118
-     * @return void
2119
-     * @throws EE_Error
2120
-     */
2121
-    private function _add_registered_meta_boxes()
2122
-    {
2123
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2124
-        // we only add meta boxes if the page_route calls for it
2125
-        if (
2126
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2127
-            && is_array(
2128
-                $this->_route_config['metaboxes']
2129
-            )
2130
-        ) {
2131
-            // this simply loops through the callbacks provided
2132
-            // and checks if there is a corresponding callback registered by the child
2133
-            // if there is then we go ahead and process the metabox loader.
2134
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2135
-                // first check for Closures
2136
-                if ($metabox_callback instanceof Closure) {
2137
-                    $result = $metabox_callback();
2138
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2139
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2140
-                } else {
2141
-                    $result = call_user_func([$this, &$metabox_callback]);
2142
-                }
2143
-                if ($result === false) {
2144
-                    // user error msg
2145
-                    $error_msg = esc_html__(
2146
-                        'An error occurred. The  requested metabox could not be found.',
2147
-                        'event_espresso'
2148
-                    );
2149
-                    // developer error msg
2150
-                    $error_msg .= '||'
2151
-                                  . sprintf(
2152
-                                      esc_html__(
2153
-                                          '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.',
2154
-                                          'event_espresso'
2155
-                                      ),
2156
-                                      $metabox_callback
2157
-                                  );
2158
-                    throw new EE_Error($error_msg);
2159
-                }
2160
-            }
2161
-        }
2162
-    }
2163
-
2164
-
2165
-    /**
2166
-     * _add_screen_columns
2167
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2168
-     * the dynamic column template and we'll setup the column options for the page.
2169
-     *
2170
-     * @return void
2171
-     */
2172
-    private function _add_screen_columns()
2173
-    {
2174
-        if (
2175
-            is_array($this->_route_config)
2176
-            && isset($this->_route_config['columns'])
2177
-            && is_array($this->_route_config['columns'])
2178
-            && count($this->_route_config['columns']) === 2
2179
-        ) {
2180
-            add_screen_option(
2181
-                'layout_columns',
2182
-                [
2183
-                    'max'     => (int) $this->_route_config['columns'][0],
2184
-                    'default' => (int) $this->_route_config['columns'][1],
2185
-                ]
2186
-            );
2187
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2188
-            $screen_id                                           = $this->_current_screen->id;
2189
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2190
-            $total_columns                                       = ! empty($screen_columns)
2191
-                ? $screen_columns
2192
-                : $this->_route_config['columns'][1];
2193
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2194
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2195
-            $this->_template_args['screen']                      = $this->_current_screen;
2196
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2197
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2198
-            // finally if we don't have has_metaboxes set in the route config
2199
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2200
-            $this->_route_config['has_metaboxes'] = true;
2201
-        }
2202
-    }
2203
-
2204
-
2205
-
2206
-    /** GLOBALLY AVAILABLE METABOXES **/
2207
-
2208
-
2209
-    /**
2210
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2211
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2212
-     * these get loaded on.
2213
-     */
2214
-    private function _espresso_news_post_box()
2215
-    {
2216
-        $news_box_title = apply_filters(
2217
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2218
-            esc_html__('New @ Event Espresso', 'event_espresso')
2219
-        );
2220
-        add_meta_box(
2221
-            'espresso_news_post_box',
2222
-            $news_box_title,
2223
-            [
2224
-                $this,
2225
-                'espresso_news_post_box',
2226
-            ],
2227
-            $this->_wp_page_slug,
2228
-            'side'
2229
-        );
2230
-    }
2231
-
2232
-
2233
-    /**
2234
-     * Code for setting up espresso ratings request metabox.
2235
-     */
2236
-    protected function _espresso_ratings_request()
2237
-    {
2238
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2239
-            return;
2240
-        }
2241
-        $ratings_box_title = apply_filters(
2242
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2243
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2244
-        );
2245
-        add_meta_box(
2246
-            'espresso_ratings_request',
2247
-            $ratings_box_title,
2248
-            [
2249
-                $this,
2250
-                'espresso_ratings_request',
2251
-            ],
2252
-            $this->_wp_page_slug,
2253
-            'side'
2254
-        );
2255
-    }
2256
-
2257
-
2258
-    /**
2259
-     * Code for setting up espresso ratings request metabox content.
2260
-     *
2261
-     * @throws DomainException
2262
-     */
2263
-    public function espresso_ratings_request()
2264
-    {
2265
-        EEH_Template::display_template(
2266
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2267
-            []
2268
-        );
2269
-    }
2270
-
2271
-
2272
-    public static function cached_rss_display($rss_id, $url)
2273
-    {
2274
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2275
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2276
-                     . '</p><p class="hide-if-js">'
2277
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2278
-                     . '</p>';
2279
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2280
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2281
-        $post      = '</div>' . "\n";
2282
-        $cache_key = 'ee_rss_' . md5($rss_id);
2283
-        $output    = get_transient($cache_key);
2284
-        if ($output !== false) {
2285
-            echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2286
-            return true;
2287
-        }
2288
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2289
-            echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2290
-            return false;
2291
-        }
2292
-        ob_start();
2293
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2294
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2295
-        return true;
2296
-    }
2297
-
2298
-
2299
-    public function espresso_news_post_box()
2300
-    {
2301
-        ?>
2089
+		return $entries_per_page_dropdown;
2090
+	}
2091
+
2092
+
2093
+	/**
2094
+	 *        _set_search_attributes
2095
+	 *
2096
+	 * @return        void
2097
+	 */
2098
+	public function _set_search_attributes()
2099
+	{
2100
+		$this->_template_args['search']['btn_label'] = sprintf(
2101
+			esc_html__('Search %s', 'event_espresso'),
2102
+			empty($this->_search_btn_label) ? $this->page_label
2103
+				: $this->_search_btn_label
2104
+		);
2105
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2106
+	}
2107
+
2108
+
2109
+
2110
+	/*** END LIST TABLE METHODS **/
2111
+
2112
+
2113
+	/**
2114
+	 * _add_registered_metaboxes
2115
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2116
+	 *
2117
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2118
+	 * @return void
2119
+	 * @throws EE_Error
2120
+	 */
2121
+	private function _add_registered_meta_boxes()
2122
+	{
2123
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2124
+		// we only add meta boxes if the page_route calls for it
2125
+		if (
2126
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2127
+			&& is_array(
2128
+				$this->_route_config['metaboxes']
2129
+			)
2130
+		) {
2131
+			// this simply loops through the callbacks provided
2132
+			// and checks if there is a corresponding callback registered by the child
2133
+			// if there is then we go ahead and process the metabox loader.
2134
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2135
+				// first check for Closures
2136
+				if ($metabox_callback instanceof Closure) {
2137
+					$result = $metabox_callback();
2138
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2139
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2140
+				} else {
2141
+					$result = call_user_func([$this, &$metabox_callback]);
2142
+				}
2143
+				if ($result === false) {
2144
+					// user error msg
2145
+					$error_msg = esc_html__(
2146
+						'An error occurred. The  requested metabox could not be found.',
2147
+						'event_espresso'
2148
+					);
2149
+					// developer error msg
2150
+					$error_msg .= '||'
2151
+								  . sprintf(
2152
+									  esc_html__(
2153
+										  '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.',
2154
+										  'event_espresso'
2155
+									  ),
2156
+									  $metabox_callback
2157
+								  );
2158
+					throw new EE_Error($error_msg);
2159
+				}
2160
+			}
2161
+		}
2162
+	}
2163
+
2164
+
2165
+	/**
2166
+	 * _add_screen_columns
2167
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2168
+	 * the dynamic column template and we'll setup the column options for the page.
2169
+	 *
2170
+	 * @return void
2171
+	 */
2172
+	private function _add_screen_columns()
2173
+	{
2174
+		if (
2175
+			is_array($this->_route_config)
2176
+			&& isset($this->_route_config['columns'])
2177
+			&& is_array($this->_route_config['columns'])
2178
+			&& count($this->_route_config['columns']) === 2
2179
+		) {
2180
+			add_screen_option(
2181
+				'layout_columns',
2182
+				[
2183
+					'max'     => (int) $this->_route_config['columns'][0],
2184
+					'default' => (int) $this->_route_config['columns'][1],
2185
+				]
2186
+			);
2187
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2188
+			$screen_id                                           = $this->_current_screen->id;
2189
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2190
+			$total_columns                                       = ! empty($screen_columns)
2191
+				? $screen_columns
2192
+				: $this->_route_config['columns'][1];
2193
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2194
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2195
+			$this->_template_args['screen']                      = $this->_current_screen;
2196
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2197
+																   . 'admin_details_metabox_column_wrapper.template.php';
2198
+			// finally if we don't have has_metaboxes set in the route config
2199
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2200
+			$this->_route_config['has_metaboxes'] = true;
2201
+		}
2202
+	}
2203
+
2204
+
2205
+
2206
+	/** GLOBALLY AVAILABLE METABOXES **/
2207
+
2208
+
2209
+	/**
2210
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2211
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2212
+	 * these get loaded on.
2213
+	 */
2214
+	private function _espresso_news_post_box()
2215
+	{
2216
+		$news_box_title = apply_filters(
2217
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2218
+			esc_html__('New @ Event Espresso', 'event_espresso')
2219
+		);
2220
+		add_meta_box(
2221
+			'espresso_news_post_box',
2222
+			$news_box_title,
2223
+			[
2224
+				$this,
2225
+				'espresso_news_post_box',
2226
+			],
2227
+			$this->_wp_page_slug,
2228
+			'side'
2229
+		);
2230
+	}
2231
+
2232
+
2233
+	/**
2234
+	 * Code for setting up espresso ratings request metabox.
2235
+	 */
2236
+	protected function _espresso_ratings_request()
2237
+	{
2238
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2239
+			return;
2240
+		}
2241
+		$ratings_box_title = apply_filters(
2242
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2243
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2244
+		);
2245
+		add_meta_box(
2246
+			'espresso_ratings_request',
2247
+			$ratings_box_title,
2248
+			[
2249
+				$this,
2250
+				'espresso_ratings_request',
2251
+			],
2252
+			$this->_wp_page_slug,
2253
+			'side'
2254
+		);
2255
+	}
2256
+
2257
+
2258
+	/**
2259
+	 * Code for setting up espresso ratings request metabox content.
2260
+	 *
2261
+	 * @throws DomainException
2262
+	 */
2263
+	public function espresso_ratings_request()
2264
+	{
2265
+		EEH_Template::display_template(
2266
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2267
+			[]
2268
+		);
2269
+	}
2270
+
2271
+
2272
+	public static function cached_rss_display($rss_id, $url)
2273
+	{
2274
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2275
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2276
+					 . '</p><p class="hide-if-js">'
2277
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2278
+					 . '</p>';
2279
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2280
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2281
+		$post      = '</div>' . "\n";
2282
+		$cache_key = 'ee_rss_' . md5($rss_id);
2283
+		$output    = get_transient($cache_key);
2284
+		if ($output !== false) {
2285
+			echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2286
+			return true;
2287
+		}
2288
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2289
+			echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2290
+			return false;
2291
+		}
2292
+		ob_start();
2293
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2294
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2295
+		return true;
2296
+	}
2297
+
2298
+
2299
+	public function espresso_news_post_box()
2300
+	{
2301
+		?>
2302 2302
         <div class="padding">
2303 2303
             <div id="espresso_news_post_box_content" class="infolinks">
2304 2304
                 <?php
2305
-                // Get RSS Feed(s)
2306
-                self::cached_rss_display(
2307
-                    'espresso_news_post_box_content',
2308
-                    esc_url_raw(
2309
-                        apply_filters(
2310
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2311
-                            'https://eventespresso.com/feed/'
2312
-                        )
2313
-                    )
2314
-                );
2315
-                ?>
2305
+				// Get RSS Feed(s)
2306
+				self::cached_rss_display(
2307
+					'espresso_news_post_box_content',
2308
+					esc_url_raw(
2309
+						apply_filters(
2310
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2311
+							'https://eventespresso.com/feed/'
2312
+						)
2313
+					)
2314
+				);
2315
+				?>
2316 2316
             </div>
2317 2317
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2318 2318
         </div>
2319 2319
         <?php
2320
-    }
2321
-
2322
-
2323
-    private function _espresso_links_post_box()
2324
-    {
2325
-        // Hiding until we actually have content to put in here...
2326
-        // 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');
2327
-    }
2328
-
2329
-
2330
-    public function espresso_links_post_box()
2331
-    {
2332
-        // Hiding until we actually have content to put in here...
2333
-        // EEH_Template::display_template(
2334
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2335
-        // );
2336
-    }
2337
-
2338
-
2339
-    protected function _espresso_sponsors_post_box()
2340
-    {
2341
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2342
-            add_meta_box(
2343
-                'espresso_sponsors_post_box',
2344
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2345
-                [$this, 'espresso_sponsors_post_box'],
2346
-                $this->_wp_page_slug,
2347
-                'side'
2348
-            );
2349
-        }
2350
-    }
2351
-
2352
-
2353
-    public function espresso_sponsors_post_box()
2354
-    {
2355
-        EEH_Template::display_template(
2356
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2357
-        );
2358
-    }
2359
-
2360
-
2361
-    private function _publish_post_box()
2362
-    {
2363
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2364
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2365
-        // then we'll use that for the metabox label.
2366
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2367
-        if (! empty($this->_labels['publishbox'])) {
2368
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2369
-                : $this->_labels['publishbox'];
2370
-        } else {
2371
-            $box_label = esc_html__('Publish', 'event_espresso');
2372
-        }
2373
-        $box_label = apply_filters(
2374
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2375
-            $box_label,
2376
-            $this->_req_action,
2377
-            $this
2378
-        );
2379
-        add_meta_box(
2380
-            $meta_box_ref,
2381
-            $box_label,
2382
-            [$this, 'editor_overview'],
2383
-            $this->_current_screen->id,
2384
-            'side',
2385
-            'high'
2386
-        );
2387
-    }
2388
-
2389
-
2390
-    public function editor_overview()
2391
-    {
2392
-        // if we have extra content set let's add it in if not make sure its empty
2393
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2394
-            ? $this->_template_args['publish_box_extra_content']
2395
-            : '';
2396
-        echo EEH_Template::display_template(
2397
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2398
-            $this->_template_args,
2399
-            true
2400
-        );
2401
-    }
2402
-
2403
-
2404
-    /** end of globally available metaboxes section **/
2405
-
2406
-
2407
-    /**
2408
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2409
-     * protected method.
2410
-     *
2411
-     * @param string $name
2412
-     * @param int    $id
2413
-     * @param bool   $delete
2414
-     * @param string $save_close_redirect_URL
2415
-     * @param bool   $both_btns
2416
-     * @throws EE_Error
2417
-     * @throws InvalidArgumentException
2418
-     * @throws InvalidDataTypeException
2419
-     * @throws InvalidInterfaceException
2420
-     * @see   $this->_set_publish_post_box_vars for param details
2421
-     * @since 4.6.0
2422
-     */
2423
-    public function set_publish_post_box_vars(
2424
-        $name = '',
2425
-        $id = 0,
2426
-        $delete = false,
2427
-        $save_close_redirect_URL = '',
2428
-        $both_btns = true
2429
-    ) {
2430
-        $this->_set_publish_post_box_vars(
2431
-            $name,
2432
-            $id,
2433
-            $delete,
2434
-            $save_close_redirect_URL,
2435
-            $both_btns
2436
-        );
2437
-    }
2438
-
2439
-
2440
-    /**
2441
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2442
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2443
-     * save, and save and close buttons to work properly, then you will want to include a
2444
-     * values for the name and id arguments.
2445
-     *
2446
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2447
-     * @param int     $id                         id attached to the item published
2448
-     * @param string  $delete                     page route callback for the delete action
2449
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2450
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2451
-     *                                            the Save button
2452
-     * @throws EE_Error
2453
-     * @throws InvalidArgumentException
2454
-     * @throws InvalidDataTypeException
2455
-     * @throws InvalidInterfaceException
2456
-     * @todo  Add in validation for name/id arguments.
2457
-     */
2458
-    protected function _set_publish_post_box_vars(
2459
-        $name = '',
2460
-        $id = 0,
2461
-        $delete = '',
2462
-        $save_close_redirect_URL = '',
2463
-        $both_btns = true
2464
-    ) {
2465
-        // if Save & Close, use a custom redirect URL or default to the main page?
2466
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2467
-            ? $save_close_redirect_URL
2468
-            : $this->_admin_base_url;
2469
-        // create the Save & Close and Save buttons
2470
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2471
-        // if we have extra content set let's add it in if not make sure its empty
2472
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2473
-            ? $this->_template_args['publish_box_extra_content']
2474
-            : '';
2475
-        if ($delete && ! empty($id)) {
2476
-            // make sure we have a default if just true is sent.
2477
-            $delete           = ! empty($delete) ? $delete : 'delete';
2478
-            $delete_link_args = [$name => $id];
2479
-            $delete           = $this->get_action_link_or_button(
2480
-                $delete,
2481
-                $delete,
2482
-                $delete_link_args,
2483
-                'submitdelete deletion',
2484
-                '',
2485
-                false
2486
-            );
2487
-        }
2488
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2489
-        if (! empty($name) && ! empty($id)) {
2490
-            $hidden_field_arr[ $name ] = [
2491
-                'type'  => 'hidden',
2492
-                'value' => $id,
2493
-            ];
2494
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2495
-        } else {
2496
-            $hf = '';
2497
-        }
2498
-        // add hidden field
2499
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2500
-            ? $hf[ $name ]['field']
2501
-            : $hf;
2502
-    }
2503
-
2504
-
2505
-    /**
2506
-     * displays an error message to ppl who have javascript disabled
2507
-     *
2508
-     * @return void
2509
-     */
2510
-    private function _display_no_javascript_warning()
2511
-    {
2512
-        ?>
2320
+	}
2321
+
2322
+
2323
+	private function _espresso_links_post_box()
2324
+	{
2325
+		// Hiding until we actually have content to put in here...
2326
+		// 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');
2327
+	}
2328
+
2329
+
2330
+	public function espresso_links_post_box()
2331
+	{
2332
+		// Hiding until we actually have content to put in here...
2333
+		// EEH_Template::display_template(
2334
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2335
+		// );
2336
+	}
2337
+
2338
+
2339
+	protected function _espresso_sponsors_post_box()
2340
+	{
2341
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2342
+			add_meta_box(
2343
+				'espresso_sponsors_post_box',
2344
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2345
+				[$this, 'espresso_sponsors_post_box'],
2346
+				$this->_wp_page_slug,
2347
+				'side'
2348
+			);
2349
+		}
2350
+	}
2351
+
2352
+
2353
+	public function espresso_sponsors_post_box()
2354
+	{
2355
+		EEH_Template::display_template(
2356
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2357
+		);
2358
+	}
2359
+
2360
+
2361
+	private function _publish_post_box()
2362
+	{
2363
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2364
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2365
+		// then we'll use that for the metabox label.
2366
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2367
+		if (! empty($this->_labels['publishbox'])) {
2368
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2369
+				: $this->_labels['publishbox'];
2370
+		} else {
2371
+			$box_label = esc_html__('Publish', 'event_espresso');
2372
+		}
2373
+		$box_label = apply_filters(
2374
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2375
+			$box_label,
2376
+			$this->_req_action,
2377
+			$this
2378
+		);
2379
+		add_meta_box(
2380
+			$meta_box_ref,
2381
+			$box_label,
2382
+			[$this, 'editor_overview'],
2383
+			$this->_current_screen->id,
2384
+			'side',
2385
+			'high'
2386
+		);
2387
+	}
2388
+
2389
+
2390
+	public function editor_overview()
2391
+	{
2392
+		// if we have extra content set let's add it in if not make sure its empty
2393
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2394
+			? $this->_template_args['publish_box_extra_content']
2395
+			: '';
2396
+		echo EEH_Template::display_template(
2397
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2398
+			$this->_template_args,
2399
+			true
2400
+		);
2401
+	}
2402
+
2403
+
2404
+	/** end of globally available metaboxes section **/
2405
+
2406
+
2407
+	/**
2408
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2409
+	 * protected method.
2410
+	 *
2411
+	 * @param string $name
2412
+	 * @param int    $id
2413
+	 * @param bool   $delete
2414
+	 * @param string $save_close_redirect_URL
2415
+	 * @param bool   $both_btns
2416
+	 * @throws EE_Error
2417
+	 * @throws InvalidArgumentException
2418
+	 * @throws InvalidDataTypeException
2419
+	 * @throws InvalidInterfaceException
2420
+	 * @see   $this->_set_publish_post_box_vars for param details
2421
+	 * @since 4.6.0
2422
+	 */
2423
+	public function set_publish_post_box_vars(
2424
+		$name = '',
2425
+		$id = 0,
2426
+		$delete = false,
2427
+		$save_close_redirect_URL = '',
2428
+		$both_btns = true
2429
+	) {
2430
+		$this->_set_publish_post_box_vars(
2431
+			$name,
2432
+			$id,
2433
+			$delete,
2434
+			$save_close_redirect_URL,
2435
+			$both_btns
2436
+		);
2437
+	}
2438
+
2439
+
2440
+	/**
2441
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2442
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2443
+	 * save, and save and close buttons to work properly, then you will want to include a
2444
+	 * values for the name and id arguments.
2445
+	 *
2446
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2447
+	 * @param int     $id                         id attached to the item published
2448
+	 * @param string  $delete                     page route callback for the delete action
2449
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2450
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2451
+	 *                                            the Save button
2452
+	 * @throws EE_Error
2453
+	 * @throws InvalidArgumentException
2454
+	 * @throws InvalidDataTypeException
2455
+	 * @throws InvalidInterfaceException
2456
+	 * @todo  Add in validation for name/id arguments.
2457
+	 */
2458
+	protected function _set_publish_post_box_vars(
2459
+		$name = '',
2460
+		$id = 0,
2461
+		$delete = '',
2462
+		$save_close_redirect_URL = '',
2463
+		$both_btns = true
2464
+	) {
2465
+		// if Save & Close, use a custom redirect URL or default to the main page?
2466
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2467
+			? $save_close_redirect_URL
2468
+			: $this->_admin_base_url;
2469
+		// create the Save & Close and Save buttons
2470
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2471
+		// if we have extra content set let's add it in if not make sure its empty
2472
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2473
+			? $this->_template_args['publish_box_extra_content']
2474
+			: '';
2475
+		if ($delete && ! empty($id)) {
2476
+			// make sure we have a default if just true is sent.
2477
+			$delete           = ! empty($delete) ? $delete : 'delete';
2478
+			$delete_link_args = [$name => $id];
2479
+			$delete           = $this->get_action_link_or_button(
2480
+				$delete,
2481
+				$delete,
2482
+				$delete_link_args,
2483
+				'submitdelete deletion',
2484
+				'',
2485
+				false
2486
+			);
2487
+		}
2488
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2489
+		if (! empty($name) && ! empty($id)) {
2490
+			$hidden_field_arr[ $name ] = [
2491
+				'type'  => 'hidden',
2492
+				'value' => $id,
2493
+			];
2494
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2495
+		} else {
2496
+			$hf = '';
2497
+		}
2498
+		// add hidden field
2499
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2500
+			? $hf[ $name ]['field']
2501
+			: $hf;
2502
+	}
2503
+
2504
+
2505
+	/**
2506
+	 * displays an error message to ppl who have javascript disabled
2507
+	 *
2508
+	 * @return void
2509
+	 */
2510
+	private function _display_no_javascript_warning()
2511
+	{
2512
+		?>
2513 2513
         <noscript>
2514 2514
             <div id="no-js-message" class="error">
2515 2515
                 <p style="font-size:1.3em;">
2516 2516
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2517 2517
                     <?php esc_html_e(
2518
-                        '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.',
2519
-                        'event_espresso'
2520
-                    ); ?>
2518
+						'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.',
2519
+						'event_espresso'
2520
+					); ?>
2521 2521
                 </p>
2522 2522
             </div>
2523 2523
         </noscript>
2524 2524
         <?php
2525
-    }
2526
-
2527
-
2528
-    /**
2529
-     * displays espresso success and/or error notices
2530
-     *
2531
-     * @return void
2532
-     */
2533
-    protected function _display_espresso_notices()
2534
-    {
2535
-        $notices = $this->_get_transient(true);
2536
-        echo stripslashes($notices);
2537
-    }
2538
-
2539
-
2540
-    /**
2541
-     * spinny things pacify the masses
2542
-     *
2543
-     * @return void
2544
-     */
2545
-    protected function _add_admin_page_ajax_loading_img()
2546
-    {
2547
-        ?>
2525
+	}
2526
+
2527
+
2528
+	/**
2529
+	 * displays espresso success and/or error notices
2530
+	 *
2531
+	 * @return void
2532
+	 */
2533
+	protected function _display_espresso_notices()
2534
+	{
2535
+		$notices = $this->_get_transient(true);
2536
+		echo stripslashes($notices);
2537
+	}
2538
+
2539
+
2540
+	/**
2541
+	 * spinny things pacify the masses
2542
+	 *
2543
+	 * @return void
2544
+	 */
2545
+	protected function _add_admin_page_ajax_loading_img()
2546
+	{
2547
+		?>
2548 2548
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2549 2549
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2550
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2550
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2551 2551
         </div>
2552 2552
         <?php
2553
-    }
2553
+	}
2554 2554
 
2555 2555
 
2556
-    /**
2557
-     * add admin page overlay for modal boxes
2558
-     *
2559
-     * @return void
2560
-     */
2561
-    protected function _add_admin_page_overlay()
2562
-    {
2563
-        ?>
2556
+	/**
2557
+	 * add admin page overlay for modal boxes
2558
+	 *
2559
+	 * @return void
2560
+	 */
2561
+	protected function _add_admin_page_overlay()
2562
+	{
2563
+		?>
2564 2564
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2565 2565
         <?php
2566
-    }
2567
-
2568
-
2569
-    /**
2570
-     * facade for add_meta_box
2571
-     *
2572
-     * @param string  $action        where the metabox gets displayed
2573
-     * @param string  $title         Title of Metabox (output in metabox header)
2574
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2575
-     *                               instead of the one created in here.
2576
-     * @param array   $callback_args an array of args supplied for the metabox
2577
-     * @param string  $column        what metabox column
2578
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2579
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2580
-     *                               created but just set our own callback for wp's add_meta_box.
2581
-     * @throws DomainException
2582
-     */
2583
-    public function _add_admin_page_meta_box(
2584
-        $action,
2585
-        $title,
2586
-        $callback,
2587
-        $callback_args,
2588
-        $column = 'normal',
2589
-        $priority = 'high',
2590
-        $create_func = true
2591
-    ) {
2592
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2593
-        // 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.
2594
-        if (empty($callback_args) && $create_func) {
2595
-            $callback_args = [
2596
-                'template_path' => $this->_template_path,
2597
-                'template_args' => $this->_template_args,
2598
-            ];
2599
-        }
2600
-        // 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)
2601
-        $call_back_func = $create_func
2602
-            ? function ($post, $metabox) {
2603
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2604
-                echo EEH_Template::display_template(
2605
-                    $metabox['args']['template_path'],
2606
-                    $metabox['args']['template_args'],
2607
-                    true
2608
-                );
2609
-            }
2610
-            : $callback;
2611
-        add_meta_box(
2612
-            str_replace('_', '-', $action) . '-mbox',
2613
-            $title,
2614
-            $call_back_func,
2615
-            $this->_wp_page_slug,
2616
-            $column,
2617
-            $priority,
2618
-            $callback_args
2619
-        );
2620
-    }
2621
-
2622
-
2623
-    /**
2624
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2625
-     *
2626
-     * @throws DomainException
2627
-     * @throws EE_Error
2628
-     */
2629
-    public function display_admin_page_with_metabox_columns()
2630
-    {
2631
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2632
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2633
-            $this->_column_template_path,
2634
-            $this->_template_args,
2635
-            true
2636
-        );
2637
-        // the final wrapper
2638
-        $this->admin_page_wrapper();
2639
-    }
2640
-
2641
-
2642
-    /**
2643
-     * generates  HTML wrapper for an admin details page
2644
-     *
2645
-     * @return void
2646
-     * @throws EE_Error
2647
-     * @throws DomainException
2648
-     */
2649
-    public function display_admin_page_with_sidebar()
2650
-    {
2651
-        $this->_display_admin_page(true);
2652
-    }
2653
-
2654
-
2655
-    /**
2656
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2657
-     *
2658
-     * @return void
2659
-     * @throws EE_Error
2660
-     * @throws DomainException
2661
-     */
2662
-    public function display_admin_page_with_no_sidebar()
2663
-    {
2664
-        $this->_display_admin_page();
2665
-    }
2666
-
2667
-
2668
-    /**
2669
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2670
-     *
2671
-     * @return void
2672
-     * @throws EE_Error
2673
-     * @throws DomainException
2674
-     */
2675
-    public function display_about_admin_page()
2676
-    {
2677
-        $this->_display_admin_page(false, true);
2678
-    }
2679
-
2680
-
2681
-    /**
2682
-     * display_admin_page
2683
-     * contains the code for actually displaying an admin page
2684
-     *
2685
-     * @param boolean $sidebar true with sidebar, false without
2686
-     * @param boolean $about   use the about_admin_wrapper instead of the default.
2687
-     * @return void
2688
-     * @throws DomainException
2689
-     * @throws EE_Error
2690
-     */
2691
-    private function _display_admin_page($sidebar = false, $about = false)
2692
-    {
2693
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2694
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2695
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2696
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2697
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2698
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2699
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2700
-            ? 'poststuff'
2701
-            : 'espresso-default-admin';
2702
-        $template_path                                     = $sidebar
2703
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2704
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2705
-        if ($this->request->isAjax()) {
2706
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2707
-        }
2708
-        $template_path                                     = ! empty($this->_column_template_path)
2709
-            ? $this->_column_template_path : $template_path;
2710
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2711
-            ? $this->_template_args['admin_page_content']
2712
-            : '';
2713
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2714
-            ? $this->_template_args['before_admin_page_content']
2715
-            : '';
2716
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2717
-            ? $this->_template_args['after_admin_page_content']
2718
-            : '';
2719
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2720
-            $template_path,
2721
-            $this->_template_args,
2722
-            true
2723
-        );
2724
-        // the final template wrapper
2725
-        $this->admin_page_wrapper($about);
2726
-    }
2727
-
2728
-
2729
-    /**
2730
-     * This is used to display caf preview pages.
2731
-     *
2732
-     * @param string $utm_campaign_source what is the key used for google analytics link
2733
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2734
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2735
-     * @return void
2736
-     * @throws DomainException
2737
-     * @throws EE_Error
2738
-     * @throws InvalidArgumentException
2739
-     * @throws InvalidDataTypeException
2740
-     * @throws InvalidInterfaceException
2741
-     * @since 4.3.2
2742
-     */
2743
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2744
-    {
2745
-        // let's generate a default preview action button if there isn't one already present.
2746
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2747
-            'Upgrade to Event Espresso 4 Right Now',
2748
-            'event_espresso'
2749
-        );
2750
-        $buy_now_url                                   = add_query_arg(
2751
-            [
2752
-                'ee_ver'       => 'ee4',
2753
-                'utm_source'   => 'ee4_plugin_admin',
2754
-                'utm_medium'   => 'link',
2755
-                'utm_campaign' => $utm_campaign_source,
2756
-                'utm_content'  => 'buy_now_button',
2757
-            ],
2758
-            'https://eventespresso.com/pricing/'
2759
-        );
2760
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2761
-            ? $this->get_action_link_or_button(
2762
-                '',
2763
-                'buy_now',
2764
-                [],
2765
-                'button-primary button-large',
2766
-                esc_url_raw($buy_now_url),
2767
-                true
2768
-            )
2769
-            : $this->_template_args['preview_action_button'];
2770
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2771
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2772
-            $this->_template_args,
2773
-            true
2774
-        );
2775
-        $this->_display_admin_page($display_sidebar);
2776
-    }
2777
-
2778
-
2779
-    /**
2780
-     * display_admin_list_table_page_with_sidebar
2781
-     * generates HTML wrapper for an admin_page with list_table
2782
-     *
2783
-     * @return void
2784
-     * @throws EE_Error
2785
-     * @throws DomainException
2786
-     */
2787
-    public function display_admin_list_table_page_with_sidebar()
2788
-    {
2789
-        $this->_display_admin_list_table_page(true);
2790
-    }
2791
-
2792
-
2793
-    /**
2794
-     * display_admin_list_table_page_with_no_sidebar
2795
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2796
-     *
2797
-     * @return void
2798
-     * @throws EE_Error
2799
-     * @throws DomainException
2800
-     */
2801
-    public function display_admin_list_table_page_with_no_sidebar()
2802
-    {
2803
-        $this->_display_admin_list_table_page();
2804
-    }
2805
-
2806
-
2807
-    /**
2808
-     * generates html wrapper for an admin_list_table page
2809
-     *
2810
-     * @param boolean $sidebar whether to display with sidebar or not.
2811
-     * @return void
2812
-     * @throws DomainException
2813
-     * @throws EE_Error
2814
-     */
2815
-    private function _display_admin_list_table_page($sidebar = false)
2816
-    {
2817
-        // setup search attributes
2818
-        $this->_set_search_attributes();
2819
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
2820
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2821
-        $this->_template_args['table_url']        = $this->request->isAjax()
2822
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2823
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2824
-        $this->_template_args['list_table']       = $this->_list_table_object;
2825
-        $this->_template_args['current_route']    = $this->_req_action;
2826
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2827
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2828
-        if (! empty($ajax_sorting_callback)) {
2829
-            $sortable_list_table_form_fields = wp_nonce_field(
2830
-                $ajax_sorting_callback . '_nonce',
2831
-                $ajax_sorting_callback . '_nonce',
2832
-                false,
2833
-                false
2834
-            );
2835
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2836
-                                                . $this->page_slug
2837
-                                                . '" />';
2838
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2839
-                                                . $ajax_sorting_callback
2840
-                                                . '" />';
2841
-        } else {
2842
-            $sortable_list_table_form_fields = '';
2843
-        }
2844
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2845
-        $hidden_form_fields                                      =
2846
-            isset($this->_template_args['list_table_hidden_fields'])
2847
-                ? $this->_template_args['list_table_hidden_fields']
2848
-                : '';
2849
-
2850
-        $nonce_ref          = $this->_req_action . '_nonce';
2851
-        $hidden_form_fields .= '
2566
+	}
2567
+
2568
+
2569
+	/**
2570
+	 * facade for add_meta_box
2571
+	 *
2572
+	 * @param string  $action        where the metabox gets displayed
2573
+	 * @param string  $title         Title of Metabox (output in metabox header)
2574
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2575
+	 *                               instead of the one created in here.
2576
+	 * @param array   $callback_args an array of args supplied for the metabox
2577
+	 * @param string  $column        what metabox column
2578
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2579
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2580
+	 *                               created but just set our own callback for wp's add_meta_box.
2581
+	 * @throws DomainException
2582
+	 */
2583
+	public function _add_admin_page_meta_box(
2584
+		$action,
2585
+		$title,
2586
+		$callback,
2587
+		$callback_args,
2588
+		$column = 'normal',
2589
+		$priority = 'high',
2590
+		$create_func = true
2591
+	) {
2592
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2593
+		// 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.
2594
+		if (empty($callback_args) && $create_func) {
2595
+			$callback_args = [
2596
+				'template_path' => $this->_template_path,
2597
+				'template_args' => $this->_template_args,
2598
+			];
2599
+		}
2600
+		// 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)
2601
+		$call_back_func = $create_func
2602
+			? function ($post, $metabox) {
2603
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2604
+				echo EEH_Template::display_template(
2605
+					$metabox['args']['template_path'],
2606
+					$metabox['args']['template_args'],
2607
+					true
2608
+				);
2609
+			}
2610
+			: $callback;
2611
+		add_meta_box(
2612
+			str_replace('_', '-', $action) . '-mbox',
2613
+			$title,
2614
+			$call_back_func,
2615
+			$this->_wp_page_slug,
2616
+			$column,
2617
+			$priority,
2618
+			$callback_args
2619
+		);
2620
+	}
2621
+
2622
+
2623
+	/**
2624
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2625
+	 *
2626
+	 * @throws DomainException
2627
+	 * @throws EE_Error
2628
+	 */
2629
+	public function display_admin_page_with_metabox_columns()
2630
+	{
2631
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2632
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2633
+			$this->_column_template_path,
2634
+			$this->_template_args,
2635
+			true
2636
+		);
2637
+		// the final wrapper
2638
+		$this->admin_page_wrapper();
2639
+	}
2640
+
2641
+
2642
+	/**
2643
+	 * generates  HTML wrapper for an admin details page
2644
+	 *
2645
+	 * @return void
2646
+	 * @throws EE_Error
2647
+	 * @throws DomainException
2648
+	 */
2649
+	public function display_admin_page_with_sidebar()
2650
+	{
2651
+		$this->_display_admin_page(true);
2652
+	}
2653
+
2654
+
2655
+	/**
2656
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2657
+	 *
2658
+	 * @return void
2659
+	 * @throws EE_Error
2660
+	 * @throws DomainException
2661
+	 */
2662
+	public function display_admin_page_with_no_sidebar()
2663
+	{
2664
+		$this->_display_admin_page();
2665
+	}
2666
+
2667
+
2668
+	/**
2669
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2670
+	 *
2671
+	 * @return void
2672
+	 * @throws EE_Error
2673
+	 * @throws DomainException
2674
+	 */
2675
+	public function display_about_admin_page()
2676
+	{
2677
+		$this->_display_admin_page(false, true);
2678
+	}
2679
+
2680
+
2681
+	/**
2682
+	 * display_admin_page
2683
+	 * contains the code for actually displaying an admin page
2684
+	 *
2685
+	 * @param boolean $sidebar true with sidebar, false without
2686
+	 * @param boolean $about   use the about_admin_wrapper instead of the default.
2687
+	 * @return void
2688
+	 * @throws DomainException
2689
+	 * @throws EE_Error
2690
+	 */
2691
+	private function _display_admin_page($sidebar = false, $about = false)
2692
+	{
2693
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2694
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2695
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2696
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2697
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2698
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2699
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2700
+			? 'poststuff'
2701
+			: 'espresso-default-admin';
2702
+		$template_path                                     = $sidebar
2703
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2704
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2705
+		if ($this->request->isAjax()) {
2706
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2707
+		}
2708
+		$template_path                                     = ! empty($this->_column_template_path)
2709
+			? $this->_column_template_path : $template_path;
2710
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2711
+			? $this->_template_args['admin_page_content']
2712
+			: '';
2713
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2714
+			? $this->_template_args['before_admin_page_content']
2715
+			: '';
2716
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2717
+			? $this->_template_args['after_admin_page_content']
2718
+			: '';
2719
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2720
+			$template_path,
2721
+			$this->_template_args,
2722
+			true
2723
+		);
2724
+		// the final template wrapper
2725
+		$this->admin_page_wrapper($about);
2726
+	}
2727
+
2728
+
2729
+	/**
2730
+	 * This is used to display caf preview pages.
2731
+	 *
2732
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2733
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2734
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2735
+	 * @return void
2736
+	 * @throws DomainException
2737
+	 * @throws EE_Error
2738
+	 * @throws InvalidArgumentException
2739
+	 * @throws InvalidDataTypeException
2740
+	 * @throws InvalidInterfaceException
2741
+	 * @since 4.3.2
2742
+	 */
2743
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2744
+	{
2745
+		// let's generate a default preview action button if there isn't one already present.
2746
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2747
+			'Upgrade to Event Espresso 4 Right Now',
2748
+			'event_espresso'
2749
+		);
2750
+		$buy_now_url                                   = add_query_arg(
2751
+			[
2752
+				'ee_ver'       => 'ee4',
2753
+				'utm_source'   => 'ee4_plugin_admin',
2754
+				'utm_medium'   => 'link',
2755
+				'utm_campaign' => $utm_campaign_source,
2756
+				'utm_content'  => 'buy_now_button',
2757
+			],
2758
+			'https://eventespresso.com/pricing/'
2759
+		);
2760
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2761
+			? $this->get_action_link_or_button(
2762
+				'',
2763
+				'buy_now',
2764
+				[],
2765
+				'button-primary button-large',
2766
+				esc_url_raw($buy_now_url),
2767
+				true
2768
+			)
2769
+			: $this->_template_args['preview_action_button'];
2770
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2771
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2772
+			$this->_template_args,
2773
+			true
2774
+		);
2775
+		$this->_display_admin_page($display_sidebar);
2776
+	}
2777
+
2778
+
2779
+	/**
2780
+	 * display_admin_list_table_page_with_sidebar
2781
+	 * generates HTML wrapper for an admin_page with list_table
2782
+	 *
2783
+	 * @return void
2784
+	 * @throws EE_Error
2785
+	 * @throws DomainException
2786
+	 */
2787
+	public function display_admin_list_table_page_with_sidebar()
2788
+	{
2789
+		$this->_display_admin_list_table_page(true);
2790
+	}
2791
+
2792
+
2793
+	/**
2794
+	 * display_admin_list_table_page_with_no_sidebar
2795
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2796
+	 *
2797
+	 * @return void
2798
+	 * @throws EE_Error
2799
+	 * @throws DomainException
2800
+	 */
2801
+	public function display_admin_list_table_page_with_no_sidebar()
2802
+	{
2803
+		$this->_display_admin_list_table_page();
2804
+	}
2805
+
2806
+
2807
+	/**
2808
+	 * generates html wrapper for an admin_list_table page
2809
+	 *
2810
+	 * @param boolean $sidebar whether to display with sidebar or not.
2811
+	 * @return void
2812
+	 * @throws DomainException
2813
+	 * @throws EE_Error
2814
+	 */
2815
+	private function _display_admin_list_table_page($sidebar = false)
2816
+	{
2817
+		// setup search attributes
2818
+		$this->_set_search_attributes();
2819
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
2820
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2821
+		$this->_template_args['table_url']        = $this->request->isAjax()
2822
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2823
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2824
+		$this->_template_args['list_table']       = $this->_list_table_object;
2825
+		$this->_template_args['current_route']    = $this->_req_action;
2826
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2827
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2828
+		if (! empty($ajax_sorting_callback)) {
2829
+			$sortable_list_table_form_fields = wp_nonce_field(
2830
+				$ajax_sorting_callback . '_nonce',
2831
+				$ajax_sorting_callback . '_nonce',
2832
+				false,
2833
+				false
2834
+			);
2835
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2836
+												. $this->page_slug
2837
+												. '" />';
2838
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2839
+												. $ajax_sorting_callback
2840
+												. '" />';
2841
+		} else {
2842
+			$sortable_list_table_form_fields = '';
2843
+		}
2844
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2845
+		$hidden_form_fields                                      =
2846
+			isset($this->_template_args['list_table_hidden_fields'])
2847
+				? $this->_template_args['list_table_hidden_fields']
2848
+				: '';
2849
+
2850
+		$nonce_ref          = $this->_req_action . '_nonce';
2851
+		$hidden_form_fields .= '
2852 2852
             <input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2853 2853
 
2854
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2855
-        // display message about search results?
2856
-        $search = $this->request->getRequestParam('s');
2857
-        $this->_template_args['before_list_table'] .= ! empty($search)
2858
-            ? '<p class="ee-search-results">' . sprintf(
2859
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2860
-                trim($search, '%')
2861
-            ) . '</p>'
2862
-            : '';
2863
-        // filter before_list_table template arg
2864
-        $this->_template_args['before_list_table'] = apply_filters(
2865
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2866
-            $this->_template_args['before_list_table'],
2867
-            $this->page_slug,
2868
-            $this->request->requestParams(),
2869
-            $this->_req_action
2870
-        );
2871
-        // convert to array and filter again
2872
-        // arrays are easier to inject new items in a specific location,
2873
-        // but would not be backwards compatible, so we have to add a new filter
2874
-        $this->_template_args['before_list_table'] = implode(
2875
-            " \n",
2876
-            (array) apply_filters(
2877
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2878
-                (array) $this->_template_args['before_list_table'],
2879
-                $this->page_slug,
2880
-                $this->request->requestParams(),
2881
-                $this->_req_action
2882
-            )
2883
-        );
2884
-        // filter after_list_table template arg
2885
-        $this->_template_args['after_list_table'] = apply_filters(
2886
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2887
-            $this->_template_args['after_list_table'],
2888
-            $this->page_slug,
2889
-            $this->request->requestParams(),
2890
-            $this->_req_action
2891
-        );
2892
-        // convert to array and filter again
2893
-        // arrays are easier to inject new items in a specific location,
2894
-        // but would not be backwards compatible, so we have to add a new filter
2895
-        $this->_template_args['after_list_table']   = implode(
2896
-            " \n",
2897
-            (array) apply_filters(
2898
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2899
-                (array) $this->_template_args['after_list_table'],
2900
-                $this->page_slug,
2901
-                $this->request->requestParams(),
2902
-                $this->_req_action
2903
-            )
2904
-        );
2905
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2906
-            $template_path,
2907
-            $this->_template_args,
2908
-            true
2909
-        );
2910
-        // the final template wrapper
2911
-        if ($sidebar) {
2912
-            $this->display_admin_page_with_sidebar();
2913
-        } else {
2914
-            $this->display_admin_page_with_no_sidebar();
2915
-        }
2916
-    }
2917
-
2918
-
2919
-    /**
2920
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2921
-     * html string for the legend.
2922
-     * $items are expected in an array in the following format:
2923
-     * $legend_items = array(
2924
-     *        'item_id' => array(
2925
-     *            'icon' => 'http://url_to_icon_being_described.png',
2926
-     *            'desc' => esc_html__('localized description of item');
2927
-     *        )
2928
-     * );
2929
-     *
2930
-     * @param array $items see above for format of array
2931
-     * @return string html string of legend
2932
-     * @throws DomainException
2933
-     */
2934
-    protected function _display_legend($items)
2935
-    {
2936
-        $this->_template_args['items'] = apply_filters(
2937
-            'FHEE__EE_Admin_Page___display_legend__items',
2938
-            (array) $items,
2939
-            $this
2940
-        );
2941
-        return EEH_Template::display_template(
2942
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2943
-            $this->_template_args,
2944
-            true
2945
-        );
2946
-    }
2947
-
2948
-
2949
-    /**
2950
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2951
-     * The returned json object is created from an array in the following format:
2952
-     * array(
2953
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2954
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
2955
-     *  'notices' => '', // - contains any EE_Error formatted notices
2956
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2957
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
2958
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
2959
-     *  that might be included in here)
2960
-     * )
2961
-     * The json object is populated by whatever is set in the $_template_args property.
2962
-     *
2963
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
2964
-     *                                 instead of displayed.
2965
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
2966
-     * @return void
2967
-     * @throws EE_Error
2968
-     */
2969
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
2970
-    {
2971
-        // make sure any EE_Error notices have been handled.
2972
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
2973
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
2974
-        unset($this->_template_args['data']);
2975
-        $json = [
2976
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2977
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2978
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2979
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2980
-            'notices'   => EE_Error::get_notices(),
2981
-            'content'   => isset($this->_template_args['admin_page_content'])
2982
-                ? $this->_template_args['admin_page_content'] : '',
2983
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
2984
-            'isEEajax'  => true
2985
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2986
-        ];
2987
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
2988
-        if (null === error_get_last() || ! headers_sent()) {
2989
-            header('Content-Type: application/json; charset=UTF-8');
2990
-        }
2991
-        echo wp_json_encode($json);
2992
-        exit();
2993
-    }
2994
-
2995
-
2996
-    /**
2997
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2998
-     *
2999
-     * @return void
3000
-     * @throws EE_Error
3001
-     */
3002
-    public function return_json()
3003
-    {
3004
-        if ($this->request->isAjax()) {
3005
-            $this->_return_json();
3006
-        } else {
3007
-            throw new EE_Error(
3008
-                sprintf(
3009
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3010
-                    __FUNCTION__
3011
-                )
3012
-            );
3013
-        }
3014
-    }
3015
-
3016
-
3017
-    /**
3018
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3019
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3020
-     *
3021
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3022
-     */
3023
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3024
-    {
3025
-        $this->_hook_obj = $hook_obj;
3026
-    }
3027
-
3028
-
3029
-    /**
3030
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3031
-     *
3032
-     * @param boolean $about whether to use the special about page wrapper or default.
3033
-     * @return void
3034
-     * @throws DomainException
3035
-     * @throws EE_Error
3036
-     */
3037
-    public function admin_page_wrapper($about = false)
3038
-    {
3039
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3040
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3041
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3042
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3043
-
3044
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3045
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3046
-            isset($this->_template_args['before_admin_page_content'])
3047
-                ? $this->_template_args['before_admin_page_content']
3048
-                : ''
3049
-        );
3050
-
3051
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3052
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3053
-            isset($this->_template_args['after_admin_page_content'])
3054
-                ? $this->_template_args['after_admin_page_content']
3055
-                : ''
3056
-        );
3057
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3058
-
3059
-        if ($this->request->isAjax()) {
3060
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3061
-                // $template_path,
3062
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3063
-                $this->_template_args,
3064
-                true
3065
-            );
3066
-            $this->_return_json();
3067
-        }
3068
-        // load settings page wrapper template
3069
-        $template_path = $about
3070
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3071
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3072
-
3073
-        EEH_Template::display_template($template_path, $this->_template_args);
3074
-    }
3075
-
3076
-
3077
-    /**
3078
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3079
-     *
3080
-     * @return string html
3081
-     * @throws EE_Error
3082
-     */
3083
-    protected function _get_main_nav_tabs()
3084
-    {
3085
-        // let's generate the html using the EEH_Tabbed_Content helper.
3086
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3087
-        // (rather than setting in the page_routes array)
3088
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3089
-    }
3090
-
3091
-
3092
-    /**
3093
-     *        sort nav tabs
3094
-     *
3095
-     * @param $a
3096
-     * @param $b
3097
-     * @return int
3098
-     */
3099
-    private function _sort_nav_tabs($a, $b)
3100
-    {
3101
-        if ($a['order'] === $b['order']) {
3102
-            return 0;
3103
-        }
3104
-        return ($a['order'] < $b['order']) ? -1 : 1;
3105
-    }
3106
-
3107
-
3108
-    /**
3109
-     *    generates HTML for the forms used on admin pages
3110
-     *
3111
-     * @param array  $input_vars   - array of input field details
3112
-     * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3113
-     *                             use)
3114
-     * @param bool   $id
3115
-     * @return array|string
3116
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3117
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3118
-     */
3119
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3120
-    {
3121
-        return $generator === 'string'
3122
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3123
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3124
-    }
3125
-
3126
-
3127
-    /**
3128
-     * generates the "Save" and "Save & Close" buttons for edit forms
3129
-     *
3130
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3131
-     *                                   Close" button.
3132
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3133
-     *                                   'Save', [1] => 'save & close')
3134
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3135
-     *                                   via the "name" value in the button).  We can also use this to just dump
3136
-     *                                   default actions by submitting some other value.
3137
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3138
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3139
-     *                                   close (normal form handling).
3140
-     */
3141
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3142
-    {
3143
-        // make sure $text and $actions are in an array
3144
-        $text          = (array) $text;
3145
-        $actions       = (array) $actions;
3146
-        $referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3147
-        $button_text   = ! empty($text)
3148
-            ? $text
3149
-            : [
3150
-                esc_html__('Save', 'event_espresso'),
3151
-                esc_html__('Save and Close', 'event_espresso'),
3152
-            ];
3153
-        $default_names = ['save', 'save_and_close'];
3154
-        $buttons = '';
3155
-        foreach ($button_text as $key => $button) {
3156
-            $ref     = $default_names[ $key ];
3157
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3158
-            $buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3159
-                        . 'value="' . $button . '" name="' . $name . '" '
3160
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3161
-            if (! $both) {
3162
-                break;
3163
-            }
3164
-        }
3165
-        // add in a hidden index for the current page (so save and close redirects properly)
3166
-        $buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3167
-                   . $referrer_url
3168
-                   . '" />';
3169
-        $this->_template_args['save_buttons'] = $buttons;
3170
-    }
3171
-
3172
-
3173
-    /**
3174
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3175
-     *
3176
-     * @param string $route
3177
-     * @param array  $additional_hidden_fields
3178
-     * @see   $this->_set_add_edit_form_tags() for details on params
3179
-     * @since 4.6.0
3180
-     */
3181
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3182
-    {
3183
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3184
-    }
3185
-
3186
-
3187
-    /**
3188
-     * set form open and close tags on add/edit pages.
3189
-     *
3190
-     * @param string $route                    the route you want the form to direct to
3191
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3192
-     * @return void
3193
-     */
3194
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3195
-    {
3196
-        if (empty($route)) {
3197
-            $user_msg = esc_html__(
3198
-                'An error occurred. No action was set for this page\'s form.',
3199
-                'event_espresso'
3200
-            );
3201
-            $dev_msg  = $user_msg . "\n"
3202
-                        . sprintf(
3203
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3204
-                            __FUNCTION__,
3205
-                            __CLASS__
3206
-                        );
3207
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3208
-        }
3209
-        // open form
3210
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3211
-                                                             . $this->_admin_base_url
3212
-                                                             . '" id="'
3213
-                                                             . $route
3214
-                                                             . '_event_form" >';
3215
-        // add nonce
3216
-        $nonce                                             =
3217
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3218
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3219
-        // add REQUIRED form action
3220
-        $hidden_fields = [
3221
-            'action' => ['type' => 'hidden', 'value' => $route],
3222
-        ];
3223
-        // merge arrays
3224
-        $hidden_fields = is_array($additional_hidden_fields)
3225
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3226
-            : $hidden_fields;
3227
-        // generate form fields
3228
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3229
-        // add fields to form
3230
-        foreach ((array) $form_fields as $form_field) {
3231
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3232
-        }
3233
-        // close form
3234
-        $this->_template_args['after_admin_page_content'] = '</form>';
3235
-    }
3236
-
3237
-
3238
-    /**
3239
-     * Public Wrapper for _redirect_after_action() method since its
3240
-     * discovered it would be useful for external code to have access.
3241
-     *
3242
-     * @param bool   $success
3243
-     * @param string $what
3244
-     * @param string $action_desc
3245
-     * @param array  $query_args
3246
-     * @param bool   $override_overwrite
3247
-     * @throws EE_Error
3248
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3249
-     * @since 4.5.0
3250
-     */
3251
-    public function redirect_after_action(
3252
-        $success = false,
3253
-        $what = 'item',
3254
-        $action_desc = 'processed',
3255
-        $query_args = [],
3256
-        $override_overwrite = false
3257
-    ) {
3258
-        $this->_redirect_after_action(
3259
-            $success,
3260
-            $what,
3261
-            $action_desc,
3262
-            $query_args,
3263
-            $override_overwrite
3264
-        );
3265
-    }
3266
-
3267
-
3268
-    /**
3269
-     * Helper method for merging existing request data with the returned redirect url.
3270
-     *
3271
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3272
-     * filters are still applied.
3273
-     *
3274
-     * @param array $new_route_data
3275
-     * @return array
3276
-     */
3277
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3278
-    {
3279
-        foreach ($this->request->requestParams() as $ref => $value) {
3280
-            // unset nonces
3281
-            if (strpos($ref, 'nonce') !== false) {
3282
-                $this->request->unSetRequestParam($ref);
3283
-                continue;
3284
-            }
3285
-            // urlencode values.
3286
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3287
-            $this->request->setRequestParam($ref, $value);
3288
-        }
3289
-        return array_merge($this->request->requestParams(), $new_route_data);
3290
-    }
3291
-
3292
-
3293
-    /**
3294
-     *    _redirect_after_action
3295
-     *
3296
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3297
-     * @param string $what               - what the action was performed on
3298
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3299
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3300
-     *                                   action is completed
3301
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3302
-     *                                   override this so that they show.
3303
-     * @return void
3304
-     * @throws EE_Error
3305
-     */
3306
-    protected function _redirect_after_action(
3307
-        $success = 0,
3308
-        $what = 'item',
3309
-        $action_desc = 'processed',
3310
-        $query_args = [],
3311
-        $override_overwrite = false
3312
-    ) {
3313
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3314
-        // class name for actions/filters.
3315
-        $classname = get_class($this);
3316
-        // set redirect url.
3317
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3318
-        // otherwise we go with whatever is set as the _admin_base_url
3319
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3320
-        $notices      = EE_Error::get_notices(false);
3321
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3322
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3323
-            EE_Error::overwrite_success();
3324
-        }
3325
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3326
-            // how many records affected ? more than one record ? or just one ?
3327
-            if ($success > 1) {
3328
-                // set plural msg
3329
-                EE_Error::add_success(
3330
-                    sprintf(
3331
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3332
-                        $what,
3333
-                        $action_desc
3334
-                    ),
3335
-                    __FILE__,
3336
-                    __FUNCTION__,
3337
-                    __LINE__
3338
-                );
3339
-            } elseif ($success === 1) {
3340
-                // set singular msg
3341
-                EE_Error::add_success(
3342
-                    sprintf(
3343
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3344
-                        $what,
3345
-                        $action_desc
3346
-                    ),
3347
-                    __FILE__,
3348
-                    __FUNCTION__,
3349
-                    __LINE__
3350
-                );
3351
-            }
3352
-        }
3353
-        // check that $query_args isn't something crazy
3354
-        if (! is_array($query_args)) {
3355
-            $query_args = [];
3356
-        }
3357
-        /**
3358
-         * Allow injecting actions before the query_args are modified for possible different
3359
-         * redirections on save and close actions
3360
-         *
3361
-         * @param array $query_args       The original query_args array coming into the
3362
-         *                                method.
3363
-         * @since 4.2.0
3364
-         */
3365
-        do_action(
3366
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3367
-            $query_args
3368
-        );
3369
-        // calculate where we're going (if we have a "save and close" button pushed)
3370
-
3371
-        if (
3372
-            $this->request->requestParamIsSet('save_and_close')
3373
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3374
-        ) {
3375
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3376
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3377
-            // regenerate query args array from referrer URL
3378
-            parse_str($parsed_url['query'], $query_args);
3379
-            // correct page and action will be in the query args now
3380
-            $redirect_url = admin_url('admin.php');
3381
-        }
3382
-        // merge any default query_args set in _default_route_query_args property
3383
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3384
-            $args_to_merge = [];
3385
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3386
-                // is there a wp_referer array in our _default_route_query_args property?
3387
-                if ($query_param === 'wp_referer') {
3388
-                    $query_value = (array) $query_value;
3389
-                    foreach ($query_value as $reference => $value) {
3390
-                        if (strpos($reference, 'nonce') !== false) {
3391
-                            continue;
3392
-                        }
3393
-                        // finally we will override any arguments in the referer with
3394
-                        // what might be set on the _default_route_query_args array.
3395
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3396
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3397
-                        } else {
3398
-                            $args_to_merge[ $reference ] = urlencode($value);
3399
-                        }
3400
-                    }
3401
-                    continue;
3402
-                }
3403
-                $args_to_merge[ $query_param ] = $query_value;
3404
-            }
3405
-            // now let's merge these arguments but override with what was specifically sent in to the
3406
-            // redirect.
3407
-            $query_args = array_merge($args_to_merge, $query_args);
3408
-        }
3409
-        $this->_process_notices($query_args);
3410
-        // generate redirect url
3411
-        // if redirecting to anything other than the main page, add a nonce
3412
-        if (isset($query_args['action'])) {
3413
-            // manually generate wp_nonce and merge that with the query vars
3414
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3415
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3416
-        }
3417
-        // we're adding some hooks and filters in here for processing any things just before redirects
3418
-        // (example: an admin page has done an insert or update and we want to run something after that).
3419
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3420
-        $redirect_url = apply_filters(
3421
-            'FHEE_redirect_' . $classname . $this->_req_action,
3422
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3423
-            $query_args
3424
-        );
3425
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3426
-        if ($this->request->isAjax()) {
3427
-            $default_data                    = [
3428
-                'close'        => true,
3429
-                'redirect_url' => $redirect_url,
3430
-                'where'        => 'main',
3431
-                'what'         => 'append',
3432
-            ];
3433
-            $this->_template_args['success'] = $success;
3434
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3435
-                $default_data,
3436
-                $this->_template_args['data']
3437
-            ) : $default_data;
3438
-            $this->_return_json();
3439
-        }
3440
-        wp_safe_redirect($redirect_url);
3441
-        exit();
3442
-    }
3443
-
3444
-
3445
-    /**
3446
-     * process any notices before redirecting (or returning ajax request)
3447
-     * This method sets the $this->_template_args['notices'] attribute;
3448
-     *
3449
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3450
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3451
-     *                                  page_routes haven't been defined yet.
3452
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3453
-     *                                  still save a transient for the notice.
3454
-     * @return void
3455
-     * @throws EE_Error
3456
-     */
3457
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3458
-    {
3459
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3460
-        if ($this->request->isAjax()) {
3461
-            $notices = EE_Error::get_notices(false);
3462
-            if (empty($this->_template_args['success'])) {
3463
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3464
-            }
3465
-            if (empty($this->_template_args['errors'])) {
3466
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3467
-            }
3468
-            if (empty($this->_template_args['attention'])) {
3469
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3470
-            }
3471
-        }
3472
-        $this->_template_args['notices'] = EE_Error::get_notices();
3473
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3474
-        if (! $this->request->isAjax() || $sticky_notices) {
3475
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3476
-            $this->_add_transient(
3477
-                $route,
3478
-                $this->_template_args['notices'],
3479
-                true,
3480
-                $skip_route_verify
3481
-            );
3482
-        }
3483
-    }
3484
-
3485
-
3486
-    /**
3487
-     * get_action_link_or_button
3488
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3489
-     *
3490
-     * @param string $action        use this to indicate which action the url is generated with.
3491
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3492
-     *                              property.
3493
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3494
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3495
-     * @param string $base_url      If this is not provided
3496
-     *                              the _admin_base_url will be used as the default for the button base_url.
3497
-     *                              Otherwise this value will be used.
3498
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3499
-     * @return string
3500
-     * @throws InvalidArgumentException
3501
-     * @throws InvalidInterfaceException
3502
-     * @throws InvalidDataTypeException
3503
-     * @throws EE_Error
3504
-     */
3505
-    public function get_action_link_or_button(
3506
-        $action,
3507
-        $type = 'add',
3508
-        $extra_request = [],
3509
-        $class = 'button button--primary',
3510
-        $base_url = '',
3511
-        $exclude_nonce = false
3512
-    ) {
3513
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3514
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3515
-            throw new EE_Error(
3516
-                sprintf(
3517
-                    esc_html__(
3518
-                        'There is no page route for given action for the button.  This action was given: %s',
3519
-                        'event_espresso'
3520
-                    ),
3521
-                    $action
3522
-                )
3523
-            );
3524
-        }
3525
-        if (! isset($this->_labels['buttons'][ $type ])) {
3526
-            throw new EE_Error(
3527
-                sprintf(
3528
-                    esc_html__(
3529
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3530
-                        'event_espresso'
3531
-                    ),
3532
-                    $type
3533
-                )
3534
-            );
3535
-        }
3536
-        // finally check user access for this button.
3537
-        $has_access = $this->check_user_access($action, true);
3538
-        if (! $has_access) {
3539
-            return '';
3540
-        }
3541
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3542
-        $query_args = [
3543
-            'action' => $action,
3544
-        ];
3545
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3546
-        if (! empty($extra_request)) {
3547
-            $query_args = array_merge($extra_request, $query_args);
3548
-        }
3549
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3550
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3551
-    }
3552
-
3553
-
3554
-    /**
3555
-     * _per_page_screen_option
3556
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3557
-     *
3558
-     * @return void
3559
-     * @throws InvalidArgumentException
3560
-     * @throws InvalidInterfaceException
3561
-     * @throws InvalidDataTypeException
3562
-     */
3563
-    protected function _per_page_screen_option()
3564
-    {
3565
-        $option = 'per_page';
3566
-        $args   = [
3567
-            'label'   => apply_filters(
3568
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3569
-                $this->_admin_page_title,
3570
-                $this
3571
-            ),
3572
-            'default' => (int) apply_filters(
3573
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3574
-                20
3575
-            ),
3576
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3577
-        ];
3578
-        // ONLY add the screen option if the user has access to it.
3579
-        if ($this->check_user_access($this->_current_view, true)) {
3580
-            add_screen_option($option, $args);
3581
-        }
3582
-    }
3583
-
3584
-
3585
-    /**
3586
-     * set_per_page_screen_option
3587
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3588
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3589
-     * admin_menu.
3590
-     *
3591
-     * @return void
3592
-     */
3593
-    private function _set_per_page_screen_options()
3594
-    {
3595
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3596
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3597
-            if (! $user = wp_get_current_user()) {
3598
-                return;
3599
-            }
3600
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3601
-            if (! $option) {
3602
-                return;
3603
-            }
3604
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3605
-            $map_option = $option;
3606
-            $option     = str_replace('-', '_', $option);
3607
-            switch ($map_option) {
3608
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3609
-                    $max_value = apply_filters(
3610
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3611
-                        999,
3612
-                        $this->_current_page,
3613
-                        $this->_current_view
3614
-                    );
3615
-                    if ($value < 1) {
3616
-                        return;
3617
-                    }
3618
-                    $value = min($value, $max_value);
3619
-                    break;
3620
-                default:
3621
-                    $value = apply_filters(
3622
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3623
-                        false,
3624
-                        $option,
3625
-                        $value
3626
-                    );
3627
-                    if (false === $value) {
3628
-                        return;
3629
-                    }
3630
-                    break;
3631
-            }
3632
-            update_user_meta($user->ID, $option, $value);
3633
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3634
-            exit;
3635
-        }
3636
-    }
3637
-
3638
-
3639
-    /**
3640
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3641
-     *
3642
-     * @param array $data array that will be assigned to template args.
3643
-     */
3644
-    public function set_template_args($data)
3645
-    {
3646
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3647
-    }
3648
-
3649
-
3650
-    /**
3651
-     * This makes available the WP transient system for temporarily moving data between routes
3652
-     *
3653
-     * @param string $route             the route that should receive the transient
3654
-     * @param array  $data              the data that gets sent
3655
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3656
-     *                                  normal route transient.
3657
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3658
-     *                                  when we are adding a transient before page_routes have been defined.
3659
-     * @return void
3660
-     * @throws EE_Error
3661
-     */
3662
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3663
-    {
3664
-        $user_id = get_current_user_id();
3665
-        if (! $skip_route_verify) {
3666
-            $this->_verify_route($route);
3667
-        }
3668
-        // now let's set the string for what kind of transient we're setting
3669
-        $transient = $notices
3670
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3671
-            : 'rte_tx_' . $route . '_' . $user_id;
3672
-        $data      = $notices ? ['notices' => $data] : $data;
3673
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3674
-        $existing = is_multisite() && is_network_admin()
3675
-            ? get_site_transient($transient)
3676
-            : get_transient($transient);
3677
-        if ($existing) {
3678
-            $data = array_merge((array) $data, (array) $existing);
3679
-        }
3680
-        if (is_multisite() && is_network_admin()) {
3681
-            set_site_transient($transient, $data, 8);
3682
-        } else {
3683
-            set_transient($transient, $data, 8);
3684
-        }
3685
-    }
3686
-
3687
-
3688
-    /**
3689
-     * this retrieves the temporary transient that has been set for moving data between routes.
3690
-     *
3691
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3692
-     * @param string $route
3693
-     * @return mixed data
3694
-     */
3695
-    protected function _get_transient($notices = false, $route = '')
3696
-    {
3697
-        $user_id   = get_current_user_id();
3698
-        $route     = ! $route ? $this->_req_action : $route;
3699
-        $transient = $notices
3700
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3701
-            : 'rte_tx_' . $route . '_' . $user_id;
3702
-        $data      = is_multisite() && is_network_admin()
3703
-            ? get_site_transient($transient)
3704
-            : get_transient($transient);
3705
-        // delete transient after retrieval (just in case it hasn't expired);
3706
-        if (is_multisite() && is_network_admin()) {
3707
-            delete_site_transient($transient);
3708
-        } else {
3709
-            delete_transient($transient);
3710
-        }
3711
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3712
-    }
3713
-
3714
-
3715
-    /**
3716
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3717
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3718
-     * default route callback on the EE_Admin page you want it run.)
3719
-     *
3720
-     * @return void
3721
-     */
3722
-    protected function _transient_garbage_collection()
3723
-    {
3724
-        global $wpdb;
3725
-        // retrieve all existing transients
3726
-        $query =
3727
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3728
-        if ($results = $wpdb->get_results($query)) {
3729
-            foreach ($results as $result) {
3730
-                $transient = str_replace('_transient_', '', $result->option_name);
3731
-                get_transient($transient);
3732
-                if (is_multisite() && is_network_admin()) {
3733
-                    get_site_transient($transient);
3734
-                }
3735
-            }
3736
-        }
3737
-    }
3738
-
3739
-
3740
-    /**
3741
-     * get_view
3742
-     *
3743
-     * @return string content of _view property
3744
-     */
3745
-    public function get_view()
3746
-    {
3747
-        return $this->_view;
3748
-    }
3749
-
3750
-
3751
-    /**
3752
-     * getter for the protected $_views property
3753
-     *
3754
-     * @return array
3755
-     */
3756
-    public function get_views()
3757
-    {
3758
-        return $this->_views;
3759
-    }
3760
-
3761
-
3762
-    /**
3763
-     * get_current_page
3764
-     *
3765
-     * @return string _current_page property value
3766
-     */
3767
-    public function get_current_page()
3768
-    {
3769
-        return $this->_current_page;
3770
-    }
3771
-
3772
-
3773
-    /**
3774
-     * get_current_view
3775
-     *
3776
-     * @return string _current_view property value
3777
-     */
3778
-    public function get_current_view()
3779
-    {
3780
-        return $this->_current_view;
3781
-    }
3782
-
3783
-
3784
-    /**
3785
-     * get_current_screen
3786
-     *
3787
-     * @return object The current WP_Screen object
3788
-     */
3789
-    public function get_current_screen()
3790
-    {
3791
-        return $this->_current_screen;
3792
-    }
3793
-
3794
-
3795
-    /**
3796
-     * get_current_page_view_url
3797
-     *
3798
-     * @return string This returns the url for the current_page_view.
3799
-     */
3800
-    public function get_current_page_view_url()
3801
-    {
3802
-        return $this->_current_page_view_url;
3803
-    }
3804
-
3805
-
3806
-    /**
3807
-     * just returns the Request
3808
-     *
3809
-     * @return RequestInterface
3810
-     */
3811
-    public function get_request()
3812
-    {
3813
-        return $this->request;
3814
-    }
3815
-
3816
-
3817
-    /**
3818
-     * just returns the _req_data property
3819
-     *
3820
-     * @return array
3821
-     */
3822
-    public function get_request_data()
3823
-    {
3824
-        return $this->request->requestParams();
3825
-    }
3826
-
3827
-
3828
-    /**
3829
-     * returns the _req_data protected property
3830
-     *
3831
-     * @return string
3832
-     */
3833
-    public function get_req_action()
3834
-    {
3835
-        return $this->_req_action;
3836
-    }
3837
-
3838
-
3839
-    /**
3840
-     * @return bool  value of $_is_caf property
3841
-     */
3842
-    public function is_caf()
3843
-    {
3844
-        return $this->_is_caf;
3845
-    }
3846
-
3847
-
3848
-    /**
3849
-     * @return mixed
3850
-     */
3851
-    public function default_espresso_metaboxes()
3852
-    {
3853
-        return $this->_default_espresso_metaboxes;
3854
-    }
3855
-
3856
-
3857
-    /**
3858
-     * @return mixed
3859
-     */
3860
-    public function admin_base_url()
3861
-    {
3862
-        return $this->_admin_base_url;
3863
-    }
3864
-
3865
-
3866
-    /**
3867
-     * @return mixed
3868
-     */
3869
-    public function wp_page_slug()
3870
-    {
3871
-        return $this->_wp_page_slug;
3872
-    }
3873
-
3874
-
3875
-    /**
3876
-     * updates  espresso configuration settings
3877
-     *
3878
-     * @param string                   $tab
3879
-     * @param EE_Config_Base|EE_Config $config
3880
-     * @param string                   $file file where error occurred
3881
-     * @param string                   $func function  where error occurred
3882
-     * @param string                   $line line no where error occurred
3883
-     * @return boolean
3884
-     */
3885
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3886
-    {
3887
-        // remove any options that are NOT going to be saved with the config settings.
3888
-        if (isset($config->core->ee_ueip_optin)) {
3889
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3890
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3891
-            update_option('ee_ueip_has_notified', true);
3892
-        }
3893
-        // and save it (note we're also doing the network save here)
3894
-        $net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3895
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3896
-        if ($config_saved && $net_saved) {
3897
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3898
-            return true;
3899
-        }
3900
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3901
-        return false;
3902
-    }
3903
-
3904
-
3905
-    /**
3906
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3907
-     *
3908
-     * @return array
3909
-     */
3910
-    public function get_yes_no_values()
3911
-    {
3912
-        return $this->_yes_no_values;
3913
-    }
3914
-
3915
-
3916
-    protected function _get_dir()
3917
-    {
3918
-        $reflector = new ReflectionClass(get_class($this));
3919
-        return dirname($reflector->getFileName());
3920
-    }
3921
-
3922
-
3923
-    /**
3924
-     * A helper for getting a "next link".
3925
-     *
3926
-     * @param string $url   The url to link to
3927
-     * @param string $class The class to use.
3928
-     * @return string
3929
-     */
3930
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3931
-    {
3932
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3933
-    }
3934
-
3935
-
3936
-    /**
3937
-     * A helper for getting a "previous link".
3938
-     *
3939
-     * @param string $url   The url to link to
3940
-     * @param string $class The class to use.
3941
-     * @return string
3942
-     */
3943
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3944
-    {
3945
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3946
-    }
3947
-
3948
-
3949
-
3950
-
3951
-
3952
-
3953
-
3954
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3955
-
3956
-
3957
-    /**
3958
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3959
-     * 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
3960
-     * _req_data array.
3961
-     *
3962
-     * @return bool success/fail
3963
-     * @throws EE_Error
3964
-     * @throws InvalidArgumentException
3965
-     * @throws ReflectionException
3966
-     * @throws InvalidDataTypeException
3967
-     * @throws InvalidInterfaceException
3968
-     */
3969
-    protected function _process_resend_registration()
3970
-    {
3971
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3972
-        do_action(
3973
-            'AHEE__EE_Admin_Page___process_resend_registration',
3974
-            $this->_template_args['success'],
3975
-            $this->request->requestParams()
3976
-        );
3977
-        return $this->_template_args['success'];
3978
-    }
3979
-
3980
-
3981
-    /**
3982
-     * This automatically processes any payment message notifications when manual payment has been applied.
3983
-     *
3984
-     * @param EE_Payment $payment
3985
-     * @return bool success/fail
3986
-     */
3987
-    protected function _process_payment_notification(EE_Payment $payment)
3988
-    {
3989
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3990
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3991
-        $this->_template_args['success'] = apply_filters(
3992
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3993
-            false,
3994
-            $payment
3995
-        );
3996
-        return $this->_template_args['success'];
3997
-    }
3998
-
3999
-
4000
-    /**
4001
-     * @param EEM_Base      $entity_model
4002
-     * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4003
-     * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4004
-     * @param string        $delete_column  name of the field that denotes whether entity is trashed
4005
-     * @param callable|null $callback       called after entity is trashed, restored, or deleted
4006
-     * @return int|float
4007
-     * @throws EE_Error
4008
-     */
4009
-    protected function trashRestoreDeleteEntities(
4010
-        EEM_Base $entity_model,
4011
-        $entity_PK_name,
4012
-        $action = EE_Admin_List_Table::ACTION_DELETE,
4013
-        $delete_column = '',
4014
-        callable $callback = null
4015
-    ) {
4016
-        $entity_PK      = $entity_model->get_primary_key_field();
4017
-        $entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4018
-        $entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4019
-        // grab ID if deleting a single entity
4020
-        if ($this->request->requestParamIsSet($entity_PK_name)) {
4021
-            $ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4022
-            return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4023
-        }
4024
-        // or grab checkbox array if bulk deleting
4025
-        $checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4026
-        if (empty($checkboxes)) {
4027
-            return 0;
4028
-        }
4029
-        $success = 0;
4030
-        $IDs     = array_keys($checkboxes);
4031
-        // cycle thru bulk action checkboxes
4032
-        foreach ($IDs as $ID) {
4033
-            // increment $success
4034
-            if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4035
-                $success++;
4036
-            }
4037
-        }
4038
-        $count = (int) count($checkboxes);
4039
-        // if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4040
-        // otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4041
-        return $success === $count ? $count : $success / $count;
4042
-    }
4043
-
4044
-
4045
-    /**
4046
-     * @param EE_Primary_Key_Field_Base $entity_PK
4047
-     * @return string
4048
-     * @throws EE_Error
4049
-     * @since   4.10.30.p
4050
-     */
4051
-    private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK)
4052
-    {
4053
-        $entity_PK_type = $entity_PK->getSchemaType();
4054
-        switch ($entity_PK_type) {
4055
-            case 'boolean':
4056
-                return 'bool';
4057
-            case 'integer':
4058
-                return 'int';
4059
-            case 'number':
4060
-                return 'float';
4061
-            case 'string':
4062
-                return 'string';
4063
-        }
4064
-        throw new RuntimeException(
4065
-            sprintf(
4066
-                esc_html__(
4067
-                    '"%1$s" is an invalid schema type for the %2$s primary key.',
4068
-                    'event_espresso'
4069
-                ),
4070
-                $entity_PK_type,
4071
-                $entity_PK->get_name()
4072
-            )
4073
-        );
4074
-    }
4075
-
4076
-
4077
-    /**
4078
-     * @param EEM_Base      $entity_model
4079
-     * @param int|string    $entity_ID
4080
-     * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4081
-     * @param string        $delete_column name of the field that denotes whether entity is trashed
4082
-     * @param callable|null $callback      called after entity is trashed, restored, or deleted
4083
-     * @return bool
4084
-     */
4085
-    protected function trashRestoreDeleteEntity(
4086
-        EEM_Base $entity_model,
4087
-        $entity_ID,
4088
-        $action,
4089
-        $delete_column,
4090
-        callable $callback = null
4091
-    ) {
4092
-        $entity_ID = absint($entity_ID);
4093
-        if (! $entity_ID) {
4094
-            $this->trashRestoreDeleteError($action, $entity_model);
4095
-        }
4096
-        $result = 0;
4097
-        try {
4098
-            $entity = $entity_model->get_one_by_ID($entity_ID);
4099
-            if (! $entity instanceof EE_Base_Class) {
4100
-                throw new DomainException(
4101
-                    sprintf(
4102
-                        esc_html__(
4103
-                            'Missing or invalid %1$s entity with ID of "%2$s" returned from db.',
4104
-                            'event_espresso'
4105
-                        ),
4106
-                        str_replace('EEM_', '', $entity_model->get_this_model_name()),
4107
-                        $entity_ID
4108
-                    )
4109
-                );
4110
-            }
4111
-            switch ($action) {
4112
-                case EE_Admin_List_Table::ACTION_DELETE:
4113
-                    $result = (bool) $entity->delete_permanently();
4114
-                    break;
4115
-                case EE_Admin_List_Table::ACTION_RESTORE:
4116
-                    $result = $entity->delete_or_restore(false);
4117
-                    break;
4118
-                case EE_Admin_List_Table::ACTION_TRASH:
4119
-                    $result = $entity->delete_or_restore();
4120
-                    break;
4121
-            }
4122
-        } catch (Exception $exception) {
4123
-            $this->trashRestoreDeleteError($action, $entity_model, $exception);
4124
-        }
4125
-        if (is_callable($callback)) {
4126
-            call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4127
-        }
4128
-        return $result;
4129
-    }
4130
-
4131
-
4132
-    /**
4133
-     * @param EEM_Base $entity_model
4134
-     * @param string   $delete_column
4135
-     * @since 4.10.30.p
4136
-     */
4137
-    private function validateDeleteColumn(EEM_Base $entity_model, $delete_column)
4138
-    {
4139
-        if (empty($delete_column)) {
4140
-            throw new DomainException(
4141
-                sprintf(
4142
-                    esc_html__(
4143
-                        'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4144
-                        'event_espresso'
4145
-                    ),
4146
-                    $entity_model->get_this_model_name()
4147
-                )
4148
-            );
4149
-        }
4150
-        if (! $entity_model->has_field($delete_column)) {
4151
-            throw new DomainException(
4152
-                sprintf(
4153
-                    esc_html__(
4154
-                        'The %1$s field does not exist on the %2$s model.',
4155
-                        'event_espresso'
4156
-                    ),
4157
-                    $delete_column,
4158
-                    $entity_model->get_this_model_name()
4159
-                )
4160
-            );
4161
-        }
4162
-    }
4163
-
4164
-
4165
-    /**
4166
-     * @param EEM_Base       $entity_model
4167
-     * @param Exception|null $exception
4168
-     * @param string         $action
4169
-     * @since 4.10.30.p
4170
-     */
4171
-    private function trashRestoreDeleteError($action, EEM_Base $entity_model, Exception $exception = null)
4172
-    {
4173
-        if ($exception instanceof Exception) {
4174
-            throw new RuntimeException(
4175
-                sprintf(
4176
-                    esc_html__(
4177
-                        'Could not %1$s the %2$s because the following error occurred: %3$s',
4178
-                        'event_espresso'
4179
-                    ),
4180
-                    $action,
4181
-                    $entity_model->get_this_model_name(),
4182
-                    $exception->getMessage()
4183
-                )
4184
-            );
4185
-        }
4186
-        throw new RuntimeException(
4187
-            sprintf(
4188
-                esc_html__(
4189
-                    'Could not %1$s the %2$s because an invalid ID was received.',
4190
-                    'event_espresso'
4191
-                ),
4192
-                $action,
4193
-                $entity_model->get_this_model_name()
4194
-            )
4195
-        );
4196
-    }
2854
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2855
+		// display message about search results?
2856
+		$search = $this->request->getRequestParam('s');
2857
+		$this->_template_args['before_list_table'] .= ! empty($search)
2858
+			? '<p class="ee-search-results">' . sprintf(
2859
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2860
+				trim($search, '%')
2861
+			) . '</p>'
2862
+			: '';
2863
+		// filter before_list_table template arg
2864
+		$this->_template_args['before_list_table'] = apply_filters(
2865
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2866
+			$this->_template_args['before_list_table'],
2867
+			$this->page_slug,
2868
+			$this->request->requestParams(),
2869
+			$this->_req_action
2870
+		);
2871
+		// convert to array and filter again
2872
+		// arrays are easier to inject new items in a specific location,
2873
+		// but would not be backwards compatible, so we have to add a new filter
2874
+		$this->_template_args['before_list_table'] = implode(
2875
+			" \n",
2876
+			(array) apply_filters(
2877
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2878
+				(array) $this->_template_args['before_list_table'],
2879
+				$this->page_slug,
2880
+				$this->request->requestParams(),
2881
+				$this->_req_action
2882
+			)
2883
+		);
2884
+		// filter after_list_table template arg
2885
+		$this->_template_args['after_list_table'] = apply_filters(
2886
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2887
+			$this->_template_args['after_list_table'],
2888
+			$this->page_slug,
2889
+			$this->request->requestParams(),
2890
+			$this->_req_action
2891
+		);
2892
+		// convert to array and filter again
2893
+		// arrays are easier to inject new items in a specific location,
2894
+		// but would not be backwards compatible, so we have to add a new filter
2895
+		$this->_template_args['after_list_table']   = implode(
2896
+			" \n",
2897
+			(array) apply_filters(
2898
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2899
+				(array) $this->_template_args['after_list_table'],
2900
+				$this->page_slug,
2901
+				$this->request->requestParams(),
2902
+				$this->_req_action
2903
+			)
2904
+		);
2905
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2906
+			$template_path,
2907
+			$this->_template_args,
2908
+			true
2909
+		);
2910
+		// the final template wrapper
2911
+		if ($sidebar) {
2912
+			$this->display_admin_page_with_sidebar();
2913
+		} else {
2914
+			$this->display_admin_page_with_no_sidebar();
2915
+		}
2916
+	}
2917
+
2918
+
2919
+	/**
2920
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2921
+	 * html string for the legend.
2922
+	 * $items are expected in an array in the following format:
2923
+	 * $legend_items = array(
2924
+	 *        'item_id' => array(
2925
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2926
+	 *            'desc' => esc_html__('localized description of item');
2927
+	 *        )
2928
+	 * );
2929
+	 *
2930
+	 * @param array $items see above for format of array
2931
+	 * @return string html string of legend
2932
+	 * @throws DomainException
2933
+	 */
2934
+	protected function _display_legend($items)
2935
+	{
2936
+		$this->_template_args['items'] = apply_filters(
2937
+			'FHEE__EE_Admin_Page___display_legend__items',
2938
+			(array) $items,
2939
+			$this
2940
+		);
2941
+		return EEH_Template::display_template(
2942
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2943
+			$this->_template_args,
2944
+			true
2945
+		);
2946
+	}
2947
+
2948
+
2949
+	/**
2950
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2951
+	 * The returned json object is created from an array in the following format:
2952
+	 * array(
2953
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2954
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
2955
+	 *  'notices' => '', // - contains any EE_Error formatted notices
2956
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2957
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
2958
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
2959
+	 *  that might be included in here)
2960
+	 * )
2961
+	 * The json object is populated by whatever is set in the $_template_args property.
2962
+	 *
2963
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
2964
+	 *                                 instead of displayed.
2965
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
2966
+	 * @return void
2967
+	 * @throws EE_Error
2968
+	 */
2969
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
2970
+	{
2971
+		// make sure any EE_Error notices have been handled.
2972
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
2973
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
2974
+		unset($this->_template_args['data']);
2975
+		$json = [
2976
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2977
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2978
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2979
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2980
+			'notices'   => EE_Error::get_notices(),
2981
+			'content'   => isset($this->_template_args['admin_page_content'])
2982
+				? $this->_template_args['admin_page_content'] : '',
2983
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
2984
+			'isEEajax'  => true
2985
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2986
+		];
2987
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
2988
+		if (null === error_get_last() || ! headers_sent()) {
2989
+			header('Content-Type: application/json; charset=UTF-8');
2990
+		}
2991
+		echo wp_json_encode($json);
2992
+		exit();
2993
+	}
2994
+
2995
+
2996
+	/**
2997
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2998
+	 *
2999
+	 * @return void
3000
+	 * @throws EE_Error
3001
+	 */
3002
+	public function return_json()
3003
+	{
3004
+		if ($this->request->isAjax()) {
3005
+			$this->_return_json();
3006
+		} else {
3007
+			throw new EE_Error(
3008
+				sprintf(
3009
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3010
+					__FUNCTION__
3011
+				)
3012
+			);
3013
+		}
3014
+	}
3015
+
3016
+
3017
+	/**
3018
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3019
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3020
+	 *
3021
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3022
+	 */
3023
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3024
+	{
3025
+		$this->_hook_obj = $hook_obj;
3026
+	}
3027
+
3028
+
3029
+	/**
3030
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3031
+	 *
3032
+	 * @param boolean $about whether to use the special about page wrapper or default.
3033
+	 * @return void
3034
+	 * @throws DomainException
3035
+	 * @throws EE_Error
3036
+	 */
3037
+	public function admin_page_wrapper($about = false)
3038
+	{
3039
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3040
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3041
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3042
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3043
+
3044
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3045
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3046
+			isset($this->_template_args['before_admin_page_content'])
3047
+				? $this->_template_args['before_admin_page_content']
3048
+				: ''
3049
+		);
3050
+
3051
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3052
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3053
+			isset($this->_template_args['after_admin_page_content'])
3054
+				? $this->_template_args['after_admin_page_content']
3055
+				: ''
3056
+		);
3057
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3058
+
3059
+		if ($this->request->isAjax()) {
3060
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3061
+				// $template_path,
3062
+				EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3063
+				$this->_template_args,
3064
+				true
3065
+			);
3066
+			$this->_return_json();
3067
+		}
3068
+		// load settings page wrapper template
3069
+		$template_path = $about
3070
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3071
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3072
+
3073
+		EEH_Template::display_template($template_path, $this->_template_args);
3074
+	}
3075
+
3076
+
3077
+	/**
3078
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3079
+	 *
3080
+	 * @return string html
3081
+	 * @throws EE_Error
3082
+	 */
3083
+	protected function _get_main_nav_tabs()
3084
+	{
3085
+		// let's generate the html using the EEH_Tabbed_Content helper.
3086
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3087
+		// (rather than setting in the page_routes array)
3088
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3089
+	}
3090
+
3091
+
3092
+	/**
3093
+	 *        sort nav tabs
3094
+	 *
3095
+	 * @param $a
3096
+	 * @param $b
3097
+	 * @return int
3098
+	 */
3099
+	private function _sort_nav_tabs($a, $b)
3100
+	{
3101
+		if ($a['order'] === $b['order']) {
3102
+			return 0;
3103
+		}
3104
+		return ($a['order'] < $b['order']) ? -1 : 1;
3105
+	}
3106
+
3107
+
3108
+	/**
3109
+	 *    generates HTML for the forms used on admin pages
3110
+	 *
3111
+	 * @param array  $input_vars   - array of input field details
3112
+	 * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3113
+	 *                             use)
3114
+	 * @param bool   $id
3115
+	 * @return array|string
3116
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3117
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3118
+	 */
3119
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3120
+	{
3121
+		return $generator === 'string'
3122
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3123
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3124
+	}
3125
+
3126
+
3127
+	/**
3128
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3129
+	 *
3130
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3131
+	 *                                   Close" button.
3132
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3133
+	 *                                   'Save', [1] => 'save & close')
3134
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3135
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3136
+	 *                                   default actions by submitting some other value.
3137
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3138
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3139
+	 *                                   close (normal form handling).
3140
+	 */
3141
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3142
+	{
3143
+		// make sure $text and $actions are in an array
3144
+		$text          = (array) $text;
3145
+		$actions       = (array) $actions;
3146
+		$referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3147
+		$button_text   = ! empty($text)
3148
+			? $text
3149
+			: [
3150
+				esc_html__('Save', 'event_espresso'),
3151
+				esc_html__('Save and Close', 'event_espresso'),
3152
+			];
3153
+		$default_names = ['save', 'save_and_close'];
3154
+		$buttons = '';
3155
+		foreach ($button_text as $key => $button) {
3156
+			$ref     = $default_names[ $key ];
3157
+			$name    = ! empty($actions) ? $actions[ $key ] : $ref;
3158
+			$buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3159
+						. 'value="' . $button . '" name="' . $name . '" '
3160
+						. 'id="' . $this->_current_view . '_' . $ref . '" />';
3161
+			if (! $both) {
3162
+				break;
3163
+			}
3164
+		}
3165
+		// add in a hidden index for the current page (so save and close redirects properly)
3166
+		$buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3167
+				   . $referrer_url
3168
+				   . '" />';
3169
+		$this->_template_args['save_buttons'] = $buttons;
3170
+	}
3171
+
3172
+
3173
+	/**
3174
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3175
+	 *
3176
+	 * @param string $route
3177
+	 * @param array  $additional_hidden_fields
3178
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3179
+	 * @since 4.6.0
3180
+	 */
3181
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3182
+	{
3183
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3184
+	}
3185
+
3186
+
3187
+	/**
3188
+	 * set form open and close tags on add/edit pages.
3189
+	 *
3190
+	 * @param string $route                    the route you want the form to direct to
3191
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3192
+	 * @return void
3193
+	 */
3194
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3195
+	{
3196
+		if (empty($route)) {
3197
+			$user_msg = esc_html__(
3198
+				'An error occurred. No action was set for this page\'s form.',
3199
+				'event_espresso'
3200
+			);
3201
+			$dev_msg  = $user_msg . "\n"
3202
+						. sprintf(
3203
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3204
+							__FUNCTION__,
3205
+							__CLASS__
3206
+						);
3207
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3208
+		}
3209
+		// open form
3210
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3211
+															 . $this->_admin_base_url
3212
+															 . '" id="'
3213
+															 . $route
3214
+															 . '_event_form" >';
3215
+		// add nonce
3216
+		$nonce                                             =
3217
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3218
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3219
+		// add REQUIRED form action
3220
+		$hidden_fields = [
3221
+			'action' => ['type' => 'hidden', 'value' => $route],
3222
+		];
3223
+		// merge arrays
3224
+		$hidden_fields = is_array($additional_hidden_fields)
3225
+			? array_merge($hidden_fields, $additional_hidden_fields)
3226
+			: $hidden_fields;
3227
+		// generate form fields
3228
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3229
+		// add fields to form
3230
+		foreach ((array) $form_fields as $form_field) {
3231
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3232
+		}
3233
+		// close form
3234
+		$this->_template_args['after_admin_page_content'] = '</form>';
3235
+	}
3236
+
3237
+
3238
+	/**
3239
+	 * Public Wrapper for _redirect_after_action() method since its
3240
+	 * discovered it would be useful for external code to have access.
3241
+	 *
3242
+	 * @param bool   $success
3243
+	 * @param string $what
3244
+	 * @param string $action_desc
3245
+	 * @param array  $query_args
3246
+	 * @param bool   $override_overwrite
3247
+	 * @throws EE_Error
3248
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3249
+	 * @since 4.5.0
3250
+	 */
3251
+	public function redirect_after_action(
3252
+		$success = false,
3253
+		$what = 'item',
3254
+		$action_desc = 'processed',
3255
+		$query_args = [],
3256
+		$override_overwrite = false
3257
+	) {
3258
+		$this->_redirect_after_action(
3259
+			$success,
3260
+			$what,
3261
+			$action_desc,
3262
+			$query_args,
3263
+			$override_overwrite
3264
+		);
3265
+	}
3266
+
3267
+
3268
+	/**
3269
+	 * Helper method for merging existing request data with the returned redirect url.
3270
+	 *
3271
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3272
+	 * filters are still applied.
3273
+	 *
3274
+	 * @param array $new_route_data
3275
+	 * @return array
3276
+	 */
3277
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3278
+	{
3279
+		foreach ($this->request->requestParams() as $ref => $value) {
3280
+			// unset nonces
3281
+			if (strpos($ref, 'nonce') !== false) {
3282
+				$this->request->unSetRequestParam($ref);
3283
+				continue;
3284
+			}
3285
+			// urlencode values.
3286
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3287
+			$this->request->setRequestParam($ref, $value);
3288
+		}
3289
+		return array_merge($this->request->requestParams(), $new_route_data);
3290
+	}
3291
+
3292
+
3293
+	/**
3294
+	 *    _redirect_after_action
3295
+	 *
3296
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3297
+	 * @param string $what               - what the action was performed on
3298
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3299
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3300
+	 *                                   action is completed
3301
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3302
+	 *                                   override this so that they show.
3303
+	 * @return void
3304
+	 * @throws EE_Error
3305
+	 */
3306
+	protected function _redirect_after_action(
3307
+		$success = 0,
3308
+		$what = 'item',
3309
+		$action_desc = 'processed',
3310
+		$query_args = [],
3311
+		$override_overwrite = false
3312
+	) {
3313
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3314
+		// class name for actions/filters.
3315
+		$classname = get_class($this);
3316
+		// set redirect url.
3317
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3318
+		// otherwise we go with whatever is set as the _admin_base_url
3319
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3320
+		$notices      = EE_Error::get_notices(false);
3321
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3322
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3323
+			EE_Error::overwrite_success();
3324
+		}
3325
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3326
+			// how many records affected ? more than one record ? or just one ?
3327
+			if ($success > 1) {
3328
+				// set plural msg
3329
+				EE_Error::add_success(
3330
+					sprintf(
3331
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3332
+						$what,
3333
+						$action_desc
3334
+					),
3335
+					__FILE__,
3336
+					__FUNCTION__,
3337
+					__LINE__
3338
+				);
3339
+			} elseif ($success === 1) {
3340
+				// set singular msg
3341
+				EE_Error::add_success(
3342
+					sprintf(
3343
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3344
+						$what,
3345
+						$action_desc
3346
+					),
3347
+					__FILE__,
3348
+					__FUNCTION__,
3349
+					__LINE__
3350
+				);
3351
+			}
3352
+		}
3353
+		// check that $query_args isn't something crazy
3354
+		if (! is_array($query_args)) {
3355
+			$query_args = [];
3356
+		}
3357
+		/**
3358
+		 * Allow injecting actions before the query_args are modified for possible different
3359
+		 * redirections on save and close actions
3360
+		 *
3361
+		 * @param array $query_args       The original query_args array coming into the
3362
+		 *                                method.
3363
+		 * @since 4.2.0
3364
+		 */
3365
+		do_action(
3366
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3367
+			$query_args
3368
+		);
3369
+		// calculate where we're going (if we have a "save and close" button pushed)
3370
+
3371
+		if (
3372
+			$this->request->requestParamIsSet('save_and_close')
3373
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3374
+		) {
3375
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3376
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3377
+			// regenerate query args array from referrer URL
3378
+			parse_str($parsed_url['query'], $query_args);
3379
+			// correct page and action will be in the query args now
3380
+			$redirect_url = admin_url('admin.php');
3381
+		}
3382
+		// merge any default query_args set in _default_route_query_args property
3383
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3384
+			$args_to_merge = [];
3385
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3386
+				// is there a wp_referer array in our _default_route_query_args property?
3387
+				if ($query_param === 'wp_referer') {
3388
+					$query_value = (array) $query_value;
3389
+					foreach ($query_value as $reference => $value) {
3390
+						if (strpos($reference, 'nonce') !== false) {
3391
+							continue;
3392
+						}
3393
+						// finally we will override any arguments in the referer with
3394
+						// what might be set on the _default_route_query_args array.
3395
+						if (isset($this->_default_route_query_args[ $reference ])) {
3396
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3397
+						} else {
3398
+							$args_to_merge[ $reference ] = urlencode($value);
3399
+						}
3400
+					}
3401
+					continue;
3402
+				}
3403
+				$args_to_merge[ $query_param ] = $query_value;
3404
+			}
3405
+			// now let's merge these arguments but override with what was specifically sent in to the
3406
+			// redirect.
3407
+			$query_args = array_merge($args_to_merge, $query_args);
3408
+		}
3409
+		$this->_process_notices($query_args);
3410
+		// generate redirect url
3411
+		// if redirecting to anything other than the main page, add a nonce
3412
+		if (isset($query_args['action'])) {
3413
+			// manually generate wp_nonce and merge that with the query vars
3414
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3415
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3416
+		}
3417
+		// we're adding some hooks and filters in here for processing any things just before redirects
3418
+		// (example: an admin page has done an insert or update and we want to run something after that).
3419
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3420
+		$redirect_url = apply_filters(
3421
+			'FHEE_redirect_' . $classname . $this->_req_action,
3422
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3423
+			$query_args
3424
+		);
3425
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3426
+		if ($this->request->isAjax()) {
3427
+			$default_data                    = [
3428
+				'close'        => true,
3429
+				'redirect_url' => $redirect_url,
3430
+				'where'        => 'main',
3431
+				'what'         => 'append',
3432
+			];
3433
+			$this->_template_args['success'] = $success;
3434
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3435
+				$default_data,
3436
+				$this->_template_args['data']
3437
+			) : $default_data;
3438
+			$this->_return_json();
3439
+		}
3440
+		wp_safe_redirect($redirect_url);
3441
+		exit();
3442
+	}
3443
+
3444
+
3445
+	/**
3446
+	 * process any notices before redirecting (or returning ajax request)
3447
+	 * This method sets the $this->_template_args['notices'] attribute;
3448
+	 *
3449
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3450
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3451
+	 *                                  page_routes haven't been defined yet.
3452
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3453
+	 *                                  still save a transient for the notice.
3454
+	 * @return void
3455
+	 * @throws EE_Error
3456
+	 */
3457
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3458
+	{
3459
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3460
+		if ($this->request->isAjax()) {
3461
+			$notices = EE_Error::get_notices(false);
3462
+			if (empty($this->_template_args['success'])) {
3463
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3464
+			}
3465
+			if (empty($this->_template_args['errors'])) {
3466
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3467
+			}
3468
+			if (empty($this->_template_args['attention'])) {
3469
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3470
+			}
3471
+		}
3472
+		$this->_template_args['notices'] = EE_Error::get_notices();
3473
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3474
+		if (! $this->request->isAjax() || $sticky_notices) {
3475
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3476
+			$this->_add_transient(
3477
+				$route,
3478
+				$this->_template_args['notices'],
3479
+				true,
3480
+				$skip_route_verify
3481
+			);
3482
+		}
3483
+	}
3484
+
3485
+
3486
+	/**
3487
+	 * get_action_link_or_button
3488
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3489
+	 *
3490
+	 * @param string $action        use this to indicate which action the url is generated with.
3491
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3492
+	 *                              property.
3493
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3494
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3495
+	 * @param string $base_url      If this is not provided
3496
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3497
+	 *                              Otherwise this value will be used.
3498
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3499
+	 * @return string
3500
+	 * @throws InvalidArgumentException
3501
+	 * @throws InvalidInterfaceException
3502
+	 * @throws InvalidDataTypeException
3503
+	 * @throws EE_Error
3504
+	 */
3505
+	public function get_action_link_or_button(
3506
+		$action,
3507
+		$type = 'add',
3508
+		$extra_request = [],
3509
+		$class = 'button button--primary',
3510
+		$base_url = '',
3511
+		$exclude_nonce = false
3512
+	) {
3513
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3514
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3515
+			throw new EE_Error(
3516
+				sprintf(
3517
+					esc_html__(
3518
+						'There is no page route for given action for the button.  This action was given: %s',
3519
+						'event_espresso'
3520
+					),
3521
+					$action
3522
+				)
3523
+			);
3524
+		}
3525
+		if (! isset($this->_labels['buttons'][ $type ])) {
3526
+			throw new EE_Error(
3527
+				sprintf(
3528
+					esc_html__(
3529
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3530
+						'event_espresso'
3531
+					),
3532
+					$type
3533
+				)
3534
+			);
3535
+		}
3536
+		// finally check user access for this button.
3537
+		$has_access = $this->check_user_access($action, true);
3538
+		if (! $has_access) {
3539
+			return '';
3540
+		}
3541
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3542
+		$query_args = [
3543
+			'action' => $action,
3544
+		];
3545
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3546
+		if (! empty($extra_request)) {
3547
+			$query_args = array_merge($extra_request, $query_args);
3548
+		}
3549
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3550
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3551
+	}
3552
+
3553
+
3554
+	/**
3555
+	 * _per_page_screen_option
3556
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3557
+	 *
3558
+	 * @return void
3559
+	 * @throws InvalidArgumentException
3560
+	 * @throws InvalidInterfaceException
3561
+	 * @throws InvalidDataTypeException
3562
+	 */
3563
+	protected function _per_page_screen_option()
3564
+	{
3565
+		$option = 'per_page';
3566
+		$args   = [
3567
+			'label'   => apply_filters(
3568
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3569
+				$this->_admin_page_title,
3570
+				$this
3571
+			),
3572
+			'default' => (int) apply_filters(
3573
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3574
+				20
3575
+			),
3576
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3577
+		];
3578
+		// ONLY add the screen option if the user has access to it.
3579
+		if ($this->check_user_access($this->_current_view, true)) {
3580
+			add_screen_option($option, $args);
3581
+		}
3582
+	}
3583
+
3584
+
3585
+	/**
3586
+	 * set_per_page_screen_option
3587
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3588
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3589
+	 * admin_menu.
3590
+	 *
3591
+	 * @return void
3592
+	 */
3593
+	private function _set_per_page_screen_options()
3594
+	{
3595
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3596
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3597
+			if (! $user = wp_get_current_user()) {
3598
+				return;
3599
+			}
3600
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3601
+			if (! $option) {
3602
+				return;
3603
+			}
3604
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3605
+			$map_option = $option;
3606
+			$option     = str_replace('-', '_', $option);
3607
+			switch ($map_option) {
3608
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3609
+					$max_value = apply_filters(
3610
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3611
+						999,
3612
+						$this->_current_page,
3613
+						$this->_current_view
3614
+					);
3615
+					if ($value < 1) {
3616
+						return;
3617
+					}
3618
+					$value = min($value, $max_value);
3619
+					break;
3620
+				default:
3621
+					$value = apply_filters(
3622
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3623
+						false,
3624
+						$option,
3625
+						$value
3626
+					);
3627
+					if (false === $value) {
3628
+						return;
3629
+					}
3630
+					break;
3631
+			}
3632
+			update_user_meta($user->ID, $option, $value);
3633
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3634
+			exit;
3635
+		}
3636
+	}
3637
+
3638
+
3639
+	/**
3640
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3641
+	 *
3642
+	 * @param array $data array that will be assigned to template args.
3643
+	 */
3644
+	public function set_template_args($data)
3645
+	{
3646
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3647
+	}
3648
+
3649
+
3650
+	/**
3651
+	 * This makes available the WP transient system for temporarily moving data between routes
3652
+	 *
3653
+	 * @param string $route             the route that should receive the transient
3654
+	 * @param array  $data              the data that gets sent
3655
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3656
+	 *                                  normal route transient.
3657
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3658
+	 *                                  when we are adding a transient before page_routes have been defined.
3659
+	 * @return void
3660
+	 * @throws EE_Error
3661
+	 */
3662
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3663
+	{
3664
+		$user_id = get_current_user_id();
3665
+		if (! $skip_route_verify) {
3666
+			$this->_verify_route($route);
3667
+		}
3668
+		// now let's set the string for what kind of transient we're setting
3669
+		$transient = $notices
3670
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3671
+			: 'rte_tx_' . $route . '_' . $user_id;
3672
+		$data      = $notices ? ['notices' => $data] : $data;
3673
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3674
+		$existing = is_multisite() && is_network_admin()
3675
+			? get_site_transient($transient)
3676
+			: get_transient($transient);
3677
+		if ($existing) {
3678
+			$data = array_merge((array) $data, (array) $existing);
3679
+		}
3680
+		if (is_multisite() && is_network_admin()) {
3681
+			set_site_transient($transient, $data, 8);
3682
+		} else {
3683
+			set_transient($transient, $data, 8);
3684
+		}
3685
+	}
3686
+
3687
+
3688
+	/**
3689
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3690
+	 *
3691
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3692
+	 * @param string $route
3693
+	 * @return mixed data
3694
+	 */
3695
+	protected function _get_transient($notices = false, $route = '')
3696
+	{
3697
+		$user_id   = get_current_user_id();
3698
+		$route     = ! $route ? $this->_req_action : $route;
3699
+		$transient = $notices
3700
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3701
+			: 'rte_tx_' . $route . '_' . $user_id;
3702
+		$data      = is_multisite() && is_network_admin()
3703
+			? get_site_transient($transient)
3704
+			: get_transient($transient);
3705
+		// delete transient after retrieval (just in case it hasn't expired);
3706
+		if (is_multisite() && is_network_admin()) {
3707
+			delete_site_transient($transient);
3708
+		} else {
3709
+			delete_transient($transient);
3710
+		}
3711
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3712
+	}
3713
+
3714
+
3715
+	/**
3716
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3717
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3718
+	 * default route callback on the EE_Admin page you want it run.)
3719
+	 *
3720
+	 * @return void
3721
+	 */
3722
+	protected function _transient_garbage_collection()
3723
+	{
3724
+		global $wpdb;
3725
+		// retrieve all existing transients
3726
+		$query =
3727
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3728
+		if ($results = $wpdb->get_results($query)) {
3729
+			foreach ($results as $result) {
3730
+				$transient = str_replace('_transient_', '', $result->option_name);
3731
+				get_transient($transient);
3732
+				if (is_multisite() && is_network_admin()) {
3733
+					get_site_transient($transient);
3734
+				}
3735
+			}
3736
+		}
3737
+	}
3738
+
3739
+
3740
+	/**
3741
+	 * get_view
3742
+	 *
3743
+	 * @return string content of _view property
3744
+	 */
3745
+	public function get_view()
3746
+	{
3747
+		return $this->_view;
3748
+	}
3749
+
3750
+
3751
+	/**
3752
+	 * getter for the protected $_views property
3753
+	 *
3754
+	 * @return array
3755
+	 */
3756
+	public function get_views()
3757
+	{
3758
+		return $this->_views;
3759
+	}
3760
+
3761
+
3762
+	/**
3763
+	 * get_current_page
3764
+	 *
3765
+	 * @return string _current_page property value
3766
+	 */
3767
+	public function get_current_page()
3768
+	{
3769
+		return $this->_current_page;
3770
+	}
3771
+
3772
+
3773
+	/**
3774
+	 * get_current_view
3775
+	 *
3776
+	 * @return string _current_view property value
3777
+	 */
3778
+	public function get_current_view()
3779
+	{
3780
+		return $this->_current_view;
3781
+	}
3782
+
3783
+
3784
+	/**
3785
+	 * get_current_screen
3786
+	 *
3787
+	 * @return object The current WP_Screen object
3788
+	 */
3789
+	public function get_current_screen()
3790
+	{
3791
+		return $this->_current_screen;
3792
+	}
3793
+
3794
+
3795
+	/**
3796
+	 * get_current_page_view_url
3797
+	 *
3798
+	 * @return string This returns the url for the current_page_view.
3799
+	 */
3800
+	public function get_current_page_view_url()
3801
+	{
3802
+		return $this->_current_page_view_url;
3803
+	}
3804
+
3805
+
3806
+	/**
3807
+	 * just returns the Request
3808
+	 *
3809
+	 * @return RequestInterface
3810
+	 */
3811
+	public function get_request()
3812
+	{
3813
+		return $this->request;
3814
+	}
3815
+
3816
+
3817
+	/**
3818
+	 * just returns the _req_data property
3819
+	 *
3820
+	 * @return array
3821
+	 */
3822
+	public function get_request_data()
3823
+	{
3824
+		return $this->request->requestParams();
3825
+	}
3826
+
3827
+
3828
+	/**
3829
+	 * returns the _req_data protected property
3830
+	 *
3831
+	 * @return string
3832
+	 */
3833
+	public function get_req_action()
3834
+	{
3835
+		return $this->_req_action;
3836
+	}
3837
+
3838
+
3839
+	/**
3840
+	 * @return bool  value of $_is_caf property
3841
+	 */
3842
+	public function is_caf()
3843
+	{
3844
+		return $this->_is_caf;
3845
+	}
3846
+
3847
+
3848
+	/**
3849
+	 * @return mixed
3850
+	 */
3851
+	public function default_espresso_metaboxes()
3852
+	{
3853
+		return $this->_default_espresso_metaboxes;
3854
+	}
3855
+
3856
+
3857
+	/**
3858
+	 * @return mixed
3859
+	 */
3860
+	public function admin_base_url()
3861
+	{
3862
+		return $this->_admin_base_url;
3863
+	}
3864
+
3865
+
3866
+	/**
3867
+	 * @return mixed
3868
+	 */
3869
+	public function wp_page_slug()
3870
+	{
3871
+		return $this->_wp_page_slug;
3872
+	}
3873
+
3874
+
3875
+	/**
3876
+	 * updates  espresso configuration settings
3877
+	 *
3878
+	 * @param string                   $tab
3879
+	 * @param EE_Config_Base|EE_Config $config
3880
+	 * @param string                   $file file where error occurred
3881
+	 * @param string                   $func function  where error occurred
3882
+	 * @param string                   $line line no where error occurred
3883
+	 * @return boolean
3884
+	 */
3885
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3886
+	{
3887
+		// remove any options that are NOT going to be saved with the config settings.
3888
+		if (isset($config->core->ee_ueip_optin)) {
3889
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3890
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3891
+			update_option('ee_ueip_has_notified', true);
3892
+		}
3893
+		// and save it (note we're also doing the network save here)
3894
+		$net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3895
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3896
+		if ($config_saved && $net_saved) {
3897
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3898
+			return true;
3899
+		}
3900
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3901
+		return false;
3902
+	}
3903
+
3904
+
3905
+	/**
3906
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3907
+	 *
3908
+	 * @return array
3909
+	 */
3910
+	public function get_yes_no_values()
3911
+	{
3912
+		return $this->_yes_no_values;
3913
+	}
3914
+
3915
+
3916
+	protected function _get_dir()
3917
+	{
3918
+		$reflector = new ReflectionClass(get_class($this));
3919
+		return dirname($reflector->getFileName());
3920
+	}
3921
+
3922
+
3923
+	/**
3924
+	 * A helper for getting a "next link".
3925
+	 *
3926
+	 * @param string $url   The url to link to
3927
+	 * @param string $class The class to use.
3928
+	 * @return string
3929
+	 */
3930
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3931
+	{
3932
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3933
+	}
3934
+
3935
+
3936
+	/**
3937
+	 * A helper for getting a "previous link".
3938
+	 *
3939
+	 * @param string $url   The url to link to
3940
+	 * @param string $class The class to use.
3941
+	 * @return string
3942
+	 */
3943
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3944
+	{
3945
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3946
+	}
3947
+
3948
+
3949
+
3950
+
3951
+
3952
+
3953
+
3954
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3955
+
3956
+
3957
+	/**
3958
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3959
+	 * 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
3960
+	 * _req_data array.
3961
+	 *
3962
+	 * @return bool success/fail
3963
+	 * @throws EE_Error
3964
+	 * @throws InvalidArgumentException
3965
+	 * @throws ReflectionException
3966
+	 * @throws InvalidDataTypeException
3967
+	 * @throws InvalidInterfaceException
3968
+	 */
3969
+	protected function _process_resend_registration()
3970
+	{
3971
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3972
+		do_action(
3973
+			'AHEE__EE_Admin_Page___process_resend_registration',
3974
+			$this->_template_args['success'],
3975
+			$this->request->requestParams()
3976
+		);
3977
+		return $this->_template_args['success'];
3978
+	}
3979
+
3980
+
3981
+	/**
3982
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3983
+	 *
3984
+	 * @param EE_Payment $payment
3985
+	 * @return bool success/fail
3986
+	 */
3987
+	protected function _process_payment_notification(EE_Payment $payment)
3988
+	{
3989
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3990
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3991
+		$this->_template_args['success'] = apply_filters(
3992
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3993
+			false,
3994
+			$payment
3995
+		);
3996
+		return $this->_template_args['success'];
3997
+	}
3998
+
3999
+
4000
+	/**
4001
+	 * @param EEM_Base      $entity_model
4002
+	 * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4003
+	 * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4004
+	 * @param string        $delete_column  name of the field that denotes whether entity is trashed
4005
+	 * @param callable|null $callback       called after entity is trashed, restored, or deleted
4006
+	 * @return int|float
4007
+	 * @throws EE_Error
4008
+	 */
4009
+	protected function trashRestoreDeleteEntities(
4010
+		EEM_Base $entity_model,
4011
+		$entity_PK_name,
4012
+		$action = EE_Admin_List_Table::ACTION_DELETE,
4013
+		$delete_column = '',
4014
+		callable $callback = null
4015
+	) {
4016
+		$entity_PK      = $entity_model->get_primary_key_field();
4017
+		$entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4018
+		$entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4019
+		// grab ID if deleting a single entity
4020
+		if ($this->request->requestParamIsSet($entity_PK_name)) {
4021
+			$ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4022
+			return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4023
+		}
4024
+		// or grab checkbox array if bulk deleting
4025
+		$checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4026
+		if (empty($checkboxes)) {
4027
+			return 0;
4028
+		}
4029
+		$success = 0;
4030
+		$IDs     = array_keys($checkboxes);
4031
+		// cycle thru bulk action checkboxes
4032
+		foreach ($IDs as $ID) {
4033
+			// increment $success
4034
+			if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4035
+				$success++;
4036
+			}
4037
+		}
4038
+		$count = (int) count($checkboxes);
4039
+		// if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4040
+		// otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4041
+		return $success === $count ? $count : $success / $count;
4042
+	}
4043
+
4044
+
4045
+	/**
4046
+	 * @param EE_Primary_Key_Field_Base $entity_PK
4047
+	 * @return string
4048
+	 * @throws EE_Error
4049
+	 * @since   4.10.30.p
4050
+	 */
4051
+	private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK)
4052
+	{
4053
+		$entity_PK_type = $entity_PK->getSchemaType();
4054
+		switch ($entity_PK_type) {
4055
+			case 'boolean':
4056
+				return 'bool';
4057
+			case 'integer':
4058
+				return 'int';
4059
+			case 'number':
4060
+				return 'float';
4061
+			case 'string':
4062
+				return 'string';
4063
+		}
4064
+		throw new RuntimeException(
4065
+			sprintf(
4066
+				esc_html__(
4067
+					'"%1$s" is an invalid schema type for the %2$s primary key.',
4068
+					'event_espresso'
4069
+				),
4070
+				$entity_PK_type,
4071
+				$entity_PK->get_name()
4072
+			)
4073
+		);
4074
+	}
4075
+
4076
+
4077
+	/**
4078
+	 * @param EEM_Base      $entity_model
4079
+	 * @param int|string    $entity_ID
4080
+	 * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4081
+	 * @param string        $delete_column name of the field that denotes whether entity is trashed
4082
+	 * @param callable|null $callback      called after entity is trashed, restored, or deleted
4083
+	 * @return bool
4084
+	 */
4085
+	protected function trashRestoreDeleteEntity(
4086
+		EEM_Base $entity_model,
4087
+		$entity_ID,
4088
+		$action,
4089
+		$delete_column,
4090
+		callable $callback = null
4091
+	) {
4092
+		$entity_ID = absint($entity_ID);
4093
+		if (! $entity_ID) {
4094
+			$this->trashRestoreDeleteError($action, $entity_model);
4095
+		}
4096
+		$result = 0;
4097
+		try {
4098
+			$entity = $entity_model->get_one_by_ID($entity_ID);
4099
+			if (! $entity instanceof EE_Base_Class) {
4100
+				throw new DomainException(
4101
+					sprintf(
4102
+						esc_html__(
4103
+							'Missing or invalid %1$s entity with ID of "%2$s" returned from db.',
4104
+							'event_espresso'
4105
+						),
4106
+						str_replace('EEM_', '', $entity_model->get_this_model_name()),
4107
+						$entity_ID
4108
+					)
4109
+				);
4110
+			}
4111
+			switch ($action) {
4112
+				case EE_Admin_List_Table::ACTION_DELETE:
4113
+					$result = (bool) $entity->delete_permanently();
4114
+					break;
4115
+				case EE_Admin_List_Table::ACTION_RESTORE:
4116
+					$result = $entity->delete_or_restore(false);
4117
+					break;
4118
+				case EE_Admin_List_Table::ACTION_TRASH:
4119
+					$result = $entity->delete_or_restore();
4120
+					break;
4121
+			}
4122
+		} catch (Exception $exception) {
4123
+			$this->trashRestoreDeleteError($action, $entity_model, $exception);
4124
+		}
4125
+		if (is_callable($callback)) {
4126
+			call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4127
+		}
4128
+		return $result;
4129
+	}
4130
+
4131
+
4132
+	/**
4133
+	 * @param EEM_Base $entity_model
4134
+	 * @param string   $delete_column
4135
+	 * @since 4.10.30.p
4136
+	 */
4137
+	private function validateDeleteColumn(EEM_Base $entity_model, $delete_column)
4138
+	{
4139
+		if (empty($delete_column)) {
4140
+			throw new DomainException(
4141
+				sprintf(
4142
+					esc_html__(
4143
+						'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4144
+						'event_espresso'
4145
+					),
4146
+					$entity_model->get_this_model_name()
4147
+				)
4148
+			);
4149
+		}
4150
+		if (! $entity_model->has_field($delete_column)) {
4151
+			throw new DomainException(
4152
+				sprintf(
4153
+					esc_html__(
4154
+						'The %1$s field does not exist on the %2$s model.',
4155
+						'event_espresso'
4156
+					),
4157
+					$delete_column,
4158
+					$entity_model->get_this_model_name()
4159
+				)
4160
+			);
4161
+		}
4162
+	}
4163
+
4164
+
4165
+	/**
4166
+	 * @param EEM_Base       $entity_model
4167
+	 * @param Exception|null $exception
4168
+	 * @param string         $action
4169
+	 * @since 4.10.30.p
4170
+	 */
4171
+	private function trashRestoreDeleteError($action, EEM_Base $entity_model, Exception $exception = null)
4172
+	{
4173
+		if ($exception instanceof Exception) {
4174
+			throw new RuntimeException(
4175
+				sprintf(
4176
+					esc_html__(
4177
+						'Could not %1$s the %2$s because the following error occurred: %3$s',
4178
+						'event_espresso'
4179
+					),
4180
+					$action,
4181
+					$entity_model->get_this_model_name(),
4182
+					$exception->getMessage()
4183
+				)
4184
+			);
4185
+		}
4186
+		throw new RuntimeException(
4187
+			sprintf(
4188
+				esc_html__(
4189
+					'Could not %1$s the %2$s because an invalid ID was received.',
4190
+					'event_espresso'
4191
+				),
4192
+				$action,
4193
+				$entity_model->get_this_model_name()
4194
+			)
4195
+		);
4196
+	}
4197 4197
 }
Please login to merge, or discard this patch.
Spacing   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
         $ee_menu_slugs = (array) $ee_menu_slugs;
516 516
         if (
517 517
             ! $this->request->isAjax()
518
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
518
+            && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))
519 519
         ) {
520 520
             return;
521 521
         }
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
             : $req_action;
536 536
 
537 537
         $this->_current_view = $this->_req_action;
538
-        $this->_req_nonce    = $this->_req_action . '_nonce';
538
+        $this->_req_nonce    = $this->_req_action.'_nonce';
539 539
         $this->_define_page_props();
540 540
         $this->_current_page_view_url = add_query_arg(
541 541
             ['page' => $this->_current_page, 'action' => $this->_current_view],
@@ -572,21 +572,21 @@  discard block
 block discarded – undo
572 572
         }
573 573
         // filter routes and page_config so addons can add their stuff. Filtering done per class
574 574
         $this->_page_routes = apply_filters(
575
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
575
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
576 576
             $this->_page_routes,
577 577
             $this
578 578
         );
579 579
         $this->_page_config = apply_filters(
580
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
580
+            'FHEE__'.get_class($this).'__page_setup__page_config',
581 581
             $this->_page_config,
582 582
             $this
583 583
         );
584 584
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
585 585
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
586
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
586
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
587 587
             add_action(
588 588
                 'AHEE__EE_Admin_Page__route_admin_request',
589
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
589
+                [$this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view],
590 590
                 10,
591 591
                 2
592 592
             );
@@ -599,8 +599,8 @@  discard block
 block discarded – undo
599 599
             if ($this->_is_UI_request) {
600 600
                 // admin_init stuff - global, all views for this page class, specific view
601 601
                 add_action('admin_init', [$this, 'admin_init'], 10);
602
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
603
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
602
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
603
+                    add_action('admin_init', [$this, 'admin_init_'.$this->_current_view], 15);
604 604
                 }
605 605
             } else {
606 606
                 // hijack regular WP loading and route admin request immediately
@@ -619,12 +619,12 @@  discard block
 block discarded – undo
619 619
      */
620 620
     private function _do_other_page_hooks()
621 621
     {
622
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
622
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, []);
623 623
         foreach ($registered_pages as $page) {
624 624
             // now let's setup the file name and class that should be present
625 625
             $classname = str_replace('.class.php', '', $page);
626 626
             // autoloaders should take care of loading file
627
-            if (! class_exists($classname)) {
627
+            if ( ! class_exists($classname)) {
628 628
                 $error_msg[] = sprintf(
629 629
                     esc_html__(
630 630
                         'Something went wrong with loading the %s admin hooks page.',
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
                                    ),
642 642
                                    $page,
643 643
                                    '<br />',
644
-                                   '<strong>' . $classname . '</strong>'
644
+                                   '<strong>'.$classname.'</strong>'
645 645
                                );
646 646
                 throw new EE_Error(implode('||', $error_msg));
647 647
             }
@@ -683,13 +683,13 @@  discard block
 block discarded – undo
683 683
         // load admin_notices - global, page class, and view specific
684 684
         add_action('admin_notices', [$this, 'admin_notices_global'], 5);
685 685
         add_action('admin_notices', [$this, 'admin_notices'], 10);
686
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
687
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
686
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
687
+            add_action('admin_notices', [$this, 'admin_notices_'.$this->_current_view], 15);
688 688
         }
689 689
         // load network admin_notices - global, page class, and view specific
690 690
         add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
691
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
692
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
691
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
692
+            add_action('network_admin_notices', [$this, 'network_admin_notices_'.$this->_current_view]);
693 693
         }
694 694
         // this will save any per_page screen options if they are present
695 695
         $this->_set_per_page_screen_options();
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
     protected function _verify_routes()
811 811
     {
812 812
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
813
-        if (! $this->_current_page && ! $this->request->isAjax()) {
813
+        if ( ! $this->_current_page && ! $this->request->isAjax()) {
814 814
             return false;
815 815
         }
816 816
         $this->_route = false;
@@ -822,7 +822,7 @@  discard block
 block discarded – undo
822 822
                 $this->_admin_page_title
823 823
             );
824 824
             // developer error msg
825
-            $error_msg .= '||' . $error_msg
825
+            $error_msg .= '||'.$error_msg
826 826
                           . esc_html__(
827 827
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
828 828
                               'event_espresso'
@@ -831,9 +831,9 @@  discard block
 block discarded – undo
831 831
         }
832 832
         // and that the requested page route exists
833 833
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
834
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
835
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
836
-                ? $this->_page_config[ $this->_req_action ]
834
+            $this->_route        = $this->_page_routes[$this->_req_action];
835
+            $this->_route_config = isset($this->_page_config[$this->_req_action])
836
+                ? $this->_page_config[$this->_req_action]
837 837
                 : [];
838 838
         } else {
839 839
             // user error msg
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
                 $this->_admin_page_title
846 846
             );
847 847
             // developer error msg
848
-            $error_msg .= '||' . $error_msg
848
+            $error_msg .= '||'.$error_msg
849 849
                           . sprintf(
850 850
                               esc_html__(
851 851
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
             throw new EE_Error($error_msg);
857 857
         }
858 858
         // and that a default route exists
859
-        if (! array_key_exists('default', $this->_page_routes)) {
859
+        if ( ! array_key_exists('default', $this->_page_routes)) {
860 860
             // user error msg
861 861
             $error_msg = sprintf(
862 862
                 esc_html__(
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
                 $this->_admin_page_title
867 867
             );
868 868
             // developer error msg
869
-            $error_msg .= '||' . $error_msg
869
+            $error_msg .= '||'.$error_msg
870 870
                           . esc_html__(
871 871
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
872 872
                               'event_espresso'
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
             $this->_admin_page_title
908 908
         );
909 909
         // developer error msg
910
-        $error_msg .= '||' . $error_msg
910
+        $error_msg .= '||'.$error_msg
911 911
                       . sprintf(
912 912
                           esc_html__(
913 913
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
     protected function _verify_nonce($nonce, $nonce_ref)
933 933
     {
934 934
         // verify nonce against expected value
935
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
935
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
936 936
             // these are not the droids you are looking for !!!
937 937
             $msg = sprintf(
938 938
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
                     __CLASS__
950 950
                 );
951 951
             }
952
-            if (! $this->request->isAjax()) {
952
+            if ( ! $this->request->isAjax()) {
953 953
                 wp_die($msg);
954 954
             }
955 955
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
      */
974 974
     protected function _route_admin_request()
975 975
     {
976
-        if (! $this->_is_UI_request) {
976
+        if ( ! $this->_is_UI_request) {
977 977
             $this->_verify_routes();
978 978
         }
979 979
         $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
         $error_msg = '';
994 994
         // action right before calling route
995 995
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
996
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
996
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
997 997
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
998 998
         }
999 999
         // right before calling the route, let's clean the _wp_http_referer
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
         );
1006 1006
         $this->request->setRequestParam('_wp_http_referer', $cleaner_request_uri);
1007 1007
         $this->request->setServerParam('REQUEST_URI', $cleaner_request_uri);
1008
-        if (! empty($func)) {
1008
+        if ( ! empty($func)) {
1009 1009
             if (is_array($func)) {
1010 1010
                 [$class, $method] = $func;
1011 1011
             } elseif (strpos($func, '::') !== false) {
@@ -1014,7 +1014,7 @@  discard block
 block discarded – undo
1014 1014
                 $class  = $this;
1015 1015
                 $method = $func;
1016 1016
             }
1017
-            if (! (is_object($class) && $class === $this)) {
1017
+            if ( ! (is_object($class) && $class === $this)) {
1018 1018
                 // send along this admin page object for access by addons.
1019 1019
                 $args['admin_page_object'] = $this;
1020 1020
             }
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
                     $method
1056 1056
                 );
1057 1057
             }
1058
-            if (! empty($error_msg)) {
1058
+            if ( ! empty($error_msg)) {
1059 1059
                 throw new EE_Error($error_msg);
1060 1060
             }
1061 1061
         }
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
                 if (strpos($key, 'nonce') !== false) {
1141 1141
                     continue;
1142 1142
                 }
1143
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1143
+                $args['wp_referer['.$key.']'] = is_string($value) ? htmlspecialchars($value) : $value;
1144 1144
             }
1145 1145
         }
1146 1146
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1179,12 +1179,12 @@  discard block
 block discarded – undo
1179 1179
      */
1180 1180
     protected function _add_help_tabs()
1181 1181
     {
1182
-        if (isset($this->_page_config[ $this->_req_action ])) {
1183
-            $config = $this->_page_config[ $this->_req_action ];
1182
+        if (isset($this->_page_config[$this->_req_action])) {
1183
+            $config = $this->_page_config[$this->_req_action];
1184 1184
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1185 1185
             if (is_array($config) && isset($config['help_sidebar'])) {
1186 1186
                 // check that the callback given is valid
1187
-                if (! method_exists($this, $config['help_sidebar'])) {
1187
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1188 1188
                     throw new EE_Error(
1189 1189
                         sprintf(
1190 1190
                             esc_html__(
@@ -1197,18 +1197,18 @@  discard block
 block discarded – undo
1197 1197
                     );
1198 1198
                 }
1199 1199
                 $content = apply_filters(
1200
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1200
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1201 1201
                     $this->{$config['help_sidebar']}()
1202 1202
                 );
1203 1203
                 $this->_current_screen->set_help_sidebar($content);
1204 1204
             }
1205
-            if (! isset($config['help_tabs'])) {
1205
+            if ( ! isset($config['help_tabs'])) {
1206 1206
                 return;
1207 1207
             } //no help tabs for this route
1208 1208
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1209 1209
                 // we're here so there ARE help tabs!
1210 1210
                 // make sure we've got what we need
1211
-                if (! isset($cfg['title'])) {
1211
+                if ( ! isset($cfg['title'])) {
1212 1212
                     throw new EE_Error(
1213 1213
                         esc_html__(
1214 1214
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
                         )
1217 1217
                     );
1218 1218
                 }
1219
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1219
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1220 1220
                     throw new EE_Error(
1221 1221
                         esc_html__(
1222 1222
                             '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',
@@ -1225,11 +1225,11 @@  discard block
 block discarded – undo
1225 1225
                     );
1226 1226
                 }
1227 1227
                 // first priority goes to content.
1228
-                if (! empty($cfg['content'])) {
1228
+                if ( ! empty($cfg['content'])) {
1229 1229
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1230 1230
                     // second priority goes to filename
1231
-                } elseif (! empty($cfg['filename'])) {
1232
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1231
+                } elseif ( ! empty($cfg['filename'])) {
1232
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1233 1233
                     // 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)
1234 1234
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1235 1235
                                                              . basename($this->_get_dir())
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
                                                              . $cfg['filename']
1238 1238
                                                              . '.help_tab.php' : $file_path;
1239 1239
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1240
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1240
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1241 1241
                         EE_Error::add_error(
1242 1242
                             sprintf(
1243 1243
                                 esc_html__(
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
                     return;
1286 1286
                 }
1287 1287
                 // setup config array for help tab method
1288
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1288
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1289 1289
                 $_ht = [
1290 1290
                     'id'       => $id,
1291 1291
                     'title'    => $cfg['title'],
@@ -1309,8 +1309,8 @@  discard block
 block discarded – undo
1309 1309
             $qtips = (array) $this->_route_config['qtips'];
1310 1310
             // load qtip loader
1311 1311
             $path = [
1312
-                $this->_get_dir() . '/qtips/',
1313
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1312
+                $this->_get_dir().'/qtips/',
1313
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1314 1314
             ];
1315 1315
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1316 1316
         }
@@ -1332,7 +1332,7 @@  discard block
 block discarded – undo
1332 1332
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1333 1333
         $i = 0;
1334 1334
         foreach ($this->_page_config as $slug => $config) {
1335
-            if (! is_array($config) || empty($config['nav'])) {
1335
+            if ( ! is_array($config) || empty($config['nav'])) {
1336 1336
                 continue;
1337 1337
             }
1338 1338
             // no nav tab for this config
@@ -1341,12 +1341,12 @@  discard block
 block discarded – undo
1341 1341
                 // nav tab is only to appear when route requested.
1342 1342
                 continue;
1343 1343
             }
1344
-            if (! $this->check_user_access($slug, true)) {
1344
+            if ( ! $this->check_user_access($slug, true)) {
1345 1345
                 // no nav tab because current user does not have access.
1346 1346
                 continue;
1347 1347
             }
1348
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1349
-            $this->_nav_tabs[ $slug ] = [
1348
+            $css_class                = isset($config['css_class']) ? $config['css_class'].' ' : '';
1349
+            $this->_nav_tabs[$slug] = [
1350 1350
                 'url'       => isset($config['nav']['url'])
1351 1351
                     ? $config['nav']['url']
1352 1352
                     : self::add_query_args_and_nonce(
@@ -1358,14 +1358,14 @@  discard block
 block discarded – undo
1358 1358
                     : ucwords(
1359 1359
                         str_replace('_', ' ', $slug)
1360 1360
                     ),
1361
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1361
+                'css_class' => $this->_req_action === $slug ? $css_class.'nav-tab-active' : $css_class,
1362 1362
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1363 1363
             ];
1364 1364
             $i++;
1365 1365
         }
1366 1366
         // if $this->_nav_tabs is empty then lets set the default
1367 1367
         if (empty($this->_nav_tabs)) {
1368
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1368
+            $this->_nav_tabs[$this->_default_nav_tab_name] = [
1369 1369
                 'url'       => $this->_admin_base_url,
1370 1370
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1371 1371
                 'css_class' => 'nav-tab-active',
@@ -1390,10 +1390,10 @@  discard block
 block discarded – undo
1390 1390
             foreach ($this->_route_config['labels'] as $label => $text) {
1391 1391
                 if (is_array($text)) {
1392 1392
                     foreach ($text as $sublabel => $subtext) {
1393
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1393
+                        $this->_labels[$label][$sublabel] = $subtext;
1394 1394
                     }
1395 1395
                 } else {
1396
-                    $this->_labels[ $label ] = $text;
1396
+                    $this->_labels[$label] = $text;
1397 1397
                 }
1398 1398
             }
1399 1399
         }
@@ -1415,12 +1415,12 @@  discard block
 block discarded – undo
1415 1415
     {
1416 1416
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1417 1417
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1418
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1418
+        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1419 1419
                           && is_array(
1420
-                              $this->_page_routes[ $route_to_check ]
1420
+                              $this->_page_routes[$route_to_check]
1421 1421
                           )
1422
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1423
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1422
+                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1423
+            ? $this->_page_routes[$route_to_check]['capability'] : null;
1424 1424
         if (empty($capability) && empty($route_to_check)) {
1425 1425
             $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1426 1426
                 : $this->_route['capability'];
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
         ';
1541 1541
 
1542 1542
         // current set timezone for timezone js
1543
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1543
+        echo '<span id="current_timezone" class="hidden">'.esc_html(EEH_DTT_Helper::get_timezone()).'</span>';
1544 1544
     }
1545 1545
 
1546 1546
 
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
         // loop through the array and setup content
1575 1575
         foreach ($help_array as $trigger => $help) {
1576 1576
             // make sure the array is setup properly
1577
-            if (! isset($help['title']) || ! isset($help['content'])) {
1577
+            if ( ! isset($help['title']) || ! isset($help['content'])) {
1578 1578
                 throw new EE_Error(
1579 1579
                     esc_html__(
1580 1580
                         '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',
@@ -1588,8 +1588,8 @@  discard block
 block discarded – undo
1588 1588
                 'help_popup_title'   => $help['title'],
1589 1589
                 'help_popup_content' => $help['content'],
1590 1590
             ];
1591
-            $content       .= EEH_Template::display_template(
1592
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1591
+            $content .= EEH_Template::display_template(
1592
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1593 1593
                 $template_args,
1594 1594
                 true
1595 1595
             );
@@ -1611,15 +1611,15 @@  discard block
 block discarded – undo
1611 1611
     private function _get_help_content()
1612 1612
     {
1613 1613
         // what is the method we're looking for?
1614
-        $method_name = '_help_popup_content_' . $this->_req_action;
1614
+        $method_name = '_help_popup_content_'.$this->_req_action;
1615 1615
         // if method doesn't exist let's get out.
1616
-        if (! method_exists($this, $method_name)) {
1616
+        if ( ! method_exists($this, $method_name)) {
1617 1617
             return [];
1618 1618
         }
1619 1619
         // k we're good to go let's retrieve the help array
1620 1620
         $help_array = call_user_func([$this, $method_name]);
1621 1621
         // make sure we've got an array!
1622
-        if (! is_array($help_array)) {
1622
+        if ( ! is_array($help_array)) {
1623 1623
             throw new EE_Error(
1624 1624
                 esc_html__(
1625 1625
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1651,15 +1651,15 @@  discard block
 block discarded – undo
1651 1651
         // 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
1652 1652
         $help_array   = $this->_get_help_content();
1653 1653
         $help_content = '';
1654
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1655
-            $help_array[ $trigger_id ] = [
1654
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1655
+            $help_array[$trigger_id] = [
1656 1656
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1657 1657
                 'content' => esc_html__(
1658 1658
                     '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.)',
1659 1659
                     'event_espresso'
1660 1660
                 ),
1661 1661
             ];
1662
-            $help_content              = $this->_set_help_popup_content($help_array);
1662
+            $help_content = $this->_set_help_popup_content($help_array);
1663 1663
         }
1664 1664
         // let's setup the trigger
1665 1665
         $content = '<a class="ee-dialog" href="?height='
@@ -1727,15 +1727,15 @@  discard block
 block discarded – undo
1727 1727
         // register all styles
1728 1728
         wp_register_style(
1729 1729
             'espresso-ui-theme',
1730
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1730
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1731 1731
             [],
1732 1732
             EVENT_ESPRESSO_VERSION
1733 1733
         );
1734
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1734
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1735 1735
         // helpers styles
1736 1736
         wp_register_style(
1737 1737
             'ee-text-links',
1738
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1738
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css',
1739 1739
             [],
1740 1740
             EVENT_ESPRESSO_VERSION
1741 1741
         );
@@ -1743,21 +1743,21 @@  discard block
 block discarded – undo
1743 1743
         // register all scripts
1744 1744
         wp_register_script(
1745 1745
             'ee-dialog',
1746
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1746
+            EE_ADMIN_URL.'assets/ee-dialog-helper.js',
1747 1747
             ['jquery', 'jquery-ui-draggable'],
1748 1748
             EVENT_ESPRESSO_VERSION,
1749 1749
             true
1750 1750
         );
1751 1751
         wp_register_script(
1752 1752
             'ee_admin_js',
1753
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1753
+            EE_ADMIN_URL.'assets/ee-admin-page.js',
1754 1754
             ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1755 1755
             EVENT_ESPRESSO_VERSION,
1756 1756
             true
1757 1757
         );
1758 1758
         wp_register_script(
1759 1759
             'jquery-ui-timepicker-addon',
1760
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1760
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js',
1761 1761
             ['jquery-ui-datepicker', 'jquery-ui-slider'],
1762 1762
             EVENT_ESPRESSO_VERSION,
1763 1763
             true
@@ -1765,7 +1765,7 @@  discard block
 block discarded – undo
1765 1765
         // script for sorting tables
1766 1766
         wp_register_script(
1767 1767
             'espresso_ajax_table_sorting',
1768
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1768
+            EE_ADMIN_URL.'assets/espresso_ajax_table_sorting.js',
1769 1769
             ['ee_admin_js', 'jquery-ui-sortable'],
1770 1770
             EVENT_ESPRESSO_VERSION,
1771 1771
             true
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
         // script for parsing uri's
1774 1774
         wp_register_script(
1775 1775
             'ee-parse-uri',
1776
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1776
+            EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js',
1777 1777
             [],
1778 1778
             EVENT_ESPRESSO_VERSION,
1779 1779
             true
@@ -1781,7 +1781,7 @@  discard block
 block discarded – undo
1781 1781
         // and parsing associative serialized form elements
1782 1782
         wp_register_script(
1783 1783
             'ee-serialize-full-array',
1784
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1784
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js',
1785 1785
             ['jquery'],
1786 1786
             EVENT_ESPRESSO_VERSION,
1787 1787
             true
@@ -1789,28 +1789,28 @@  discard block
 block discarded – undo
1789 1789
         // helpers scripts
1790 1790
         wp_register_script(
1791 1791
             'ee-text-links',
1792
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1792
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js',
1793 1793
             ['jquery'],
1794 1794
             EVENT_ESPRESSO_VERSION,
1795 1795
             true
1796 1796
         );
1797 1797
         wp_register_script(
1798 1798
             'ee-moment-core',
1799
-            EE_GLOBAL_ASSETS_URL . 'moment/moment-with-locales.min.js',
1799
+            EE_GLOBAL_ASSETS_URL.'moment/moment-with-locales.min.js',
1800 1800
             [],
1801 1801
             EVENT_ESPRESSO_VERSION,
1802 1802
             true
1803 1803
         );
1804 1804
         wp_register_script(
1805 1805
             'ee-moment',
1806
-            EE_GLOBAL_ASSETS_URL . 'moment/moment-timezone-with-data.min.js',
1806
+            EE_GLOBAL_ASSETS_URL.'moment/moment-timezone-with-data.min.js',
1807 1807
             ['ee-moment-core'],
1808 1808
             EVENT_ESPRESSO_VERSION,
1809 1809
             true
1810 1810
         );
1811 1811
         wp_register_script(
1812 1812
             'ee-datepicker',
1813
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1813
+            EE_ADMIN_URL.'assets/ee-datepicker.js',
1814 1814
             ['jquery-ui-timepicker-addon', 'ee-moment'],
1815 1815
             EVENT_ESPRESSO_VERSION,
1816 1816
             true
@@ -1843,7 +1843,7 @@  discard block
 block discarded – undo
1843 1843
         wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1844 1844
         add_filter(
1845 1845
             'admin_body_class',
1846
-            function ($classes) {
1846
+            function($classes) {
1847 1847
                 if (strpos($classes, 'espresso-admin') === false) {
1848 1848
                     $classes .= ' espresso-admin';
1849 1849
                 }
@@ -1931,12 +1931,12 @@  discard block
 block discarded – undo
1931 1931
     protected function _set_list_table()
1932 1932
     {
1933 1933
         // first is this a list_table view?
1934
-        if (! isset($this->_route_config['list_table'])) {
1934
+        if ( ! isset($this->_route_config['list_table'])) {
1935 1935
             return;
1936 1936
         } //not a list_table view so get out.
1937 1937
         // list table functions are per view specific (because some admin pages might have more than one list table!)
1938
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
1939
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1938
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
1939
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1940 1940
             // user error msg
1941 1941
             $error_msg = esc_html__(
1942 1942
                 'An error occurred. The requested list table views could not be found.',
@@ -1956,10 +1956,10 @@  discard block
 block discarded – undo
1956 1956
         }
1957 1957
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1958 1958
         $this->_views = apply_filters(
1959
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1959
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
1960 1960
             $this->_views
1961 1961
         );
1962
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1962
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1963 1963
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1964 1964
         $this->_set_list_table_view();
1965 1965
         $this->_set_list_table_object();
@@ -1994,7 +1994,7 @@  discard block
 block discarded – undo
1994 1994
     protected function _set_list_table_object()
1995 1995
     {
1996 1996
         if (isset($this->_route_config['list_table'])) {
1997
-            if (! class_exists($this->_route_config['list_table'])) {
1997
+            if ( ! class_exists($this->_route_config['list_table'])) {
1998 1998
                 throw new EE_Error(
1999 1999
                     sprintf(
2000 2000
                         esc_html__(
@@ -2032,15 +2032,15 @@  discard block
 block discarded – undo
2032 2032
         foreach ($this->_views as $key => $view) {
2033 2033
             $query_args = [];
2034 2034
             // check for current view
2035
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2035
+            $this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2036 2036
             $query_args['action']                        = $this->_req_action;
2037
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2037
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2038 2038
             $query_args['status']                        = $view['slug'];
2039 2039
             // merge any other arguments sent in.
2040
-            if (isset($extra_query_args[ $view['slug'] ])) {
2041
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2040
+            if (isset($extra_query_args[$view['slug']])) {
2041
+                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2042 2042
             }
2043
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2043
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2044 2044
         }
2045 2045
         return $this->_views;
2046 2046
     }
@@ -2071,14 +2071,14 @@  discard block
 block discarded – undo
2071 2071
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2072 2072
         foreach ($values as $value) {
2073 2073
             if ($value < $max_entries) {
2074
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2074
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2075 2075
                 $entries_per_page_dropdown .= '
2076
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2076
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2077 2077
             }
2078 2078
         }
2079
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2079
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2080 2080
         $entries_per_page_dropdown .= '
2081
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2081
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2082 2082
         $entries_per_page_dropdown .= '
2083 2083
 					</select>
2084 2084
 					entries
@@ -2102,7 +2102,7 @@  discard block
 block discarded – undo
2102 2102
             empty($this->_search_btn_label) ? $this->page_label
2103 2103
                 : $this->_search_btn_label
2104 2104
         );
2105
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2105
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2106 2106
     }
2107 2107
 
2108 2108
 
@@ -2190,7 +2190,7 @@  discard block
 block discarded – undo
2190 2190
             $total_columns                                       = ! empty($screen_columns)
2191 2191
                 ? $screen_columns
2192 2192
                 : $this->_route_config['columns'][1];
2193
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2193
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2194 2194
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2195 2195
             $this->_template_args['screen']                      = $this->_current_screen;
2196 2196
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2235,7 +2235,7 @@  discard block
 block discarded – undo
2235 2235
      */
2236 2236
     protected function _espresso_ratings_request()
2237 2237
     {
2238
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2238
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2239 2239
             return;
2240 2240
         }
2241 2241
         $ratings_box_title = apply_filters(
@@ -2263,7 +2263,7 @@  discard block
 block discarded – undo
2263 2263
     public function espresso_ratings_request()
2264 2264
     {
2265 2265
         EEH_Template::display_template(
2266
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2266
+            EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php',
2267 2267
             []
2268 2268
         );
2269 2269
     }
@@ -2271,22 +2271,22 @@  discard block
 block discarded – undo
2271 2271
 
2272 2272
     public static function cached_rss_display($rss_id, $url)
2273 2273
     {
2274
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2274
+        $loading = '<p class="widget-loading hide-if-no-js">'
2275 2275
                      . esc_html__('Loading&#8230;', 'event_espresso')
2276 2276
                      . '</p><p class="hide-if-js">'
2277 2277
                      . esc_html__('This widget requires JavaScript.', 'event_espresso')
2278 2278
                      . '</p>';
2279
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2280
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2281
-        $post      = '</div>' . "\n";
2282
-        $cache_key = 'ee_rss_' . md5($rss_id);
2279
+        $pre       = '<div class="espresso-rss-display">'."\n\t";
2280
+        $pre .= '<span id="'.esc_attr($rss_id).'_url" class="hidden">'.esc_url_raw($url).'</span>';
2281
+        $post      = '</div>'."\n";
2282
+        $cache_key = 'ee_rss_'.md5($rss_id);
2283 2283
         $output    = get_transient($cache_key);
2284 2284
         if ($output !== false) {
2285
-            echo wp_kses($pre . $output . $post, AllowedTags::getWithFormTags());
2285
+            echo wp_kses($pre.$output.$post, AllowedTags::getWithFormTags());
2286 2286
             return true;
2287 2287
         }
2288
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2289
-            echo wp_kses($pre . $loading . $post, AllowedTags::getWithFormTags());
2288
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2289
+            echo wp_kses($pre.$loading.$post, AllowedTags::getWithFormTags());
2290 2290
             return false;
2291 2291
         }
2292 2292
         ob_start();
@@ -2353,19 +2353,19 @@  discard block
 block discarded – undo
2353 2353
     public function espresso_sponsors_post_box()
2354 2354
     {
2355 2355
         EEH_Template::display_template(
2356
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2356
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2357 2357
         );
2358 2358
     }
2359 2359
 
2360 2360
 
2361 2361
     private function _publish_post_box()
2362 2362
     {
2363
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2363
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2364 2364
         // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2365 2365
         // then we'll use that for the metabox label.
2366 2366
         // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2367
-        if (! empty($this->_labels['publishbox'])) {
2368
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2367
+        if ( ! empty($this->_labels['publishbox'])) {
2368
+            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2369 2369
                 : $this->_labels['publishbox'];
2370 2370
         } else {
2371 2371
             $box_label = esc_html__('Publish', 'event_espresso');
@@ -2394,7 +2394,7 @@  discard block
 block discarded – undo
2394 2394
             ? $this->_template_args['publish_box_extra_content']
2395 2395
             : '';
2396 2396
         echo EEH_Template::display_template(
2397
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2397
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2398 2398
             $this->_template_args,
2399 2399
             true
2400 2400
         );
@@ -2486,18 +2486,18 @@  discard block
 block discarded – undo
2486 2486
             );
2487 2487
         }
2488 2488
         $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2489
-        if (! empty($name) && ! empty($id)) {
2490
-            $hidden_field_arr[ $name ] = [
2489
+        if ( ! empty($name) && ! empty($id)) {
2490
+            $hidden_field_arr[$name] = [
2491 2491
                 'type'  => 'hidden',
2492 2492
                 'value' => $id,
2493 2493
             ];
2494
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2494
+            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2495 2495
         } else {
2496 2496
             $hf = '';
2497 2497
         }
2498 2498
         // add hidden field
2499 2499
         $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2500
-            ? $hf[ $name ]['field']
2500
+            ? $hf[$name]['field']
2501 2501
             : $hf;
2502 2502
     }
2503 2503
 
@@ -2599,7 +2599,7 @@  discard block
 block discarded – undo
2599 2599
         }
2600 2600
         // 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)
2601 2601
         $call_back_func = $create_func
2602
-            ? function ($post, $metabox) {
2602
+            ? function($post, $metabox) {
2603 2603
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2604 2604
                 echo EEH_Template::display_template(
2605 2605
                     $metabox['args']['template_path'],
@@ -2609,7 +2609,7 @@  discard block
 block discarded – undo
2609 2609
             }
2610 2610
             : $callback;
2611 2611
         add_meta_box(
2612
-            str_replace('_', '-', $action) . '-mbox',
2612
+            str_replace('_', '-', $action).'-mbox',
2613 2613
             $title,
2614 2614
             $call_back_func,
2615 2615
             $this->_wp_page_slug,
@@ -2701,9 +2701,9 @@  discard block
 block discarded – undo
2701 2701
             : 'espresso-default-admin';
2702 2702
         $template_path                                     = $sidebar
2703 2703
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2704
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2704
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2705 2705
         if ($this->request->isAjax()) {
2706
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2706
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2707 2707
         }
2708 2708
         $template_path                                     = ! empty($this->_column_template_path)
2709 2709
             ? $this->_column_template_path : $template_path;
@@ -2743,11 +2743,11 @@  discard block
 block discarded – undo
2743 2743
     public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2744 2744
     {
2745 2745
         // let's generate a default preview action button if there isn't one already present.
2746
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2746
+        $this->_labels['buttons']['buy_now'] = esc_html__(
2747 2747
             'Upgrade to Event Espresso 4 Right Now',
2748 2748
             'event_espresso'
2749 2749
         );
2750
-        $buy_now_url                                   = add_query_arg(
2750
+        $buy_now_url = add_query_arg(
2751 2751
             [
2752 2752
                 'ee_ver'       => 'ee4',
2753 2753
                 'utm_source'   => 'ee4_plugin_admin',
@@ -2767,8 +2767,8 @@  discard block
 block discarded – undo
2767 2767
                 true
2768 2768
             )
2769 2769
             : $this->_template_args['preview_action_button'];
2770
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2771
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2770
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2771
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2772 2772
             $this->_template_args,
2773 2773
             true
2774 2774
         );
@@ -2817,7 +2817,7 @@  discard block
 block discarded – undo
2817 2817
         // setup search attributes
2818 2818
         $this->_set_search_attributes();
2819 2819
         $this->_template_args['current_page']     = $this->_wp_page_slug;
2820
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2820
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2821 2821
         $this->_template_args['table_url']        = $this->request->isAjax()
2822 2822
             ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2823 2823
             : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
@@ -2825,10 +2825,10 @@  discard block
 block discarded – undo
2825 2825
         $this->_template_args['current_route']    = $this->_req_action;
2826 2826
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2827 2827
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2828
-        if (! empty($ajax_sorting_callback)) {
2828
+        if ( ! empty($ajax_sorting_callback)) {
2829 2829
             $sortable_list_table_form_fields = wp_nonce_field(
2830
-                $ajax_sorting_callback . '_nonce',
2831
-                $ajax_sorting_callback . '_nonce',
2830
+                $ajax_sorting_callback.'_nonce',
2831
+                $ajax_sorting_callback.'_nonce',
2832 2832
                 false,
2833 2833
                 false
2834 2834
             );
@@ -2847,18 +2847,18 @@  discard block
 block discarded – undo
2847 2847
                 ? $this->_template_args['list_table_hidden_fields']
2848 2848
                 : '';
2849 2849
 
2850
-        $nonce_ref          = $this->_req_action . '_nonce';
2850
+        $nonce_ref = $this->_req_action.'_nonce';
2851 2851
         $hidden_form_fields .= '
2852
-            <input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2852
+            <input type="hidden" name="' . $nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">';
2853 2853
 
2854
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2854
+        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2855 2855
         // display message about search results?
2856 2856
         $search = $this->request->getRequestParam('s');
2857 2857
         $this->_template_args['before_list_table'] .= ! empty($search)
2858
-            ? '<p class="ee-search-results">' . sprintf(
2858
+            ? '<p class="ee-search-results">'.sprintf(
2859 2859
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2860 2860
                 trim($search, '%')
2861
-            ) . '</p>'
2861
+            ).'</p>'
2862 2862
             : '';
2863 2863
         // filter before_list_table template arg
2864 2864
         $this->_template_args['before_list_table'] = apply_filters(
@@ -2892,7 +2892,7 @@  discard block
 block discarded – undo
2892 2892
         // convert to array and filter again
2893 2893
         // arrays are easier to inject new items in a specific location,
2894 2894
         // but would not be backwards compatible, so we have to add a new filter
2895
-        $this->_template_args['after_list_table']   = implode(
2895
+        $this->_template_args['after_list_table'] = implode(
2896 2896
             " \n",
2897 2897
             (array) apply_filters(
2898 2898
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
@@ -2939,7 +2939,7 @@  discard block
 block discarded – undo
2939 2939
             $this
2940 2940
         );
2941 2941
         return EEH_Template::display_template(
2942
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2942
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
2943 2943
             $this->_template_args,
2944 2944
             true
2945 2945
         );
@@ -3048,18 +3048,18 @@  discard block
 block discarded – undo
3048 3048
                 : ''
3049 3049
         );
3050 3050
 
3051
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3051
+        $this->_template_args['after_admin_page_content'] = apply_filters(
3052 3052
             "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3053 3053
             isset($this->_template_args['after_admin_page_content'])
3054 3054
                 ? $this->_template_args['after_admin_page_content']
3055 3055
                 : ''
3056 3056
         );
3057
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3057
+        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3058 3058
 
3059 3059
         if ($this->request->isAjax()) {
3060 3060
             $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3061 3061
                 // $template_path,
3062
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3062
+                EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php',
3063 3063
                 $this->_template_args,
3064 3064
                 true
3065 3065
             );
@@ -3068,7 +3068,7 @@  discard block
 block discarded – undo
3068 3068
         // load settings page wrapper template
3069 3069
         $template_path = $about
3070 3070
             ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3071
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3071
+            : EE_ADMIN_TEMPLATE.'admin_wrapper.template.php';
3072 3072
 
3073 3073
         EEH_Template::display_template($template_path, $this->_template_args);
3074 3074
     }
@@ -3153,12 +3153,12 @@  discard block
 block discarded – undo
3153 3153
         $default_names = ['save', 'save_and_close'];
3154 3154
         $buttons = '';
3155 3155
         foreach ($button_text as $key => $button) {
3156
-            $ref     = $default_names[ $key ];
3157
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3158
-            $buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3159
-                        . 'value="' . $button . '" name="' . $name . '" '
3160
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3161
-            if (! $both) {
3156
+            $ref     = $default_names[$key];
3157
+            $name    = ! empty($actions) ? $actions[$key] : $ref;
3158
+            $buttons .= '<input type="submit" class="button-primary '.$ref.'" '
3159
+                        . 'value="'.$button.'" name="'.$name.'" '
3160
+                        . 'id="'.$this->_current_view.'_'.$ref.'" />';
3161
+            if ( ! $both) {
3162 3162
                 break;
3163 3163
             }
3164 3164
         }
@@ -3198,13 +3198,13 @@  discard block
 block discarded – undo
3198 3198
                 'An error occurred. No action was set for this page\'s form.',
3199 3199
                 'event_espresso'
3200 3200
             );
3201
-            $dev_msg  = $user_msg . "\n"
3201
+            $dev_msg = $user_msg."\n"
3202 3202
                         . sprintf(
3203 3203
                             esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3204 3204
                             __FUNCTION__,
3205 3205
                             __CLASS__
3206 3206
                         );
3207
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3207
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3208 3208
         }
3209 3209
         // open form
3210 3210
         $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
@@ -3213,9 +3213,9 @@  discard block
 block discarded – undo
3213 3213
                                                              . $route
3214 3214
                                                              . '_event_form" >';
3215 3215
         // add nonce
3216
-        $nonce                                             =
3217
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3218
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3216
+        $nonce =
3217
+            wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3218
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3219 3219
         // add REQUIRED form action
3220 3220
         $hidden_fields = [
3221 3221
             'action' => ['type' => 'hidden', 'value' => $route],
@@ -3228,7 +3228,7 @@  discard block
 block discarded – undo
3228 3228
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3229 3229
         // add fields to form
3230 3230
         foreach ((array) $form_fields as $form_field) {
3231
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3231
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3232 3232
         }
3233 3233
         // close form
3234 3234
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3319,10 +3319,10 @@  discard block
 block discarded – undo
3319 3319
         $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3320 3320
         $notices      = EE_Error::get_notices(false);
3321 3321
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3322
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3322
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3323 3323
             EE_Error::overwrite_success();
3324 3324
         }
3325
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3325
+        if ( ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3326 3326
             // how many records affected ? more than one record ? or just one ?
3327 3327
             if ($success > 1) {
3328 3328
                 // set plural msg
@@ -3351,7 +3351,7 @@  discard block
 block discarded – undo
3351 3351
             }
3352 3352
         }
3353 3353
         // check that $query_args isn't something crazy
3354
-        if (! is_array($query_args)) {
3354
+        if ( ! is_array($query_args)) {
3355 3355
             $query_args = [];
3356 3356
         }
3357 3357
         /**
@@ -3380,7 +3380,7 @@  discard block
 block discarded – undo
3380 3380
             $redirect_url = admin_url('admin.php');
3381 3381
         }
3382 3382
         // merge any default query_args set in _default_route_query_args property
3383
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3383
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3384 3384
             $args_to_merge = [];
3385 3385
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3386 3386
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3392,15 +3392,15 @@  discard block
 block discarded – undo
3392 3392
                         }
3393 3393
                         // finally we will override any arguments in the referer with
3394 3394
                         // what might be set on the _default_route_query_args array.
3395
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3396
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3395
+                        if (isset($this->_default_route_query_args[$reference])) {
3396
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3397 3397
                         } else {
3398
-                            $args_to_merge[ $reference ] = urlencode($value);
3398
+                            $args_to_merge[$reference] = urlencode($value);
3399 3399
                         }
3400 3400
                     }
3401 3401
                     continue;
3402 3402
                 }
3403
-                $args_to_merge[ $query_param ] = $query_value;
3403
+                $args_to_merge[$query_param] = $query_value;
3404 3404
             }
3405 3405
             // now let's merge these arguments but override with what was specifically sent in to the
3406 3406
             // redirect.
@@ -3412,19 +3412,19 @@  discard block
 block discarded – undo
3412 3412
         if (isset($query_args['action'])) {
3413 3413
             // manually generate wp_nonce and merge that with the query vars
3414 3414
             // becuz the wp_nonce_url function wrecks havoc on some vars
3415
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3415
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3416 3416
         }
3417 3417
         // we're adding some hooks and filters in here for processing any things just before redirects
3418 3418
         // (example: an admin page has done an insert or update and we want to run something after that).
3419
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3419
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3420 3420
         $redirect_url = apply_filters(
3421
-            'FHEE_redirect_' . $classname . $this->_req_action,
3421
+            'FHEE_redirect_'.$classname.$this->_req_action,
3422 3422
             self::add_query_args_and_nonce($query_args, $redirect_url),
3423 3423
             $query_args
3424 3424
         );
3425 3425
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3426 3426
         if ($this->request->isAjax()) {
3427
-            $default_data                    = [
3427
+            $default_data = [
3428 3428
                 'close'        => true,
3429 3429
                 'redirect_url' => $redirect_url,
3430 3430
                 'where'        => 'main',
@@ -3471,7 +3471,7 @@  discard block
 block discarded – undo
3471 3471
         }
3472 3472
         $this->_template_args['notices'] = EE_Error::get_notices();
3473 3473
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3474
-        if (! $this->request->isAjax() || $sticky_notices) {
3474
+        if ( ! $this->request->isAjax() || $sticky_notices) {
3475 3475
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3476 3476
             $this->_add_transient(
3477 3477
                 $route,
@@ -3511,7 +3511,7 @@  discard block
 block discarded – undo
3511 3511
         $exclude_nonce = false
3512 3512
     ) {
3513 3513
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3514
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3514
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3515 3515
             throw new EE_Error(
3516 3516
                 sprintf(
3517 3517
                     esc_html__(
@@ -3522,7 +3522,7 @@  discard block
 block discarded – undo
3522 3522
                 )
3523 3523
             );
3524 3524
         }
3525
-        if (! isset($this->_labels['buttons'][ $type ])) {
3525
+        if ( ! isset($this->_labels['buttons'][$type])) {
3526 3526
             throw new EE_Error(
3527 3527
                 sprintf(
3528 3528
                     esc_html__(
@@ -3535,7 +3535,7 @@  discard block
 block discarded – undo
3535 3535
         }
3536 3536
         // finally check user access for this button.
3537 3537
         $has_access = $this->check_user_access($action, true);
3538
-        if (! $has_access) {
3538
+        if ( ! $has_access) {
3539 3539
             return '';
3540 3540
         }
3541 3541
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3543,11 +3543,11 @@  discard block
 block discarded – undo
3543 3543
             'action' => $action,
3544 3544
         ];
3545 3545
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3546
-        if (! empty($extra_request)) {
3546
+        if ( ! empty($extra_request)) {
3547 3547
             $query_args = array_merge($extra_request, $query_args);
3548 3548
         }
3549 3549
         $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3550
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3550
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3551 3551
     }
3552 3552
 
3553 3553
 
@@ -3573,7 +3573,7 @@  discard block
 block discarded – undo
3573 3573
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3574 3574
                 20
3575 3575
             ),
3576
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3576
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3577 3577
         ];
3578 3578
         // ONLY add the screen option if the user has access to it.
3579 3579
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3594,18 +3594,18 @@  discard block
 block discarded – undo
3594 3594
     {
3595 3595
         if ($this->request->requestParamIsSet('wp_screen_options')) {
3596 3596
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3597
-            if (! $user = wp_get_current_user()) {
3597
+            if ( ! $user = wp_get_current_user()) {
3598 3598
                 return;
3599 3599
             }
3600 3600
             $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3601
-            if (! $option) {
3601
+            if ( ! $option) {
3602 3602
                 return;
3603 3603
             }
3604
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3604
+            $value = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3605 3605
             $map_option = $option;
3606 3606
             $option     = str_replace('-', '_', $option);
3607 3607
             switch ($map_option) {
3608
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3608
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3609 3609
                     $max_value = apply_filters(
3610 3610
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3611 3611
                         999,
@@ -3662,13 +3662,13 @@  discard block
 block discarded – undo
3662 3662
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3663 3663
     {
3664 3664
         $user_id = get_current_user_id();
3665
-        if (! $skip_route_verify) {
3665
+        if ( ! $skip_route_verify) {
3666 3666
             $this->_verify_route($route);
3667 3667
         }
3668 3668
         // now let's set the string for what kind of transient we're setting
3669 3669
         $transient = $notices
3670
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3671
-            : 'rte_tx_' . $route . '_' . $user_id;
3670
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3671
+            : 'rte_tx_'.$route.'_'.$user_id;
3672 3672
         $data      = $notices ? ['notices' => $data] : $data;
3673 3673
         // is there already a transient for this route?  If there is then let's ADD to that transient
3674 3674
         $existing = is_multisite() && is_network_admin()
@@ -3697,8 +3697,8 @@  discard block
 block discarded – undo
3697 3697
         $user_id   = get_current_user_id();
3698 3698
         $route     = ! $route ? $this->_req_action : $route;
3699 3699
         $transient = $notices
3700
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3701
-            : 'rte_tx_' . $route . '_' . $user_id;
3700
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3701
+            : 'rte_tx_'.$route.'_'.$user_id;
3702 3702
         $data      = is_multisite() && is_network_admin()
3703 3703
             ? get_site_transient($transient)
3704 3704
             : get_transient($transient);
@@ -3929,7 +3929,7 @@  discard block
 block discarded – undo
3929 3929
      */
3930 3930
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3931 3931
     {
3932
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3932
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3933 3933
     }
3934 3934
 
3935 3935
 
@@ -3942,7 +3942,7 @@  discard block
 block discarded – undo
3942 3942
      */
3943 3943
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3944 3944
     {
3945
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3945
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3946 3946
     }
3947 3947
 
3948 3948
 
@@ -4090,13 +4090,13 @@  discard block
 block discarded – undo
4090 4090
         callable $callback = null
4091 4091
     ) {
4092 4092
         $entity_ID = absint($entity_ID);
4093
-        if (! $entity_ID) {
4093
+        if ( ! $entity_ID) {
4094 4094
             $this->trashRestoreDeleteError($action, $entity_model);
4095 4095
         }
4096 4096
         $result = 0;
4097 4097
         try {
4098 4098
             $entity = $entity_model->get_one_by_ID($entity_ID);
4099
-            if (! $entity instanceof EE_Base_Class) {
4099
+            if ( ! $entity instanceof EE_Base_Class) {
4100 4100
                 throw new DomainException(
4101 4101
                     sprintf(
4102 4102
                         esc_html__(
@@ -4147,7 +4147,7 @@  discard block
 block discarded – undo
4147 4147
                 )
4148 4148
             );
4149 4149
         }
4150
-        if (! $entity_model->has_field($delete_column)) {
4150
+        if ( ! $entity_model->has_field($delete_column)) {
4151 4151
             throw new DomainException(
4152 4152
                 sprintf(
4153 4153
                     esc_html__(
Please login to merge, or discard this patch.
core/helpers/EEH_Qtip_Loader.helper.php 2 patches
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -11,230 +11,230 @@
 block discarded – undo
11 11
  */
12 12
 class EEH_Qtip_Loader extends EEH_Base
13 13
 {
14
-    /**
15
-     * EEH_Qtip_Loader Object
16
-     * @var EEH_Qtip_Loader
17
-     * @access private
18
-     */
19
-    private static $_instance = null;
20
-
21
-    /**
22
-     * array of qtip config objects
23
-     * @var EE_Qtip_Config[]
24
-     */
25
-    private $_qtips = array();
26
-
27
-
28
-
29
-    /**
30
-     *@singleton method used to instantiate class object
31
-     *@access public
32
-     *@return EEH_Qtip_Loader instance
33
-     */
34
-    public static function instance()
35
-    {
36
-        // check if class object is instantiated
37
-        if (self::$_instance === null  or ! is_object(self::$_instance) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) {
38
-            self::$_instance = new self();
39
-        }
40
-        return self::$_instance;
41
-    }
42
-
43
-
44
-
45
-    /**
46
-     *private constructor to prevent direct creation
47
-     * @Constructor
48
-     * @access private
49
-     * @return \EEH_Qtip_Loader
50
-     */
51
-    private function __construct()
52
-    {
53
-        // let's just make sure this is instantiated in the right place.
54
-        if (did_action('wp_print_styles') || did_action('admin_head')) {
55
-            EE_Error::doing_it_wrong('EEH_Qtip_Loader', esc_html__('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1');
56
-        }
57
-    }
58
-
59
-
60
-    /**
61
-     * Call this from wp_enqueue_scripts or admin_enqueue_scripts to setup and enqueue the qtip library
62
-     *
63
-     * @access public
64
-     * @return void
65
-     */
66
-    public function register_and_enqueue()
67
-    {
68
-        $qtips_js = !defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.js' : EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.js';
69
-        $qtip_map = EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.map';
70
-        $qtipcss = !defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.css' : EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.css';
71
-
72
-        wp_register_script('qtip-map', $qtip_map, array(), '3', true);
73
-        wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', true);
74
-        wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, true);
75
-
76
-        wp_register_style('qtip-css', $qtipcss, array(), '2.2');
77
-
78
-        // k now let's see if there are any registered qtips.  If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!)
79
-        if (!empty($this->_qtips)) {
80
-            wp_enqueue_script('ee-qtip-helper');
81
-            wp_enqueue_style('qtip-css');
82
-            $qtips = array();
83
-            foreach ($this->_qtips as $qtip) {
84
-                $qts = $qtip->get_tips();
85
-                foreach ($qts as $qt) {
86
-                    if (! $qt instanceof EE_Qtip) {
87
-                        continue;
88
-                    }
89
-                    $qtips[] = array(
90
-                        'content_id' => $qt->content_id,
91
-                        'options' => $qt->options,
92
-                        'target' => $qt->target,
93
-                        );
94
-                }
95
-            }
96
-            if (!empty($qtips)) {
97
-                wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ));
98
-            }
99
-        } else {
100
-            // qtips has been requested without any registration (so assuming its just directly used in the admin).
101
-            wp_enqueue_script('qtip');
102
-            wp_enqueue_style('qtip-css');
103
-        }
104
-    }
105
-
106
-
107
-
108
-    /**
109
-     * This simply registers the given qtip config and:
110
-     * - adds it to the $_qtips property array.
111
-     * - sets up the content containers for all qtips in the config,
112
-     * - registers and enqueues the qtip scripts and styles.
113
-     *
114
-     * @access public
115
-     * @param  array  $paths      Array of paths to check for the EE_Qtip class. If present we check these path(s) first.  If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded.
116
-     * @param  string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips]
117
-     * @return void
118
-     */
119
-    public function register($configname, $paths = array())
120
-    {
121
-
122
-        // let's just make sure this is instantiated in the right place.
123
-        if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
124
-            EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', esc_html__('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1');
125
-        }
126
-
127
-        $configname = (array) $configname; // typecast to array
128
-        foreach ($configname as $config) {
129
-            $this->_register($config, $paths);
130
-        }
131
-
132
-        // hook into appropriate footer
133
-        $footer_action = is_admin() ? 'admin_footer' : 'wp_footer';
134
-        add_action($footer_action, array($this, 'setup_qtip'), 10);
135
-
136
-        // make sure we "turn on" qtip js.
137
-        add_filter('FHEE_load_qtip', '__return_true');
138
-    }
139
-
140
-
141
-
142
-    /**
143
-     * private utility for registering and setting up qtip config objects
144
-     *
145
-     * @access private
146
-     * @param  string $config the short name of the class (will be used to generate the expected classname)
147
-     * @param  array  $paths  array of paths to check (or if empty we check core/libraries/qtips or assume its loaded)
148
-     * @throws EE_Error
149
-     * @return void
150
-     */
151
-    private function _register($config, $paths)
152
-    {
153
-        // before doing anything we have to make sure that EE_Qtip_Config parent is required.
154
-        EE_Registry::instance()->load_lib('Qtip_Config', array(), true);
155
-
156
-        if (!empty($paths)) {
157
-            $paths = (array) $paths;
158
-            foreach ($paths as $path) {
159
-                $path = $path . $config . '.lib.php';
160
-                if (!is_readable($path)) {
161
-                    continue;
162
-                } else {
163
-                    require_once $path;
164
-                }
165
-            }
166
-        }
167
-
168
-        // does class exist at this point?  If it does then let's instantiate.  If it doesn't then let's continue with other paths.
169
-        if (!class_exists($config)) {
170
-            $path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php';
171
-            if (!is_readable($path)) {
172
-                throw new EE_Error(sprintf(esc_html__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable.  Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config));
173
-            } else {
174
-                require_once $path;
175
-            }
176
-        }
177
-
178
-        // now we attempt a class_exists one more time.
179
-        if (!class_exists($config)) {
180
-            throw new EE_Error(sprintf(esc_html__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config));
181
-        }
182
-
183
-        // made it HERE?  FINALLY, let's get things setup.
184
-        $a = new ReflectionClass($config);
185
-        $qtip = $a->newInstance();
186
-
187
-        // verify that $qtip is a valid object
188
-        if (! $qtip instanceof EE_Qtip_Config) {
189
-            throw new EE_Error(sprintf(esc_html__('The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>'));
190
-        }
191
-
192
-        $this->_qtips[] = $a->newInstance();
193
-    }
194
-
195
-
196
-
197
-    /**
198
-     * This takes care of generating the qtip content containers.
199
-     * Output gets put in the appropriate page footer (depending on context (either admin_footer or wp_footer) )
200
-     *
201
-     * @access public
202
-     * @return void
203
-     */
204
-    public function setup_qtip()
205
-    {
206
-        if (empty($this->_qtips)) {
207
-            return; // no qtips!
208
-        }
209
-
210
-        $content = array();
211
-
212
-        foreach ($this->_qtips as $qtip) {
213
-            $content[] = $this->_generate_content_container($qtip);
214
-        }
215
-
216
-        echo implode('<br />', $content);
217
-    }
218
-
219
-
220
-    /**
221
-     * Generates a content container from a given EE_Qtip_Config object.
222
-     *
223
-     * @param  EE_Qtip_Config $qtip
224
-     * @return string  (html content container for qtip);
225
-     */
226
-    private function _generate_content_container($qtip)
227
-    {
228
-        $qts = $qtip->get_tips();
229
-        $content = array();
230
-        foreach ($qts as $qt) {
231
-            if (! $qt instanceof EE_Qtip) {
232
-                continue;
233
-            }
234
-            $content[] = '<div class="ee-qtip-helper-content hidden" id="' . esc_attr($qt->content_id) . '">' .
235
-                         $qt->content . '</div>';
236
-        }
237
-
238
-        return implode('<br />', $content);
239
-    }
14
+	/**
15
+	 * EEH_Qtip_Loader Object
16
+	 * @var EEH_Qtip_Loader
17
+	 * @access private
18
+	 */
19
+	private static $_instance = null;
20
+
21
+	/**
22
+	 * array of qtip config objects
23
+	 * @var EE_Qtip_Config[]
24
+	 */
25
+	private $_qtips = array();
26
+
27
+
28
+
29
+	/**
30
+	 *@singleton method used to instantiate class object
31
+	 *@access public
32
+	 *@return EEH_Qtip_Loader instance
33
+	 */
34
+	public static function instance()
35
+	{
36
+		// check if class object is instantiated
37
+		if (self::$_instance === null  or ! is_object(self::$_instance) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) {
38
+			self::$_instance = new self();
39
+		}
40
+		return self::$_instance;
41
+	}
42
+
43
+
44
+
45
+	/**
46
+	 *private constructor to prevent direct creation
47
+	 * @Constructor
48
+	 * @access private
49
+	 * @return \EEH_Qtip_Loader
50
+	 */
51
+	private function __construct()
52
+	{
53
+		// let's just make sure this is instantiated in the right place.
54
+		if (did_action('wp_print_styles') || did_action('admin_head')) {
55
+			EE_Error::doing_it_wrong('EEH_Qtip_Loader', esc_html__('This helper must be instantiated before or within a callback for the WordPress wp_enqueue_scripts hook action hook.', 'event_espresso'), '4.1');
56
+		}
57
+	}
58
+
59
+
60
+	/**
61
+	 * Call this from wp_enqueue_scripts or admin_enqueue_scripts to setup and enqueue the qtip library
62
+	 *
63
+	 * @access public
64
+	 * @return void
65
+	 */
66
+	public function register_and_enqueue()
67
+	{
68
+		$qtips_js = !defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.js' : EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.js';
69
+		$qtip_map = EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.map';
70
+		$qtipcss = !defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.css' : EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.css';
71
+
72
+		wp_register_script('qtip-map', $qtip_map, array(), '3', true);
73
+		wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', true);
74
+		wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, true);
75
+
76
+		wp_register_style('qtip-css', $qtipcss, array(), '2.2');
77
+
78
+		// k now let's see if there are any registered qtips.  If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!)
79
+		if (!empty($this->_qtips)) {
80
+			wp_enqueue_script('ee-qtip-helper');
81
+			wp_enqueue_style('qtip-css');
82
+			$qtips = array();
83
+			foreach ($this->_qtips as $qtip) {
84
+				$qts = $qtip->get_tips();
85
+				foreach ($qts as $qt) {
86
+					if (! $qt instanceof EE_Qtip) {
87
+						continue;
88
+					}
89
+					$qtips[] = array(
90
+						'content_id' => $qt->content_id,
91
+						'options' => $qt->options,
92
+						'target' => $qt->target,
93
+						);
94
+				}
95
+			}
96
+			if (!empty($qtips)) {
97
+				wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ));
98
+			}
99
+		} else {
100
+			// qtips has been requested without any registration (so assuming its just directly used in the admin).
101
+			wp_enqueue_script('qtip');
102
+			wp_enqueue_style('qtip-css');
103
+		}
104
+	}
105
+
106
+
107
+
108
+	/**
109
+	 * This simply registers the given qtip config and:
110
+	 * - adds it to the $_qtips property array.
111
+	 * - sets up the content containers for all qtips in the config,
112
+	 * - registers and enqueues the qtip scripts and styles.
113
+	 *
114
+	 * @access public
115
+	 * @param  array  $paths      Array of paths to check for the EE_Qtip class. If present we check these path(s) first.  If not present (empty array), then it's assumed it's either in core/libraries/qtips OR the file is already loaded.
116
+	 * @param  string|array $configname name of the Qtip class (full class name is expected and will be used for looking for file, Qtip config classes must extend EE_Qtip_Config) [if this is an array, then we loop through the array to instantiate and setup the qtips]
117
+	 * @return void
118
+	 */
119
+	public function register($configname, $paths = array())
120
+	{
121
+
122
+		// let's just make sure this is instantiated in the right place.
123
+		if (did_action('wp_enqueue_scripts') || did_action('admin_enqueue_scripts')) {
124
+			EE_Error::doing_it_wrong('EEH_Qtip_Loader->register()', esc_html__('EE_Qtip_Config objects must be registered before wp_enqueue_scripts is called.', 'event_espresso'), '4.1');
125
+		}
126
+
127
+		$configname = (array) $configname; // typecast to array
128
+		foreach ($configname as $config) {
129
+			$this->_register($config, $paths);
130
+		}
131
+
132
+		// hook into appropriate footer
133
+		$footer_action = is_admin() ? 'admin_footer' : 'wp_footer';
134
+		add_action($footer_action, array($this, 'setup_qtip'), 10);
135
+
136
+		// make sure we "turn on" qtip js.
137
+		add_filter('FHEE_load_qtip', '__return_true');
138
+	}
139
+
140
+
141
+
142
+	/**
143
+	 * private utility for registering and setting up qtip config objects
144
+	 *
145
+	 * @access private
146
+	 * @param  string $config the short name of the class (will be used to generate the expected classname)
147
+	 * @param  array  $paths  array of paths to check (or if empty we check core/libraries/qtips or assume its loaded)
148
+	 * @throws EE_Error
149
+	 * @return void
150
+	 */
151
+	private function _register($config, $paths)
152
+	{
153
+		// before doing anything we have to make sure that EE_Qtip_Config parent is required.
154
+		EE_Registry::instance()->load_lib('Qtip_Config', array(), true);
155
+
156
+		if (!empty($paths)) {
157
+			$paths = (array) $paths;
158
+			foreach ($paths as $path) {
159
+				$path = $path . $config . '.lib.php';
160
+				if (!is_readable($path)) {
161
+					continue;
162
+				} else {
163
+					require_once $path;
164
+				}
165
+			}
166
+		}
167
+
168
+		// does class exist at this point?  If it does then let's instantiate.  If it doesn't then let's continue with other paths.
169
+		if (!class_exists($config)) {
170
+			$path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php';
171
+			if (!is_readable($path)) {
172
+				throw new EE_Error(sprintf(esc_html__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable.  Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config));
173
+			} else {
174
+				require_once $path;
175
+			}
176
+		}
177
+
178
+		// now we attempt a class_exists one more time.
179
+		if (!class_exists($config)) {
180
+			throw new EE_Error(sprintf(esc_html__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config));
181
+		}
182
+
183
+		// made it HERE?  FINALLY, let's get things setup.
184
+		$a = new ReflectionClass($config);
185
+		$qtip = $a->newInstance();
186
+
187
+		// verify that $qtip is a valid object
188
+		if (! $qtip instanceof EE_Qtip_Config) {
189
+			throw new EE_Error(sprintf(esc_html__('The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>'));
190
+		}
191
+
192
+		$this->_qtips[] = $a->newInstance();
193
+	}
194
+
195
+
196
+
197
+	/**
198
+	 * This takes care of generating the qtip content containers.
199
+	 * Output gets put in the appropriate page footer (depending on context (either admin_footer or wp_footer) )
200
+	 *
201
+	 * @access public
202
+	 * @return void
203
+	 */
204
+	public function setup_qtip()
205
+	{
206
+		if (empty($this->_qtips)) {
207
+			return; // no qtips!
208
+		}
209
+
210
+		$content = array();
211
+
212
+		foreach ($this->_qtips as $qtip) {
213
+			$content[] = $this->_generate_content_container($qtip);
214
+		}
215
+
216
+		echo implode('<br />', $content);
217
+	}
218
+
219
+
220
+	/**
221
+	 * Generates a content container from a given EE_Qtip_Config object.
222
+	 *
223
+	 * @param  EE_Qtip_Config $qtip
224
+	 * @return string  (html content container for qtip);
225
+	 */
226
+	private function _generate_content_container($qtip)
227
+	{
228
+		$qts = $qtip->get_tips();
229
+		$content = array();
230
+		foreach ($qts as $qt) {
231
+			if (! $qt instanceof EE_Qtip) {
232
+				continue;
233
+			}
234
+			$content[] = '<div class="ee-qtip-helper-content hidden" id="' . esc_attr($qt->content_id) . '">' .
235
+						 $qt->content . '</div>';
236
+		}
237
+
238
+		return implode('<br />', $content);
239
+	}
240 240
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     public static function instance()
35 35
     {
36 36
         // check if class object is instantiated
37
-        if (self::$_instance === null  or ! is_object(self::$_instance) or ! ( self::$_instance instanceof EEH_Qtip_Loader )) {
37
+        if (self::$_instance === null or ! is_object(self::$_instance) or ! (self::$_instance instanceof EEH_Qtip_Loader)) {
38 38
             self::$_instance = new self();
39 39
         }
40 40
         return self::$_instance;
@@ -65,25 +65,25 @@  discard block
 block discarded – undo
65 65
      */
66 66
     public function register_and_enqueue()
67 67
     {
68
-        $qtips_js = !defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.js' : EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.js';
69
-        $qtip_map = EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.map';
70
-        $qtipcss = !defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.css' : EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.css';
68
+        $qtips_js = ! defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.js' : EE_GLOBAL_ASSETS_URL.'qtip/jquery.qtip.js';
69
+        $qtip_map = EE_GLOBAL_ASSETS_URL.'qtip/jquery.qtip.min.map';
70
+        $qtipcss = ! defined('SCRIPT_DEBUG') ? EE_GLOBAL_ASSETS_URL . 'qtip/jquery.qtip.min.css' : EE_GLOBAL_ASSETS_URL.'qtip/jquery.qtip.css';
71 71
 
72 72
         wp_register_script('qtip-map', $qtip_map, array(), '3', true);
73 73
         wp_register_script('qtip', $qtips_js, array('jquery'), '3.0.3', true);
74
-        wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS . 'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, true);
74
+        wp_register_script('ee-qtip-helper', EE_HELPERS_ASSETS.'ee-qtip-helper.js', array('qtip', 'jquery-cookie'), EVENT_ESPRESSO_VERSION, true);
75 75
 
76 76
         wp_register_style('qtip-css', $qtipcss, array(), '2.2');
77 77
 
78 78
         // k now let's see if there are any registered qtips.  If there are, then we need to setup the localized script for ee-qtip-helper.js (and enqueue ee-qtip-helper.js of course!)
79
-        if (!empty($this->_qtips)) {
79
+        if ( ! empty($this->_qtips)) {
80 80
             wp_enqueue_script('ee-qtip-helper');
81 81
             wp_enqueue_style('qtip-css');
82 82
             $qtips = array();
83 83
             foreach ($this->_qtips as $qtip) {
84 84
                 $qts = $qtip->get_tips();
85 85
                 foreach ($qts as $qt) {
86
-                    if (! $qt instanceof EE_Qtip) {
86
+                    if ( ! $qt instanceof EE_Qtip) {
87 87
                         continue;
88 88
                     }
89 89
                     $qtips[] = array(
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
                         );
94 94
                 }
95 95
             }
96
-            if (!empty($qtips)) {
97
-                wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array( 'qtips' => $qtips ));
96
+            if ( ! empty($qtips)) {
97
+                wp_localize_script('ee-qtip-helper', 'EE_QTIP_HELPER', array('qtips' => $qtips));
98 98
             }
99 99
         } else {
100 100
             // qtips has been requested without any registration (so assuming its just directly used in the admin).
@@ -153,11 +153,11 @@  discard block
 block discarded – undo
153 153
         // before doing anything we have to make sure that EE_Qtip_Config parent is required.
154 154
         EE_Registry::instance()->load_lib('Qtip_Config', array(), true);
155 155
 
156
-        if (!empty($paths)) {
156
+        if ( ! empty($paths)) {
157 157
             $paths = (array) $paths;
158 158
             foreach ($paths as $path) {
159
-                $path = $path . $config . '.lib.php';
160
-                if (!is_readable($path)) {
159
+                $path = $path.$config.'.lib.php';
160
+                if ( ! is_readable($path)) {
161 161
                     continue;
162 162
                 } else {
163 163
                     require_once $path;
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
         }
167 167
 
168 168
         // does class exist at this point?  If it does then let's instantiate.  If it doesn't then let's continue with other paths.
169
-        if (!class_exists($config)) {
170
-            $path = EE_LIBRARIES . 'qtips/' . $config . '.lib.php';
171
-            if (!is_readable($path)) {
169
+        if ( ! class_exists($config)) {
170
+            $path = EE_LIBRARIES.'qtips/'.$config.'.lib.php';
171
+            if ( ! is_readable($path)) {
172 172
                 throw new EE_Error(sprintf(esc_html__('Unable to load the Qtip Config registered for this page (%s) because none of the file paths attempted are readable.  Please check the spelling of the paths you\'ve used in the registration', 'event_espresso'), $config));
173 173
             } else {
174 174
                 require_once $path;
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         }
177 177
 
178 178
         // now we attempt a class_exists one more time.
179
-        if (!class_exists($config)) {
179
+        if ( ! class_exists($config)) {
180 180
             throw new EE_Error(sprintf(esc_html__('The Qtip_Config class being registered (%s) does not exist, please check the spelling.', 'event_espresso'), $config));
181 181
         }
182 182
 
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
         $qtip = $a->newInstance();
186 186
 
187 187
         // verify that $qtip is a valid object
188
-        if (! $qtip instanceof EE_Qtip_Config) {
188
+        if ( ! $qtip instanceof EE_Qtip_Config) {
189 189
             throw new EE_Error(sprintf(esc_html__('The class given for the Qtip loader (%1$s) is not a child of the %2$sEE_Qtip_Config%3$s class. Please make sure you are extending EE_Qtip_Config.', 'event_espresso'), $config, '<strong>', '</strong>'));
190 190
         }
191 191
 
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
         $qts = $qtip->get_tips();
229 229
         $content = array();
230 230
         foreach ($qts as $qt) {
231
-            if (! $qt instanceof EE_Qtip) {
231
+            if ( ! $qt instanceof EE_Qtip) {
232 232
                 continue;
233 233
             }
234
-            $content[] = '<div class="ee-qtip-helper-content hidden" id="' . esc_attr($qt->content_id) . '">' .
235
-                         $qt->content . '</div>';
234
+            $content[] = '<div class="ee-qtip-helper-content hidden" id="'.esc_attr($qt->content_id).'">'.
235
+                         $qt->content.'</div>';
236 236
         }
237 237
 
238 238
         return implode('<br />', $content);
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -38,103 +38,103 @@
 block discarded – undo
38 38
  * @since           4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.6.2');
65
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                        esc_html__(
79
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                            'event_espresso'
81
-                        ),
82
-                        EE_MIN_PHP_VER_REQUIRED,
83
-                        PHP_VERSION,
84
-                        '<br/>',
85
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+						esc_html__(
79
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+							'event_espresso'
81
+						),
82
+						EE_MIN_PHP_VER_REQUIRED,
83
+						PHP_VERSION,
84
+						'<br/>',
85
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
-        /**
98
-         * espresso_version
99
-         * Returns the plugin version
100
-         *
101
-         * @return string
102
-         */
103
-        function espresso_version()
104
-        {
105
-            return apply_filters('FHEE__espresso__espresso_version', '4.10.39.rc.013');
106
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
97
+		/**
98
+		 * espresso_version
99
+		 * Returns the plugin version
100
+		 *
101
+		 * @return string
102
+		 */
103
+		function espresso_version()
104
+		{
105
+			return apply_filters('FHEE__espresso__espresso_version', '4.10.39.rc.013');
106
+		}
107 107
 
108
-        /**
109
-         * espresso_plugin_activation
110
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
-         */
112
-        function espresso_plugin_activation()
113
-        {
114
-            update_option('ee_espresso_activation', true);
115
-        }
108
+		/**
109
+		 * espresso_plugin_activation
110
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
111
+		 */
112
+		function espresso_plugin_activation()
113
+		{
114
+			update_option('ee_espresso_activation', true);
115
+		}
116 116
 
117
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
117
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
118 118
 
119
-        require_once __DIR__ . '/core/bootstrap_espresso.php';
120
-        bootstrap_espresso();
121
-    }
119
+		require_once __DIR__ . '/core/bootstrap_espresso.php';
120
+		bootstrap_espresso();
121
+	}
122 122
 }
123 123
 if (! function_exists('espresso_deactivate_plugin')) {
124
-    /**
125
-     *    deactivate_plugin
126
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
-     *
128
-     * @access public
129
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
-     * @return    void
131
-     */
132
-    function espresso_deactivate_plugin($plugin_basename = '')
133
-    {
134
-        if (! function_exists('deactivate_plugins')) {
135
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
-        }
137
-        unset($_GET['activate'], $_REQUEST['activate']);
138
-        deactivate_plugins($plugin_basename);
139
-    }
124
+	/**
125
+	 *    deactivate_plugin
126
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
127
+	 *
128
+	 * @access public
129
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
130
+	 * @return    void
131
+	 */
132
+	function espresso_deactivate_plugin($plugin_basename = '')
133
+	{
134
+		if (! function_exists('deactivate_plugins')) {
135
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+		}
137
+		unset($_GET['activate'], $_REQUEST['activate']);
138
+		deactivate_plugins($plugin_basename);
139
+	}
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.
core/services/licensing/LicenseService.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -14,94 +14,94 @@
 block discarded – undo
14 14
  */
15 15
 class LicenseService
16 16
 {
17
-    /**
18
-     * @var Config
19
-     */
20
-    private $config;
21
-
22
-
23
-    /**
24
-     * @var Stats
25
-     */
26
-    private $stats_collection;
27
-
28
-    public function __construct(Stats $stats_collection, Config $config)
29
-    {
30
-        $this->config = $config;
31
-        $this->stats_collection = $stats_collection;
32
-        $this->loadPueClient();
33
-    }
34
-
35
-    private function loadPueClient()
36
-    {
37
-        // PUE Auto Upgrades stuff
38
-        if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
39
-            require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
40
-
41
-            // $options needs to be an array with the included keys as listed.
42
-            $options = array(
43
-                // 'optionName' => '', //(optional) - used as the reference for saving update information in the
44
-                // clients options table.  Will be automatically set if left blank.
45
-                'apikey'                => $this->config->siteLicenseKey(),
46
-                // (required), you will need to obtain the apikey that the client gets from your site and
47
-                // then saves in their sites options table (see 'getting an api-key' below)
48
-                'lang_domain'           => $this->config->i18nDomain(),
49
-                // (optional) - put here whatever reference you are using for the localization of your plugin (if it's
50
-                // localized).  That way strings in this file will be included in the translation for your plugin.
51
-                'checkPeriod'           => $this->config->checkPeriod(),
52
-                // (optional) - use this parameter to indicate how often you want the client's install to ping your
53
-                // server for update checks.  The integer indicates hours.  If you don't include this parameter it will
54
-                // default to 12 hours.
55
-                'option_key'            => $this->config->optionKey(),
56
-                // this is what is used to reference the api_key in your plugin options.  PUE uses this to trigger
57
-                // updating your information message whenever this option_key is modified.
58
-                'options_page_slug'     => $this->config->optionsPageSlug(),
59
-                'plugin_basename'       => EE_PLUGIN_BASENAME,
60
-                'use_wp_update'         => true,
61
-                // if TRUE then you want FREE versions of the plugin to be updated from WP
62
-                'extra_stats'           => $this->stats_collection->statsCallback(),
63
-                'turn_on_notices_saved' => true,
64
-            );
65
-            // initiate the class and start the plugin update engine!
66
-            new \PluginUpdateEngineChecker(
67
-                $this->config->hostServerUrl(),
68
-                $this->config->pluginSlug(),
69
-                $options
70
-            );
71
-        }
72
-    }
73
-
74
-
75
-    /**
76
-     * This is a handy helper method for retrieving whether there is an update available for the given plugin.
77
-     *
78
-     * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
79
-     *                          identify plugins. Defaults to core update
80
-     * @return boolean           True if update available, false if not.
81
-     */
82
-    public static function isUpdateAvailable($basename = '')
83
-    {
84
-        $basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME;
85
-
86
-        $update = false;
87
-
88
-        // should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
89
-        $folder = '/' . dirname($basename);
90
-
91
-        $plugins = get_plugins($folder);
92
-        $current = get_site_transient('update_plugins');
93
-
94
-        foreach ((array) $plugins as $plugin_file => $plugin_data) {
95
-            if (isset($current->response['plugin_file'])) {
96
-                $update = true;
97
-            }
98
-        }
99
-
100
-        // it's possible that there is an update but an invalid site-license-key is in use
101
-        if (get_site_option('pue_json_error_' . $basename)) {
102
-            $update = true;
103
-        }
104
-
105
-        return $update;
106
-    }
17
+	/**
18
+	 * @var Config
19
+	 */
20
+	private $config;
21
+
22
+
23
+	/**
24
+	 * @var Stats
25
+	 */
26
+	private $stats_collection;
27
+
28
+	public function __construct(Stats $stats_collection, Config $config)
29
+	{
30
+		$this->config = $config;
31
+		$this->stats_collection = $stats_collection;
32
+		$this->loadPueClient();
33
+	}
34
+
35
+	private function loadPueClient()
36
+	{
37
+		// PUE Auto Upgrades stuff
38
+		if (is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) { // include the file
39
+			require_once(EE_THIRD_PARTY . 'pue/pue-client.php');
40
+
41
+			// $options needs to be an array with the included keys as listed.
42
+			$options = array(
43
+				// 'optionName' => '', //(optional) - used as the reference for saving update information in the
44
+				// clients options table.  Will be automatically set if left blank.
45
+				'apikey'                => $this->config->siteLicenseKey(),
46
+				// (required), you will need to obtain the apikey that the client gets from your site and
47
+				// then saves in their sites options table (see 'getting an api-key' below)
48
+				'lang_domain'           => $this->config->i18nDomain(),
49
+				// (optional) - put here whatever reference you are using for the localization of your plugin (if it's
50
+				// localized).  That way strings in this file will be included in the translation for your plugin.
51
+				'checkPeriod'           => $this->config->checkPeriod(),
52
+				// (optional) - use this parameter to indicate how often you want the client's install to ping your
53
+				// server for update checks.  The integer indicates hours.  If you don't include this parameter it will
54
+				// default to 12 hours.
55
+				'option_key'            => $this->config->optionKey(),
56
+				// this is what is used to reference the api_key in your plugin options.  PUE uses this to trigger
57
+				// updating your information message whenever this option_key is modified.
58
+				'options_page_slug'     => $this->config->optionsPageSlug(),
59
+				'plugin_basename'       => EE_PLUGIN_BASENAME,
60
+				'use_wp_update'         => true,
61
+				// if TRUE then you want FREE versions of the plugin to be updated from WP
62
+				'extra_stats'           => $this->stats_collection->statsCallback(),
63
+				'turn_on_notices_saved' => true,
64
+			);
65
+			// initiate the class and start the plugin update engine!
66
+			new \PluginUpdateEngineChecker(
67
+				$this->config->hostServerUrl(),
68
+				$this->config->pluginSlug(),
69
+				$options
70
+			);
71
+		}
72
+	}
73
+
74
+
75
+	/**
76
+	 * This is a handy helper method for retrieving whether there is an update available for the given plugin.
77
+	 *
78
+	 * @param  string $basename Use the equivalent result from plugin_basename() for this param as WP uses that to
79
+	 *                          identify plugins. Defaults to core update
80
+	 * @return boolean           True if update available, false if not.
81
+	 */
82
+	public static function isUpdateAvailable($basename = '')
83
+	{
84
+		$basename = ! empty($basename) ? $basename : EE_PLUGIN_BASENAME;
85
+
86
+		$update = false;
87
+
88
+		// should take "event-espresso-core/espresso.php" and change to "/event-espresso-core"
89
+		$folder = '/' . dirname($basename);
90
+
91
+		$plugins = get_plugins($folder);
92
+		$current = get_site_transient('update_plugins');
93
+
94
+		foreach ((array) $plugins as $plugin_file => $plugin_data) {
95
+			if (isset($current->response['plugin_file'])) {
96
+				$update = true;
97
+			}
98
+		}
99
+
100
+		// it's possible that there is an update but an invalid site-license-key is in use
101
+		if (get_site_option('pue_json_error_' . $basename)) {
102
+			$update = true;
103
+		}
104
+
105
+		return $update;
106
+	}
107 107
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Addon.lib.php 3 patches
Indentation   +1253 added lines, -1253 removed lines patch added patch discarded remove patch
@@ -22,1257 +22,1257 @@
 block discarded – undo
22 22
  */
23 23
 class EE_Register_Addon implements EEI_Plugin_API
24 24
 {
25
-    /**
26
-     * possibly truncated version of the EE core version string
27
-     *
28
-     * @var string
29
-     */
30
-    protected static $_core_version = '';
31
-
32
-    /**
33
-     * Holds values for registered addons
34
-     *
35
-     * @var array
36
-     */
37
-    protected static $_settings = array();
38
-
39
-    /**
40
-     * @var  array $_incompatible_addons keys are addon SLUGS
41
-     * (first argument passed to EE_Register_Addon::register()), keys are
42
-     * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004).
43
-     * Generally this should be used sparingly, as we don't want to muddle up
44
-     * EE core with knowledge of ALL the addons out there.
45
-     * If you want NO versions of an addon to run with a certain version of core,
46
-     * it's usually best to define the addon's "min_core_version" as part of its call
47
-     * to EE_Register_Addon::register(), rather than using this array with a super high value for its
48
-     * minimum plugin version.
49
-     * @access    protected
50
-     */
51
-    protected static $_incompatible_addons = array(
52
-        'Multi_Event_Registration' => '2.0.11.rc.002',
53
-        'Promotions'               => '1.0.0.rc.084',
54
-    );
55
-
56
-
57
-    /**
58
-     * We should always be comparing core to a version like '4.3.0.rc.000',
59
-     * not just '4.3.0'.
60
-     * So if the addon developer doesn't provide that full version string,
61
-     * fill in the blanks for them
62
-     *
63
-     * @param string $min_core_version
64
-     * @return string always like '4.3.0.rc.000'
65
-     */
66
-    protected static function _effective_version($min_core_version)
67
-    {
68
-        // versions: 4 . 3 . 1 . p . 123
69
-        // offsets:    0 . 1 . 2 . 3 . 4
70
-        $version_parts = explode('.', $min_core_version);
71
-        // check they specified the micro version (after 2nd period)
72
-        if (! isset($version_parts[2])) {
73
-            $version_parts[2] = '0';
74
-        }
75
-        // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
76
-        // soon we can assume that's 'rc', but this current version is 'alpha'
77
-        if (! isset($version_parts[3])) {
78
-            $version_parts[3] = 'dev';
79
-        }
80
-        if (! isset($version_parts[4])) {
81
-            $version_parts[4] = '000';
82
-        }
83
-        return implode('.', $version_parts);
84
-    }
85
-
86
-
87
-    /**
88
-     * Returns whether or not the min core version requirement of the addon is met
89
-     *
90
-     * @param string $min_core_version    the minimum core version required by the addon
91
-     * @param string $actual_core_version the actual core version, optional
92
-     * @return boolean
93
-     */
94
-    public static function _meets_min_core_version_requirement(
95
-        $min_core_version,
96
-        $actual_core_version = EVENT_ESPRESSO_VERSION
97
-    ) {
98
-        return version_compare(
99
-            self::_effective_version($actual_core_version),
100
-            self::_effective_version($min_core_version),
101
-            '>='
102
-        );
103
-    }
104
-
105
-
106
-    /**
107
-     * Method for registering new EE_Addons.
108
-     * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
109
-     * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
110
-     * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
111
-     * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
112
-     * 'activate_plugin', it registers the addon still, but its components are not registered
113
-     * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
114
-     * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
115
-     * (so that we can detect that the addon has activated on the subsequent request)
116
-     *
117
-     * @since    4.3.0
118
-     * @param string                  $addon_name                       [Required] the EE_Addon's name.
119
-     * @param  array                  $setup_args                       {
120
-     *                                                                  An array of arguments provided for registering
121
-     *                                                                  the message type.
122
-     * @type  string                  $class_name                       the addon's main file name.
123
-     *                                                                  If left blank, generated from the addon name,
124
-     *                                                                  changes something like "calendar" to
125
-     *                                                                  "EE_Calendar"
126
-     * @type string                   $min_core_version                 the minimum version of EE Core that the
127
-     *                                                                  addon will work with. eg "4.8.1.rc.084"
128
-     * @type string                   $version                          the "software" version for the addon. eg
129
-     *                                                                  "1.0.0.p" for a first stable release, or
130
-     *                                                                  "1.0.0.rc.043" for a version in progress
131
-     * @type string                   $main_file_path                   the full server path to the main file
132
-     *                                                                  loaded directly by WP
133
-     * @type DomainInterface $domain                                    child class of
134
-     *                                                                  EventEspresso\core\domain\DomainBase
135
-     * @type string                   $domain_fqcn                      Fully Qualified Class Name
136
-     *                                                                  for the addon's Domain class
137
-     *                                                                  (see EventEspresso\core\domain\Domain)
138
-     * @type string                   $admin_path                       full server path to the folder where the
139
-     *                                                                  addon\'s admin files reside
140
-     * @type string                   $admin_callback                   a method to be called when the EE Admin is
141
-     *                                                                  first invoked, can be used for hooking into
142
-     *                                                                  any admin page
143
-     * @type string                   $config_section                   the section name for this addon's
144
-     *                                                                  configuration settings section
145
-     *                                                                  (defaults to "addons")
146
-     * @type string                   $config_class                     the class name for this addon's
147
-     *                                                                  configuration settings object
148
-     * @type string                   $config_name                      the class name for this addon's
149
-     *                                                                  configuration settings object
150
-     * @type string                   $autoloader_paths                 [Required] an array of class names and the full
151
-     *                                                                  server paths to those files.
152
-     * @type string                   $autoloader_folders               an array of  "full server paths" for any
153
-     *                                                                  folders containing classes that might be
154
-     *                                                                  invoked by the addon
155
-     * @type string                   $dms_paths                        [Required] an array of full server paths to
156
-     *                                                                  folders that contain data migration scripts.
157
-     *                                                                  The key should be the EE_Addon class name that
158
-     *                                                                  this set of data migration scripts belongs to.
159
-     *                                                                  If the EE_Addon class is namespaced, then this
160
-     *                                                                  needs to be the Fully Qualified Class Name
161
-     * @type string                   $module_paths                     an array of full server paths to any
162
-     *                                                                  EED_Modules used by the addon
163
-     * @type string                   $shortcode_paths                  an array of full server paths to folders
164
-     *                                                                  that contain EES_Shortcodes
165
-     * @type string                   $widget_paths                     an array of full server paths to folders
166
-     *                                                                  that contain WP_Widgets
167
-     * @type string                   $pue_options
168
-     * @type array                    $capabilities                     an array indexed by role name
169
-     *                                                                  (i.e administrator,author ) and the values
170
-     *                                                                  are an array of caps to add to the role.
171
-     *                                                                  'administrator' => array(
172
-     *                                                                  'read_addon',
173
-     *                                                                  'edit_addon',
174
-     *                                                                  etc.
175
-     *                                                                  ).
176
-     * @type EE_Meta_Capability_Map[] $capability_maps                  an array of EE_Meta_Capability_Map object
177
-     *                                                                  for any addons that need to register any
178
-     *                                                                  special meta mapped capabilities.  Should
179
-     *                                                                  be indexed where the key is the
180
-     *                                                                  EE_Meta_Capability_Map class name and the
181
-     *                                                                  values are the arguments sent to the class.
182
-     * @type array                    $model_paths                      array of folders containing DB models
183
-     * @see      EE_Register_Model
184
-     * @type array                    $class_paths                      array of folders containing DB classes
185
-     * @see      EE_Register_Model
186
-     * @type array                    $model_extension_paths            array of folders containing DB model
187
-     *                                                                  extensions
188
-     * @see      EE_Register_Model_Extension
189
-     * @type array                    $class_extension_paths            array of folders containing DB class
190
-     *                                                                  extensions
191
-     * @see      EE_Register_Model_Extension
192
-     * @type array message_types {
193
-     *                                                                  An array of message types with the key as
194
-     *                                                                  the message type name and the values as
195
-     *                                                                  below:
196
-     * @type string                   $mtfilename                       [Required] The filename of the message type
197
-     *                                                                  being registered. This will be the main
198
-     *                                                                  EE_{Message Type Name}_message_type class.
199
-     *                                                                  for example:
200
-     *                                                                  EE_Declined_Registration_message_type.class.php
201
-     * @type array                    $autoloadpaths                    [Required] An array of paths to add to the
202
-     *                                                                  messages autoloader for the new message type.
203
-     * @type array                    $messengers_to_activate_with      An array of messengers that this message
204
-     *                                                                  type should activate with. Each value in
205
-     *                                                                  the
206
-     *                                                                  array
207
-     *                                                                  should match the name property of a
208
-     *                                                                  EE_messenger. Optional.
209
-     * @type array                    $messengers_to_validate_with      An array of messengers that this message
210
-     *                                                                  type should validate with. Each value in
211
-     *                                                                  the
212
-     *                                                                  array
213
-     *                                                                  should match the name property of an
214
-     *                                                                  EE_messenger.
215
-     *                                                                  Optional.
216
-     *                                                                  }
217
-     * @type array                    $custom_post_types
218
-     * @type array                    $custom_taxonomies
219
-     * @type array                    $payment_method_paths             each element is the folder containing the
220
-     *                                                                  EE_PMT_Base child class
221
-     *                                                                  (eg,
222
-     *                                                                  '/wp-content/plugins/my_plugin/Payomatic/'
223
-     *                                                                  which contains the files
224
-     *                                                                  EE_PMT_Payomatic.pm.php)
225
-     * @type array                    $default_terms
226
-     * @type array                    $namespace                        {
227
-     *                                                                  An array with two items for registering the
228
-     *                                                                  addon's namespace. (If, for some reason, you
229
-     *                                                                  require additional namespaces,
230
-     *                                                                  use
231
-     *                                                                  EventEspresso\core\Psr4Autoloader::addNamespace()
232
-     *                                                                  directly)
233
-     * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
234
-     * @type string                   $FQNS                             the namespace prefix
235
-     * @type string                   $DIR                              a base directory for class files in the
236
-     *                                                                  namespace.
237
-     *                                                                  }
238
-     *                                                                  }
239
-     * @type string                   $privacy_policies                 FQNSs (namespaces, each of which contains only
240
-     *                                                                  privacy policy classes) or FQCNs (specific
241
-     *                                                                  classnames of privacy policy classes)
242
-     * @type string                   $personal_data_exporters          FQNSs (namespaces, each of which contains only
243
-     *                                                                  privacy policy classes) or FQCNs (specific
244
-     *                                                                  classnames of privacy policy classes)
245
-     * @type string                   $personal_data_erasers            FQNSs (namespaces, each of which contains only
246
-     *                                                                  privacy policy classes) or FQCNs (specific
247
-     *                                                                  classnames of privacy policy classes)
248
-     * @return void
249
-     * @throws DomainException
250
-     * @throws EE_Error
251
-     * @throws InvalidArgumentException
252
-     * @throws InvalidDataTypeException
253
-     * @throws InvalidInterfaceException
254
-     */
255
-    public static function register($addon_name = '', array $setup_args = array())
256
-    {
257
-        // required fields MUST be present, so let's make sure they are.
258
-        EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
259
-        // get class name for addon
260
-        $class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
261
-        // setup $_settings array from incoming values.
262
-        $addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
263
-        // setup PUE
264
-        EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
265
-        // does this addon work with this version of core or WordPress ?
266
-        // does this addon work with this version of core or WordPress ?
267
-        if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
268
-            return;
269
-        }
270
-        // register namespaces
271
-        EE_Register_Addon::_setup_namespaces($addon_settings);
272
-        // check if this is an activation request
273
-        if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
274
-            // dont bother setting up the rest of the addon atm
275
-            return;
276
-        }
277
-        // we need cars
278
-        EE_Register_Addon::_setup_autoloaders($addon_name);
279
-        // register new models and extensions
280
-        EE_Register_Addon::_register_models_and_extensions($addon_name);
281
-        // setup DMS
282
-        EE_Register_Addon::_register_data_migration_scripts($addon_name);
283
-        // if config_class is present let's register config.
284
-        EE_Register_Addon::_register_config($addon_name);
285
-        // register admin pages
286
-        EE_Register_Addon::_register_admin_pages($addon_name);
287
-        // add to list of modules to be registered
288
-        EE_Register_Addon::_register_modules($addon_name);
289
-        // add to list of shortcodes to be registered
290
-        EE_Register_Addon::_register_shortcodes($addon_name);
291
-        // add to list of widgets to be registered
292
-        EE_Register_Addon::_register_widgets($addon_name);
293
-        // register capability related stuff.
294
-        EE_Register_Addon::_register_capabilities($addon_name);
295
-        // any message type to register?
296
-        EE_Register_Addon::_register_message_types($addon_name);
297
-        // any custom post type/ custom capabilities or default terms to register
298
-        EE_Register_Addon::_register_custom_post_types($addon_name);
299
-        // and any payment methods
300
-        EE_Register_Addon::_register_payment_methods($addon_name);
301
-        // and privacy policy generators
302
-        EE_Register_Addon::registerPrivacyPolicies($addon_name);
303
-        // and privacy policy generators
304
-        EE_Register_Addon::registerPersonalDataExporters($addon_name);
305
-        // and privacy policy generators
306
-        EE_Register_Addon::registerPersonalDataErasers($addon_name);
307
-        // load and instantiate main addon class
308
-        $addon = EE_Register_Addon::_load_and_init_addon_class($addon_name);
309
-        // delay calling after_registration hook on each addon until after all add-ons have been registered.
310
-        add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999);
311
-    }
312
-
313
-
314
-    /**
315
-     * @param string $addon_name
316
-     * @param array  $setup_args
317
-     * @return void
318
-     * @throws EE_Error
319
-     */
320
-    private static function _verify_parameters($addon_name, array $setup_args)
321
-    {
322
-        // required fields MUST be present, so let's make sure they are.
323
-        if (empty($addon_name) || ! is_array($setup_args)) {
324
-            throw new EE_Error(
325
-                esc_html__(
326
-                    'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.',
327
-                    'event_espresso'
328
-                )
329
-            );
330
-        }
331
-        if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
332
-            throw new EE_Error(
333
-                sprintf(
334
-                    esc_html__(
335
-                        'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s',
336
-                        'event_espresso'
337
-                    ),
338
-                    implode(',', array_keys($setup_args))
339
-                )
340
-            );
341
-        }
342
-        // check that addon has not already been registered with that name
343
-        if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
344
-            throw new EE_Error(
345
-                sprintf(
346
-                    esc_html__(
347
-                        'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
348
-                        'event_espresso'
349
-                    ),
350
-                    $addon_name
351
-                )
352
-            );
353
-        }
354
-    }
355
-
356
-
357
-    /**
358
-     * @param string $addon_name
359
-     * @param array  $setup_args
360
-     * @return string
361
-     */
362
-    private static function _parse_class_name($addon_name, array $setup_args)
363
-    {
364
-        if (empty($setup_args['class_name'])) {
365
-            // generate one by first separating name with spaces
366
-            $class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
367
-            // capitalize, then replace spaces with underscores
368
-            $class_name = str_replace(' ', '_', ucwords($class_name));
369
-        } else {
370
-            $class_name = $setup_args['class_name'];
371
-        }
372
-        // check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
373
-        return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
374
-            ? $class_name
375
-            : 'EE_' . $class_name;
376
-    }
377
-
378
-
379
-    /**
380
-     * @param string $class_name
381
-     * @param array  $setup_args
382
-     * @return array
383
-     */
384
-    private static function _get_addon_settings($class_name, array $setup_args)
385
-    {
386
-        // setup $_settings array from incoming values.
387
-        $addon_settings = array(
388
-            // generated from the addon name, changes something like "calendar" to "EE_Calendar"
389
-            'class_name'            => $class_name,
390
-            // the addon slug for use in URLs, etc
391
-            'plugin_slug'           => isset($setup_args['plugin_slug'])
392
-                ? (string) $setup_args['plugin_slug']
393
-                : '',
394
-            // page slug to be used when generating the "Settings" link on the WP plugin page
395
-            'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
396
-                ? (string) $setup_args['plugin_action_slug']
397
-                : '',
398
-            // the "software" version for the addon
399
-            'version'               => isset($setup_args['version'])
400
-                ? (string) $setup_args['version']
401
-                : '',
402
-            // the minimum version of EE Core that the addon will work with
403
-            'min_core_version'      => isset($setup_args['min_core_version'])
404
-                ? (string) $setup_args['min_core_version']
405
-                : '',
406
-            // the minimum version of WordPress that the addon will work with
407
-            'min_wp_version'        => isset($setup_args['min_wp_version'])
408
-                ? (string) $setup_args['min_wp_version']
409
-                : EE_MIN_WP_VER_REQUIRED,
410
-            // full server path to main file (file loaded directly by WP)
411
-            'main_file_path'        => isset($setup_args['main_file_path'])
412
-                ? (string) $setup_args['main_file_path']
413
-                : '',
414
-            // instance of \EventEspresso\core\domain\DomainInterface
415
-            'domain'                => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface
416
-                ? $setup_args['domain']
417
-                : null,
418
-            // Fully Qualified Class Name for the addon's Domain class
419
-            'domain_fqcn'           => isset($setup_args['domain_fqcn'])
420
-                ? (string) $setup_args['domain_fqcn']
421
-                : '',
422
-            // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
423
-            'admin_path'            => isset($setup_args['admin_path'])
424
-                ? (string) $setup_args['admin_path'] : '',
425
-            // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
426
-            'admin_callback'        => isset($setup_args['admin_callback'])
427
-                ? (string) $setup_args['admin_callback']
428
-                : '',
429
-            // the section name for this addon's configuration settings section (defaults to "addons")
430
-            'config_section'        => isset($setup_args['config_section'])
431
-                ? (string) $setup_args['config_section']
432
-                : 'addons',
433
-            // the class name for this addon's configuration settings object
434
-            'config_class'          => isset($setup_args['config_class'])
435
-                ? (string) $setup_args['config_class'] : '',
436
-            // the name given to the config for this addons' configuration settings object (optional)
437
-            'config_name'           => isset($setup_args['config_name'])
438
-                ? (string) $setup_args['config_name'] : '',
439
-            // an array of "class names" => "full server paths" for any classes that might be invoked by the addon
440
-            'autoloader_paths'      => isset($setup_args['autoloader_paths'])
441
-                ? (array) $setup_args['autoloader_paths']
442
-                : array(),
443
-            // an array of  "full server paths" for any folders containing classes that might be invoked by the addon
444
-            'autoloader_folders'    => isset($setup_args['autoloader_folders'])
445
-                ? (array) $setup_args['autoloader_folders']
446
-                : array(),
447
-            // array of full server paths to any EE_DMS data migration scripts used by the addon.
448
-            // The key should be the EE_Addon class name that this set of data migration scripts belongs to.
449
-            // If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name
450
-            'dms_paths'             => isset($setup_args['dms_paths'])
451
-                ? (array) $setup_args['dms_paths']
452
-                : array(),
453
-            // array of full server paths to any EED_Modules used by the addon
454
-            'module_paths'          => isset($setup_args['module_paths'])
455
-                ? (array) $setup_args['module_paths']
456
-                : array(),
457
-            // array of full server paths to any EES_Shortcodes used by the addon
458
-            'shortcode_paths'       => isset($setup_args['shortcode_paths'])
459
-                ? (array) $setup_args['shortcode_paths']
460
-                : array(),
461
-            'shortcode_fqcns'       => isset($setup_args['shortcode_fqcns'])
462
-                ? (array) $setup_args['shortcode_fqcns']
463
-                : array(),
464
-            // array of full server paths to any WP_Widgets used by the addon
465
-            'widget_paths'          => isset($setup_args['widget_paths'])
466
-                ? (array) $setup_args['widget_paths']
467
-                : array(),
468
-            // array of PUE options used by the addon
469
-            'pue_options'           => isset($setup_args['pue_options'])
470
-                ? (array) $setup_args['pue_options']
471
-                : array(),
472
-            'message_types'         => isset($setup_args['message_types'])
473
-                ? (array) $setup_args['message_types']
474
-                : array(),
475
-            'capabilities'          => isset($setup_args['capabilities'])
476
-                ? (array) $setup_args['capabilities']
477
-                : array(),
478
-            'capability_maps'       => isset($setup_args['capability_maps'])
479
-                ? (array) $setup_args['capability_maps']
480
-                : array(),
481
-            'model_paths'           => isset($setup_args['model_paths'])
482
-                ? (array) $setup_args['model_paths']
483
-                : array(),
484
-            'class_paths'           => isset($setup_args['class_paths'])
485
-                ? (array) $setup_args['class_paths']
486
-                : array(),
487
-            'model_extension_paths' => isset($setup_args['model_extension_paths'])
488
-                ? (array) $setup_args['model_extension_paths']
489
-                : array(),
490
-            'class_extension_paths' => isset($setup_args['class_extension_paths'])
491
-                ? (array) $setup_args['class_extension_paths']
492
-                : array(),
493
-            'custom_post_types'     => isset($setup_args['custom_post_types'])
494
-                ? (array) $setup_args['custom_post_types']
495
-                : array(),
496
-            'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
497
-                ? (array) $setup_args['custom_taxonomies']
498
-                : array(),
499
-            'payment_method_paths'  => isset($setup_args['payment_method_paths'])
500
-                ? (array) $setup_args['payment_method_paths']
501
-                : array(),
502
-            'default_terms'         => isset($setup_args['default_terms'])
503
-                ? (array) $setup_args['default_terms']
504
-                : array(),
505
-            // if not empty, inserts a new table row after this plugin's row on the WP Plugins page
506
-            // that can be used for adding upgrading/marketing info
507
-            'plugins_page_row'      => isset($setup_args['plugins_page_row']) ? $setup_args['plugins_page_row'] : '',
508
-            'namespace'             => isset(
509
-                $setup_args['namespace']['FQNS'],
510
-                $setup_args['namespace']['DIR']
511
-            )
512
-                ? (array) $setup_args['namespace']
513
-                : array(),
514
-            'privacy_policies'      => isset($setup_args['privacy_policies'])
515
-                ? (array) $setup_args['privacy_policies']
516
-                : '',
517
-        );
518
-        // if plugin_action_slug is NOT set, but an admin page path IS set,
519
-        // then let's just use the plugin_slug since that will be used for linking to the admin page
520
-        $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
521
-                                                && ! empty($addon_settings['admin_path'])
522
-            ? $addon_settings['plugin_slug']
523
-            : $addon_settings['plugin_action_slug'];
524
-        // full server path to main file (file loaded directly by WP)
525
-        $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
526
-        return $addon_settings;
527
-    }
528
-
529
-
530
-    /**
531
-     * @param string $addon_name
532
-     * @param array  $addon_settings
533
-     * @return boolean
534
-     */
535
-    private static function _addon_is_compatible($addon_name, array $addon_settings)
536
-    {
537
-        global $wp_version;
538
-        $incompatibility_message = '';
539
-        // check whether this addon version is compatible with EE core
540
-        if (
541
-            isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
542
-            && ! self::_meets_min_core_version_requirement(
543
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
544
-                $addon_settings['version']
545
-            )
546
-        ) {
547
-            $incompatibility_message = sprintf(
548
-                esc_html__(
549
-                    '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.',
550
-                    'event_espresso'
551
-                ),
552
-                $addon_name,
553
-                '<br />',
554
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
555
-                '<span style="font-weight: bold; color: #D54E21;">',
556
-                '</span><br />'
557
-            );
558
-        } elseif (
559
-            ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
560
-        ) {
561
-            $incompatibility_message = sprintf(
562
-                esc_html__(
563
-                    '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".',
564
-                    'event_espresso'
565
-                ),
566
-                $addon_name,
567
-                self::_effective_version($addon_settings['min_core_version']),
568
-                self::_effective_version(espresso_version()),
569
-                '<br />',
570
-                '<span style="font-weight: bold; color: #D54E21;">',
571
-                '</span><br />'
572
-            );
573
-        } elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
574
-            $incompatibility_message = sprintf(
575
-                esc_html__(
576
-                    '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.',
577
-                    'event_espresso'
578
-                ),
579
-                $addon_name,
580
-                $addon_settings['min_wp_version'],
581
-                '<br />',
582
-                '<span style="font-weight: bold; color: #D54E21;">',
583
-                '</span><br />'
584
-            );
585
-        }
586
-        if (! empty($incompatibility_message)) {
587
-            // remove 'activate' from the REQUEST
588
-            // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
589
-            /** @var RequestInterface $request */
590
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
591
-            $request->unSetRequestParam('activate', true);
592
-            if (current_user_can('activate_plugins')) {
593
-                // show an error message indicating the plugin didn't activate properly
594
-                EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
595
-            }
596
-            // BAIL FROM THE ADDON REGISTRATION PROCESS
597
-            return false;
598
-        }
599
-        // addon IS compatible
600
-        return true;
601
-    }
602
-
603
-
604
-    /**
605
-     * if plugin update engine is being used for auto-updates,
606
-     * then let's set that up now before going any further so that ALL addons can be updated
607
-     * (not needed if PUE is not being used)
608
-     *
609
-     * @param string $addon_name
610
-     * @param string $class_name
611
-     * @param array  $setup_args
612
-     * @return void
613
-     */
614
-    private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
615
-    {
616
-        if (! empty($setup_args['pue_options'])) {
617
-            self::$_settings[ $addon_name ]['pue_options'] = array(
618
-                'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
619
-                    ? (string) $setup_args['pue_options']['pue_plugin_slug']
620
-                    : 'espresso_' . strtolower($class_name),
621
-                'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
622
-                    ? (string) $setup_args['pue_options']['plugin_basename']
623
-                    : plugin_basename($setup_args['main_file_path']),
624
-                'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
625
-                    ? (string) $setup_args['pue_options']['checkPeriod']
626
-                    : '24',
627
-                'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
628
-                    ? (string) $setup_args['pue_options']['use_wp_update']
629
-                    : false,
630
-            );
631
-            add_action(
632
-                'AHEE__EE_System__brew_espresso__after_pue_init',
633
-                array('EE_Register_Addon', 'load_pue_update')
634
-            );
635
-        }
636
-    }
637
-
638
-
639
-    /**
640
-     * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
641
-     *
642
-     * @param array $addon_settings
643
-     * @return void
644
-     */
645
-    private static function _setup_namespaces(array $addon_settings)
646
-    {
647
-        //
648
-        if (
649
-            isset(
650
-                $addon_settings['namespace']['FQNS'],
651
-                $addon_settings['namespace']['DIR']
652
-            )
653
-        ) {
654
-            EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
655
-                $addon_settings['namespace']['FQNS'],
656
-                $addon_settings['namespace']['DIR']
657
-            );
658
-        }
659
-    }
660
-
661
-
662
-    /**
663
-     * @param string $addon_name
664
-     * @param array  $addon_settings
665
-     * @return bool
666
-     * @throws InvalidArgumentException
667
-     * @throws InvalidDataTypeException
668
-     * @throws InvalidInterfaceException
669
-     */
670
-    private static function _addon_activation($addon_name, array $addon_settings)
671
-    {
672
-        // this is an activation request
673
-        if (did_action('activate_plugin')) {
674
-            // to find if THIS is the addon that was activated, just check if we have already registered it or not
675
-            // (as the newly-activated addon wasn't around the first time addons were registered).
676
-            // Note: the presence of pue_options in the addon registration options will initialize the $_settings
677
-            // property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
678
-            if (
679
-                ! isset(self::$_settings[ $addon_name ])
680
-                || (isset(self::$_settings[ $addon_name ])
681
-                    && ! isset(self::$_settings[ $addon_name ]['class_name'])
682
-                )
683
-            ) {
684
-                self::$_settings[ $addon_name ] = $addon_settings;
685
-                $addon = self::_load_and_init_addon_class($addon_name);
686
-                $addon->set_activation_indicator_option();
687
-                // dont bother setting up the rest of the addon.
688
-                // we know it was just activated and the request will end soon
689
-            }
690
-            return true;
691
-        }
692
-        // make sure this was called in the right place!
693
-        if (
694
-            ! did_action('AHEE__EE_System__load_espresso_addons')
695
-            || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
696
-        ) {
697
-            EE_Error::doing_it_wrong(
698
-                __METHOD__,
699
-                sprintf(
700
-                    esc_html__(
701
-                        'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.',
702
-                        'event_espresso'
703
-                    ),
704
-                    $addon_name
705
-                ),
706
-                '4.3.0'
707
-            );
708
-        }
709
-        // make sure addon settings are set correctly without overwriting anything existing
710
-        if (isset(self::$_settings[ $addon_name ])) {
711
-            self::$_settings[ $addon_name ] += $addon_settings;
712
-        } else {
713
-            self::$_settings[ $addon_name ] = $addon_settings;
714
-        }
715
-        return false;
716
-    }
717
-
718
-
719
-    /**
720
-     * @param string $addon_name
721
-     * @return void
722
-     * @throws EE_Error
723
-     */
724
-    private static function _setup_autoloaders($addon_name)
725
-    {
726
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
727
-            // setup autoloader for single file
728
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
729
-        }
730
-        // setup autoloaders for folders
731
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
732
-            foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
733
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
734
-            }
735
-        }
736
-    }
737
-
738
-
739
-    /**
740
-     * register new models and extensions
741
-     *
742
-     * @param string $addon_name
743
-     * @return void
744
-     * @throws EE_Error
745
-     */
746
-    private static function _register_models_and_extensions($addon_name)
747
-    {
748
-        // register new models
749
-        if (
750
-            ! empty(self::$_settings[ $addon_name ]['model_paths'])
751
-            || ! empty(self::$_settings[ $addon_name ]['class_paths'])
752
-        ) {
753
-            EE_Register_Model::register(
754
-                $addon_name,
755
-                array(
756
-                    'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
757
-                    'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
758
-                )
759
-            );
760
-        }
761
-        // register model extensions
762
-        if (
763
-            ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
764
-            || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
765
-        ) {
766
-            EE_Register_Model_Extensions::register(
767
-                $addon_name,
768
-                array(
769
-                    'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
770
-                    'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
771
-                )
772
-            );
773
-        }
774
-    }
775
-
776
-
777
-    /**
778
-     * @param string $addon_name
779
-     * @return void
780
-     * @throws EE_Error
781
-     */
782
-    private static function _register_data_migration_scripts($addon_name)
783
-    {
784
-        // setup DMS
785
-        if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
786
-            EE_Register_Data_Migration_Scripts::register(
787
-                $addon_name,
788
-                array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
789
-            );
790
-        }
791
-    }
792
-
793
-
794
-    /**
795
-     * @param string $addon_name
796
-     * @return void
797
-     * @throws EE_Error
798
-     */
799
-    private static function _register_config($addon_name)
800
-    {
801
-        // if config_class is present let's register config.
802
-        if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
803
-            EE_Register_Config::register(
804
-                self::$_settings[ $addon_name ]['config_class'],
805
-                array(
806
-                    'config_section' => self::$_settings[ $addon_name ]['config_section'],
807
-                    'config_name'    => self::$_settings[ $addon_name ]['config_name'],
808
-                )
809
-            );
810
-        }
811
-    }
812
-
813
-
814
-    /**
815
-     * @param string $addon_name
816
-     * @return void
817
-     * @throws EE_Error
818
-     */
819
-    private static function _register_admin_pages($addon_name)
820
-    {
821
-        if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
822
-            EE_Register_Admin_Page::register(
823
-                $addon_name,
824
-                array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
825
-            );
826
-        }
827
-    }
828
-
829
-
830
-    /**
831
-     * @param string $addon_name
832
-     * @return void
833
-     * @throws EE_Error
834
-     */
835
-    private static function _register_modules($addon_name)
836
-    {
837
-        if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
838
-            EE_Register_Module::register(
839
-                $addon_name,
840
-                array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
841
-            );
842
-        }
843
-    }
844
-
845
-
846
-    /**
847
-     * @param string $addon_name
848
-     * @return void
849
-     * @throws EE_Error
850
-     */
851
-    private static function _register_shortcodes($addon_name)
852
-    {
853
-        if (
854
-            ! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
855
-            || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
856
-        ) {
857
-            EE_Register_Shortcode::register(
858
-                $addon_name,
859
-                array(
860
-                    'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
861
-                        ? self::$_settings[ $addon_name ]['shortcode_paths'] : array(),
862
-                    'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
863
-                        ? self::$_settings[ $addon_name ]['shortcode_fqcns'] : array(),
864
-                )
865
-            );
866
-        }
867
-    }
868
-
869
-
870
-    /**
871
-     * @param string $addon_name
872
-     * @return void
873
-     * @throws EE_Error
874
-     */
875
-    private static function _register_widgets($addon_name)
876
-    {
877
-        if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
878
-            EE_Register_Widget::register(
879
-                $addon_name,
880
-                array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
881
-            );
882
-        }
883
-    }
884
-
885
-
886
-    /**
887
-     * @param string $addon_name
888
-     * @return void
889
-     * @throws EE_Error
890
-     */
891
-    private static function _register_capabilities($addon_name)
892
-    {
893
-        if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
894
-            EE_Register_Capabilities::register(
895
-                $addon_name,
896
-                array(
897
-                    'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
898
-                    'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
899
-                )
900
-            );
901
-        }
902
-    }
903
-
904
-
905
-    /**
906
-     * @param string $addon_name
907
-     * @return void
908
-     */
909
-    private static function _register_message_types($addon_name)
910
-    {
911
-        if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
912
-            add_action(
913
-                'EE_Brewing_Regular___messages_caf',
914
-                array('EE_Register_Addon', 'register_message_types')
915
-            );
916
-        }
917
-    }
918
-
919
-
920
-    /**
921
-     * @param string $addon_name
922
-     * @return void
923
-     * @throws EE_Error
924
-     */
925
-    private static function _register_custom_post_types($addon_name)
926
-    {
927
-        if (
928
-            ! empty(self::$_settings[ $addon_name ]['custom_post_types'])
929
-            || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
930
-        ) {
931
-            EE_Register_CPT::register(
932
-                $addon_name,
933
-                array(
934
-                    'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
935
-                    'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
936
-                    'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
937
-                )
938
-            );
939
-        }
940
-    }
941
-
942
-
943
-    /**
944
-     * @param string $addon_name
945
-     * @return void
946
-     * @throws InvalidArgumentException
947
-     * @throws InvalidInterfaceException
948
-     * @throws InvalidDataTypeException
949
-     * @throws DomainException
950
-     * @throws EE_Error
951
-     */
952
-    private static function _register_payment_methods($addon_name)
953
-    {
954
-        if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
955
-            EE_Register_Payment_Method::register(
956
-                $addon_name,
957
-                array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
958
-            );
959
-        }
960
-    }
961
-
962
-
963
-    /**
964
-     * @param string $addon_name
965
-     * @return void
966
-     * @throws InvalidArgumentException
967
-     * @throws InvalidInterfaceException
968
-     * @throws InvalidDataTypeException
969
-     * @throws DomainException
970
-     */
971
-    private static function registerPrivacyPolicies($addon_name)
972
-    {
973
-        if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) {
974
-            EE_Register_Privacy_Policy::register(
975
-                $addon_name,
976
-                self::$_settings[ $addon_name ]['privacy_policies']
977
-            );
978
-        }
979
-    }
980
-
981
-
982
-    /**
983
-     * @param string $addon_name
984
-     * @return void
985
-     */
986
-    private static function registerPersonalDataExporters($addon_name)
987
-    {
988
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) {
989
-            EE_Register_Personal_Data_Eraser::register(
990
-                $addon_name,
991
-                self::$_settings[ $addon_name ]['personal_data_exporters']
992
-            );
993
-        }
994
-    }
995
-
996
-
997
-    /**
998
-     * @param string $addon_name
999
-     * @return void
1000
-     */
1001
-    private static function registerPersonalDataErasers($addon_name)
1002
-    {
1003
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) {
1004
-            EE_Register_Personal_Data_Eraser::register(
1005
-                $addon_name,
1006
-                self::$_settings[ $addon_name ]['personal_data_erasers']
1007
-            );
1008
-        }
1009
-    }
1010
-
1011
-
1012
-    /**
1013
-     * Loads and instantiates the EE_Addon class and adds it onto the registry
1014
-     *
1015
-     * @param string $addon_name
1016
-     * @return EE_Addon
1017
-     * @throws InvalidArgumentException
1018
-     * @throws InvalidInterfaceException
1019
-     * @throws InvalidDataTypeException
1020
-     */
1021
-    private static function _load_and_init_addon_class($addon_name)
1022
-    {
1023
-        $addon = LoaderFactory::getLoader()->getShared(
1024
-            self::$_settings[ $addon_name ]['class_name'],
1025
-            array('EE_Registry::create(addon)' => true)
1026
-        );
1027
-        if (! $addon instanceof EE_Addon) {
1028
-            throw new DomainException(
1029
-                sprintf(
1030
-                    esc_html__(
1031
-                        'Failed to instantiate the %1$s class. PLease check that the class exists.',
1032
-                        'event_espresso'
1033
-                    ),
1034
-                    $addon_name
1035
-                )
1036
-            );
1037
-        }
1038
-        // setter inject dep map if required
1039
-        if ($addon->dependencyMap() === null) {
1040
-            $addon->setDependencyMap(LoaderFactory::getLoader()->getShared('EE_Dependency_Map'));
1041
-        }
1042
-        // setter inject domain if required
1043
-        EE_Register_Addon::injectAddonDomain($addon_name, $addon);
1044
-
1045
-        $addon->set_name($addon_name);
1046
-        $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
1047
-        $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
1048
-        $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
1049
-        $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
1050
-        $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
1051
-        $addon->set_version(self::$_settings[ $addon_name ]['version']);
1052
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
1053
-        $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
1054
-        $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
1055
-        $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
1056
-        // setup the add-on's pue_slug if we have one.
1057
-        if (! empty(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug'])) {
1058
-            $addon->setPueSlug(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug']);
1059
-        }
1060
-        // unfortunately this can't be hooked in upon construction,
1061
-        // because we don't have the plugin's mainfile path upon construction.
1062
-        register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
1063
-        // call any additional admin_callback functions during load_admin_controller hook
1064
-        if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1065
-            add_action(
1066
-                'AHEE__EE_System__load_controllers__load_admin_controllers',
1067
-                array($addon, self::$_settings[ $addon_name ]['admin_callback'])
1068
-            );
1069
-        }
1070
-        return $addon;
1071
-    }
1072
-
1073
-
1074
-    /**
1075
-     * @param string   $addon_name
1076
-     * @param EE_Addon $addon
1077
-     * @since   4.10.13.p
1078
-     */
1079
-    private static function injectAddonDomain($addon_name, EE_Addon $addon)
1080
-    {
1081
-        if ($addon instanceof RequiresDomainInterface && $addon->domain() === null) {
1082
-            // using supplied Domain object
1083
-            $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
1084
-                ? self::$_settings[ $addon_name ]['domain']
1085
-                : null;
1086
-            // or construct one using Domain FQCN
1087
-            if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
1088
-                $domain = LoaderFactory::getLoader()->getShared(
1089
-                    self::$_settings[ $addon_name ]['domain_fqcn'],
1090
-                    [
1091
-                        new EventEspresso\core\domain\values\FilePath(
1092
-                            self::$_settings[ $addon_name ]['main_file_path']
1093
-                        ),
1094
-                        EventEspresso\core\domain\values\Version::fromString(
1095
-                            self::$_settings[ $addon_name ]['version']
1096
-                        ),
1097
-                    ]
1098
-                );
1099
-            }
1100
-            if ($domain instanceof DomainInterface) {
1101
-                $addon->setDomain($domain);
1102
-            }
1103
-        }
1104
-    }
1105
-
1106
-
1107
-    /**
1108
-     *    load_pue_update - Update notifications
1109
-     *
1110
-     * @return void
1111
-     * @throws InvalidArgumentException
1112
-     * @throws InvalidDataTypeException
1113
-     * @throws InvalidInterfaceException
1114
-     */
1115
-    public static function load_pue_update()
1116
-    {
1117
-        // PUE client existence
1118
-        if (! is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) return;
1119
-
1120
-        // load PUE client
1121
-        require_once EE_THIRD_PARTY . 'pue/pue-client.php';
1122
-        $license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com';
1123
-        // cycle thru settings
1124
-        foreach (self::$_settings as $settings) {
1125
-            if (empty($settings['pue_options'])) continue;
1126
-
1127
-            // initiate the class and start the plugin update engine!
1128
-            new PluginUpdateEngineChecker(
1129
-                // host file URL
1130
-                $license_server,
1131
-                // plugin slug(s)
1132
-                array(
1133
-                    'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1134
-                    'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1135
-                ),
1136
-                // options
1137
-                array(
1138
-                    'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
1139
-                    'lang_domain'       => 'event_espresso',
1140
-                    'checkPeriod'       => $settings['pue_options']['checkPeriod'],
1141
-                    'option_key'        => 'ee_site_license_key',
1142
-                    'options_page_slug' => 'event_espresso',
1143
-                    'plugin_basename'   => $settings['pue_options']['plugin_basename'],
1144
-                    // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
1145
-                    'use_wp_update'     => $settings['pue_options']['use_wp_update'],
1146
-                )
1147
-            );
1148
-        }
1149
-    }
1150
-
1151
-
1152
-    /**
1153
-     * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
1154
-     *
1155
-     * @since 4.4.0
1156
-     * @return void
1157
-     * @throws EE_Error
1158
-     */
1159
-    public static function register_message_types()
1160
-    {
1161
-        foreach (self::$_settings as $settings) {
1162
-            if (! empty($settings['message_types'])) {
1163
-                foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1164
-                    EE_Register_Message_Type::register($message_type, $message_type_settings);
1165
-                }
1166
-            }
1167
-        }
1168
-    }
1169
-
1170
-
1171
-    /**
1172
-     * This deregisters an addon that was previously registered with a specific addon_name.
1173
-     *
1174
-     * @param string $addon_name the name for the addon that was previously registered
1175
-     * @throws DomainException
1176
-     * @throws InvalidArgumentException
1177
-     * @throws InvalidDataTypeException
1178
-     * @throws InvalidInterfaceException
1179
-     *@since    4.3.0
1180
-     */
1181
-    public static function deregister($addon_name = '')
1182
-    {
1183
-        if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1184
-            try {
1185
-                do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1186
-                $class_name = self::$_settings[ $addon_name ]['class_name'];
1187
-                if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1188
-                    // setup DMS
1189
-                    EE_Register_Data_Migration_Scripts::deregister($addon_name);
1190
-                }
1191
-                if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1192
-                    // register admin page
1193
-                    EE_Register_Admin_Page::deregister($addon_name);
1194
-                }
1195
-                if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1196
-                    // add to list of modules to be registered
1197
-                    EE_Register_Module::deregister($addon_name);
1198
-                }
1199
-                if (
1200
-                    ! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1201
-                    || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1202
-                ) {
1203
-                    // add to list of shortcodes to be registered
1204
-                    EE_Register_Shortcode::deregister($addon_name);
1205
-                }
1206
-                if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1207
-                    // if config_class present let's register config.
1208
-                    EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1209
-                }
1210
-                if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1211
-                    // add to list of widgets to be registered
1212
-                    EE_Register_Widget::deregister($addon_name);
1213
-                }
1214
-                if (
1215
-                    ! empty(self::$_settings[ $addon_name ]['model_paths'])
1216
-                    || ! empty(self::$_settings[ $addon_name ]['class_paths'])
1217
-                ) {
1218
-                    // add to list of shortcodes to be registered
1219
-                    EE_Register_Model::deregister($addon_name);
1220
-                }
1221
-                if (
1222
-                    ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1223
-                    || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1224
-                ) {
1225
-                    // add to list of shortcodes to be registered
1226
-                    EE_Register_Model_Extensions::deregister($addon_name);
1227
-                }
1228
-                if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1229
-                    foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1230
-                        EE_Register_Message_Type::deregister($message_type);
1231
-                    }
1232
-                }
1233
-                // deregister capabilities for addon
1234
-                if (
1235
-                    ! empty(self::$_settings[ $addon_name ]['capabilities'])
1236
-                    || ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1237
-                ) {
1238
-                    EE_Register_Capabilities::deregister($addon_name);
1239
-                }
1240
-                // deregister custom_post_types for addon
1241
-                if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1242
-                    EE_Register_CPT::deregister($addon_name);
1243
-                }
1244
-                if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1245
-                    EE_Register_Payment_Method::deregister($addon_name);
1246
-                }
1247
-                $addon = EE_Registry::instance()->getAddon($class_name);
1248
-                if ($addon instanceof EE_Addon) {
1249
-                    remove_action(
1250
-                        'deactivate_' . $addon->get_main_plugin_file_basename(),
1251
-                        array($addon, 'deactivation')
1252
-                    );
1253
-                    remove_action(
1254
-                        'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1255
-                        array($addon, 'initialize_db_if_no_migrations_required')
1256
-                    );
1257
-                    // remove `after_registration` call
1258
-                    remove_action(
1259
-                        'AHEE__EE_System__load_espresso_addons__complete',
1260
-                        array($addon, 'after_registration'),
1261
-                        999
1262
-                    );
1263
-                }
1264
-                EE_Registry::instance()->removeAddon($class_name);
1265
-                LoaderFactory::getLoader()->remove($class_name);
1266
-            } catch (OutOfBoundsException $addon_not_yet_registered_exception) {
1267
-                // the add-on was not yet registered in the registry,
1268
-                // so RegistryContainer::__get() throws this exception.
1269
-                // also no need to worry about this or log it,
1270
-                // it's ok to deregister an add-on before its registered in the registry
1271
-            } catch (Exception $e) {
1272
-                new ExceptionLogger($e);
1273
-            }
1274
-            unset(self::$_settings[ $addon_name ]);
1275
-            do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1276
-        }
1277
-    }
25
+	/**
26
+	 * possibly truncated version of the EE core version string
27
+	 *
28
+	 * @var string
29
+	 */
30
+	protected static $_core_version = '';
31
+
32
+	/**
33
+	 * Holds values for registered addons
34
+	 *
35
+	 * @var array
36
+	 */
37
+	protected static $_settings = array();
38
+
39
+	/**
40
+	 * @var  array $_incompatible_addons keys are addon SLUGS
41
+	 * (first argument passed to EE_Register_Addon::register()), keys are
42
+	 * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004).
43
+	 * Generally this should be used sparingly, as we don't want to muddle up
44
+	 * EE core with knowledge of ALL the addons out there.
45
+	 * If you want NO versions of an addon to run with a certain version of core,
46
+	 * it's usually best to define the addon's "min_core_version" as part of its call
47
+	 * to EE_Register_Addon::register(), rather than using this array with a super high value for its
48
+	 * minimum plugin version.
49
+	 * @access    protected
50
+	 */
51
+	protected static $_incompatible_addons = array(
52
+		'Multi_Event_Registration' => '2.0.11.rc.002',
53
+		'Promotions'               => '1.0.0.rc.084',
54
+	);
55
+
56
+
57
+	/**
58
+	 * We should always be comparing core to a version like '4.3.0.rc.000',
59
+	 * not just '4.3.0'.
60
+	 * So if the addon developer doesn't provide that full version string,
61
+	 * fill in the blanks for them
62
+	 *
63
+	 * @param string $min_core_version
64
+	 * @return string always like '4.3.0.rc.000'
65
+	 */
66
+	protected static function _effective_version($min_core_version)
67
+	{
68
+		// versions: 4 . 3 . 1 . p . 123
69
+		// offsets:    0 . 1 . 2 . 3 . 4
70
+		$version_parts = explode('.', $min_core_version);
71
+		// check they specified the micro version (after 2nd period)
72
+		if (! isset($version_parts[2])) {
73
+			$version_parts[2] = '0';
74
+		}
75
+		// if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
76
+		// soon we can assume that's 'rc', but this current version is 'alpha'
77
+		if (! isset($version_parts[3])) {
78
+			$version_parts[3] = 'dev';
79
+		}
80
+		if (! isset($version_parts[4])) {
81
+			$version_parts[4] = '000';
82
+		}
83
+		return implode('.', $version_parts);
84
+	}
85
+
86
+
87
+	/**
88
+	 * Returns whether or not the min core version requirement of the addon is met
89
+	 *
90
+	 * @param string $min_core_version    the minimum core version required by the addon
91
+	 * @param string $actual_core_version the actual core version, optional
92
+	 * @return boolean
93
+	 */
94
+	public static function _meets_min_core_version_requirement(
95
+		$min_core_version,
96
+		$actual_core_version = EVENT_ESPRESSO_VERSION
97
+	) {
98
+		return version_compare(
99
+			self::_effective_version($actual_core_version),
100
+			self::_effective_version($min_core_version),
101
+			'>='
102
+		);
103
+	}
104
+
105
+
106
+	/**
107
+	 * Method for registering new EE_Addons.
108
+	 * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
109
+	 * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
110
+	 * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
111
+	 * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
112
+	 * 'activate_plugin', it registers the addon still, but its components are not registered
113
+	 * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
114
+	 * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
115
+	 * (so that we can detect that the addon has activated on the subsequent request)
116
+	 *
117
+	 * @since    4.3.0
118
+	 * @param string                  $addon_name                       [Required] the EE_Addon's name.
119
+	 * @param  array                  $setup_args                       {
120
+	 *                                                                  An array of arguments provided for registering
121
+	 *                                                                  the message type.
122
+	 * @type  string                  $class_name                       the addon's main file name.
123
+	 *                                                                  If left blank, generated from the addon name,
124
+	 *                                                                  changes something like "calendar" to
125
+	 *                                                                  "EE_Calendar"
126
+	 * @type string                   $min_core_version                 the minimum version of EE Core that the
127
+	 *                                                                  addon will work with. eg "4.8.1.rc.084"
128
+	 * @type string                   $version                          the "software" version for the addon. eg
129
+	 *                                                                  "1.0.0.p" for a first stable release, or
130
+	 *                                                                  "1.0.0.rc.043" for a version in progress
131
+	 * @type string                   $main_file_path                   the full server path to the main file
132
+	 *                                                                  loaded directly by WP
133
+	 * @type DomainInterface $domain                                    child class of
134
+	 *                                                                  EventEspresso\core\domain\DomainBase
135
+	 * @type string                   $domain_fqcn                      Fully Qualified Class Name
136
+	 *                                                                  for the addon's Domain class
137
+	 *                                                                  (see EventEspresso\core\domain\Domain)
138
+	 * @type string                   $admin_path                       full server path to the folder where the
139
+	 *                                                                  addon\'s admin files reside
140
+	 * @type string                   $admin_callback                   a method to be called when the EE Admin is
141
+	 *                                                                  first invoked, can be used for hooking into
142
+	 *                                                                  any admin page
143
+	 * @type string                   $config_section                   the section name for this addon's
144
+	 *                                                                  configuration settings section
145
+	 *                                                                  (defaults to "addons")
146
+	 * @type string                   $config_class                     the class name for this addon's
147
+	 *                                                                  configuration settings object
148
+	 * @type string                   $config_name                      the class name for this addon's
149
+	 *                                                                  configuration settings object
150
+	 * @type string                   $autoloader_paths                 [Required] an array of class names and the full
151
+	 *                                                                  server paths to those files.
152
+	 * @type string                   $autoloader_folders               an array of  "full server paths" for any
153
+	 *                                                                  folders containing classes that might be
154
+	 *                                                                  invoked by the addon
155
+	 * @type string                   $dms_paths                        [Required] an array of full server paths to
156
+	 *                                                                  folders that contain data migration scripts.
157
+	 *                                                                  The key should be the EE_Addon class name that
158
+	 *                                                                  this set of data migration scripts belongs to.
159
+	 *                                                                  If the EE_Addon class is namespaced, then this
160
+	 *                                                                  needs to be the Fully Qualified Class Name
161
+	 * @type string                   $module_paths                     an array of full server paths to any
162
+	 *                                                                  EED_Modules used by the addon
163
+	 * @type string                   $shortcode_paths                  an array of full server paths to folders
164
+	 *                                                                  that contain EES_Shortcodes
165
+	 * @type string                   $widget_paths                     an array of full server paths to folders
166
+	 *                                                                  that contain WP_Widgets
167
+	 * @type string                   $pue_options
168
+	 * @type array                    $capabilities                     an array indexed by role name
169
+	 *                                                                  (i.e administrator,author ) and the values
170
+	 *                                                                  are an array of caps to add to the role.
171
+	 *                                                                  'administrator' => array(
172
+	 *                                                                  'read_addon',
173
+	 *                                                                  'edit_addon',
174
+	 *                                                                  etc.
175
+	 *                                                                  ).
176
+	 * @type EE_Meta_Capability_Map[] $capability_maps                  an array of EE_Meta_Capability_Map object
177
+	 *                                                                  for any addons that need to register any
178
+	 *                                                                  special meta mapped capabilities.  Should
179
+	 *                                                                  be indexed where the key is the
180
+	 *                                                                  EE_Meta_Capability_Map class name and the
181
+	 *                                                                  values are the arguments sent to the class.
182
+	 * @type array                    $model_paths                      array of folders containing DB models
183
+	 * @see      EE_Register_Model
184
+	 * @type array                    $class_paths                      array of folders containing DB classes
185
+	 * @see      EE_Register_Model
186
+	 * @type array                    $model_extension_paths            array of folders containing DB model
187
+	 *                                                                  extensions
188
+	 * @see      EE_Register_Model_Extension
189
+	 * @type array                    $class_extension_paths            array of folders containing DB class
190
+	 *                                                                  extensions
191
+	 * @see      EE_Register_Model_Extension
192
+	 * @type array message_types {
193
+	 *                                                                  An array of message types with the key as
194
+	 *                                                                  the message type name and the values as
195
+	 *                                                                  below:
196
+	 * @type string                   $mtfilename                       [Required] The filename of the message type
197
+	 *                                                                  being registered. This will be the main
198
+	 *                                                                  EE_{Message Type Name}_message_type class.
199
+	 *                                                                  for example:
200
+	 *                                                                  EE_Declined_Registration_message_type.class.php
201
+	 * @type array                    $autoloadpaths                    [Required] An array of paths to add to the
202
+	 *                                                                  messages autoloader for the new message type.
203
+	 * @type array                    $messengers_to_activate_with      An array of messengers that this message
204
+	 *                                                                  type should activate with. Each value in
205
+	 *                                                                  the
206
+	 *                                                                  array
207
+	 *                                                                  should match the name property of a
208
+	 *                                                                  EE_messenger. Optional.
209
+	 * @type array                    $messengers_to_validate_with      An array of messengers that this message
210
+	 *                                                                  type should validate with. Each value in
211
+	 *                                                                  the
212
+	 *                                                                  array
213
+	 *                                                                  should match the name property of an
214
+	 *                                                                  EE_messenger.
215
+	 *                                                                  Optional.
216
+	 *                                                                  }
217
+	 * @type array                    $custom_post_types
218
+	 * @type array                    $custom_taxonomies
219
+	 * @type array                    $payment_method_paths             each element is the folder containing the
220
+	 *                                                                  EE_PMT_Base child class
221
+	 *                                                                  (eg,
222
+	 *                                                                  '/wp-content/plugins/my_plugin/Payomatic/'
223
+	 *                                                                  which contains the files
224
+	 *                                                                  EE_PMT_Payomatic.pm.php)
225
+	 * @type array                    $default_terms
226
+	 * @type array                    $namespace                        {
227
+	 *                                                                  An array with two items for registering the
228
+	 *                                                                  addon's namespace. (If, for some reason, you
229
+	 *                                                                  require additional namespaces,
230
+	 *                                                                  use
231
+	 *                                                                  EventEspresso\core\Psr4Autoloader::addNamespace()
232
+	 *                                                                  directly)
233
+	 * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
234
+	 * @type string                   $FQNS                             the namespace prefix
235
+	 * @type string                   $DIR                              a base directory for class files in the
236
+	 *                                                                  namespace.
237
+	 *                                                                  }
238
+	 *                                                                  }
239
+	 * @type string                   $privacy_policies                 FQNSs (namespaces, each of which contains only
240
+	 *                                                                  privacy policy classes) or FQCNs (specific
241
+	 *                                                                  classnames of privacy policy classes)
242
+	 * @type string                   $personal_data_exporters          FQNSs (namespaces, each of which contains only
243
+	 *                                                                  privacy policy classes) or FQCNs (specific
244
+	 *                                                                  classnames of privacy policy classes)
245
+	 * @type string                   $personal_data_erasers            FQNSs (namespaces, each of which contains only
246
+	 *                                                                  privacy policy classes) or FQCNs (specific
247
+	 *                                                                  classnames of privacy policy classes)
248
+	 * @return void
249
+	 * @throws DomainException
250
+	 * @throws EE_Error
251
+	 * @throws InvalidArgumentException
252
+	 * @throws InvalidDataTypeException
253
+	 * @throws InvalidInterfaceException
254
+	 */
255
+	public static function register($addon_name = '', array $setup_args = array())
256
+	{
257
+		// required fields MUST be present, so let's make sure they are.
258
+		EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
259
+		// get class name for addon
260
+		$class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
261
+		// setup $_settings array from incoming values.
262
+		$addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
263
+		// setup PUE
264
+		EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
265
+		// does this addon work with this version of core or WordPress ?
266
+		// does this addon work with this version of core or WordPress ?
267
+		if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
268
+			return;
269
+		}
270
+		// register namespaces
271
+		EE_Register_Addon::_setup_namespaces($addon_settings);
272
+		// check if this is an activation request
273
+		if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
274
+			// dont bother setting up the rest of the addon atm
275
+			return;
276
+		}
277
+		// we need cars
278
+		EE_Register_Addon::_setup_autoloaders($addon_name);
279
+		// register new models and extensions
280
+		EE_Register_Addon::_register_models_and_extensions($addon_name);
281
+		// setup DMS
282
+		EE_Register_Addon::_register_data_migration_scripts($addon_name);
283
+		// if config_class is present let's register config.
284
+		EE_Register_Addon::_register_config($addon_name);
285
+		// register admin pages
286
+		EE_Register_Addon::_register_admin_pages($addon_name);
287
+		// add to list of modules to be registered
288
+		EE_Register_Addon::_register_modules($addon_name);
289
+		// add to list of shortcodes to be registered
290
+		EE_Register_Addon::_register_shortcodes($addon_name);
291
+		// add to list of widgets to be registered
292
+		EE_Register_Addon::_register_widgets($addon_name);
293
+		// register capability related stuff.
294
+		EE_Register_Addon::_register_capabilities($addon_name);
295
+		// any message type to register?
296
+		EE_Register_Addon::_register_message_types($addon_name);
297
+		// any custom post type/ custom capabilities or default terms to register
298
+		EE_Register_Addon::_register_custom_post_types($addon_name);
299
+		// and any payment methods
300
+		EE_Register_Addon::_register_payment_methods($addon_name);
301
+		// and privacy policy generators
302
+		EE_Register_Addon::registerPrivacyPolicies($addon_name);
303
+		// and privacy policy generators
304
+		EE_Register_Addon::registerPersonalDataExporters($addon_name);
305
+		// and privacy policy generators
306
+		EE_Register_Addon::registerPersonalDataErasers($addon_name);
307
+		// load and instantiate main addon class
308
+		$addon = EE_Register_Addon::_load_and_init_addon_class($addon_name);
309
+		// delay calling after_registration hook on each addon until after all add-ons have been registered.
310
+		add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999);
311
+	}
312
+
313
+
314
+	/**
315
+	 * @param string $addon_name
316
+	 * @param array  $setup_args
317
+	 * @return void
318
+	 * @throws EE_Error
319
+	 */
320
+	private static function _verify_parameters($addon_name, array $setup_args)
321
+	{
322
+		// required fields MUST be present, so let's make sure they are.
323
+		if (empty($addon_name) || ! is_array($setup_args)) {
324
+			throw new EE_Error(
325
+				esc_html__(
326
+					'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.',
327
+					'event_espresso'
328
+				)
329
+			);
330
+		}
331
+		if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
332
+			throw new EE_Error(
333
+				sprintf(
334
+					esc_html__(
335
+						'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s',
336
+						'event_espresso'
337
+					),
338
+					implode(',', array_keys($setup_args))
339
+				)
340
+			);
341
+		}
342
+		// check that addon has not already been registered with that name
343
+		if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
344
+			throw new EE_Error(
345
+				sprintf(
346
+					esc_html__(
347
+						'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
348
+						'event_espresso'
349
+					),
350
+					$addon_name
351
+				)
352
+			);
353
+		}
354
+	}
355
+
356
+
357
+	/**
358
+	 * @param string $addon_name
359
+	 * @param array  $setup_args
360
+	 * @return string
361
+	 */
362
+	private static function _parse_class_name($addon_name, array $setup_args)
363
+	{
364
+		if (empty($setup_args['class_name'])) {
365
+			// generate one by first separating name with spaces
366
+			$class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
367
+			// capitalize, then replace spaces with underscores
368
+			$class_name = str_replace(' ', '_', ucwords($class_name));
369
+		} else {
370
+			$class_name = $setup_args['class_name'];
371
+		}
372
+		// check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
373
+		return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
374
+			? $class_name
375
+			: 'EE_' . $class_name;
376
+	}
377
+
378
+
379
+	/**
380
+	 * @param string $class_name
381
+	 * @param array  $setup_args
382
+	 * @return array
383
+	 */
384
+	private static function _get_addon_settings($class_name, array $setup_args)
385
+	{
386
+		// setup $_settings array from incoming values.
387
+		$addon_settings = array(
388
+			// generated from the addon name, changes something like "calendar" to "EE_Calendar"
389
+			'class_name'            => $class_name,
390
+			// the addon slug for use in URLs, etc
391
+			'plugin_slug'           => isset($setup_args['plugin_slug'])
392
+				? (string) $setup_args['plugin_slug']
393
+				: '',
394
+			// page slug to be used when generating the "Settings" link on the WP plugin page
395
+			'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
396
+				? (string) $setup_args['plugin_action_slug']
397
+				: '',
398
+			// the "software" version for the addon
399
+			'version'               => isset($setup_args['version'])
400
+				? (string) $setup_args['version']
401
+				: '',
402
+			// the minimum version of EE Core that the addon will work with
403
+			'min_core_version'      => isset($setup_args['min_core_version'])
404
+				? (string) $setup_args['min_core_version']
405
+				: '',
406
+			// the minimum version of WordPress that the addon will work with
407
+			'min_wp_version'        => isset($setup_args['min_wp_version'])
408
+				? (string) $setup_args['min_wp_version']
409
+				: EE_MIN_WP_VER_REQUIRED,
410
+			// full server path to main file (file loaded directly by WP)
411
+			'main_file_path'        => isset($setup_args['main_file_path'])
412
+				? (string) $setup_args['main_file_path']
413
+				: '',
414
+			// instance of \EventEspresso\core\domain\DomainInterface
415
+			'domain'                => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface
416
+				? $setup_args['domain']
417
+				: null,
418
+			// Fully Qualified Class Name for the addon's Domain class
419
+			'domain_fqcn'           => isset($setup_args['domain_fqcn'])
420
+				? (string) $setup_args['domain_fqcn']
421
+				: '',
422
+			// path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
423
+			'admin_path'            => isset($setup_args['admin_path'])
424
+				? (string) $setup_args['admin_path'] : '',
425
+			// a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
426
+			'admin_callback'        => isset($setup_args['admin_callback'])
427
+				? (string) $setup_args['admin_callback']
428
+				: '',
429
+			// the section name for this addon's configuration settings section (defaults to "addons")
430
+			'config_section'        => isset($setup_args['config_section'])
431
+				? (string) $setup_args['config_section']
432
+				: 'addons',
433
+			// the class name for this addon's configuration settings object
434
+			'config_class'          => isset($setup_args['config_class'])
435
+				? (string) $setup_args['config_class'] : '',
436
+			// the name given to the config for this addons' configuration settings object (optional)
437
+			'config_name'           => isset($setup_args['config_name'])
438
+				? (string) $setup_args['config_name'] : '',
439
+			// an array of "class names" => "full server paths" for any classes that might be invoked by the addon
440
+			'autoloader_paths'      => isset($setup_args['autoloader_paths'])
441
+				? (array) $setup_args['autoloader_paths']
442
+				: array(),
443
+			// an array of  "full server paths" for any folders containing classes that might be invoked by the addon
444
+			'autoloader_folders'    => isset($setup_args['autoloader_folders'])
445
+				? (array) $setup_args['autoloader_folders']
446
+				: array(),
447
+			// array of full server paths to any EE_DMS data migration scripts used by the addon.
448
+			// The key should be the EE_Addon class name that this set of data migration scripts belongs to.
449
+			// If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name
450
+			'dms_paths'             => isset($setup_args['dms_paths'])
451
+				? (array) $setup_args['dms_paths']
452
+				: array(),
453
+			// array of full server paths to any EED_Modules used by the addon
454
+			'module_paths'          => isset($setup_args['module_paths'])
455
+				? (array) $setup_args['module_paths']
456
+				: array(),
457
+			// array of full server paths to any EES_Shortcodes used by the addon
458
+			'shortcode_paths'       => isset($setup_args['shortcode_paths'])
459
+				? (array) $setup_args['shortcode_paths']
460
+				: array(),
461
+			'shortcode_fqcns'       => isset($setup_args['shortcode_fqcns'])
462
+				? (array) $setup_args['shortcode_fqcns']
463
+				: array(),
464
+			// array of full server paths to any WP_Widgets used by the addon
465
+			'widget_paths'          => isset($setup_args['widget_paths'])
466
+				? (array) $setup_args['widget_paths']
467
+				: array(),
468
+			// array of PUE options used by the addon
469
+			'pue_options'           => isset($setup_args['pue_options'])
470
+				? (array) $setup_args['pue_options']
471
+				: array(),
472
+			'message_types'         => isset($setup_args['message_types'])
473
+				? (array) $setup_args['message_types']
474
+				: array(),
475
+			'capabilities'          => isset($setup_args['capabilities'])
476
+				? (array) $setup_args['capabilities']
477
+				: array(),
478
+			'capability_maps'       => isset($setup_args['capability_maps'])
479
+				? (array) $setup_args['capability_maps']
480
+				: array(),
481
+			'model_paths'           => isset($setup_args['model_paths'])
482
+				? (array) $setup_args['model_paths']
483
+				: array(),
484
+			'class_paths'           => isset($setup_args['class_paths'])
485
+				? (array) $setup_args['class_paths']
486
+				: array(),
487
+			'model_extension_paths' => isset($setup_args['model_extension_paths'])
488
+				? (array) $setup_args['model_extension_paths']
489
+				: array(),
490
+			'class_extension_paths' => isset($setup_args['class_extension_paths'])
491
+				? (array) $setup_args['class_extension_paths']
492
+				: array(),
493
+			'custom_post_types'     => isset($setup_args['custom_post_types'])
494
+				? (array) $setup_args['custom_post_types']
495
+				: array(),
496
+			'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
497
+				? (array) $setup_args['custom_taxonomies']
498
+				: array(),
499
+			'payment_method_paths'  => isset($setup_args['payment_method_paths'])
500
+				? (array) $setup_args['payment_method_paths']
501
+				: array(),
502
+			'default_terms'         => isset($setup_args['default_terms'])
503
+				? (array) $setup_args['default_terms']
504
+				: array(),
505
+			// if not empty, inserts a new table row after this plugin's row on the WP Plugins page
506
+			// that can be used for adding upgrading/marketing info
507
+			'plugins_page_row'      => isset($setup_args['plugins_page_row']) ? $setup_args['plugins_page_row'] : '',
508
+			'namespace'             => isset(
509
+				$setup_args['namespace']['FQNS'],
510
+				$setup_args['namespace']['DIR']
511
+			)
512
+				? (array) $setup_args['namespace']
513
+				: array(),
514
+			'privacy_policies'      => isset($setup_args['privacy_policies'])
515
+				? (array) $setup_args['privacy_policies']
516
+				: '',
517
+		);
518
+		// if plugin_action_slug is NOT set, but an admin page path IS set,
519
+		// then let's just use the plugin_slug since that will be used for linking to the admin page
520
+		$addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
521
+												&& ! empty($addon_settings['admin_path'])
522
+			? $addon_settings['plugin_slug']
523
+			: $addon_settings['plugin_action_slug'];
524
+		// full server path to main file (file loaded directly by WP)
525
+		$addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
526
+		return $addon_settings;
527
+	}
528
+
529
+
530
+	/**
531
+	 * @param string $addon_name
532
+	 * @param array  $addon_settings
533
+	 * @return boolean
534
+	 */
535
+	private static function _addon_is_compatible($addon_name, array $addon_settings)
536
+	{
537
+		global $wp_version;
538
+		$incompatibility_message = '';
539
+		// check whether this addon version is compatible with EE core
540
+		if (
541
+			isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
542
+			&& ! self::_meets_min_core_version_requirement(
543
+				EE_Register_Addon::$_incompatible_addons[ $addon_name ],
544
+				$addon_settings['version']
545
+			)
546
+		) {
547
+			$incompatibility_message = sprintf(
548
+				esc_html__(
549
+					'%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.',
550
+					'event_espresso'
551
+				),
552
+				$addon_name,
553
+				'<br />',
554
+				EE_Register_Addon::$_incompatible_addons[ $addon_name ],
555
+				'<span style="font-weight: bold; color: #D54E21;">',
556
+				'</span><br />'
557
+			);
558
+		} elseif (
559
+			! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
560
+		) {
561
+			$incompatibility_message = sprintf(
562
+				esc_html__(
563
+					'%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".',
564
+					'event_espresso'
565
+				),
566
+				$addon_name,
567
+				self::_effective_version($addon_settings['min_core_version']),
568
+				self::_effective_version(espresso_version()),
569
+				'<br />',
570
+				'<span style="font-weight: bold; color: #D54E21;">',
571
+				'</span><br />'
572
+			);
573
+		} elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
574
+			$incompatibility_message = sprintf(
575
+				esc_html__(
576
+					'%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.',
577
+					'event_espresso'
578
+				),
579
+				$addon_name,
580
+				$addon_settings['min_wp_version'],
581
+				'<br />',
582
+				'<span style="font-weight: bold; color: #D54E21;">',
583
+				'</span><br />'
584
+			);
585
+		}
586
+		if (! empty($incompatibility_message)) {
587
+			// remove 'activate' from the REQUEST
588
+			// so WP doesn't erroneously tell the user the plugin activated fine when it didn't
589
+			/** @var RequestInterface $request */
590
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
591
+			$request->unSetRequestParam('activate', true);
592
+			if (current_user_can('activate_plugins')) {
593
+				// show an error message indicating the plugin didn't activate properly
594
+				EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
595
+			}
596
+			// BAIL FROM THE ADDON REGISTRATION PROCESS
597
+			return false;
598
+		}
599
+		// addon IS compatible
600
+		return true;
601
+	}
602
+
603
+
604
+	/**
605
+	 * if plugin update engine is being used for auto-updates,
606
+	 * then let's set that up now before going any further so that ALL addons can be updated
607
+	 * (not needed if PUE is not being used)
608
+	 *
609
+	 * @param string $addon_name
610
+	 * @param string $class_name
611
+	 * @param array  $setup_args
612
+	 * @return void
613
+	 */
614
+	private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
615
+	{
616
+		if (! empty($setup_args['pue_options'])) {
617
+			self::$_settings[ $addon_name ]['pue_options'] = array(
618
+				'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
619
+					? (string) $setup_args['pue_options']['pue_plugin_slug']
620
+					: 'espresso_' . strtolower($class_name),
621
+				'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
622
+					? (string) $setup_args['pue_options']['plugin_basename']
623
+					: plugin_basename($setup_args['main_file_path']),
624
+				'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
625
+					? (string) $setup_args['pue_options']['checkPeriod']
626
+					: '24',
627
+				'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
628
+					? (string) $setup_args['pue_options']['use_wp_update']
629
+					: false,
630
+			);
631
+			add_action(
632
+				'AHEE__EE_System__brew_espresso__after_pue_init',
633
+				array('EE_Register_Addon', 'load_pue_update')
634
+			);
635
+		}
636
+	}
637
+
638
+
639
+	/**
640
+	 * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
641
+	 *
642
+	 * @param array $addon_settings
643
+	 * @return void
644
+	 */
645
+	private static function _setup_namespaces(array $addon_settings)
646
+	{
647
+		//
648
+		if (
649
+			isset(
650
+				$addon_settings['namespace']['FQNS'],
651
+				$addon_settings['namespace']['DIR']
652
+			)
653
+		) {
654
+			EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
655
+				$addon_settings['namespace']['FQNS'],
656
+				$addon_settings['namespace']['DIR']
657
+			);
658
+		}
659
+	}
660
+
661
+
662
+	/**
663
+	 * @param string $addon_name
664
+	 * @param array  $addon_settings
665
+	 * @return bool
666
+	 * @throws InvalidArgumentException
667
+	 * @throws InvalidDataTypeException
668
+	 * @throws InvalidInterfaceException
669
+	 */
670
+	private static function _addon_activation($addon_name, array $addon_settings)
671
+	{
672
+		// this is an activation request
673
+		if (did_action('activate_plugin')) {
674
+			// to find if THIS is the addon that was activated, just check if we have already registered it or not
675
+			// (as the newly-activated addon wasn't around the first time addons were registered).
676
+			// Note: the presence of pue_options in the addon registration options will initialize the $_settings
677
+			// property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
678
+			if (
679
+				! isset(self::$_settings[ $addon_name ])
680
+				|| (isset(self::$_settings[ $addon_name ])
681
+					&& ! isset(self::$_settings[ $addon_name ]['class_name'])
682
+				)
683
+			) {
684
+				self::$_settings[ $addon_name ] = $addon_settings;
685
+				$addon = self::_load_and_init_addon_class($addon_name);
686
+				$addon->set_activation_indicator_option();
687
+				// dont bother setting up the rest of the addon.
688
+				// we know it was just activated and the request will end soon
689
+			}
690
+			return true;
691
+		}
692
+		// make sure this was called in the right place!
693
+		if (
694
+			! did_action('AHEE__EE_System__load_espresso_addons')
695
+			|| did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
696
+		) {
697
+			EE_Error::doing_it_wrong(
698
+				__METHOD__,
699
+				sprintf(
700
+					esc_html__(
701
+						'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.',
702
+						'event_espresso'
703
+					),
704
+					$addon_name
705
+				),
706
+				'4.3.0'
707
+			);
708
+		}
709
+		// make sure addon settings are set correctly without overwriting anything existing
710
+		if (isset(self::$_settings[ $addon_name ])) {
711
+			self::$_settings[ $addon_name ] += $addon_settings;
712
+		} else {
713
+			self::$_settings[ $addon_name ] = $addon_settings;
714
+		}
715
+		return false;
716
+	}
717
+
718
+
719
+	/**
720
+	 * @param string $addon_name
721
+	 * @return void
722
+	 * @throws EE_Error
723
+	 */
724
+	private static function _setup_autoloaders($addon_name)
725
+	{
726
+		if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
727
+			// setup autoloader for single file
728
+			EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
729
+		}
730
+		// setup autoloaders for folders
731
+		if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
732
+			foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
733
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
734
+			}
735
+		}
736
+	}
737
+
738
+
739
+	/**
740
+	 * register new models and extensions
741
+	 *
742
+	 * @param string $addon_name
743
+	 * @return void
744
+	 * @throws EE_Error
745
+	 */
746
+	private static function _register_models_and_extensions($addon_name)
747
+	{
748
+		// register new models
749
+		if (
750
+			! empty(self::$_settings[ $addon_name ]['model_paths'])
751
+			|| ! empty(self::$_settings[ $addon_name ]['class_paths'])
752
+		) {
753
+			EE_Register_Model::register(
754
+				$addon_name,
755
+				array(
756
+					'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
757
+					'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
758
+				)
759
+			);
760
+		}
761
+		// register model extensions
762
+		if (
763
+			! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
764
+			|| ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
765
+		) {
766
+			EE_Register_Model_Extensions::register(
767
+				$addon_name,
768
+				array(
769
+					'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
770
+					'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
771
+				)
772
+			);
773
+		}
774
+	}
775
+
776
+
777
+	/**
778
+	 * @param string $addon_name
779
+	 * @return void
780
+	 * @throws EE_Error
781
+	 */
782
+	private static function _register_data_migration_scripts($addon_name)
783
+	{
784
+		// setup DMS
785
+		if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
786
+			EE_Register_Data_Migration_Scripts::register(
787
+				$addon_name,
788
+				array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
789
+			);
790
+		}
791
+	}
792
+
793
+
794
+	/**
795
+	 * @param string $addon_name
796
+	 * @return void
797
+	 * @throws EE_Error
798
+	 */
799
+	private static function _register_config($addon_name)
800
+	{
801
+		// if config_class is present let's register config.
802
+		if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
803
+			EE_Register_Config::register(
804
+				self::$_settings[ $addon_name ]['config_class'],
805
+				array(
806
+					'config_section' => self::$_settings[ $addon_name ]['config_section'],
807
+					'config_name'    => self::$_settings[ $addon_name ]['config_name'],
808
+				)
809
+			);
810
+		}
811
+	}
812
+
813
+
814
+	/**
815
+	 * @param string $addon_name
816
+	 * @return void
817
+	 * @throws EE_Error
818
+	 */
819
+	private static function _register_admin_pages($addon_name)
820
+	{
821
+		if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
822
+			EE_Register_Admin_Page::register(
823
+				$addon_name,
824
+				array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
825
+			);
826
+		}
827
+	}
828
+
829
+
830
+	/**
831
+	 * @param string $addon_name
832
+	 * @return void
833
+	 * @throws EE_Error
834
+	 */
835
+	private static function _register_modules($addon_name)
836
+	{
837
+		if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
838
+			EE_Register_Module::register(
839
+				$addon_name,
840
+				array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
841
+			);
842
+		}
843
+	}
844
+
845
+
846
+	/**
847
+	 * @param string $addon_name
848
+	 * @return void
849
+	 * @throws EE_Error
850
+	 */
851
+	private static function _register_shortcodes($addon_name)
852
+	{
853
+		if (
854
+			! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
855
+			|| ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
856
+		) {
857
+			EE_Register_Shortcode::register(
858
+				$addon_name,
859
+				array(
860
+					'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
861
+						? self::$_settings[ $addon_name ]['shortcode_paths'] : array(),
862
+					'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
863
+						? self::$_settings[ $addon_name ]['shortcode_fqcns'] : array(),
864
+				)
865
+			);
866
+		}
867
+	}
868
+
869
+
870
+	/**
871
+	 * @param string $addon_name
872
+	 * @return void
873
+	 * @throws EE_Error
874
+	 */
875
+	private static function _register_widgets($addon_name)
876
+	{
877
+		if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
878
+			EE_Register_Widget::register(
879
+				$addon_name,
880
+				array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
881
+			);
882
+		}
883
+	}
884
+
885
+
886
+	/**
887
+	 * @param string $addon_name
888
+	 * @return void
889
+	 * @throws EE_Error
890
+	 */
891
+	private static function _register_capabilities($addon_name)
892
+	{
893
+		if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
894
+			EE_Register_Capabilities::register(
895
+				$addon_name,
896
+				array(
897
+					'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
898
+					'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
899
+				)
900
+			);
901
+		}
902
+	}
903
+
904
+
905
+	/**
906
+	 * @param string $addon_name
907
+	 * @return void
908
+	 */
909
+	private static function _register_message_types($addon_name)
910
+	{
911
+		if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
912
+			add_action(
913
+				'EE_Brewing_Regular___messages_caf',
914
+				array('EE_Register_Addon', 'register_message_types')
915
+			);
916
+		}
917
+	}
918
+
919
+
920
+	/**
921
+	 * @param string $addon_name
922
+	 * @return void
923
+	 * @throws EE_Error
924
+	 */
925
+	private static function _register_custom_post_types($addon_name)
926
+	{
927
+		if (
928
+			! empty(self::$_settings[ $addon_name ]['custom_post_types'])
929
+			|| ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
930
+		) {
931
+			EE_Register_CPT::register(
932
+				$addon_name,
933
+				array(
934
+					'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
935
+					'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
936
+					'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
937
+				)
938
+			);
939
+		}
940
+	}
941
+
942
+
943
+	/**
944
+	 * @param string $addon_name
945
+	 * @return void
946
+	 * @throws InvalidArgumentException
947
+	 * @throws InvalidInterfaceException
948
+	 * @throws InvalidDataTypeException
949
+	 * @throws DomainException
950
+	 * @throws EE_Error
951
+	 */
952
+	private static function _register_payment_methods($addon_name)
953
+	{
954
+		if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
955
+			EE_Register_Payment_Method::register(
956
+				$addon_name,
957
+				array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
958
+			);
959
+		}
960
+	}
961
+
962
+
963
+	/**
964
+	 * @param string $addon_name
965
+	 * @return void
966
+	 * @throws InvalidArgumentException
967
+	 * @throws InvalidInterfaceException
968
+	 * @throws InvalidDataTypeException
969
+	 * @throws DomainException
970
+	 */
971
+	private static function registerPrivacyPolicies($addon_name)
972
+	{
973
+		if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) {
974
+			EE_Register_Privacy_Policy::register(
975
+				$addon_name,
976
+				self::$_settings[ $addon_name ]['privacy_policies']
977
+			);
978
+		}
979
+	}
980
+
981
+
982
+	/**
983
+	 * @param string $addon_name
984
+	 * @return void
985
+	 */
986
+	private static function registerPersonalDataExporters($addon_name)
987
+	{
988
+		if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) {
989
+			EE_Register_Personal_Data_Eraser::register(
990
+				$addon_name,
991
+				self::$_settings[ $addon_name ]['personal_data_exporters']
992
+			);
993
+		}
994
+	}
995
+
996
+
997
+	/**
998
+	 * @param string $addon_name
999
+	 * @return void
1000
+	 */
1001
+	private static function registerPersonalDataErasers($addon_name)
1002
+	{
1003
+		if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) {
1004
+			EE_Register_Personal_Data_Eraser::register(
1005
+				$addon_name,
1006
+				self::$_settings[ $addon_name ]['personal_data_erasers']
1007
+			);
1008
+		}
1009
+	}
1010
+
1011
+
1012
+	/**
1013
+	 * Loads and instantiates the EE_Addon class and adds it onto the registry
1014
+	 *
1015
+	 * @param string $addon_name
1016
+	 * @return EE_Addon
1017
+	 * @throws InvalidArgumentException
1018
+	 * @throws InvalidInterfaceException
1019
+	 * @throws InvalidDataTypeException
1020
+	 */
1021
+	private static function _load_and_init_addon_class($addon_name)
1022
+	{
1023
+		$addon = LoaderFactory::getLoader()->getShared(
1024
+			self::$_settings[ $addon_name ]['class_name'],
1025
+			array('EE_Registry::create(addon)' => true)
1026
+		);
1027
+		if (! $addon instanceof EE_Addon) {
1028
+			throw new DomainException(
1029
+				sprintf(
1030
+					esc_html__(
1031
+						'Failed to instantiate the %1$s class. PLease check that the class exists.',
1032
+						'event_espresso'
1033
+					),
1034
+					$addon_name
1035
+				)
1036
+			);
1037
+		}
1038
+		// setter inject dep map if required
1039
+		if ($addon->dependencyMap() === null) {
1040
+			$addon->setDependencyMap(LoaderFactory::getLoader()->getShared('EE_Dependency_Map'));
1041
+		}
1042
+		// setter inject domain if required
1043
+		EE_Register_Addon::injectAddonDomain($addon_name, $addon);
1044
+
1045
+		$addon->set_name($addon_name);
1046
+		$addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
1047
+		$addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
1048
+		$addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
1049
+		$addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
1050
+		$addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
1051
+		$addon->set_version(self::$_settings[ $addon_name ]['version']);
1052
+		$addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
1053
+		$addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
1054
+		$addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
1055
+		$addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
1056
+		// setup the add-on's pue_slug if we have one.
1057
+		if (! empty(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug'])) {
1058
+			$addon->setPueSlug(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug']);
1059
+		}
1060
+		// unfortunately this can't be hooked in upon construction,
1061
+		// because we don't have the plugin's mainfile path upon construction.
1062
+		register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
1063
+		// call any additional admin_callback functions during load_admin_controller hook
1064
+		if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1065
+			add_action(
1066
+				'AHEE__EE_System__load_controllers__load_admin_controllers',
1067
+				array($addon, self::$_settings[ $addon_name ]['admin_callback'])
1068
+			);
1069
+		}
1070
+		return $addon;
1071
+	}
1072
+
1073
+
1074
+	/**
1075
+	 * @param string   $addon_name
1076
+	 * @param EE_Addon $addon
1077
+	 * @since   4.10.13.p
1078
+	 */
1079
+	private static function injectAddonDomain($addon_name, EE_Addon $addon)
1080
+	{
1081
+		if ($addon instanceof RequiresDomainInterface && $addon->domain() === null) {
1082
+			// using supplied Domain object
1083
+			$domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
1084
+				? self::$_settings[ $addon_name ]['domain']
1085
+				: null;
1086
+			// or construct one using Domain FQCN
1087
+			if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
1088
+				$domain = LoaderFactory::getLoader()->getShared(
1089
+					self::$_settings[ $addon_name ]['domain_fqcn'],
1090
+					[
1091
+						new EventEspresso\core\domain\values\FilePath(
1092
+							self::$_settings[ $addon_name ]['main_file_path']
1093
+						),
1094
+						EventEspresso\core\domain\values\Version::fromString(
1095
+							self::$_settings[ $addon_name ]['version']
1096
+						),
1097
+					]
1098
+				);
1099
+			}
1100
+			if ($domain instanceof DomainInterface) {
1101
+				$addon->setDomain($domain);
1102
+			}
1103
+		}
1104
+	}
1105
+
1106
+
1107
+	/**
1108
+	 *    load_pue_update - Update notifications
1109
+	 *
1110
+	 * @return void
1111
+	 * @throws InvalidArgumentException
1112
+	 * @throws InvalidDataTypeException
1113
+	 * @throws InvalidInterfaceException
1114
+	 */
1115
+	public static function load_pue_update()
1116
+	{
1117
+		// PUE client existence
1118
+		if (! is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) return;
1119
+
1120
+		// load PUE client
1121
+		require_once EE_THIRD_PARTY . 'pue/pue-client.php';
1122
+		$license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com';
1123
+		// cycle thru settings
1124
+		foreach (self::$_settings as $settings) {
1125
+			if (empty($settings['pue_options'])) continue;
1126
+
1127
+			// initiate the class and start the plugin update engine!
1128
+			new PluginUpdateEngineChecker(
1129
+				// host file URL
1130
+				$license_server,
1131
+				// plugin slug(s)
1132
+				array(
1133
+					'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1134
+					'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1135
+				),
1136
+				// options
1137
+				array(
1138
+					'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
1139
+					'lang_domain'       => 'event_espresso',
1140
+					'checkPeriod'       => $settings['pue_options']['checkPeriod'],
1141
+					'option_key'        => 'ee_site_license_key',
1142
+					'options_page_slug' => 'event_espresso',
1143
+					'plugin_basename'   => $settings['pue_options']['plugin_basename'],
1144
+					// if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
1145
+					'use_wp_update'     => $settings['pue_options']['use_wp_update'],
1146
+				)
1147
+			);
1148
+		}
1149
+	}
1150
+
1151
+
1152
+	/**
1153
+	 * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
1154
+	 *
1155
+	 * @since 4.4.0
1156
+	 * @return void
1157
+	 * @throws EE_Error
1158
+	 */
1159
+	public static function register_message_types()
1160
+	{
1161
+		foreach (self::$_settings as $settings) {
1162
+			if (! empty($settings['message_types'])) {
1163
+				foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1164
+					EE_Register_Message_Type::register($message_type, $message_type_settings);
1165
+				}
1166
+			}
1167
+		}
1168
+	}
1169
+
1170
+
1171
+	/**
1172
+	 * This deregisters an addon that was previously registered with a specific addon_name.
1173
+	 *
1174
+	 * @param string $addon_name the name for the addon that was previously registered
1175
+	 * @throws DomainException
1176
+	 * @throws InvalidArgumentException
1177
+	 * @throws InvalidDataTypeException
1178
+	 * @throws InvalidInterfaceException
1179
+	 *@since    4.3.0
1180
+	 */
1181
+	public static function deregister($addon_name = '')
1182
+	{
1183
+		if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1184
+			try {
1185
+				do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1186
+				$class_name = self::$_settings[ $addon_name ]['class_name'];
1187
+				if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1188
+					// setup DMS
1189
+					EE_Register_Data_Migration_Scripts::deregister($addon_name);
1190
+				}
1191
+				if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1192
+					// register admin page
1193
+					EE_Register_Admin_Page::deregister($addon_name);
1194
+				}
1195
+				if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1196
+					// add to list of modules to be registered
1197
+					EE_Register_Module::deregister($addon_name);
1198
+				}
1199
+				if (
1200
+					! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1201
+					|| ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1202
+				) {
1203
+					// add to list of shortcodes to be registered
1204
+					EE_Register_Shortcode::deregister($addon_name);
1205
+				}
1206
+				if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1207
+					// if config_class present let's register config.
1208
+					EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1209
+				}
1210
+				if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1211
+					// add to list of widgets to be registered
1212
+					EE_Register_Widget::deregister($addon_name);
1213
+				}
1214
+				if (
1215
+					! empty(self::$_settings[ $addon_name ]['model_paths'])
1216
+					|| ! empty(self::$_settings[ $addon_name ]['class_paths'])
1217
+				) {
1218
+					// add to list of shortcodes to be registered
1219
+					EE_Register_Model::deregister($addon_name);
1220
+				}
1221
+				if (
1222
+					! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1223
+					|| ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1224
+				) {
1225
+					// add to list of shortcodes to be registered
1226
+					EE_Register_Model_Extensions::deregister($addon_name);
1227
+				}
1228
+				if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1229
+					foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1230
+						EE_Register_Message_Type::deregister($message_type);
1231
+					}
1232
+				}
1233
+				// deregister capabilities for addon
1234
+				if (
1235
+					! empty(self::$_settings[ $addon_name ]['capabilities'])
1236
+					|| ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1237
+				) {
1238
+					EE_Register_Capabilities::deregister($addon_name);
1239
+				}
1240
+				// deregister custom_post_types for addon
1241
+				if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1242
+					EE_Register_CPT::deregister($addon_name);
1243
+				}
1244
+				if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1245
+					EE_Register_Payment_Method::deregister($addon_name);
1246
+				}
1247
+				$addon = EE_Registry::instance()->getAddon($class_name);
1248
+				if ($addon instanceof EE_Addon) {
1249
+					remove_action(
1250
+						'deactivate_' . $addon->get_main_plugin_file_basename(),
1251
+						array($addon, 'deactivation')
1252
+					);
1253
+					remove_action(
1254
+						'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1255
+						array($addon, 'initialize_db_if_no_migrations_required')
1256
+					);
1257
+					// remove `after_registration` call
1258
+					remove_action(
1259
+						'AHEE__EE_System__load_espresso_addons__complete',
1260
+						array($addon, 'after_registration'),
1261
+						999
1262
+					);
1263
+				}
1264
+				EE_Registry::instance()->removeAddon($class_name);
1265
+				LoaderFactory::getLoader()->remove($class_name);
1266
+			} catch (OutOfBoundsException $addon_not_yet_registered_exception) {
1267
+				// the add-on was not yet registered in the registry,
1268
+				// so RegistryContainer::__get() throws this exception.
1269
+				// also no need to worry about this or log it,
1270
+				// it's ok to deregister an add-on before its registered in the registry
1271
+			} catch (Exception $e) {
1272
+				new ExceptionLogger($e);
1273
+			}
1274
+			unset(self::$_settings[ $addon_name ]);
1275
+			do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1276
+		}
1277
+	}
1278 1278
 }
Please login to merge, or discard this patch.
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
         // offsets:    0 . 1 . 2 . 3 . 4
70 70
         $version_parts = explode('.', $min_core_version);
71 71
         // check they specified the micro version (after 2nd period)
72
-        if (! isset($version_parts[2])) {
72
+        if ( ! isset($version_parts[2])) {
73 73
             $version_parts[2] = '0';
74 74
         }
75 75
         // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
76 76
         // soon we can assume that's 'rc', but this current version is 'alpha'
77
-        if (! isset($version_parts[3])) {
77
+        if ( ! isset($version_parts[3])) {
78 78
             $version_parts[3] = 'dev';
79 79
         }
80
-        if (! isset($version_parts[4])) {
80
+        if ( ! isset($version_parts[4])) {
81 81
             $version_parts[4] = '000';
82 82
         }
83 83
         return implode('.', $version_parts);
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
         EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
265 265
         // does this addon work with this version of core or WordPress ?
266 266
         // does this addon work with this version of core or WordPress ?
267
-        if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
267
+        if ( ! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
268 268
             return;
269 269
         }
270 270
         // register namespaces
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
                 )
329 329
             );
330 330
         }
331
-        if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
331
+        if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
332 332
             throw new EE_Error(
333 333
                 sprintf(
334 334
                     esc_html__(
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
             );
341 341
         }
342 342
         // check that addon has not already been registered with that name
343
-        if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
343
+        if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) {
344 344
             throw new EE_Error(
345 345
                 sprintf(
346 346
                     esc_html__(
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
         // check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
373 373
         return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
374 374
             ? $class_name
375
-            : 'EE_' . $class_name;
375
+            : 'EE_'.$class_name;
376 376
     }
377 377
 
378 378
 
@@ -538,9 +538,9 @@  discard block
 block discarded – undo
538 538
         $incompatibility_message = '';
539 539
         // check whether this addon version is compatible with EE core
540 540
         if (
541
-            isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
541
+            isset(EE_Register_Addon::$_incompatible_addons[$addon_name])
542 542
             && ! self::_meets_min_core_version_requirement(
543
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
543
+                EE_Register_Addon::$_incompatible_addons[$addon_name],
544 544
                 $addon_settings['version']
545 545
             )
546 546
         ) {
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
                 ),
552 552
                 $addon_name,
553 553
                 '<br />',
554
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
554
+                EE_Register_Addon::$_incompatible_addons[$addon_name],
555 555
                 '<span style="font-weight: bold; color: #D54E21;">',
556 556
                 '</span><br />'
557 557
             );
@@ -583,7 +583,7 @@  discard block
 block discarded – undo
583 583
                 '</span><br />'
584 584
             );
585 585
         }
586
-        if (! empty($incompatibility_message)) {
586
+        if ( ! empty($incompatibility_message)) {
587 587
             // remove 'activate' from the REQUEST
588 588
             // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
589 589
             /** @var RequestInterface $request */
@@ -613,11 +613,11 @@  discard block
 block discarded – undo
613 613
      */
614 614
     private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
615 615
     {
616
-        if (! empty($setup_args['pue_options'])) {
617
-            self::$_settings[ $addon_name ]['pue_options'] = array(
616
+        if ( ! empty($setup_args['pue_options'])) {
617
+            self::$_settings[$addon_name]['pue_options'] = array(
618 618
                 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
619 619
                     ? (string) $setup_args['pue_options']['pue_plugin_slug']
620
-                    : 'espresso_' . strtolower($class_name),
620
+                    : 'espresso_'.strtolower($class_name),
621 621
                 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
622 622
                     ? (string) $setup_args['pue_options']['plugin_basename']
623 623
                     : plugin_basename($setup_args['main_file_path']),
@@ -676,12 +676,12 @@  discard block
 block discarded – undo
676 676
             // Note: the presence of pue_options in the addon registration options will initialize the $_settings
677 677
             // property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
678 678
             if (
679
-                ! isset(self::$_settings[ $addon_name ])
680
-                || (isset(self::$_settings[ $addon_name ])
681
-                    && ! isset(self::$_settings[ $addon_name ]['class_name'])
679
+                ! isset(self::$_settings[$addon_name])
680
+                || (isset(self::$_settings[$addon_name])
681
+                    && ! isset(self::$_settings[$addon_name]['class_name'])
682 682
                 )
683 683
             ) {
684
-                self::$_settings[ $addon_name ] = $addon_settings;
684
+                self::$_settings[$addon_name] = $addon_settings;
685 685
                 $addon = self::_load_and_init_addon_class($addon_name);
686 686
                 $addon->set_activation_indicator_option();
687 687
                 // dont bother setting up the rest of the addon.
@@ -707,10 +707,10 @@  discard block
 block discarded – undo
707 707
             );
708 708
         }
709 709
         // make sure addon settings are set correctly without overwriting anything existing
710
-        if (isset(self::$_settings[ $addon_name ])) {
711
-            self::$_settings[ $addon_name ] += $addon_settings;
710
+        if (isset(self::$_settings[$addon_name])) {
711
+            self::$_settings[$addon_name] += $addon_settings;
712 712
         } else {
713
-            self::$_settings[ $addon_name ] = $addon_settings;
713
+            self::$_settings[$addon_name] = $addon_settings;
714 714
         }
715 715
         return false;
716 716
     }
@@ -723,13 +723,13 @@  discard block
 block discarded – undo
723 723
      */
724 724
     private static function _setup_autoloaders($addon_name)
725 725
     {
726
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
726
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
727 727
             // setup autoloader for single file
728
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
728
+            EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
729 729
         }
730 730
         // setup autoloaders for folders
731
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
732
-            foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
731
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
732
+            foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
733 733
                 EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
734 734
             }
735 735
         }
@@ -747,27 +747,27 @@  discard block
 block discarded – undo
747 747
     {
748 748
         // register new models
749 749
         if (
750
-            ! empty(self::$_settings[ $addon_name ]['model_paths'])
751
-            || ! empty(self::$_settings[ $addon_name ]['class_paths'])
750
+            ! empty(self::$_settings[$addon_name]['model_paths'])
751
+            || ! empty(self::$_settings[$addon_name]['class_paths'])
752 752
         ) {
753 753
             EE_Register_Model::register(
754 754
                 $addon_name,
755 755
                 array(
756
-                    'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
757
-                    'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
756
+                    'model_paths' => self::$_settings[$addon_name]['model_paths'],
757
+                    'class_paths' => self::$_settings[$addon_name]['class_paths'],
758 758
                 )
759 759
             );
760 760
         }
761 761
         // register model extensions
762 762
         if (
763
-            ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
764
-            || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
763
+            ! empty(self::$_settings[$addon_name]['model_extension_paths'])
764
+            || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
765 765
         ) {
766 766
             EE_Register_Model_Extensions::register(
767 767
                 $addon_name,
768 768
                 array(
769
-                    'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
770
-                    'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
769
+                    'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'],
770
+                    'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'],
771 771
                 )
772 772
             );
773 773
         }
@@ -782,10 +782,10 @@  discard block
 block discarded – undo
782 782
     private static function _register_data_migration_scripts($addon_name)
783 783
     {
784 784
         // setup DMS
785
-        if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
785
+        if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
786 786
             EE_Register_Data_Migration_Scripts::register(
787 787
                 $addon_name,
788
-                array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
788
+                array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])
789 789
             );
790 790
         }
791 791
     }
@@ -799,12 +799,12 @@  discard block
 block discarded – undo
799 799
     private static function _register_config($addon_name)
800 800
     {
801 801
         // if config_class is present let's register config.
802
-        if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
802
+        if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
803 803
             EE_Register_Config::register(
804
-                self::$_settings[ $addon_name ]['config_class'],
804
+                self::$_settings[$addon_name]['config_class'],
805 805
                 array(
806
-                    'config_section' => self::$_settings[ $addon_name ]['config_section'],
807
-                    'config_name'    => self::$_settings[ $addon_name ]['config_name'],
806
+                    'config_section' => self::$_settings[$addon_name]['config_section'],
807
+                    'config_name'    => self::$_settings[$addon_name]['config_name'],
808 808
                 )
809 809
             );
810 810
         }
@@ -818,10 +818,10 @@  discard block
 block discarded – undo
818 818
      */
819 819
     private static function _register_admin_pages($addon_name)
820 820
     {
821
-        if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
821
+        if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
822 822
             EE_Register_Admin_Page::register(
823 823
                 $addon_name,
824
-                array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
824
+                array('page_path' => self::$_settings[$addon_name]['admin_path'])
825 825
             );
826 826
         }
827 827
     }
@@ -834,10 +834,10 @@  discard block
 block discarded – undo
834 834
      */
835 835
     private static function _register_modules($addon_name)
836 836
     {
837
-        if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
837
+        if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
838 838
             EE_Register_Module::register(
839 839
                 $addon_name,
840
-                array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
840
+                array('module_paths' => self::$_settings[$addon_name]['module_paths'])
841 841
             );
842 842
         }
843 843
     }
@@ -851,16 +851,16 @@  discard block
 block discarded – undo
851 851
     private static function _register_shortcodes($addon_name)
852 852
     {
853 853
         if (
854
-            ! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
855
-            || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
854
+            ! empty(self::$_settings[$addon_name]['shortcode_paths'])
855
+            || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
856 856
         ) {
857 857
             EE_Register_Shortcode::register(
858 858
                 $addon_name,
859 859
                 array(
860
-                    'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
861
-                        ? self::$_settings[ $addon_name ]['shortcode_paths'] : array(),
862
-                    'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
863
-                        ? self::$_settings[ $addon_name ]['shortcode_fqcns'] : array(),
860
+                    'shortcode_paths' => isset(self::$_settings[$addon_name]['shortcode_paths'])
861
+                        ? self::$_settings[$addon_name]['shortcode_paths'] : array(),
862
+                    'shortcode_fqcns' => isset(self::$_settings[$addon_name]['shortcode_fqcns'])
863
+                        ? self::$_settings[$addon_name]['shortcode_fqcns'] : array(),
864 864
                 )
865 865
             );
866 866
         }
@@ -874,10 +874,10 @@  discard block
 block discarded – undo
874 874
      */
875 875
     private static function _register_widgets($addon_name)
876 876
     {
877
-        if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
877
+        if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
878 878
             EE_Register_Widget::register(
879 879
                 $addon_name,
880
-                array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
880
+                array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])
881 881
             );
882 882
         }
883 883
     }
@@ -890,12 +890,12 @@  discard block
 block discarded – undo
890 890
      */
891 891
     private static function _register_capabilities($addon_name)
892 892
     {
893
-        if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
893
+        if ( ! empty(self::$_settings[$addon_name]['capabilities'])) {
894 894
             EE_Register_Capabilities::register(
895 895
                 $addon_name,
896 896
                 array(
897
-                    'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
898
-                    'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
897
+                    'capabilities'    => self::$_settings[$addon_name]['capabilities'],
898
+                    'capability_maps' => self::$_settings[$addon_name]['capability_maps'],
899 899
                 )
900 900
             );
901 901
         }
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
      */
909 909
     private static function _register_message_types($addon_name)
910 910
     {
911
-        if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
911
+        if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
912 912
             add_action(
913 913
                 'EE_Brewing_Regular___messages_caf',
914 914
                 array('EE_Register_Addon', 'register_message_types')
@@ -925,15 +925,15 @@  discard block
 block discarded – undo
925 925
     private static function _register_custom_post_types($addon_name)
926 926
     {
927 927
         if (
928
-            ! empty(self::$_settings[ $addon_name ]['custom_post_types'])
929
-            || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
928
+            ! empty(self::$_settings[$addon_name]['custom_post_types'])
929
+            || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])
930 930
         ) {
931 931
             EE_Register_CPT::register(
932 932
                 $addon_name,
933 933
                 array(
934
-                    'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
935
-                    'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
936
-                    'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
934
+                    'cpts'          => self::$_settings[$addon_name]['custom_post_types'],
935
+                    'cts'           => self::$_settings[$addon_name]['custom_taxonomies'],
936
+                    'default_terms' => self::$_settings[$addon_name]['default_terms'],
937 937
                 )
938 938
             );
939 939
         }
@@ -951,10 +951,10 @@  discard block
 block discarded – undo
951 951
      */
952 952
     private static function _register_payment_methods($addon_name)
953 953
     {
954
-        if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
954
+        if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
955 955
             EE_Register_Payment_Method::register(
956 956
                 $addon_name,
957
-                array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
957
+                array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])
958 958
             );
959 959
         }
960 960
     }
@@ -970,10 +970,10 @@  discard block
 block discarded – undo
970 970
      */
971 971
     private static function registerPrivacyPolicies($addon_name)
972 972
     {
973
-        if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) {
973
+        if ( ! empty(self::$_settings[$addon_name]['privacy_policies'])) {
974 974
             EE_Register_Privacy_Policy::register(
975 975
                 $addon_name,
976
-                self::$_settings[ $addon_name ]['privacy_policies']
976
+                self::$_settings[$addon_name]['privacy_policies']
977 977
             );
978 978
         }
979 979
     }
@@ -985,10 +985,10 @@  discard block
 block discarded – undo
985 985
      */
986 986
     private static function registerPersonalDataExporters($addon_name)
987 987
     {
988
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) {
988
+        if ( ! empty(self::$_settings[$addon_name]['personal_data_exporters'])) {
989 989
             EE_Register_Personal_Data_Eraser::register(
990 990
                 $addon_name,
991
-                self::$_settings[ $addon_name ]['personal_data_exporters']
991
+                self::$_settings[$addon_name]['personal_data_exporters']
992 992
             );
993 993
         }
994 994
     }
@@ -1000,10 +1000,10 @@  discard block
 block discarded – undo
1000 1000
      */
1001 1001
     private static function registerPersonalDataErasers($addon_name)
1002 1002
     {
1003
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) {
1003
+        if ( ! empty(self::$_settings[$addon_name]['personal_data_erasers'])) {
1004 1004
             EE_Register_Personal_Data_Eraser::register(
1005 1005
                 $addon_name,
1006
-                self::$_settings[ $addon_name ]['personal_data_erasers']
1006
+                self::$_settings[$addon_name]['personal_data_erasers']
1007 1007
             );
1008 1008
         }
1009 1009
     }
@@ -1021,10 +1021,10 @@  discard block
 block discarded – undo
1021 1021
     private static function _load_and_init_addon_class($addon_name)
1022 1022
     {
1023 1023
         $addon = LoaderFactory::getLoader()->getShared(
1024
-            self::$_settings[ $addon_name ]['class_name'],
1024
+            self::$_settings[$addon_name]['class_name'],
1025 1025
             array('EE_Registry::create(addon)' => true)
1026 1026
         );
1027
-        if (! $addon instanceof EE_Addon) {
1027
+        if ( ! $addon instanceof EE_Addon) {
1028 1028
             throw new DomainException(
1029 1029
                 sprintf(
1030 1030
                     esc_html__(
@@ -1043,28 +1043,28 @@  discard block
 block discarded – undo
1043 1043
         EE_Register_Addon::injectAddonDomain($addon_name, $addon);
1044 1044
 
1045 1045
         $addon->set_name($addon_name);
1046
-        $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
1047
-        $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
1048
-        $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
1049
-        $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
1050
-        $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
1051
-        $addon->set_version(self::$_settings[ $addon_name ]['version']);
1052
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
1053
-        $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
1054
-        $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
1055
-        $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
1046
+        $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']);
1047
+        $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']);
1048
+        $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']);
1049
+        $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']);
1050
+        $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']);
1051
+        $addon->set_version(self::$_settings[$addon_name]['version']);
1052
+        $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version']));
1053
+        $addon->set_config_section(self::$_settings[$addon_name]['config_section']);
1054
+        $addon->set_config_class(self::$_settings[$addon_name]['config_class']);
1055
+        $addon->set_config_name(self::$_settings[$addon_name]['config_name']);
1056 1056
         // setup the add-on's pue_slug if we have one.
1057
-        if (! empty(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug'])) {
1058
-            $addon->setPueSlug(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug']);
1057
+        if ( ! empty(self::$_settings[$addon_name]['pue_options']['pue_plugin_slug'])) {
1058
+            $addon->setPueSlug(self::$_settings[$addon_name]['pue_options']['pue_plugin_slug']);
1059 1059
         }
1060 1060
         // unfortunately this can't be hooked in upon construction,
1061 1061
         // because we don't have the plugin's mainfile path upon construction.
1062 1062
         register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
1063 1063
         // call any additional admin_callback functions during load_admin_controller hook
1064
-        if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1064
+        if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) {
1065 1065
             add_action(
1066 1066
                 'AHEE__EE_System__load_controllers__load_admin_controllers',
1067
-                array($addon, self::$_settings[ $addon_name ]['admin_callback'])
1067
+                array($addon, self::$_settings[$addon_name]['admin_callback'])
1068 1068
             );
1069 1069
         }
1070 1070
         return $addon;
@@ -1080,19 +1080,19 @@  discard block
 block discarded – undo
1080 1080
     {
1081 1081
         if ($addon instanceof RequiresDomainInterface && $addon->domain() === null) {
1082 1082
             // using supplied Domain object
1083
-            $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
1084
-                ? self::$_settings[ $addon_name ]['domain']
1083
+            $domain = self::$_settings[$addon_name]['domain'] instanceof DomainInterface
1084
+                ? self::$_settings[$addon_name]['domain']
1085 1085
                 : null;
1086 1086
             // or construct one using Domain FQCN
1087
-            if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
1087
+            if ($domain === null && self::$_settings[$addon_name]['domain_fqcn'] !== '') {
1088 1088
                 $domain = LoaderFactory::getLoader()->getShared(
1089
-                    self::$_settings[ $addon_name ]['domain_fqcn'],
1089
+                    self::$_settings[$addon_name]['domain_fqcn'],
1090 1090
                     [
1091 1091
                         new EventEspresso\core\domain\values\FilePath(
1092
-                            self::$_settings[ $addon_name ]['main_file_path']
1092
+                            self::$_settings[$addon_name]['main_file_path']
1093 1093
                         ),
1094 1094
                         EventEspresso\core\domain\values\Version::fromString(
1095
-                            self::$_settings[ $addon_name ]['version']
1095
+                            self::$_settings[$addon_name]['version']
1096 1096
                         ),
1097 1097
                     ]
1098 1098
                 );
@@ -1115,10 +1115,10 @@  discard block
 block discarded – undo
1115 1115
     public static function load_pue_update()
1116 1116
     {
1117 1117
         // PUE client existence
1118
-        if (! is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) return;
1118
+        if ( ! is_readable(EE_THIRD_PARTY.'pue/pue-client.php')) return;
1119 1119
 
1120 1120
         // load PUE client
1121
-        require_once EE_THIRD_PARTY . 'pue/pue-client.php';
1121
+        require_once EE_THIRD_PARTY.'pue/pue-client.php';
1122 1122
         $license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com';
1123 1123
         // cycle thru settings
1124 1124
         foreach (self::$_settings as $settings) {
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
                 // plugin slug(s)
1132 1132
                 array(
1133 1133
                     'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1134
-                    'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1134
+                    'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'),
1135 1135
                 ),
1136 1136
                 // options
1137 1137
                 array(
@@ -1159,7 +1159,7 @@  discard block
 block discarded – undo
1159 1159
     public static function register_message_types()
1160 1160
     {
1161 1161
         foreach (self::$_settings as $settings) {
1162
-            if (! empty($settings['message_types'])) {
1162
+            if ( ! empty($settings['message_types'])) {
1163 1163
                 foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1164 1164
                     EE_Register_Message_Type::register($message_type, $message_type_settings);
1165 1165
                 }
@@ -1180,74 +1180,74 @@  discard block
 block discarded – undo
1180 1180
      */
1181 1181
     public static function deregister($addon_name = '')
1182 1182
     {
1183
-        if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1183
+        if (isset(self::$_settings[$addon_name]['class_name'])) {
1184 1184
             try {
1185 1185
                 do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1186
-                $class_name = self::$_settings[ $addon_name ]['class_name'];
1187
-                if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1186
+                $class_name = self::$_settings[$addon_name]['class_name'];
1187
+                if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
1188 1188
                     // setup DMS
1189 1189
                     EE_Register_Data_Migration_Scripts::deregister($addon_name);
1190 1190
                 }
1191
-                if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1191
+                if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
1192 1192
                     // register admin page
1193 1193
                     EE_Register_Admin_Page::deregister($addon_name);
1194 1194
                 }
1195
-                if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1195
+                if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
1196 1196
                     // add to list of modules to be registered
1197 1197
                     EE_Register_Module::deregister($addon_name);
1198 1198
                 }
1199 1199
                 if (
1200
-                    ! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1201
-                    || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1200
+                    ! empty(self::$_settings[$addon_name]['shortcode_paths'])
1201
+                    || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
1202 1202
                 ) {
1203 1203
                     // add to list of shortcodes to be registered
1204 1204
                     EE_Register_Shortcode::deregister($addon_name);
1205 1205
                 }
1206
-                if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1206
+                if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
1207 1207
                     // if config_class present let's register config.
1208
-                    EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1208
+                    EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1209 1209
                 }
1210
-                if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1210
+                if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
1211 1211
                     // add to list of widgets to be registered
1212 1212
                     EE_Register_Widget::deregister($addon_name);
1213 1213
                 }
1214 1214
                 if (
1215
-                    ! empty(self::$_settings[ $addon_name ]['model_paths'])
1216
-                    || ! empty(self::$_settings[ $addon_name ]['class_paths'])
1215
+                    ! empty(self::$_settings[$addon_name]['model_paths'])
1216
+                    || ! empty(self::$_settings[$addon_name]['class_paths'])
1217 1217
                 ) {
1218 1218
                     // add to list of shortcodes to be registered
1219 1219
                     EE_Register_Model::deregister($addon_name);
1220 1220
                 }
1221 1221
                 if (
1222
-                    ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1223
-                    || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1222
+                    ! empty(self::$_settings[$addon_name]['model_extension_paths'])
1223
+                    || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
1224 1224
                 ) {
1225 1225
                     // add to list of shortcodes to be registered
1226 1226
                     EE_Register_Model_Extensions::deregister($addon_name);
1227 1227
                 }
1228
-                if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1229
-                    foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1228
+                if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
1229
+                    foreach ((array) self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
1230 1230
                         EE_Register_Message_Type::deregister($message_type);
1231 1231
                     }
1232 1232
                 }
1233 1233
                 // deregister capabilities for addon
1234 1234
                 if (
1235
-                    ! empty(self::$_settings[ $addon_name ]['capabilities'])
1236
-                    || ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1235
+                    ! empty(self::$_settings[$addon_name]['capabilities'])
1236
+                    || ! empty(self::$_settings[$addon_name]['capability_maps'])
1237 1237
                 ) {
1238 1238
                     EE_Register_Capabilities::deregister($addon_name);
1239 1239
                 }
1240 1240
                 // deregister custom_post_types for addon
1241
-                if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1241
+                if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1242 1242
                     EE_Register_CPT::deregister($addon_name);
1243 1243
                 }
1244
-                if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1244
+                if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1245 1245
                     EE_Register_Payment_Method::deregister($addon_name);
1246 1246
                 }
1247 1247
                 $addon = EE_Registry::instance()->getAddon($class_name);
1248 1248
                 if ($addon instanceof EE_Addon) {
1249 1249
                     remove_action(
1250
-                        'deactivate_' . $addon->get_main_plugin_file_basename(),
1250
+                        'deactivate_'.$addon->get_main_plugin_file_basename(),
1251 1251
                         array($addon, 'deactivation')
1252 1252
                     );
1253 1253
                     remove_action(
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
             } catch (Exception $e) {
1272 1272
                 new ExceptionLogger($e);
1273 1273
             }
1274
-            unset(self::$_settings[ $addon_name ]);
1274
+            unset(self::$_settings[$addon_name]);
1275 1275
             do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1276 1276
         }
1277 1277
     }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1115,14 +1115,18 @@
 block discarded – undo
1115 1115
     public static function load_pue_update()
1116 1116
     {
1117 1117
         // PUE client existence
1118
-        if (! is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) return;
1118
+        if (! is_readable(EE_THIRD_PARTY . 'pue/pue-client.php')) {
1119
+        	return;
1120
+        }
1119 1121
 
1120 1122
         // load PUE client
1121 1123
         require_once EE_THIRD_PARTY . 'pue/pue-client.php';
1122 1124
         $license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com';
1123 1125
         // cycle thru settings
1124 1126
         foreach (self::$_settings as $settings) {
1125
-            if (empty($settings['pue_options'])) continue;
1127
+            if (empty($settings['pue_options'])) {
1128
+            	continue;
1129
+            }
1126 1130
 
1127 1131
             // initiate the class and start the plugin update engine!
1128 1132
             new PluginUpdateEngineChecker(
Please login to merge, or discard this patch.