Completed
Branch BUG/3575-event-deletion-previe... (bbeda1)
by
unknown
06:40 queued 04:49
created
core/admin/templates/admin_details_metabox_column_wrapper.template.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@
 block discarded – undo
19 19
         </div> <!-- post-body-content -->
20 20
 
21 21
         <?php
22
-        // let's loop through the columns
23
-        for ($i = 1; $i <= $num_columns; $i++) {
24
-            $context = ($i === 1) ? 'normal' : 'side';
25
-            $context = ($i > 2) ? 'column' . $i : $context;
26
-            ?>
22
+		// let's loop through the columns
23
+		for ($i = 1; $i <= $num_columns; $i++) {
24
+			$context = ($i === 1) ? 'normal' : 'side';
25
+			$context = ($i > 2) ? 'column' . $i : $context;
26
+			?>
27 27
         <div id='postbox-container-<?php echo $i; ?>' class='postbox-container'>
28 28
             <?php do_meta_boxes($current_page, $context, null); ?>
29 29
         </div>
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
         // let's loop through the columns
23 23
         for ($i = 1; $i <= $num_columns; $i++) {
24 24
             $context = ($i === 1) ? 'normal' : 'side';
25
-            $context = ($i > 2) ? 'column' . $i : $context;
25
+            $context = ($i > 2) ? 'column'.$i : $context;
26 26
             ?>
27 27
         <div id='postbox-container-<?php echo $i; ?>' class='postbox-container'>
28 28
             <?php do_meta_boxes($current_page, $context, null); ?>
Please login to merge, or discard this patch.
core/admin/templates/admin_details_wrapper.template.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 do_action('add_meta_boxes', (string) $post_type, $post);
12 12
 ?>
13 13
 
14
-<?php if (! empty($admin_page_header)) : ?>
14
+<?php if ( ! empty($admin_page_header)) : ?>
15 15
     <div id="admin-page-header">
16 16
         <?php echo $admin_page_header; // already escaped ?>
17 17
     </div>
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     <!-- admin-page-header -->
21 21
     <div id="post-body" class="metabox-holder columns-2">
22 22
 
23
-        <?php if (! empty($post_body_content)) : ?>
23
+        <?php if ( ! empty($post_body_content)) : ?>
24 24
             <div id="post-body-content">
25 25
                 <?php echo $post_body_content; // already escaped ?>
26 26
             </div>
Please login to merge, or discard this patch.
core/admin/templates/admin_details_wrapper_no_sidebar.template.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 <div id="<?php echo $admin_page_wrapper_div_id; // already escaped ?>">
11 11
     <div id="post-body" class="metabox-holder columns-1">
12 12
 
13
-        <?php if (! empty($admin_page_header)) : ?>
13
+        <?php if ( ! empty($admin_page_header)) : ?>
14 14
             <div id="admin-page-header">
15 15
                 <?php echo $admin_page_header; // already escaped ?>
16 16
             </div>
Please login to merge, or discard this patch.
core/admin/EE_Admin.core.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     public static function instance(RequestInterface $request = null)
52 52
     {
53 53
         // check if class object is instantiated
54
-        if (! self::$_instance instanceof EE_Admin) {
54
+        if ( ! self::$_instance instanceof EE_Admin) {
55 55
             self::$_instance = new self($request);
56 56
         }
57 57
         return self::$_instance;
@@ -113,11 +113,11 @@  discard block
 block discarded – undo
113 113
      */
114 114
     private function _define_all_constants()
115 115
     {
116
-        if (! defined('EE_ADMIN_URL')) {
117
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
118
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
119
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/');
120
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
116
+        if ( ! defined('EE_ADMIN_URL')) {
117
+            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/');
118
+            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/');
119
+            define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates/');
120
+            define('WP_ADMIN_PATH', ABSPATH.'wp-admin/');
121 121
             define('WP_AJAX_URL', admin_url('admin-ajax.php'));
122 122
         }
123 123
     }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         // set $main_file in stone
136 136
         static $main_file;
137 137
         // if $main_file is not set yet
138
-        if (! $main_file) {
138
+        if ( ! $main_file) {
139 139
             $main_file = EE_PLUGIN_BASENAME;
140 140
         }
141 141
         if ($plugin === $main_file) {
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = [])
179 179
     {
180 180
         return [
181
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance/',
182
-            'about'       => EE_ADMIN_PAGES . 'about/',
183
-            'support'     => EE_ADMIN_PAGES . 'support/',
181
+            'maintenance' => EE_ADMIN_PAGES.'maintenance/',
182
+            'about'       => EE_ADMIN_PAGES.'about/',
183
+            'support'     => EE_ADMIN_PAGES.'support/',
184 184
         ];
185 185
     }
186 186
 
@@ -299,13 +299,13 @@  discard block
 block discarded – undo
299 299
                     '</strong>',
300 300
                     '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
301 301
                     '</a>',
302
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
302
+                    '<a href="'.EE_Admin_Page::add_query_args_and_nonce(
303 303
                         [
304 304
                             'page'   => 'espresso_maintenance_settings',
305 305
                             'action' => 'datetime_tools',
306 306
                         ],
307 307
                         admin_url('admin.php')
308
-                    ) . '">'
308
+                    ).'">'
309 309
                 ),
310 310
                 false,
311 311
                 'manage_options',
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
     public function enable_hidden_ee_nav_menu_metaboxes()
352 352
     {
353 353
         global $wp_meta_boxes, $pagenow;
354
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
354
+        if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
355 355
             return;
356 356
         }
357 357
         $user = wp_get_current_user();
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
         if (is_array($hidden_meta_boxes)) {
381 381
             foreach ($hidden_meta_boxes as $key => $meta_box_id) {
382 382
                 if (in_array($meta_box_id, $initial_meta_boxes, true)) {
383
-                    unset($hidden_meta_boxes[ $key ]);
383
+                    unset($hidden_meta_boxes[$key]);
384 384
                 }
385 385
             }
386 386
         }
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
      */
421 421
     public function modify_edit_post_link($link, $id)
422 422
     {
423
-        if (! $post = get_post($id)) {
423
+        if ( ! $post = get_post($id)) {
424 424
             return $link;
425 425
         }
426 426
         if ($post->post_type === 'espresso_attendees') {
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
         );
480 480
 
481 481
         EEH_Template::display_template(
482
-            EE_ADMIN_TEMPLATE . 'cpt_archive_page.template.php',
482
+            EE_ADMIN_TEMPLATE.'cpt_archive_page.template.php',
483 483
             [
484 484
                 $nav_menu_pages_items,
485 485
                 $nav_tab_link,
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
         ];
538 538
 
539 539
         foreach ($keys as $key => $value) {
540
-            $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
540
+            $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value;
541 541
         }
542 542
         return $menu_item;
543 543
     }
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
 
634 634
         // loop through to remove any critical pages from the array.
635 635
         foreach ($critical_pages as $page_id) {
636
-            $needle = 'value="' . $page_id . '"';
636
+            $needle = 'value="'.$page_id.'"';
637 637
             foreach ($split_output as $key => $haystack) {
638 638
                 if (strpos($haystack, $needle) !== false) {
639
-                    unset($split_output[ $key ]);
639
+                    unset($split_output[$key]);
640 640
                 }
641 641
             }
642 642
         }
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
         // calls.
658 658
         wp_enqueue_script(
659 659
             'ee-inject-wp',
660
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
660
+            EE_ADMIN_URL.'assets/ee-cpt-wp-injects.js',
661 661
             ['jquery'],
662 662
             EVENT_ESPRESSO_VERSION,
663 663
             true
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
         // register cookie script for future dependencies
666 666
         wp_register_script(
667 667
             'jquery-cookie',
668
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
668
+            EE_THIRD_PARTY_URL.'joyride/jquery.cookie.js',
669 669
             ['jquery'],
670 670
             '2.1',
671 671
             true
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
             ['page' => 'espresso_events'],
732 732
             admin_url('admin.php')
733 733
         );
734
-        $items['events']['text']         = sprintf(
734
+        $items['events']['text'] = sprintf(
735 735
             esc_html(
736 736
                 _n('%s Event', '%s Events', $events, 'event_espresso')
737 737
             ),
@@ -745,11 +745,11 @@  discard block
 block discarded – undo
745 745
                 ],
746 746
             ]
747 747
         );
748
-        $items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
748
+        $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce(
749 749
             ['page' => 'espresso_registrations'],
750 750
             admin_url('admin.php')
751 751
         );
752
-        $items['registrations']['text']  = sprintf(
752
+        $items['registrations']['text'] = sprintf(
753 753
             esc_html(
754 754
                 _n('%s Registration', '%s Registrations', $registrations, 'event_espresso')
755 755
             ),
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 
762 762
         foreach ($items as $type => $item_properties) {
763 763
             $elements[] = sprintf(
764
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
764
+                '<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>',
765 765
                 $item_properties['url'],
766 766
                 $item_properties['title'],
767 767
                 $item_properties['text']
@@ -785,10 +785,10 @@  discard block
 block discarded – undo
785 785
         // check for date_format or time_format
786 786
         switch ($option) {
787 787
             case 'date_format':
788
-                $date_time_format = $value . ' ' . get_option('time_format');
788
+                $date_time_format = $value.' '.get_option('time_format');
789 789
                 break;
790 790
             case 'time_format':
791
-                $date_time_format = get_option('date_format') . ' ' . $value;
791
+                $date_time_format = get_option('date_format').' '.$value;
792 792
                 break;
793 793
             default:
794 794
                 $date_time_format = false;
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 
812 812
 
813 813
                 foreach ($error_msg as $error) {
814
-                    $msg .= '<li>' . $error . '</li>';
814
+                    $msg .= '<li>'.$error.'</li>';
815 815
                 }
816 816
 
817 817
                 $msg .= '</ul></p><p>'
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
     public function displayStateForCriticalPages($post_states, $post)
1003 1003
     {
1004 1004
         $post_states = (array) $post_states;
1005
-        if (! $post instanceof WP_Post || $post->post_type !== 'page') {
1005
+        if ( ! $post instanceof WP_Post || $post->post_type !== 'page') {
1006 1006
             return $post_states;
1007 1007
         }
1008 1008
         /** @var EE_Core_Config $config */
Please login to merge, or discard this patch.
Indentation   +1025 added lines, -1025 removed lines patch added patch discarded remove patch
@@ -21,1029 +21,1029 @@
 block discarded – undo
21 21
 final class EE_Admin implements InterminableInterface
22 22
 {
23 23
 
24
-    /**
25
-     * @var EE_Admin $_instance
26
-     */
27
-    private static $_instance;
28
-
29
-    /**
30
-     * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
31
-     */
32
-    private $persistent_admin_notice_manager;
33
-
34
-    /**
35
-     * @var LoaderInterface
36
-     */
37
-    protected $loader;
38
-
39
-    /**
40
-     * @var RequestInterface
41
-     */
42
-    protected $request;
43
-
44
-
45
-    /**
46
-     * @param RequestInterface $request
47
-     * @singleton method used to instantiate class object
48
-     * @return EE_Admin
49
-     * @throws EE_Error
50
-     */
51
-    public static function instance(RequestInterface $request = null)
52
-    {
53
-        // check if class object is instantiated
54
-        if (! self::$_instance instanceof EE_Admin) {
55
-            self::$_instance = new self($request);
56
-        }
57
-        return self::$_instance;
58
-    }
59
-
60
-
61
-    /**
62
-     * @return EE_Admin
63
-     * @throws EE_Error
64
-     */
65
-    public static function reset()
66
-    {
67
-        self::$_instance = null;
68
-        $request         = LoaderFactory::getLoader()->getShared(RequestInterface::class);
69
-        return self::instance($request);
70
-    }
71
-
72
-
73
-    /**
74
-     * @param RequestInterface $request
75
-     * @throws EE_Error
76
-     * @throws InvalidDataTypeException
77
-     * @throws InvalidInterfaceException
78
-     * @throws InvalidArgumentException
79
-     */
80
-    protected function __construct(RequestInterface $request)
81
-    {
82
-        $this->request = $request;
83
-        $this->loader = LoaderFactory::getLoader();
84
-        // define global EE_Admin constants
85
-        $this->_define_all_constants();
86
-        // set autoloaders for our admin page classes based on included path information
87
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
88
-        // admin hooks
89
-        add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2);
90
-        add_action('AHEE__EE_System__initialize_last', [$this, 'init']);
91
-        add_action('AHEE__EE_Admin_Page__route_admin_request', [$this, 'route_admin_request'], 100, 2);
92
-        add_action('wp_loaded', [$this, 'wp_loaded'], 100);
93
-        add_action('admin_init', [$this, 'admin_init'], 100);
94
-        add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts'], 20);
95
-        add_action('admin_notices', [$this, 'display_admin_notices'], 10);
96
-        add_action('network_admin_notices', [$this, 'display_admin_notices'], 10);
97
-        add_filter('pre_update_option', [$this, 'check_for_invalid_datetime_formats'], 100, 2);
98
-        add_filter('admin_footer_text', [$this, 'espresso_admin_footer']);
99
-        add_action('load-plugins.php', [$this, 'hookIntoWpPluginsPage']);
100
-        add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2);
101
-        add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2);
102
-        // reset Environment config (we only do this on admin page loads);
103
-        EE_Registry::instance()->CFG->environment->recheck_values();
104
-        do_action('AHEE__EE_Admin__loaded');
105
-    }
106
-
107
-
108
-    /**
109
-     * _define_all_constants
110
-     * define constants that are set globally for all admin pages
111
-     *
112
-     * @return void
113
-     */
114
-    private function _define_all_constants()
115
-    {
116
-        if (! defined('EE_ADMIN_URL')) {
117
-            define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
118
-            define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
119
-            define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/');
120
-            define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
121
-            define('WP_AJAX_URL', admin_url('admin-ajax.php'));
122
-        }
123
-    }
124
-
125
-
126
-    /**
127
-     * filter_plugin_actions - adds links to the Plugins page listing
128
-     *
129
-     * @param array  $links
130
-     * @param string $plugin
131
-     * @return    array
132
-     */
133
-    public function filter_plugin_actions($links, $plugin)
134
-    {
135
-        // set $main_file in stone
136
-        static $main_file;
137
-        // if $main_file is not set yet
138
-        if (! $main_file) {
139
-            $main_file = EE_PLUGIN_BASENAME;
140
-        }
141
-        if ($plugin === $main_file) {
142
-            // compare current plugin to this one
143
-            if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
144
-                $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
145
-                                    . ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
146
-                                    . esc_html__('Maintenance Mode Active', 'event_espresso')
147
-                                    . '</a>';
148
-                array_unshift($links, $maintenance_link);
149
-            } else {
150
-                $org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
151
-                                     . esc_html__('Settings', 'event_espresso')
152
-                                     . '</a>';
153
-                $events_link       = '<a href="admin.php?page=espresso_events">'
154
-                                     . esc_html__('Events', 'event_espresso')
155
-                                     . '</a>';
156
-                // add before other links
157
-                array_unshift($links, $org_settings_link, $events_link);
158
-            }
159
-        }
160
-        return $links;
161
-    }
162
-
163
-
164
-    /**
165
-     * @deprecated 4.10.14.p
166
-     */
167
-    public function get_request()
168
-    {
169
-    }
170
-
171
-
172
-    /**
173
-     * hide_admin_pages_except_maintenance_mode
174
-     *
175
-     * @param array $admin_page_folder_names
176
-     * @return array
177
-     */
178
-    public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = [])
179
-    {
180
-        return [
181
-            'maintenance' => EE_ADMIN_PAGES . 'maintenance/',
182
-            'about'       => EE_ADMIN_PAGES . 'about/',
183
-            'support'     => EE_ADMIN_PAGES . 'support/',
184
-        ];
185
-    }
186
-
187
-
188
-    /**
189
-     * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
190
-     * EE_Front_Controller's init phases have run
191
-     *
192
-     * @return void
193
-     * @throws EE_Error
194
-     * @throws InvalidArgumentException
195
-     * @throws InvalidDataTypeException
196
-     * @throws InvalidInterfaceException
197
-     * @throws ReflectionException
198
-     * @throws ServiceNotFoundException
199
-     */
200
-    public function init()
201
-    {
202
-        // only enable most of the EE_Admin IF we're not in full maintenance mode
203
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
204
-            $this->initModelsReady();
205
-        }
206
-        // run the admin page factory but ONLY if:
207
-        // - it is a regular non ajax admin request
208
-        // - we are doing an ee admin ajax request
209
-        if ($this->request->isAdmin() || $this->request->isAdminAjax()) {
210
-            // this loads the controller for the admin pages which will setup routing etc
211
-            $this->loader->getShared('EE_Admin_Page_Loader', [$this->loader]);
212
-        }
213
-        if ($this->request->isAdminAjax()) {
214
-            return;
215
-        }
216
-        add_filter('content_save_pre', [$this, 'its_eSpresso'], 10, 1);
217
-        // make sure our CPTs and custom taxonomy metaboxes get shown for first time users
218
-        add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10);
219
-        add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10);
220
-        // exclude EE critical pages from all nav menus and wp_list_pages
221
-        add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu'], 10);
222
-    }
223
-
224
-
225
-    /**
226
-     * Gets the loader (and if it wasn't previously set, sets it)
227
-     *
228
-     * @return LoaderInterface
229
-     * @throws InvalidArgumentException
230
-     * @throws InvalidDataTypeException
231
-     * @throws InvalidInterfaceException
232
-     */
233
-    protected function getLoader()
234
-    {
235
-        return $this->loader;
236
-    }
237
-
238
-
239
-    /**
240
-     * Method that's fired on admin requests (including admin ajax) but only when the models are usable
241
-     * (ie, the site isn't in maintenance mode)
242
-     *
243
-     * @return void
244
-     * @throws EE_Error
245
-     * @since 4.9.63.p
246
-     */
247
-    protected function initModelsReady()
248
-    {
249
-        // ok so we want to enable the entire admin
250
-        $this->persistent_admin_notice_manager = $this->loader->getShared(
251
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
252
-        );
253
-        $this->persistent_admin_notice_manager->setReturnUrl(
254
-            EE_Admin_Page::add_query_args_and_nonce(
255
-                [
256
-                    'page'   => $this->request->getRequestParam('page'),
257
-                    'action' => $this->request->getRequestParam('action'),
258
-                ],
259
-                EE_ADMIN_URL
260
-            )
261
-        );
262
-        $this->maybeSetDatetimeWarningNotice();
263
-        // at a glance dashboard widget
264
-        add_filter('dashboard_glance_items', [$this, 'dashboard_glance_items'], 10);
265
-        // filter for get_edit_post_link used on comments for custom post types
266
-        add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 2);
267
-    }
268
-
269
-
270
-    /**
271
-     *    get_persistent_admin_notices
272
-     *
273
-     * @access    public
274
-     * @return void
275
-     * @throws EE_Error
276
-     * @throws InvalidArgumentException
277
-     * @throws InvalidDataTypeException
278
-     * @throws InvalidInterfaceException
279
-     */
280
-    public function maybeSetDatetimeWarningNotice()
281
-    {
282
-        // add dismissible notice for datetime changes.  Only valid if site does not have a timezone_string set.
283
-        // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
284
-        // with this.  But after enough time (indeterminate at this point) we can just remove this notice.
285
-        // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
286
-        if (
287
-            apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
288
-            && ! get_option('timezone_string')
289
-            && EEM_Event::instance()->count() > 0
290
-        ) {
291
-            new PersistentAdminNotice(
292
-                'datetime_fix_notice',
293
-                sprintf(
294
-                    esc_html__(
295
-                        '%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.',
296
-                        'event_espresso'
297
-                    ),
298
-                    '<strong>',
299
-                    '</strong>',
300
-                    '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
301
-                    '</a>',
302
-                    '<a href="' . EE_Admin_Page::add_query_args_and_nonce(
303
-                        [
304
-                            'page'   => 'espresso_maintenance_settings',
305
-                            'action' => 'datetime_tools',
306
-                        ],
307
-                        admin_url('admin.php')
308
-                    ) . '">'
309
-                ),
310
-                false,
311
-                'manage_options',
312
-                'datetime_fix_persistent_notice'
313
-            );
314
-        }
315
-    }
316
-
317
-
318
-    /**
319
-     * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
320
-     * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
321
-     * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
322
-     * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
323
-     * normal property on the post_type object.  It's found ONLY in this particular context.
324
-     *
325
-     * @param WP_Post $post_type WP post type object
326
-     * @return WP_Post
327
-     * @throws InvalidArgumentException
328
-     * @throws InvalidDataTypeException
329
-     * @throws InvalidInterfaceException
330
-     */
331
-    public function remove_pages_from_nav_menu($post_type)
332
-    {
333
-        // if this isn't the "pages" post type let's get out
334
-        if ($post_type->name !== 'page') {
335
-            return $post_type;
336
-        }
337
-        $critical_pages            = EE_Registry::instance()->CFG->core->get_critical_pages_array();
338
-        $post_type->_default_query = [
339
-            'post__not_in' => $critical_pages,
340
-        ];
341
-        return $post_type;
342
-    }
343
-
344
-
345
-    /**
346
-     * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
347
-     * metaboxes get shown as well
348
-     *
349
-     * @return void
350
-     */
351
-    public function enable_hidden_ee_nav_menu_metaboxes()
352
-    {
353
-        global $wp_meta_boxes, $pagenow;
354
-        if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
355
-            return;
356
-        }
357
-        $user = wp_get_current_user();
358
-        // has this been done yet?
359
-        if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
360
-            return;
361
-        }
362
-
363
-        $hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
364
-        $initial_meta_boxes = apply_filters(
365
-            'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
366
-            [
367
-                'nav-menu-theme-locations',
368
-                'add-page',
369
-                'add-custom-links',
370
-                'add-category',
371
-                'add-espresso_events',
372
-                'add-espresso_venues',
373
-                'add-espresso_event_categories',
374
-                'add-espresso_venue_categories',
375
-                'add-post-type-post',
376
-                'add-post-type-page',
377
-            ]
378
-        );
379
-
380
-        if (is_array($hidden_meta_boxes)) {
381
-            foreach ($hidden_meta_boxes as $key => $meta_box_id) {
382
-                if (in_array($meta_box_id, $initial_meta_boxes, true)) {
383
-                    unset($hidden_meta_boxes[ $key ]);
384
-                }
385
-            }
386
-        }
387
-        update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
388
-        update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
389
-    }
390
-
391
-
392
-    /**
393
-     * This method simply registers custom nav menu boxes for "nav_menus.php route"
394
-     * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
395
-     *
396
-     * @return void
397
-     * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
398
-     *         addons etc.
399
-     */
400
-    public function register_custom_nav_menu_boxes()
401
-    {
402
-        add_meta_box(
403
-            'add-extra-nav-menu-pages',
404
-            esc_html__('Event Espresso Pages', 'event_espresso'),
405
-            [$this, 'ee_cpt_archive_pages'],
406
-            'nav-menus',
407
-            'side',
408
-            'core'
409
-        );
410
-    }
411
-
412
-
413
-    /**
414
-     * Use this to edit the post link for our cpts so that the edit link points to the correct page.
415
-     *
416
-     * @param string $link the original link generated by wp
417
-     * @param int    $id   post id
418
-     * @return string  the (maybe) modified link
419
-     * @since   4.3.0
420
-     */
421
-    public function modify_edit_post_link($link, $id)
422
-    {
423
-        if (! $post = get_post($id)) {
424
-            return $link;
425
-        }
426
-        if ($post->post_type === 'espresso_attendees') {
427
-            $query_args = [
428
-                'action' => 'edit_attendee',
429
-                'post'   => $id,
430
-            ];
431
-            return EEH_URL::add_query_args_and_nonce(
432
-                $query_args,
433
-                admin_url('admin.php?page=espresso_registrations')
434
-            );
435
-        }
436
-        return $link;
437
-    }
438
-
439
-
440
-    public function ee_cpt_archive_pages()
441
-    {
442
-        global $nav_menu_selected_id;
443
-        $removed_args = [
444
-            'action',
445
-            'customlink-tab',
446
-            'edit-menu-item',
447
-            'menu-item',
448
-            'page-tab',
449
-            '_wpnonce',
450
-        ];
451
-        $nav_tab_link = $nav_menu_selected_id
452
-            ? esc_url(
453
-                add_query_arg(
454
-                    'extra-nav-menu-pages-tab',
455
-                    'event-archives',
456
-                    remove_query_arg($removed_args)
457
-                )
458
-            )
459
-            : '';
460
-        $select_all_link = esc_url(
461
-            add_query_arg(
462
-                [
463
-                    'extra-nav-menu-pages-tab' => 'event-archives',
464
-                    'selectall'                => 1,
465
-                ],
466
-                remove_query_arg($removed_args)
467
-            )
468
-        );
469
-        $pages = $this->_get_extra_nav_menu_pages_items();
470
-        $args['walker'] = new Walker_Nav_Menu_Checklist(false);
471
-        ;
472
-        $nav_menu_pages_items = walk_nav_menu_tree(
473
-            array_map(
474
-                [$this, '_setup_extra_nav_menu_pages_items'],
475
-                $pages
476
-            ),
477
-            0,
478
-            (object) $args
479
-        );
480
-
481
-        EEH_Template::display_template(
482
-            EE_ADMIN_TEMPLATE . 'cpt_archive_page.template.php',
483
-            [
484
-                $nav_menu_pages_items,
485
-                $nav_tab_link,
486
-                $select_all_link,
487
-            ]
488
-        );
489
-    }
490
-
491
-
492
-    /**
493
-     * Returns an array of event archive nav items.
494
-     *
495
-     * @return array
496
-     * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
497
-     *        method we use for getting the extra nav menu items
498
-     */
499
-    private function _get_extra_nav_menu_pages_items()
500
-    {
501
-        $menuitems[] = [
502
-            'title'       => esc_html__('Event List', 'event_espresso'),
503
-            'url'         => get_post_type_archive_link('espresso_events'),
504
-            'description' => esc_html__('Archive page for all events.', 'event_espresso'),
505
-        ];
506
-        return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
507
-    }
508
-
509
-
510
-    /**
511
-     * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
512
-     * the properties and converts it to the menu item object.
513
-     *
514
-     * @param $menu_item_values
515
-     * @return stdClass
516
-     * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
517
-     */
518
-    private function _setup_extra_nav_menu_pages_items($menu_item_values)
519
-    {
520
-        $menu_item = new stdClass();
521
-        $keys      = [
522
-            'ID'               => 0,
523
-            'db_id'            => 0,
524
-            'menu_item_parent' => 0,
525
-            'object_id'        => -1,
526
-            'post_parent'      => 0,
527
-            'type'             => 'custom',
528
-            'object'           => '',
529
-            'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
530
-            'title'            => '',
531
-            'url'              => '',
532
-            'target'           => '',
533
-            'attr_title'       => '',
534
-            'description'      => '',
535
-            'classes'          => [],
536
-            'xfn'              => '',
537
-        ];
538
-
539
-        foreach ($keys as $key => $value) {
540
-            $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
541
-        }
542
-        return $menu_item;
543
-    }
544
-
545
-
546
-    /**
547
-     * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
548
-     * EE_Admin_Page route is called.
549
-     *
550
-     * @return void
551
-     */
552
-    public function route_admin_request()
553
-    {
554
-    }
555
-
556
-
557
-    /**
558
-     * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
559
-     *
560
-     * @return void
561
-     */
562
-    public function wp_loaded()
563
-    {
564
-    }
565
-
566
-
567
-    /**
568
-     * admin_init
569
-     *
570
-     * @return void
571
-     * @throws InvalidArgumentException
572
-     * @throws InvalidDataTypeException
573
-     * @throws InvalidInterfaceException
574
-     */
575
-    public function admin_init()
576
-    {
577
-        /**
578
-         * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
579
-         * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
580
-         * - check if doing post processing.
581
-         * - check if doing post processing of one of EE CPTs
582
-         * - instantiate the corresponding EE CPT model for the post_type being processed.
583
-         */
584
-        $action    = $this->request->getRequestParam('action');
585
-        $post_type = $this->request->getRequestParam('post_type');
586
-        if ($post_type && $action === 'editpost') {
587
-            /** @var CustomPostTypeDefinitions $custom_post_types */
588
-            $custom_post_types = $this->loader->getShared(CustomPostTypeDefinitions::class);
589
-            $custom_post_types->getCustomPostTypeModels($post_type);
590
-        }
591
-
592
-
593
-        /**
594
-         * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
595
-         * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
596
-         * Pages" tab in the EE General Settings Admin page.
597
-         * This is for user-proofing.
598
-         */
599
-        add_filter('wp_dropdown_pages', [$this, 'modify_dropdown_pages']);
600
-        if (EE_Maintenance_Mode::instance()->models_can_query()) {
601
-            $this->adminInitModelsReady();
602
-        }
603
-    }
604
-
605
-
606
-    /**
607
-     * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode)
608
-     */
609
-    protected function adminInitModelsReady()
610
-    {
611
-        if (function_exists('wp_add_privacy_policy_content')) {
612
-            $this->loader->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager');
613
-        }
614
-    }
615
-
616
-
617
-    /**
618
-     * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
619
-     *
620
-     * @param string $output Current output.
621
-     * @return string
622
-     * @throws InvalidArgumentException
623
-     * @throws InvalidDataTypeException
624
-     * @throws InvalidInterfaceException
625
-     */
626
-    public function modify_dropdown_pages($output)
627
-    {
628
-        // get critical pages
629
-        $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
630
-
631
-        // split current output by line break for easier parsing.
632
-        $split_output = explode("\n", $output);
633
-
634
-        // loop through to remove any critical pages from the array.
635
-        foreach ($critical_pages as $page_id) {
636
-            $needle = 'value="' . $page_id . '"';
637
-            foreach ($split_output as $key => $haystack) {
638
-                if (strpos($haystack, $needle) !== false) {
639
-                    unset($split_output[ $key ]);
640
-                }
641
-            }
642
-        }
643
-        // replace output with the new contents
644
-        return implode("\n", $split_output);
645
-    }
646
-
647
-
648
-    /**
649
-     * enqueue all admin scripts that need loaded for admin pages
650
-     *
651
-     * @return void
652
-     */
653
-    public function enqueue_admin_scripts()
654
-    {
655
-        // this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
656
-        // Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
657
-        // calls.
658
-        wp_enqueue_script(
659
-            'ee-inject-wp',
660
-            EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
661
-            ['jquery'],
662
-            EVENT_ESPRESSO_VERSION,
663
-            true
664
-        );
665
-        // register cookie script for future dependencies
666
-        wp_register_script(
667
-            'jquery-cookie',
668
-            EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
669
-            ['jquery'],
670
-            '2.1',
671
-            true
672
-        );
673
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
674
-        // joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
675
-        // via: add_filter('FHEE_load_joyride', '__return_true' );
676
-        // if (apply_filters('FHEE_load_joyride', false)) {
677
-        //     // joyride style
678
-        //     wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
679
-        //     wp_register_style(
680
-        //         'ee-joyride-css',
681
-        //         EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
682
-        //         array('joyride-css'),
683
-        //         EVENT_ESPRESSO_VERSION
684
-        //     );
685
-        //     wp_register_script(
686
-        //         'joyride-modernizr',
687
-        //         EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
688
-        //         array(),
689
-        //         '2.1',
690
-        //         true
691
-        //     );
692
-        //     // joyride JS
693
-        //     wp_register_script(
694
-        //         'jquery-joyride',
695
-        //         EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
696
-        //         array('jquery-cookie', 'joyride-modernizr'),
697
-        //         '2.1',
698
-        //         true
699
-        //     );
700
-        //     // wanna go for a joyride?
701
-        //     wp_enqueue_style('ee-joyride-css');
702
-        //     wp_enqueue_script('jquery-joyride');
703
-        // }
704
-    }
705
-
706
-
707
-    /**
708
-     * display_admin_notices
709
-     *
710
-     * @return void
711
-     */
712
-    public function display_admin_notices()
713
-    {
714
-        echo EE_Error::get_notices(); // already escaped
715
-    }
716
-
717
-
718
-    /**
719
-     * @param array $elements
720
-     * @return array
721
-     * @throws EE_Error
722
-     * @throws InvalidArgumentException
723
-     * @throws InvalidDataTypeException
724
-     * @throws InvalidInterfaceException
725
-     */
726
-    public function dashboard_glance_items($elements)
727
-    {
728
-        $elements                        = is_array($elements) ? $elements : [$elements];
729
-        $events                          = EEM_Event::instance()->count();
730
-        $items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
731
-            ['page' => 'espresso_events'],
732
-            admin_url('admin.php')
733
-        );
734
-        $items['events']['text']         = sprintf(
735
-            esc_html(
736
-                _n('%s Event', '%s Events', $events, 'event_espresso')
737
-            ),
738
-            number_format_i18n($events)
739
-        );
740
-        $items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
741
-        $registrations                   = EEM_Registration::instance()->count(
742
-            [
743
-                [
744
-                    'STS_ID' => ['!=', EEM_Registration::status_id_incomplete],
745
-                ],
746
-            ]
747
-        );
748
-        $items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
749
-            ['page' => 'espresso_registrations'],
750
-            admin_url('admin.php')
751
-        );
752
-        $items['registrations']['text']  = sprintf(
753
-            esc_html(
754
-                _n('%s Registration', '%s Registrations', $registrations, 'event_espresso')
755
-            ),
756
-            number_format_i18n($registrations)
757
-        );
758
-        $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
759
-
760
-        $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
761
-
762
-        foreach ($items as $type => $item_properties) {
763
-            $elements[] = sprintf(
764
-                '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
765
-                $item_properties['url'],
766
-                $item_properties['title'],
767
-                $item_properties['text']
768
-            );
769
-        }
770
-        return $elements;
771
-    }
772
-
773
-
774
-    /**
775
-     * check_for_invalid_datetime_formats
776
-     * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
777
-     * their selected format can be parsed by PHP
778
-     *
779
-     * @param    $value
780
-     * @param    $option
781
-     * @return    string
782
-     */
783
-    public function check_for_invalid_datetime_formats($value, $option)
784
-    {
785
-        // check for date_format or time_format
786
-        switch ($option) {
787
-            case 'date_format':
788
-                $date_time_format = $value . ' ' . get_option('time_format');
789
-                break;
790
-            case 'time_format':
791
-                $date_time_format = get_option('date_format') . ' ' . $value;
792
-                break;
793
-            default:
794
-                $date_time_format = false;
795
-        }
796
-        // do we have a date_time format to check ?
797
-        if ($date_time_format) {
798
-            $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
799
-
800
-            if (is_array($error_msg)) {
801
-                $msg = '<p>'
802
-                       . sprintf(
803
-                           esc_html__(
804
-                               'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
805
-                               'event_espresso'
806
-                           ),
807
-                           date($date_time_format),
808
-                           $date_time_format
809
-                       )
810
-                       . '</p><p><ul>';
811
-
812
-
813
-                foreach ($error_msg as $error) {
814
-                    $msg .= '<li>' . $error . '</li>';
815
-                }
816
-
817
-                $msg .= '</ul></p><p>'
818
-                        . sprintf(
819
-                            esc_html__(
820
-                                '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
821
-                                'event_espresso'
822
-                            ),
823
-                            '<span style="color:#D54E21;">',
824
-                            '</span>'
825
-                        )
826
-                        . '</p>';
827
-
828
-                // trigger WP settings error
829
-                add_settings_error(
830
-                    'date_format',
831
-                    'date_format',
832
-                    $msg
833
-                );
834
-
835
-                // set format to something valid
836
-                switch ($option) {
837
-                    case 'date_format':
838
-                        $value = 'F j, Y';
839
-                        break;
840
-                    case 'time_format':
841
-                        $value = 'g:i a';
842
-                        break;
843
-                }
844
-            }
845
-        }
846
-        return $value;
847
-    }
848
-
849
-
850
-    /**
851
-     * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
852
-     *
853
-     * @param $content
854
-     * @return    string
855
-     */
856
-    public function its_eSpresso($content)
857
-    {
858
-        return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
859
-    }
860
-
861
-
862
-    /**
863
-     * espresso_admin_footer
864
-     *
865
-     * @return    string
866
-     */
867
-    public function espresso_admin_footer()
868
-    {
869
-        return EEH_Template::powered_by_event_espresso('aln-cntr', '', ['utm_content' => 'admin_footer']);
870
-    }
871
-
872
-
873
-    /**
874
-     * static method for registering ee admin page.
875
-     * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
876
-     *
877
-     * @param       $page_basename
878
-     * @param       $page_path
879
-     * @param array $config
880
-     * @return void
881
-     * @throws EE_Error
882
-     * @see        EE_Register_Admin_Page::register()
883
-     * @since      4.3.0
884
-     * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
885
-     */
886
-    public static function register_ee_admin_page($page_basename, $page_path, $config = [])
887
-    {
888
-        EE_Error::doing_it_wrong(
889
-            __METHOD__,
890
-            sprintf(
891
-                esc_html__(
892
-                    'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
893
-                    'event_espresso'
894
-                ),
895
-                $page_basename
896
-            ),
897
-            '4.3'
898
-        );
899
-        if (class_exists('EE_Register_Admin_Page')) {
900
-            $config['page_path'] = $page_path;
901
-        }
902
-        EE_Register_Admin_Page::register($page_basename, $config);
903
-    }
904
-
905
-
906
-    /**
907
-     * @param int     $post_ID
908
-     * @param WP_Post $post
909
-     * @return void
910
-     * @deprecated 4.8.41
911
-     */
912
-    public static function parse_post_content_on_save($post_ID, $post)
913
-    {
914
-        EE_Error::doing_it_wrong(
915
-            __METHOD__,
916
-            esc_html__('Usage is deprecated', 'event_espresso'),
917
-            '4.8.41'
918
-        );
919
-    }
920
-
921
-
922
-    /**
923
-     * @param  $option
924
-     * @param  $old_value
925
-     * @param  $value
926
-     * @return void
927
-     * @deprecated 4.8.41
928
-     */
929
-    public function reset_page_for_posts_on_change($option, $old_value, $value)
930
-    {
931
-        EE_Error::doing_it_wrong(
932
-            __METHOD__,
933
-            esc_html__('Usage is deprecated', 'event_espresso'),
934
-            '4.8.41'
935
-        );
936
-    }
937
-
938
-
939
-    /**
940
-     * @return void
941
-     * @deprecated 4.9.27
942
-     */
943
-    public function get_persistent_admin_notices()
944
-    {
945
-        EE_Error::doing_it_wrong(
946
-            __METHOD__,
947
-            sprintf(
948
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
949
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
950
-            ),
951
-            '4.9.27'
952
-        );
953
-    }
954
-
955
-
956
-    /**
957
-     * @throws InvalidInterfaceException
958
-     * @throws InvalidDataTypeException
959
-     * @throws DomainException
960
-     * @deprecated 4.9.27
961
-     */
962
-    public function dismiss_ee_nag_notice_callback()
963
-    {
964
-        EE_Error::doing_it_wrong(
965
-            __METHOD__,
966
-            sprintf(
967
-                esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
968
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
969
-            ),
970
-            '4.9.27'
971
-        );
972
-        $this->persistent_admin_notice_manager->dismissNotice();
973
-    }
974
-
975
-
976
-    /**
977
-     * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
978
-     *
979
-     * @throws InvalidArgumentException
980
-     * @throws InvalidDataTypeException
981
-     * @throws InvalidInterfaceException
982
-     */
983
-    public function hookIntoWpPluginsPage()
984
-    {
985
-        $this->loader->getShared('EventEspresso\core\domain\services\admin\ExitModal');
986
-        $this->loader
987
-             ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
988
-             ->decafUpsells();
989
-    }
990
-
991
-
992
-    /**
993
-     * Hooks into the "post states" filter in a wp post type list table.
994
-     *
995
-     * @param array   $post_states
996
-     * @param WP_Post $post
997
-     * @return array
998
-     * @throws InvalidArgumentException
999
-     * @throws InvalidDataTypeException
1000
-     * @throws InvalidInterfaceException
1001
-     */
1002
-    public function displayStateForCriticalPages($post_states, $post)
1003
-    {
1004
-        $post_states = (array) $post_states;
1005
-        if (! $post instanceof WP_Post || $post->post_type !== 'page') {
1006
-            return $post_states;
1007
-        }
1008
-        /** @var EE_Core_Config $config */
1009
-        $config = $this->loader->getShared('EE_Config')->core;
1010
-        if (in_array($post->ID, $config->get_critical_pages_array(), true)) {
1011
-            $post_states[] = sprintf(
1012
-            /* Translators: Using company name - Event Espresso Critical Page */
1013
-                esc_html__('%s Critical Page', 'event_espresso'),
1014
-                'Event Espresso'
1015
-            );
1016
-        }
1017
-        return $post_states;
1018
-    }
1019
-
1020
-
1021
-    /**
1022
-     * Show documentation links on the plugins page
1023
-     *
1024
-     * @param mixed $meta Plugin Row Meta
1025
-     * @param mixed $file Plugin Base file
1026
-     * @return array
1027
-     */
1028
-    public function addLinksToPluginRowMeta($meta, $file)
1029
-    {
1030
-        if (EE_PLUGIN_BASENAME === $file) {
1031
-            $row_meta = [
1032
-                'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"'
1033
-                          . ' aria-label="'
1034
-                          . esc_attr__('View Event Espresso documentation', 'event_espresso')
1035
-                          . '">'
1036
-                          . esc_html__('Docs', 'event_espresso')
1037
-                          . '</a>',
1038
-                'api'  => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"'
1039
-                          . ' aria-label="'
1040
-                          . esc_attr__('View Event Espresso API docs', 'event_espresso')
1041
-                          . '">'
1042
-                          . esc_html__('API docs', 'event_espresso')
1043
-                          . '</a>',
1044
-            ];
1045
-            return array_merge($meta, $row_meta);
1046
-        }
1047
-        return (array) $meta;
1048
-    }
24
+	/**
25
+	 * @var EE_Admin $_instance
26
+	 */
27
+	private static $_instance;
28
+
29
+	/**
30
+	 * @var PersistentAdminNoticeManager $persistent_admin_notice_manager
31
+	 */
32
+	private $persistent_admin_notice_manager;
33
+
34
+	/**
35
+	 * @var LoaderInterface
36
+	 */
37
+	protected $loader;
38
+
39
+	/**
40
+	 * @var RequestInterface
41
+	 */
42
+	protected $request;
43
+
44
+
45
+	/**
46
+	 * @param RequestInterface $request
47
+	 * @singleton method used to instantiate class object
48
+	 * @return EE_Admin
49
+	 * @throws EE_Error
50
+	 */
51
+	public static function instance(RequestInterface $request = null)
52
+	{
53
+		// check if class object is instantiated
54
+		if (! self::$_instance instanceof EE_Admin) {
55
+			self::$_instance = new self($request);
56
+		}
57
+		return self::$_instance;
58
+	}
59
+
60
+
61
+	/**
62
+	 * @return EE_Admin
63
+	 * @throws EE_Error
64
+	 */
65
+	public static function reset()
66
+	{
67
+		self::$_instance = null;
68
+		$request         = LoaderFactory::getLoader()->getShared(RequestInterface::class);
69
+		return self::instance($request);
70
+	}
71
+
72
+
73
+	/**
74
+	 * @param RequestInterface $request
75
+	 * @throws EE_Error
76
+	 * @throws InvalidDataTypeException
77
+	 * @throws InvalidInterfaceException
78
+	 * @throws InvalidArgumentException
79
+	 */
80
+	protected function __construct(RequestInterface $request)
81
+	{
82
+		$this->request = $request;
83
+		$this->loader = LoaderFactory::getLoader();
84
+		// define global EE_Admin constants
85
+		$this->_define_all_constants();
86
+		// set autoloaders for our admin page classes based on included path information
87
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_ADMIN);
88
+		// admin hooks
89
+		add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2);
90
+		add_action('AHEE__EE_System__initialize_last', [$this, 'init']);
91
+		add_action('AHEE__EE_Admin_Page__route_admin_request', [$this, 'route_admin_request'], 100, 2);
92
+		add_action('wp_loaded', [$this, 'wp_loaded'], 100);
93
+		add_action('admin_init', [$this, 'admin_init'], 100);
94
+		add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_scripts'], 20);
95
+		add_action('admin_notices', [$this, 'display_admin_notices'], 10);
96
+		add_action('network_admin_notices', [$this, 'display_admin_notices'], 10);
97
+		add_filter('pre_update_option', [$this, 'check_for_invalid_datetime_formats'], 100, 2);
98
+		add_filter('admin_footer_text', [$this, 'espresso_admin_footer']);
99
+		add_action('load-plugins.php', [$this, 'hookIntoWpPluginsPage']);
100
+		add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2);
101
+		add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2);
102
+		// reset Environment config (we only do this on admin page loads);
103
+		EE_Registry::instance()->CFG->environment->recheck_values();
104
+		do_action('AHEE__EE_Admin__loaded');
105
+	}
106
+
107
+
108
+	/**
109
+	 * _define_all_constants
110
+	 * define constants that are set globally for all admin pages
111
+	 *
112
+	 * @return void
113
+	 */
114
+	private function _define_all_constants()
115
+	{
116
+		if (! defined('EE_ADMIN_URL')) {
117
+			define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/');
118
+			define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/');
119
+			define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/');
120
+			define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/');
121
+			define('WP_AJAX_URL', admin_url('admin-ajax.php'));
122
+		}
123
+	}
124
+
125
+
126
+	/**
127
+	 * filter_plugin_actions - adds links to the Plugins page listing
128
+	 *
129
+	 * @param array  $links
130
+	 * @param string $plugin
131
+	 * @return    array
132
+	 */
133
+	public function filter_plugin_actions($links, $plugin)
134
+	{
135
+		// set $main_file in stone
136
+		static $main_file;
137
+		// if $main_file is not set yet
138
+		if (! $main_file) {
139
+			$main_file = EE_PLUGIN_BASENAME;
140
+		}
141
+		if ($plugin === $main_file) {
142
+			// compare current plugin to this one
143
+			if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) {
144
+				$maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"'
145
+									. ' title="Event Espresso is in maintenance mode.  Click this link to learn why.">'
146
+									. esc_html__('Maintenance Mode Active', 'event_espresso')
147
+									. '</a>';
148
+				array_unshift($links, $maintenance_link);
149
+			} else {
150
+				$org_settings_link = '<a href="admin.php?page=espresso_general_settings">'
151
+									 . esc_html__('Settings', 'event_espresso')
152
+									 . '</a>';
153
+				$events_link       = '<a href="admin.php?page=espresso_events">'
154
+									 . esc_html__('Events', 'event_espresso')
155
+									 . '</a>';
156
+				// add before other links
157
+				array_unshift($links, $org_settings_link, $events_link);
158
+			}
159
+		}
160
+		return $links;
161
+	}
162
+
163
+
164
+	/**
165
+	 * @deprecated 4.10.14.p
166
+	 */
167
+	public function get_request()
168
+	{
169
+	}
170
+
171
+
172
+	/**
173
+	 * hide_admin_pages_except_maintenance_mode
174
+	 *
175
+	 * @param array $admin_page_folder_names
176
+	 * @return array
177
+	 */
178
+	public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = [])
179
+	{
180
+		return [
181
+			'maintenance' => EE_ADMIN_PAGES . 'maintenance/',
182
+			'about'       => EE_ADMIN_PAGES . 'about/',
183
+			'support'     => EE_ADMIN_PAGES . 'support/',
184
+		];
185
+	}
186
+
187
+
188
+	/**
189
+	 * init- should fire after shortcode, module,  addon, other plugin (default priority), and even
190
+	 * EE_Front_Controller's init phases have run
191
+	 *
192
+	 * @return void
193
+	 * @throws EE_Error
194
+	 * @throws InvalidArgumentException
195
+	 * @throws InvalidDataTypeException
196
+	 * @throws InvalidInterfaceException
197
+	 * @throws ReflectionException
198
+	 * @throws ServiceNotFoundException
199
+	 */
200
+	public function init()
201
+	{
202
+		// only enable most of the EE_Admin IF we're not in full maintenance mode
203
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
204
+			$this->initModelsReady();
205
+		}
206
+		// run the admin page factory but ONLY if:
207
+		// - it is a regular non ajax admin request
208
+		// - we are doing an ee admin ajax request
209
+		if ($this->request->isAdmin() || $this->request->isAdminAjax()) {
210
+			// this loads the controller for the admin pages which will setup routing etc
211
+			$this->loader->getShared('EE_Admin_Page_Loader', [$this->loader]);
212
+		}
213
+		if ($this->request->isAdminAjax()) {
214
+			return;
215
+		}
216
+		add_filter('content_save_pre', [$this, 'its_eSpresso'], 10, 1);
217
+		// make sure our CPTs and custom taxonomy metaboxes get shown for first time users
218
+		add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10);
219
+		add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10);
220
+		// exclude EE critical pages from all nav menus and wp_list_pages
221
+		add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu'], 10);
222
+	}
223
+
224
+
225
+	/**
226
+	 * Gets the loader (and if it wasn't previously set, sets it)
227
+	 *
228
+	 * @return LoaderInterface
229
+	 * @throws InvalidArgumentException
230
+	 * @throws InvalidDataTypeException
231
+	 * @throws InvalidInterfaceException
232
+	 */
233
+	protected function getLoader()
234
+	{
235
+		return $this->loader;
236
+	}
237
+
238
+
239
+	/**
240
+	 * Method that's fired on admin requests (including admin ajax) but only when the models are usable
241
+	 * (ie, the site isn't in maintenance mode)
242
+	 *
243
+	 * @return void
244
+	 * @throws EE_Error
245
+	 * @since 4.9.63.p
246
+	 */
247
+	protected function initModelsReady()
248
+	{
249
+		// ok so we want to enable the entire admin
250
+		$this->persistent_admin_notice_manager = $this->loader->getShared(
251
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
252
+		);
253
+		$this->persistent_admin_notice_manager->setReturnUrl(
254
+			EE_Admin_Page::add_query_args_and_nonce(
255
+				[
256
+					'page'   => $this->request->getRequestParam('page'),
257
+					'action' => $this->request->getRequestParam('action'),
258
+				],
259
+				EE_ADMIN_URL
260
+			)
261
+		);
262
+		$this->maybeSetDatetimeWarningNotice();
263
+		// at a glance dashboard widget
264
+		add_filter('dashboard_glance_items', [$this, 'dashboard_glance_items'], 10);
265
+		// filter for get_edit_post_link used on comments for custom post types
266
+		add_filter('get_edit_post_link', [$this, 'modify_edit_post_link'], 10, 2);
267
+	}
268
+
269
+
270
+	/**
271
+	 *    get_persistent_admin_notices
272
+	 *
273
+	 * @access    public
274
+	 * @return void
275
+	 * @throws EE_Error
276
+	 * @throws InvalidArgumentException
277
+	 * @throws InvalidDataTypeException
278
+	 * @throws InvalidInterfaceException
279
+	 */
280
+	public function maybeSetDatetimeWarningNotice()
281
+	{
282
+		// add dismissible notice for datetime changes.  Only valid if site does not have a timezone_string set.
283
+		// @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version
284
+		// with this.  But after enough time (indeterminate at this point) we can just remove this notice.
285
+		// this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626
286
+		if (
287
+			apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true)
288
+			&& ! get_option('timezone_string')
289
+			&& EEM_Event::instance()->count() > 0
290
+		) {
291
+			new PersistentAdminNotice(
292
+				'datetime_fix_notice',
293
+				sprintf(
294
+					esc_html__(
295
+						'%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.',
296
+						'event_espresso'
297
+					),
298
+					'<strong>',
299
+					'</strong>',
300
+					'<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">',
301
+					'</a>',
302
+					'<a href="' . EE_Admin_Page::add_query_args_and_nonce(
303
+						[
304
+							'page'   => 'espresso_maintenance_settings',
305
+							'action' => 'datetime_tools',
306
+						],
307
+						admin_url('admin.php')
308
+					) . '">'
309
+				),
310
+				false,
311
+				'manage_options',
312
+				'datetime_fix_persistent_notice'
313
+			);
314
+		}
315
+	}
316
+
317
+
318
+	/**
319
+	 * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from
320
+	 * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in
321
+	 * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that
322
+	 * to override any queries found in the existing query for the given post type.  Note that _default_query is not a
323
+	 * normal property on the post_type object.  It's found ONLY in this particular context.
324
+	 *
325
+	 * @param WP_Post $post_type WP post type object
326
+	 * @return WP_Post
327
+	 * @throws InvalidArgumentException
328
+	 * @throws InvalidDataTypeException
329
+	 * @throws InvalidInterfaceException
330
+	 */
331
+	public function remove_pages_from_nav_menu($post_type)
332
+	{
333
+		// if this isn't the "pages" post type let's get out
334
+		if ($post_type->name !== 'page') {
335
+			return $post_type;
336
+		}
337
+		$critical_pages            = EE_Registry::instance()->CFG->core->get_critical_pages_array();
338
+		$post_type->_default_query = [
339
+			'post__not_in' => $critical_pages,
340
+		];
341
+		return $post_type;
342
+	}
343
+
344
+
345
+	/**
346
+	 * WP by default only shows three metaboxes in "nav-menus.php" for first times users.  We want to make sure our
347
+	 * metaboxes get shown as well
348
+	 *
349
+	 * @return void
350
+	 */
351
+	public function enable_hidden_ee_nav_menu_metaboxes()
352
+	{
353
+		global $wp_meta_boxes, $pagenow;
354
+		if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') {
355
+			return;
356
+		}
357
+		$user = wp_get_current_user();
358
+		// has this been done yet?
359
+		if (get_user_option('ee_nav_menu_initialized', $user->ID)) {
360
+			return;
361
+		}
362
+
363
+		$hidden_meta_boxes  = get_user_option('metaboxhidden_nav-menus', $user->ID);
364
+		$initial_meta_boxes = apply_filters(
365
+			'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes',
366
+			[
367
+				'nav-menu-theme-locations',
368
+				'add-page',
369
+				'add-custom-links',
370
+				'add-category',
371
+				'add-espresso_events',
372
+				'add-espresso_venues',
373
+				'add-espresso_event_categories',
374
+				'add-espresso_venue_categories',
375
+				'add-post-type-post',
376
+				'add-post-type-page',
377
+			]
378
+		);
379
+
380
+		if (is_array($hidden_meta_boxes)) {
381
+			foreach ($hidden_meta_boxes as $key => $meta_box_id) {
382
+				if (in_array($meta_box_id, $initial_meta_boxes, true)) {
383
+					unset($hidden_meta_boxes[ $key ]);
384
+				}
385
+			}
386
+		}
387
+		update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true);
388
+		update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true);
389
+	}
390
+
391
+
392
+	/**
393
+	 * This method simply registers custom nav menu boxes for "nav_menus.php route"
394
+	 * Currently EE is using this to make sure there are menu options for our CPT archive page routes.
395
+	 *
396
+	 * @return void
397
+	 * @todo   modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by
398
+	 *         addons etc.
399
+	 */
400
+	public function register_custom_nav_menu_boxes()
401
+	{
402
+		add_meta_box(
403
+			'add-extra-nav-menu-pages',
404
+			esc_html__('Event Espresso Pages', 'event_espresso'),
405
+			[$this, 'ee_cpt_archive_pages'],
406
+			'nav-menus',
407
+			'side',
408
+			'core'
409
+		);
410
+	}
411
+
412
+
413
+	/**
414
+	 * Use this to edit the post link for our cpts so that the edit link points to the correct page.
415
+	 *
416
+	 * @param string $link the original link generated by wp
417
+	 * @param int    $id   post id
418
+	 * @return string  the (maybe) modified link
419
+	 * @since   4.3.0
420
+	 */
421
+	public function modify_edit_post_link($link, $id)
422
+	{
423
+		if (! $post = get_post($id)) {
424
+			return $link;
425
+		}
426
+		if ($post->post_type === 'espresso_attendees') {
427
+			$query_args = [
428
+				'action' => 'edit_attendee',
429
+				'post'   => $id,
430
+			];
431
+			return EEH_URL::add_query_args_and_nonce(
432
+				$query_args,
433
+				admin_url('admin.php?page=espresso_registrations')
434
+			);
435
+		}
436
+		return $link;
437
+	}
438
+
439
+
440
+	public function ee_cpt_archive_pages()
441
+	{
442
+		global $nav_menu_selected_id;
443
+		$removed_args = [
444
+			'action',
445
+			'customlink-tab',
446
+			'edit-menu-item',
447
+			'menu-item',
448
+			'page-tab',
449
+			'_wpnonce',
450
+		];
451
+		$nav_tab_link = $nav_menu_selected_id
452
+			? esc_url(
453
+				add_query_arg(
454
+					'extra-nav-menu-pages-tab',
455
+					'event-archives',
456
+					remove_query_arg($removed_args)
457
+				)
458
+			)
459
+			: '';
460
+		$select_all_link = esc_url(
461
+			add_query_arg(
462
+				[
463
+					'extra-nav-menu-pages-tab' => 'event-archives',
464
+					'selectall'                => 1,
465
+				],
466
+				remove_query_arg($removed_args)
467
+			)
468
+		);
469
+		$pages = $this->_get_extra_nav_menu_pages_items();
470
+		$args['walker'] = new Walker_Nav_Menu_Checklist(false);
471
+		;
472
+		$nav_menu_pages_items = walk_nav_menu_tree(
473
+			array_map(
474
+				[$this, '_setup_extra_nav_menu_pages_items'],
475
+				$pages
476
+			),
477
+			0,
478
+			(object) $args
479
+		);
480
+
481
+		EEH_Template::display_template(
482
+			EE_ADMIN_TEMPLATE . 'cpt_archive_page.template.php',
483
+			[
484
+				$nav_menu_pages_items,
485
+				$nav_tab_link,
486
+				$select_all_link,
487
+			]
488
+		);
489
+	}
490
+
491
+
492
+	/**
493
+	 * Returns an array of event archive nav items.
494
+	 *
495
+	 * @return array
496
+	 * @todo  for now this method is just in place so when it gets abstracted further we can substitute in whatever
497
+	 *        method we use for getting the extra nav menu items
498
+	 */
499
+	private function _get_extra_nav_menu_pages_items()
500
+	{
501
+		$menuitems[] = [
502
+			'title'       => esc_html__('Event List', 'event_espresso'),
503
+			'url'         => get_post_type_archive_link('espresso_events'),
504
+			'description' => esc_html__('Archive page for all events.', 'event_espresso'),
505
+		];
506
+		return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems);
507
+	}
508
+
509
+
510
+	/**
511
+	 * Setup nav menu walker item for usage in the event archive nav menu metabox.  It receives a menu_item array with
512
+	 * the properties and converts it to the menu item object.
513
+	 *
514
+	 * @param $menu_item_values
515
+	 * @return stdClass
516
+	 * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php
517
+	 */
518
+	private function _setup_extra_nav_menu_pages_items($menu_item_values)
519
+	{
520
+		$menu_item = new stdClass();
521
+		$keys      = [
522
+			'ID'               => 0,
523
+			'db_id'            => 0,
524
+			'menu_item_parent' => 0,
525
+			'object_id'        => -1,
526
+			'post_parent'      => 0,
527
+			'type'             => 'custom',
528
+			'object'           => '',
529
+			'type_label'       => esc_html__('Extra Nav Menu Item', 'event_espresso'),
530
+			'title'            => '',
531
+			'url'              => '',
532
+			'target'           => '',
533
+			'attr_title'       => '',
534
+			'description'      => '',
535
+			'classes'          => [],
536
+			'xfn'              => '',
537
+		];
538
+
539
+		foreach ($keys as $key => $value) {
540
+			$menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value;
541
+		}
542
+		return $menu_item;
543
+	}
544
+
545
+
546
+	/**
547
+	 * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an
548
+	 * EE_Admin_Page route is called.
549
+	 *
550
+	 * @return void
551
+	 */
552
+	public function route_admin_request()
553
+	{
554
+	}
555
+
556
+
557
+	/**
558
+	 * wp_loaded should fire on the WordPress wp_loaded hook.  This fires on a VERY late priority.
559
+	 *
560
+	 * @return void
561
+	 */
562
+	public function wp_loaded()
563
+	{
564
+	}
565
+
566
+
567
+	/**
568
+	 * admin_init
569
+	 *
570
+	 * @return void
571
+	 * @throws InvalidArgumentException
572
+	 * @throws InvalidDataTypeException
573
+	 * @throws InvalidInterfaceException
574
+	 */
575
+	public function admin_init()
576
+	{
577
+		/**
578
+		 * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php),
579
+		 * so any hooking into core WP routes is taken care of.  So in this next few lines of code:
580
+		 * - check if doing post processing.
581
+		 * - check if doing post processing of one of EE CPTs
582
+		 * - instantiate the corresponding EE CPT model for the post_type being processed.
583
+		 */
584
+		$action    = $this->request->getRequestParam('action');
585
+		$post_type = $this->request->getRequestParam('post_type');
586
+		if ($post_type && $action === 'editpost') {
587
+			/** @var CustomPostTypeDefinitions $custom_post_types */
588
+			$custom_post_types = $this->loader->getShared(CustomPostTypeDefinitions::class);
589
+			$custom_post_types->getCustomPostTypeModels($post_type);
590
+		}
591
+
592
+
593
+		/**
594
+		 * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting
595
+		 * critical pages.  The only place critical pages need included in a generated dropdown is on the "Critical
596
+		 * Pages" tab in the EE General Settings Admin page.
597
+		 * This is for user-proofing.
598
+		 */
599
+		add_filter('wp_dropdown_pages', [$this, 'modify_dropdown_pages']);
600
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
601
+			$this->adminInitModelsReady();
602
+		}
603
+	}
604
+
605
+
606
+	/**
607
+	 * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode)
608
+	 */
609
+	protected function adminInitModelsReady()
610
+	{
611
+		if (function_exists('wp_add_privacy_policy_content')) {
612
+			$this->loader->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager');
613
+		}
614
+	}
615
+
616
+
617
+	/**
618
+	 * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection.
619
+	 *
620
+	 * @param string $output Current output.
621
+	 * @return string
622
+	 * @throws InvalidArgumentException
623
+	 * @throws InvalidDataTypeException
624
+	 * @throws InvalidInterfaceException
625
+	 */
626
+	public function modify_dropdown_pages($output)
627
+	{
628
+		// get critical pages
629
+		$critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array();
630
+
631
+		// split current output by line break for easier parsing.
632
+		$split_output = explode("\n", $output);
633
+
634
+		// loop through to remove any critical pages from the array.
635
+		foreach ($critical_pages as $page_id) {
636
+			$needle = 'value="' . $page_id . '"';
637
+			foreach ($split_output as $key => $haystack) {
638
+				if (strpos($haystack, $needle) !== false) {
639
+					unset($split_output[ $key ]);
640
+				}
641
+			}
642
+		}
643
+		// replace output with the new contents
644
+		return implode("\n", $split_output);
645
+	}
646
+
647
+
648
+	/**
649
+	 * enqueue all admin scripts that need loaded for admin pages
650
+	 *
651
+	 * @return void
652
+	 */
653
+	public function enqueue_admin_scripts()
654
+	{
655
+		// this javascript is loaded on every admin page to catch any injections ee needs to add to wp run js.
656
+		// Note: the intention of this script is to only do TARGETED injections.  I.E, only injecting on certain script
657
+		// calls.
658
+		wp_enqueue_script(
659
+			'ee-inject-wp',
660
+			EE_ADMIN_URL . 'assets/ee-cpt-wp-injects.js',
661
+			['jquery'],
662
+			EVENT_ESPRESSO_VERSION,
663
+			true
664
+		);
665
+		// register cookie script for future dependencies
666
+		wp_register_script(
667
+			'jquery-cookie',
668
+			EE_THIRD_PARTY_URL . 'joyride/jquery.cookie.js',
669
+			['jquery'],
670
+			'2.1',
671
+			true
672
+		);
673
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
674
+		// joyride is turned OFF by default, but prior to the admin_enqueue_scripts hook, can be turned back on again
675
+		// via: add_filter('FHEE_load_joyride', '__return_true' );
676
+		// if (apply_filters('FHEE_load_joyride', false)) {
677
+		//     // joyride style
678
+		//     wp_register_style('joyride-css', EE_THIRD_PARTY_URL . 'joyride/joyride-2.1.css', array(), '2.1');
679
+		//     wp_register_style(
680
+		//         'ee-joyride-css',
681
+		//         EE_GLOBAL_ASSETS_URL . 'css/ee-joyride-styles.css',
682
+		//         array('joyride-css'),
683
+		//         EVENT_ESPRESSO_VERSION
684
+		//     );
685
+		//     wp_register_script(
686
+		//         'joyride-modernizr',
687
+		//         EE_THIRD_PARTY_URL . 'joyride/modernizr.mq.js',
688
+		//         array(),
689
+		//         '2.1',
690
+		//         true
691
+		//     );
692
+		//     // joyride JS
693
+		//     wp_register_script(
694
+		//         'jquery-joyride',
695
+		//         EE_THIRD_PARTY_URL . 'joyride/jquery.joyride-2.1.js',
696
+		//         array('jquery-cookie', 'joyride-modernizr'),
697
+		//         '2.1',
698
+		//         true
699
+		//     );
700
+		//     // wanna go for a joyride?
701
+		//     wp_enqueue_style('ee-joyride-css');
702
+		//     wp_enqueue_script('jquery-joyride');
703
+		// }
704
+	}
705
+
706
+
707
+	/**
708
+	 * display_admin_notices
709
+	 *
710
+	 * @return void
711
+	 */
712
+	public function display_admin_notices()
713
+	{
714
+		echo EE_Error::get_notices(); // already escaped
715
+	}
716
+
717
+
718
+	/**
719
+	 * @param array $elements
720
+	 * @return array
721
+	 * @throws EE_Error
722
+	 * @throws InvalidArgumentException
723
+	 * @throws InvalidDataTypeException
724
+	 * @throws InvalidInterfaceException
725
+	 */
726
+	public function dashboard_glance_items($elements)
727
+	{
728
+		$elements                        = is_array($elements) ? $elements : [$elements];
729
+		$events                          = EEM_Event::instance()->count();
730
+		$items['events']['url']          = EE_Admin_Page::add_query_args_and_nonce(
731
+			['page' => 'espresso_events'],
732
+			admin_url('admin.php')
733
+		);
734
+		$items['events']['text']         = sprintf(
735
+			esc_html(
736
+				_n('%s Event', '%s Events', $events, 'event_espresso')
737
+			),
738
+			number_format_i18n($events)
739
+		);
740
+		$items['events']['title']        = esc_html__('Click to view all Events', 'event_espresso');
741
+		$registrations                   = EEM_Registration::instance()->count(
742
+			[
743
+				[
744
+					'STS_ID' => ['!=', EEM_Registration::status_id_incomplete],
745
+				],
746
+			]
747
+		);
748
+		$items['registrations']['url']   = EE_Admin_Page::add_query_args_and_nonce(
749
+			['page' => 'espresso_registrations'],
750
+			admin_url('admin.php')
751
+		);
752
+		$items['registrations']['text']  = sprintf(
753
+			esc_html(
754
+				_n('%s Registration', '%s Registrations', $registrations, 'event_espresso')
755
+			),
756
+			number_format_i18n($registrations)
757
+		);
758
+		$items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso');
759
+
760
+		$items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items);
761
+
762
+		foreach ($items as $type => $item_properties) {
763
+			$elements[] = sprintf(
764
+				'<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>',
765
+				$item_properties['url'],
766
+				$item_properties['title'],
767
+				$item_properties['text']
768
+			);
769
+		}
770
+		return $elements;
771
+	}
772
+
773
+
774
+	/**
775
+	 * check_for_invalid_datetime_formats
776
+	 * if an admin changes their date or time format settings on the WP General Settings admin page, verify that
777
+	 * their selected format can be parsed by PHP
778
+	 *
779
+	 * @param    $value
780
+	 * @param    $option
781
+	 * @return    string
782
+	 */
783
+	public function check_for_invalid_datetime_formats($value, $option)
784
+	{
785
+		// check for date_format or time_format
786
+		switch ($option) {
787
+			case 'date_format':
788
+				$date_time_format = $value . ' ' . get_option('time_format');
789
+				break;
790
+			case 'time_format':
791
+				$date_time_format = get_option('date_format') . ' ' . $value;
792
+				break;
793
+			default:
794
+				$date_time_format = false;
795
+		}
796
+		// do we have a date_time format to check ?
797
+		if ($date_time_format) {
798
+			$error_msg = EEH_DTT_Helper::validate_format_string($date_time_format);
799
+
800
+			if (is_array($error_msg)) {
801
+				$msg = '<p>'
802
+					   . sprintf(
803
+						   esc_html__(
804
+							   'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:',
805
+							   'event_espresso'
806
+						   ),
807
+						   date($date_time_format),
808
+						   $date_time_format
809
+					   )
810
+					   . '</p><p><ul>';
811
+
812
+
813
+				foreach ($error_msg as $error) {
814
+					$msg .= '<li>' . $error . '</li>';
815
+				}
816
+
817
+				$msg .= '</ul></p><p>'
818
+						. sprintf(
819
+							esc_html__(
820
+								'%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s',
821
+								'event_espresso'
822
+							),
823
+							'<span style="color:#D54E21;">',
824
+							'</span>'
825
+						)
826
+						. '</p>';
827
+
828
+				// trigger WP settings error
829
+				add_settings_error(
830
+					'date_format',
831
+					'date_format',
832
+					$msg
833
+				);
834
+
835
+				// set format to something valid
836
+				switch ($option) {
837
+					case 'date_format':
838
+						$value = 'F j, Y';
839
+						break;
840
+					case 'time_format':
841
+						$value = 'g:i a';
842
+						break;
843
+				}
844
+			}
845
+		}
846
+		return $value;
847
+	}
848
+
849
+
850
+	/**
851
+	 * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso"
852
+	 *
853
+	 * @param $content
854
+	 * @return    string
855
+	 */
856
+	public function its_eSpresso($content)
857
+	{
858
+		return str_replace('[EXPRESSO_', '[ESPRESSO_', $content);
859
+	}
860
+
861
+
862
+	/**
863
+	 * espresso_admin_footer
864
+	 *
865
+	 * @return    string
866
+	 */
867
+	public function espresso_admin_footer()
868
+	{
869
+		return EEH_Template::powered_by_event_espresso('aln-cntr', '', ['utm_content' => 'admin_footer']);
870
+	}
871
+
872
+
873
+	/**
874
+	 * static method for registering ee admin page.
875
+	 * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register.
876
+	 *
877
+	 * @param       $page_basename
878
+	 * @param       $page_path
879
+	 * @param array $config
880
+	 * @return void
881
+	 * @throws EE_Error
882
+	 * @see        EE_Register_Admin_Page::register()
883
+	 * @since      4.3.0
884
+	 * @deprecated 4.3.0    Use EE_Register_Admin_Page::register() instead
885
+	 */
886
+	public static function register_ee_admin_page($page_basename, $page_path, $config = [])
887
+	{
888
+		EE_Error::doing_it_wrong(
889
+			__METHOD__,
890
+			sprintf(
891
+				esc_html__(
892
+					'Usage is deprecated.  Use EE_Register_Admin_Page::register() for registering the %s admin page.',
893
+					'event_espresso'
894
+				),
895
+				$page_basename
896
+			),
897
+			'4.3'
898
+		);
899
+		if (class_exists('EE_Register_Admin_Page')) {
900
+			$config['page_path'] = $page_path;
901
+		}
902
+		EE_Register_Admin_Page::register($page_basename, $config);
903
+	}
904
+
905
+
906
+	/**
907
+	 * @param int     $post_ID
908
+	 * @param WP_Post $post
909
+	 * @return void
910
+	 * @deprecated 4.8.41
911
+	 */
912
+	public static function parse_post_content_on_save($post_ID, $post)
913
+	{
914
+		EE_Error::doing_it_wrong(
915
+			__METHOD__,
916
+			esc_html__('Usage is deprecated', 'event_espresso'),
917
+			'4.8.41'
918
+		);
919
+	}
920
+
921
+
922
+	/**
923
+	 * @param  $option
924
+	 * @param  $old_value
925
+	 * @param  $value
926
+	 * @return void
927
+	 * @deprecated 4.8.41
928
+	 */
929
+	public function reset_page_for_posts_on_change($option, $old_value, $value)
930
+	{
931
+		EE_Error::doing_it_wrong(
932
+			__METHOD__,
933
+			esc_html__('Usage is deprecated', 'event_espresso'),
934
+			'4.8.41'
935
+		);
936
+	}
937
+
938
+
939
+	/**
940
+	 * @return void
941
+	 * @deprecated 4.9.27
942
+	 */
943
+	public function get_persistent_admin_notices()
944
+	{
945
+		EE_Error::doing_it_wrong(
946
+			__METHOD__,
947
+			sprintf(
948
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
949
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
950
+			),
951
+			'4.9.27'
952
+		);
953
+	}
954
+
955
+
956
+	/**
957
+	 * @throws InvalidInterfaceException
958
+	 * @throws InvalidDataTypeException
959
+	 * @throws DomainException
960
+	 * @deprecated 4.9.27
961
+	 */
962
+	public function dismiss_ee_nag_notice_callback()
963
+	{
964
+		EE_Error::doing_it_wrong(
965
+			__METHOD__,
966
+			sprintf(
967
+				esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
968
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
969
+			),
970
+			'4.9.27'
971
+		);
972
+		$this->persistent_admin_notice_manager->dismissNotice();
973
+	}
974
+
975
+
976
+	/**
977
+	 * Callback on load-plugins.php hook for setting up anything hooking into the wp plugins page.
978
+	 *
979
+	 * @throws InvalidArgumentException
980
+	 * @throws InvalidDataTypeException
981
+	 * @throws InvalidInterfaceException
982
+	 */
983
+	public function hookIntoWpPluginsPage()
984
+	{
985
+		$this->loader->getShared('EventEspresso\core\domain\services\admin\ExitModal');
986
+		$this->loader
987
+			 ->getShared('EventEspresso\core\domain\services\admin\PluginUpsells')
988
+			 ->decafUpsells();
989
+	}
990
+
991
+
992
+	/**
993
+	 * Hooks into the "post states" filter in a wp post type list table.
994
+	 *
995
+	 * @param array   $post_states
996
+	 * @param WP_Post $post
997
+	 * @return array
998
+	 * @throws InvalidArgumentException
999
+	 * @throws InvalidDataTypeException
1000
+	 * @throws InvalidInterfaceException
1001
+	 */
1002
+	public function displayStateForCriticalPages($post_states, $post)
1003
+	{
1004
+		$post_states = (array) $post_states;
1005
+		if (! $post instanceof WP_Post || $post->post_type !== 'page') {
1006
+			return $post_states;
1007
+		}
1008
+		/** @var EE_Core_Config $config */
1009
+		$config = $this->loader->getShared('EE_Config')->core;
1010
+		if (in_array($post->ID, $config->get_critical_pages_array(), true)) {
1011
+			$post_states[] = sprintf(
1012
+			/* Translators: Using company name - Event Espresso Critical Page */
1013
+				esc_html__('%s Critical Page', 'event_espresso'),
1014
+				'Event Espresso'
1015
+			);
1016
+		}
1017
+		return $post_states;
1018
+	}
1019
+
1020
+
1021
+	/**
1022
+	 * Show documentation links on the plugins page
1023
+	 *
1024
+	 * @param mixed $meta Plugin Row Meta
1025
+	 * @param mixed $file Plugin Base file
1026
+	 * @return array
1027
+	 */
1028
+	public function addLinksToPluginRowMeta($meta, $file)
1029
+	{
1030
+		if (EE_PLUGIN_BASENAME === $file) {
1031
+			$row_meta = [
1032
+				'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"'
1033
+						  . ' aria-label="'
1034
+						  . esc_attr__('View Event Espresso documentation', 'event_espresso')
1035
+						  . '">'
1036
+						  . esc_html__('Docs', 'event_espresso')
1037
+						  . '</a>',
1038
+				'api'  => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"'
1039
+						  . ' aria-label="'
1040
+						  . esc_attr__('View Event Espresso API docs', 'event_espresso')
1041
+						  . '">'
1042
+						  . esc_html__('API docs', 'event_espresso')
1043
+						  . '</a>',
1044
+			];
1045
+			return array_merge($meta, $row_meta);
1046
+		}
1047
+		return (array) $meta;
1048
+	}
1049 1049
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +4112 added lines, -4112 removed lines patch added patch discarded remove patch
@@ -18,4188 +18,4188 @@
 block discarded – undo
18 18
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var LoaderInterface
23
-     */
24
-    protected $loader;
21
+	/**
22
+	 * @var LoaderInterface
23
+	 */
24
+	protected $loader;
25 25
 
26
-    /**
27
-     * @var RequestInterface
28
-     */
29
-    protected $request;
26
+	/**
27
+	 * @var RequestInterface
28
+	 */
29
+	protected $request;
30 30
 
31
-    // set in _init_page_props()
32
-    public $page_slug;
31
+	// set in _init_page_props()
32
+	public $page_slug;
33 33
 
34
-    public $page_label;
34
+	public $page_label;
35 35
 
36
-    public $page_folder;
36
+	public $page_folder;
37 37
 
38
-    // set in define_page_props()
39
-    protected $_admin_base_url;
38
+	// set in define_page_props()
39
+	protected $_admin_base_url;
40 40
 
41
-    protected $_admin_base_path;
41
+	protected $_admin_base_path;
42 42
 
43
-    protected $_admin_page_title;
43
+	protected $_admin_page_title;
44 44
 
45
-    protected $_labels;
45
+	protected $_labels;
46 46
 
47 47
 
48
-    // set early within EE_Admin_Init
49
-    protected $_wp_page_slug;
48
+	// set early within EE_Admin_Init
49
+	protected $_wp_page_slug;
50 50
 
51
-    // navtabs
52
-    protected $_nav_tabs;
51
+	// navtabs
52
+	protected $_nav_tabs;
53 53
 
54
-    protected $_default_nav_tab_name;
54
+	protected $_default_nav_tab_name;
55 55
 
56
-    /**
57
-     * @var array $_help_tour
58
-     */
59
-    protected $_help_tour = [];
56
+	/**
57
+	 * @var array $_help_tour
58
+	 */
59
+	protected $_help_tour = [];
60 60
 
61 61
 
62
-    // template variables (used by templates)
63
-    protected $_template_path;
62
+	// template variables (used by templates)
63
+	protected $_template_path;
64 64
 
65
-    protected $_column_template_path;
65
+	protected $_column_template_path;
66 66
 
67
-    /**
68
-     * @var array $_template_args
69
-     */
70
-    protected $_template_args = [];
67
+	/**
68
+	 * @var array $_template_args
69
+	 */
70
+	protected $_template_args = [];
71 71
 
72
-    /**
73
-     * this will hold the list table object for a given view.
74
-     *
75
-     * @var EE_Admin_List_Table $_list_table_object
76
-     */
77
-    protected $_list_table_object;
72
+	/**
73
+	 * this will hold the list table object for a given view.
74
+	 *
75
+	 * @var EE_Admin_List_Table $_list_table_object
76
+	 */
77
+	protected $_list_table_object;
78 78
 
79
-    // bools
80
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
79
+	// bools
80
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
81 81
 
82
-    protected $_routing;
82
+	protected $_routing;
83 83
 
84
-    // list table args
85
-    protected $_view;
84
+	// list table args
85
+	protected $_view;
86 86
 
87
-    protected $_views;
87
+	protected $_views;
88 88
 
89 89
 
90
-    // action => method pairs used for routing incoming requests
91
-    protected $_page_routes;
90
+	// action => method pairs used for routing incoming requests
91
+	protected $_page_routes;
92 92
 
93
-    /**
94
-     * @var array $_page_config
95
-     */
96
-    protected $_page_config;
93
+	/**
94
+	 * @var array $_page_config
95
+	 */
96
+	protected $_page_config;
97 97
 
98
-    /**
99
-     * the current page route and route config
100
-     *
101
-     * @var string $_route
102
-     */
103
-    protected $_route;
98
+	/**
99
+	 * the current page route and route config
100
+	 *
101
+	 * @var string $_route
102
+	 */
103
+	protected $_route;
104 104
 
105
-    /**
106
-     * @var string $_cpt_route
107
-     */
108
-    protected $_cpt_route;
105
+	/**
106
+	 * @var string $_cpt_route
107
+	 */
108
+	protected $_cpt_route;
109 109
 
110
-    /**
111
-     * @var array $_route_config
112
-     */
113
-    protected $_route_config;
110
+	/**
111
+	 * @var array $_route_config
112
+	 */
113
+	protected $_route_config;
114 114
 
115
-    /**
116
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
117
-     * actions.
118
-     *
119
-     * @since 4.6.x
120
-     * @var array.
121
-     */
122
-    protected $_default_route_query_args;
123
-
124
-    // set via request page and action args.
125
-    protected $_current_page;
126
-
127
-    protected $_current_view;
128
-
129
-    protected $_current_page_view_url;
130
-
131
-    /**
132
-     * unprocessed value for the 'action' request param (default '')
133
-     *
134
-     * @var string
135
-     */
136
-    protected $raw_req_action = '';
137
-
138
-    /**
139
-     * unprocessed value for the 'page' request param (default '')
140
-     *
141
-     * @var string
142
-     */
143
-    protected $raw_req_page = '';
144
-
145
-    /**
146
-     * sanitized request action (and nonce)
147
-     *
148
-     * @var string
149
-     */
150
-    protected $_req_action = '';
151
-
152
-    /**
153
-     * sanitized request action nonce
154
-     *
155
-     * @var string
156
-     */
157
-    protected $_req_nonce = '';
158
-
159
-    /**
160
-     * @var string
161
-     */
162
-    protected $_search_btn_label = '';
163
-
164
-    /**
165
-     * @var string
166
-     */
167
-    protected $_search_box_callback = '';
168
-
169
-    /**
170
-     * @var WP_Screen
171
-     */
172
-    protected $_current_screen;
173
-
174
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
175
-    protected $_hook_obj;
176
-
177
-    // for holding incoming request data
178
-    protected $_req_data = [];
179
-
180
-    // yes / no array for admin form fields
181
-    protected $_yes_no_values = [];
182
-
183
-    // some default things shared by all child classes
184
-    protected $_default_espresso_metaboxes;
185
-
186
-    /**
187
-     * @var EE_Registry
188
-     */
189
-    protected $EE = null;
190
-
191
-
192
-    /**
193
-     * This is just a property that flags whether the given route is a caffeinated route or not.
194
-     *
195
-     * @var boolean
196
-     */
197
-    protected $_is_caf = false;
198
-
199
-
200
-    /**
201
-     * @Constructor
202
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
203
-     * @throws EE_Error
204
-     * @throws InvalidArgumentException
205
-     * @throws ReflectionException
206
-     * @throws InvalidDataTypeException
207
-     * @throws InvalidInterfaceException
208
-     */
209
-    public function __construct($routing = true)
210
-    {
211
-        $this->loader  = LoaderFactory::getLoader();
212
-        $this->request = $this->loader->getShared(RequestInterface::class);
213
-        $this->_routing = $routing;
214
-
215
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
216
-            $this->_is_caf = true;
217
-        }
218
-        $this->_yes_no_values = [
219
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
220
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
221
-        ];
222
-        // set the _req_data property.
223
-        $this->_req_data = $this->request->requestParams();
224
-        // set initial page props (child method)
225
-        $this->_init_page_props();
226
-        // set global defaults
227
-        $this->_set_defaults();
228
-        // set early because incoming requests could be ajax related and we need to register those hooks.
229
-        $this->_global_ajax_hooks();
230
-        $this->_ajax_hooks();
231
-        // other_page_hooks have to be early too.
232
-        $this->_do_other_page_hooks();
233
-        // set up page dependencies
234
-        $this->_before_page_setup();
235
-        $this->_page_setup();
236
-        // die();
237
-    }
238
-
239
-
240
-    /**
241
-     * _init_page_props
242
-     * Child classes use to set at least the following properties:
243
-     * $page_slug.
244
-     * $page_label.
245
-     *
246
-     * @abstract
247
-     * @return void
248
-     */
249
-    abstract protected function _init_page_props();
250
-
251
-
252
-    /**
253
-     * _ajax_hooks
254
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
255
-     * Note: within the ajax callback methods.
256
-     *
257
-     * @abstract
258
-     * @return void
259
-     */
260
-    abstract protected function _ajax_hooks();
261
-
262
-
263
-    /**
264
-     * _define_page_props
265
-     * child classes define page properties in here.  Must include at least:
266
-     * $_admin_base_url = base_url for all admin pages
267
-     * $_admin_page_title = default admin_page_title for admin pages
268
-     * $_labels = array of default labels for various automatically generated elements:
269
-     *    array(
270
-     *        'buttons' => array(
271
-     *            'add' => esc_html__('label for add new button'),
272
-     *            'edit' => esc_html__('label for edit button'),
273
-     *            'delete' => esc_html__('label for delete button')
274
-     *            )
275
-     *        )
276
-     *
277
-     * @abstract
278
-     * @return void
279
-     */
280
-    abstract protected function _define_page_props();
281
-
282
-
283
-    /**
284
-     * _set_page_routes
285
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
286
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
287
-     * have a 'default' route. Here's the format
288
-     * $this->_page_routes = array(
289
-     *        'default' => array(
290
-     *            'func' => '_default_method_handling_route',
291
-     *            'args' => array('array','of','args'),
292
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
293
-     *            ajax request, backend processing)
294
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
295
-     *            headers route after.  The string you enter here should match the defined route reference for a
296
-     *            headers sent route.
297
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
298
-     *            this route.
299
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
300
-     *            checks).
301
-     *        ),
302
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
303
-     *        handling method.
304
-     *        )
305
-     * )
306
-     *
307
-     * @abstract
308
-     * @return void
309
-     */
310
-    abstract protected function _set_page_routes();
311
-
312
-
313
-    /**
314
-     * _set_page_config
315
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
316
-     * array corresponds to the page_route for the loaded page. Format:
317
-     * $this->_page_config = array(
318
-     *        'default' => array(
319
-     *            'labels' => array(
320
-     *                'buttons' => array(
321
-     *                    'add' => esc_html__('label for adding item'),
322
-     *                    'edit' => esc_html__('label for editing item'),
323
-     *                    'delete' => esc_html__('label for deleting item')
324
-     *                ),
325
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
326
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
327
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
328
-     *            _define_page_props() method
329
-     *            'nav' => array(
330
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
331
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
332
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
333
-     *                'order' => 10, //required to indicate tab position.
334
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
335
-     *                displayed then add this parameter.
336
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
337
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
338
-     *            metaboxes set for eventespresso admin pages.
339
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
340
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
341
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
342
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
343
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
344
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
345
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
346
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
347
-     *            want to display.
348
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
349
-     *                'tab_id' => array(
350
-     *                    'title' => 'tab_title',
351
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
352
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
353
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
354
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
355
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
356
-     *                    attempt to use the callback which should match the name of a method in the class
357
-     *                    ),
358
-     *                'tab2_id' => array(
359
-     *                    'title' => 'tab2 title',
360
-     *                    'filename' => 'file_name_2'
361
-     *                    'callback' => 'callback_method_for_content',
362
-     *                 ),
363
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
364
-     *            help tab area on an admin page. @return void
365
-     *
366
-     * @link
367
-     *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
368
-     *                'help_tour' => array(
369
-     *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
370
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
371
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
372
-     *                ),
373
-     *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
374
-     *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
375
-     *                visited just set
376
-     *                'require_nonce' to FALSE
377
-     *                )
378
-     *                )
379
-     *
380
-     * @abstract
381
-     */
382
-    abstract protected function _set_page_config();
383
-
384
-
385
-
386
-
387
-
388
-    /** end sample help_tour methods **/
389
-    /**
390
-     * _add_screen_options
391
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
392
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
393
-     * to a particular view.
394
-     *
395
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
396
-     *         see also WP_Screen object documents...
397
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
398
-     * @abstract
399
-     * @return void
400
-     */
401
-    abstract protected function _add_screen_options();
402
-
403
-
404
-    /**
405
-     * _add_feature_pointers
406
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
407
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
408
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
409
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
410
-     * extended) also see:
411
-     *
412
-     * @link   http://eamann.com/tech/wordpress-portland/
413
-     * @abstract
414
-     * @return void
415
-     */
416
-    abstract protected function _add_feature_pointers();
417
-
418
-
419
-    /**
420
-     * load_scripts_styles
421
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
422
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
423
-     * scripts/styles per view by putting them in a dynamic function in this format
424
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
425
-     *
426
-     * @abstract
427
-     * @return void
428
-     */
429
-    abstract public function load_scripts_styles();
430
-
431
-
432
-    /**
433
-     * admin_init
434
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
435
-     * all pages/views loaded by child class.
436
-     *
437
-     * @abstract
438
-     * @return void
439
-     */
440
-    abstract public function admin_init();
441
-
442
-
443
-    /**
444
-     * admin_notices
445
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
446
-     * all pages/views loaded by child class.
447
-     *
448
-     * @abstract
449
-     * @return void
450
-     */
451
-    abstract public function admin_notices();
452
-
453
-
454
-    /**
455
-     * admin_footer_scripts
456
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
457
-     * will apply to all pages/views loaded by child class.
458
-     *
459
-     * @return void
460
-     */
461
-    abstract public function admin_footer_scripts();
462
-
463
-
464
-    /**
465
-     * admin_footer
466
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
467
-     * apply to all pages/views loaded by child class.
468
-     *
469
-     * @return void
470
-     */
471
-    public function admin_footer()
472
-    {
473
-    }
474
-
475
-
476
-    /**
477
-     * _global_ajax_hooks
478
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
479
-     * Note: within the ajax callback methods.
480
-     *
481
-     * @abstract
482
-     * @return void
483
-     */
484
-    protected function _global_ajax_hooks()
485
-    {
486
-        // for lazy loading of metabox content
487
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
488
-    }
489
-
490
-
491
-    public function ajax_metabox_content()
492
-    {
493
-        $content_id  = $this->request->getRequestParam('contentid', '');
494
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
495
-        self::cached_rss_display($content_id, $content_url);
496
-        wp_die();
497
-    }
498
-
499
-
500
-    /**
501
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
502
-     *
503
-     * @return void
504
-     */
505
-    protected function _before_page_setup()
506
-    {
507
-        // default is to do nothing
508
-    }
509
-
510
-
511
-    /**
512
-     * Makes sure any things that need to be loaded early get handled.
513
-     * We also escape early here if the page requested doesn't match the object.
514
-     *
515
-     * @final
516
-     * @return void
517
-     * @throws EE_Error
518
-     * @throws InvalidArgumentException
519
-     * @throws ReflectionException
520
-     * @throws InvalidDataTypeException
521
-     * @throws InvalidInterfaceException
522
-     */
523
-    final protected function _page_setup()
524
-    {
525
-        // requires?
526
-        // admin_init stuff - global - we're setting this REALLY early
527
-        // so if EE_Admin pages have to hook into other WP pages they can.
528
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
529
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
530
-        // next verify if we need to load anything...
531
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
532
-        $this->page_folder   = strtolower(
533
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
534
-        );
535
-        global $ee_menu_slugs;
536
-        $ee_menu_slugs = (array) $ee_menu_slugs;
537
-        if (
538
-            ! $this->request->isAjax()
539
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
540
-        ) {
541
-            return;
542
-        }
543
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
544
-        // we need to copy the action from the second to the first
545
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
546
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
547
-        $action     = $action !== '-1' ? $action : $action2;
548
-        $req_action = $action !== '-1' ? $action : 'default';
549
-
550
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
551
-        // then let's use the route as the action.
552
-        // This covers cases where we're coming in from a list table that isn't on the default route.
553
-        $route = $this->request->getRequestParam('route');
554
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
555
-            ? $route
556
-            : $req_action;
557
-
558
-        $this->_current_view = $this->_req_action;
559
-        $this->_req_nonce    = $this->_req_action . '_nonce';
560
-        $this->_define_page_props();
561
-        $this->_current_page_view_url = add_query_arg(
562
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
563
-            $this->_admin_base_url
564
-        );
565
-        // default things
566
-        $this->_default_espresso_metaboxes = [
567
-            '_espresso_news_post_box',
568
-            '_espresso_links_post_box',
569
-            '_espresso_ratings_request',
570
-            '_espresso_sponsors_post_box',
571
-        ];
572
-        // set page configs
573
-        $this->_set_page_routes();
574
-        $this->_set_page_config();
575
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
576
-        if ($this->request->requestParamIsSet('wp_referer')) {
577
-            $this->_default_route_query_args['wp_referer'] = $this->request->getRequestParam(
578
-                'wp_referer',
579
-                null,
580
-                'url'
581
-            );
582
-        }
583
-        // for caffeinated and other extended functionality.
584
-        //  If there is a _extend_page_config method
585
-        // then let's run that to modify the all the various page configuration arrays
586
-        if (method_exists($this, '_extend_page_config')) {
587
-            $this->_extend_page_config();
588
-        }
589
-        // for CPT and other extended functionality.
590
-        // If there is an _extend_page_config_for_cpt
591
-        // then let's run that to modify all the various page configuration arrays.
592
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
593
-            $this->_extend_page_config_for_cpt();
594
-        }
595
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
596
-        $this->_page_routes = apply_filters(
597
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
598
-            $this->_page_routes,
599
-            $this
600
-        );
601
-        $this->_page_config = apply_filters(
602
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
603
-            $this->_page_config,
604
-            $this
605
-        );
606
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
607
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
608
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
609
-            add_action(
610
-                'AHEE__EE_Admin_Page__route_admin_request',
611
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
612
-                10,
613
-                2
614
-            );
615
-        }
616
-        // next route only if routing enabled
617
-        if ($this->_routing && ! $this->request->isAjax()) {
618
-            $this->_verify_routes();
619
-            // next let's just check user_access and kill if no access
620
-            $this->check_user_access();
621
-            if ($this->_is_UI_request) {
622
-                // admin_init stuff - global, all views for this page class, specific view
623
-                add_action('admin_init', [$this, 'admin_init'], 10);
624
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
625
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
626
-                }
627
-            } else {
628
-                // hijack regular WP loading and route admin request immediately
629
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
630
-                $this->route_admin_request();
631
-            }
632
-        }
633
-    }
634
-
635
-
636
-    /**
637
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
638
-     *
639
-     * @return void
640
-     * @throws EE_Error
641
-     */
642
-    private function _do_other_page_hooks()
643
-    {
644
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
645
-        foreach ($registered_pages as $page) {
646
-            // now let's setup the file name and class that should be present
647
-            $classname = str_replace('.class.php', '', $page);
648
-            // autoloaders should take care of loading file
649
-            if (! class_exists($classname)) {
650
-                $error_msg[] = sprintf(
651
-                    esc_html__(
652
-                        'Something went wrong with loading the %s admin hooks page.',
653
-                        'event_espresso'
654
-                    ),
655
-                    $page
656
-                );
657
-                $error_msg[] = $error_msg[0]
658
-                               . "\r\n"
659
-                               . sprintf(
660
-                                   esc_html__(
661
-                                       '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',
662
-                                       'event_espresso'
663
-                                   ),
664
-                                   $page,
665
-                                   '<br />',
666
-                                   '<strong>' . $classname . '</strong>'
667
-                               );
668
-                throw new EE_Error(implode('||', $error_msg));
669
-            }
670
-            // notice we are passing the instance of this class to the hook object.
671
-            $this->loader->getShared($classname, [$this]);
672
-        }
673
-    }
674
-
675
-
676
-    /**
677
-     * @throws ReflectionException
678
-     * @throws EE_Error
679
-     */
680
-    public function load_page_dependencies()
681
-    {
682
-        try {
683
-            $this->_load_page_dependencies();
684
-        } catch (EE_Error $e) {
685
-            $e->get_error();
686
-        }
687
-    }
688
-
689
-
690
-    /**
691
-     * load_page_dependencies
692
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
693
-     *
694
-     * @return void
695
-     * @throws DomainException
696
-     * @throws EE_Error
697
-     * @throws InvalidArgumentException
698
-     * @throws InvalidDataTypeException
699
-     * @throws InvalidInterfaceException
700
-     */
701
-    protected function _load_page_dependencies()
702
-    {
703
-        // let's set the current_screen and screen options to override what WP set
704
-        $this->_current_screen = get_current_screen();
705
-        // load admin_notices - global, page class, and view specific
706
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
707
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
708
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
709
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
710
-        }
711
-        // load network admin_notices - global, page class, and view specific
712
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
713
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
714
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
715
-        }
716
-        // this will save any per_page screen options if they are present
717
-        $this->_set_per_page_screen_options();
718
-        // setup list table properties
719
-        $this->_set_list_table();
720
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
721
-        // However in some cases the metaboxes will need to be added within a route handling callback.
722
-        $this->_add_registered_meta_boxes();
723
-        $this->_add_screen_columns();
724
-        // add screen options - global, page child class, and view specific
725
-        $this->_add_global_screen_options();
726
-        $this->_add_screen_options();
727
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
728
-        if (method_exists($this, $add_screen_options)) {
729
-            $this->{$add_screen_options}();
730
-        }
731
-        // add help tab(s) and tours- set via page_config and qtips.
732
-        // $this->_add_help_tour();
733
-        $this->_add_help_tabs();
734
-        $this->_add_qtips();
735
-        // add feature_pointers - global, page child class, and view specific
736
-        $this->_add_feature_pointers();
737
-        $this->_add_global_feature_pointers();
738
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
739
-        if (method_exists($this, $add_feature_pointer)) {
740
-            $this->{$add_feature_pointer}();
741
-        }
742
-        // enqueue scripts/styles - global, page class, and view specific
743
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
744
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
745
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
746
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
747
-        }
748
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
749
-        // admin_print_footer_scripts - global, page child class, and view specific.
750
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
751
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
752
-        // is a good use case. Notice the late priority we're giving these
753
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
754
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
755
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
756
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
757
-        }
758
-        // admin footer scripts
759
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
760
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
761
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
762
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
763
-        }
764
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
765
-        // targeted hook
766
-        do_action(
767
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
768
-        );
769
-    }
770
-
771
-
772
-    /**
773
-     * _set_defaults
774
-     * This sets some global defaults for class properties.
775
-     */
776
-    private function _set_defaults()
777
-    {
778
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
779
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
780
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
781
-        $this->_page_config          = $this->_default_route_query_args = [];
782
-        $this->_default_nav_tab_name = 'overview';
783
-        // init template args
784
-        $this->_template_args = [
785
-            'admin_page_header'  => '',
786
-            'admin_page_content' => '',
787
-            'post_body_content'  => '',
788
-            'before_list_table'  => '',
789
-            'after_list_table'   => '',
790
-        ];
791
-    }
792
-
793
-
794
-    /**
795
-     * route_admin_request
796
-     *
797
-     * @return void
798
-     * @throws InvalidArgumentException
799
-     * @throws InvalidInterfaceException
800
-     * @throws InvalidDataTypeException
801
-     * @throws EE_Error
802
-     * @throws ReflectionException
803
-     * @see    _route_admin_request()
804
-     */
805
-    public function route_admin_request()
806
-    {
807
-        try {
808
-            $this->_route_admin_request();
809
-        } catch (EE_Error $e) {
810
-            $e->get_error();
811
-        }
812
-    }
813
-
814
-
815
-    public function set_wp_page_slug($wp_page_slug)
816
-    {
817
-        $this->_wp_page_slug = $wp_page_slug;
818
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
819
-        if (is_network_admin()) {
820
-            $this->_wp_page_slug .= '-network';
821
-        }
822
-    }
823
-
824
-
825
-    /**
826
-     * _verify_routes
827
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
828
-     * we know if we need to drop out.
829
-     *
830
-     * @return bool
831
-     * @throws EE_Error
832
-     */
833
-    protected function _verify_routes()
834
-    {
835
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
836
-        if (! $this->_current_page && ! $this->request->isAjax()) {
837
-            return false;
838
-        }
839
-        $this->_route = false;
840
-        // check that the page_routes array is not empty
841
-        if (empty($this->_page_routes)) {
842
-            // user error msg
843
-            $error_msg = sprintf(
844
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
845
-                $this->_admin_page_title
846
-            );
847
-            // developer error msg
848
-            $error_msg .= '||' . $error_msg
849
-                          . esc_html__(
850
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
851
-                              'event_espresso'
852
-                          );
853
-            throw new EE_Error($error_msg);
854
-        }
855
-        // and that the requested page route exists
856
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
857
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
858
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
859
-                ? $this->_page_config[ $this->_req_action ]
860
-                : [];
861
-        } else {
862
-            // user error msg
863
-            $error_msg = sprintf(
864
-                esc_html__(
865
-                    'The requested page route does not exist for the %s admin page.',
866
-                    'event_espresso'
867
-                ),
868
-                $this->_admin_page_title
869
-            );
870
-            // developer error msg
871
-            $error_msg .= '||' . $error_msg
872
-                          . sprintf(
873
-                              esc_html__(
874
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
875
-                                  'event_espresso'
876
-                              ),
877
-                              $this->_req_action
878
-                          );
879
-            throw new EE_Error($error_msg);
880
-        }
881
-        // and that a default route exists
882
-        if (! array_key_exists('default', $this->_page_routes)) {
883
-            // user error msg
884
-            $error_msg = sprintf(
885
-                esc_html__(
886
-                    'A default page route has not been set for the % admin page.',
887
-                    'event_espresso'
888
-                ),
889
-                $this->_admin_page_title
890
-            );
891
-            // developer error msg
892
-            $error_msg .= '||' . $error_msg
893
-                          . esc_html__(
894
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
895
-                              'event_espresso'
896
-                          );
897
-            throw new EE_Error($error_msg);
898
-        }
899
-        // first lets' catch if the UI request has EVER been set.
900
-        if ($this->_is_UI_request === null) {
901
-            // lets set if this is a UI request or not.
902
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
903
-            // wait a minute... we might have a noheader in the route array
904
-            $this->_is_UI_request = ! (
905
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
906
-            )
907
-                ? $this->_is_UI_request
908
-                : false;
909
-        }
910
-        $this->_set_current_labels();
911
-        return true;
912
-    }
913
-
914
-
915
-    /**
916
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
917
-     *
918
-     * @param string $route the route name we're verifying
919
-     * @return bool we'll throw an exception if this isn't a valid route.
920
-     * @throws EE_Error
921
-     */
922
-    protected function _verify_route($route)
923
-    {
924
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
925
-            return true;
926
-        }
927
-        // user error msg
928
-        $error_msg = sprintf(
929
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
930
-            $this->_admin_page_title
931
-        );
932
-        // developer error msg
933
-        $error_msg .= '||' . $error_msg
934
-                      . sprintf(
935
-                          esc_html__(
936
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
937
-                              'event_espresso'
938
-                          ),
939
-                          $route
940
-                      );
941
-        throw new EE_Error($error_msg);
942
-    }
943
-
944
-
945
-    /**
946
-     * perform nonce verification
947
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
948
-     * using this method (and save retyping!)
949
-     *
950
-     * @param string $nonce     The nonce sent
951
-     * @param string $nonce_ref The nonce reference string (name0)
952
-     * @return void
953
-     * @throws EE_Error
954
-     */
955
-    protected function _verify_nonce($nonce, $nonce_ref)
956
-    {
957
-        // verify nonce against expected value
958
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
959
-            // these are not the droids you are looking for !!!
960
-            $msg = sprintf(
961
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
962
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
963
-                '</a>'
964
-            );
965
-            if (WP_DEBUG) {
966
-                $msg .= "\n  ";
967
-                $msg .= sprintf(
968
-                    esc_html__(
969
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
970
-                        'event_espresso'
971
-                    ),
972
-                    __CLASS__
973
-                );
974
-            }
975
-            if (! $this->request->isAjax()) {
976
-                wp_die($msg);
977
-            }
978
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
979
-            $this->_return_json();
980
-        }
981
-    }
982
-
983
-
984
-    /**
985
-     * _route_admin_request()
986
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
987
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
988
-     * in the page routes and then will try to load the corresponding method.
989
-     *
990
-     * @return void
991
-     * @throws EE_Error
992
-     * @throws InvalidArgumentException
993
-     * @throws InvalidDataTypeException
994
-     * @throws InvalidInterfaceException
995
-     * @throws ReflectionException
996
-     */
997
-    protected function _route_admin_request()
998
-    {
999
-        if (! $this->_is_UI_request) {
1000
-            $this->_verify_routes();
1001
-        }
1002
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1003
-        if ($this->_req_action !== 'default' && $nonce_check) {
1004
-            // set nonce from post data
1005
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
1006
-            $this->_verify_nonce($nonce, $this->_req_nonce);
1007
-        }
1008
-        // set the nav_tabs array but ONLY if this is  UI_request
1009
-        if ($this->_is_UI_request) {
1010
-            $this->_set_nav_tabs();
1011
-        }
1012
-        // grab callback function
1013
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
1014
-        // check if callback has args
1015
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1016
-        $error_msg = '';
1017
-        // action right before calling route
1018
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1019
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1020
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1021
-        }
1022
-        // right before calling the route, let's clean the _wp_http_referer
1023
-        $this->request->setServerParam(
1024
-            'REQUEST_URI',
1025
-            remove_query_arg(
1026
-                '_wp_http_referer',
1027
-                wp_unslash($this->request->getServerParam('REQUEST_URI'))
1028
-            )
1029
-        );
1030
-        if (! empty($func)) {
1031
-            if (is_array($func)) {
1032
-                list($class, $method) = $func;
1033
-            } elseif (strpos($func, '::') !== false) {
1034
-                list($class, $method) = explode('::', $func);
1035
-            } else {
1036
-                $class  = $this;
1037
-                $method = $func;
1038
-            }
1039
-            if (! (is_object($class) && $class === $this)) {
1040
-                // send along this admin page object for access by addons.
1041
-                $args['admin_page_object'] = $this;
1042
-            }
1043
-            if (
115
+	/**
116
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
117
+	 * actions.
118
+	 *
119
+	 * @since 4.6.x
120
+	 * @var array.
121
+	 */
122
+	protected $_default_route_query_args;
123
+
124
+	// set via request page and action args.
125
+	protected $_current_page;
126
+
127
+	protected $_current_view;
128
+
129
+	protected $_current_page_view_url;
130
+
131
+	/**
132
+	 * unprocessed value for the 'action' request param (default '')
133
+	 *
134
+	 * @var string
135
+	 */
136
+	protected $raw_req_action = '';
137
+
138
+	/**
139
+	 * unprocessed value for the 'page' request param (default '')
140
+	 *
141
+	 * @var string
142
+	 */
143
+	protected $raw_req_page = '';
144
+
145
+	/**
146
+	 * sanitized request action (and nonce)
147
+	 *
148
+	 * @var string
149
+	 */
150
+	protected $_req_action = '';
151
+
152
+	/**
153
+	 * sanitized request action nonce
154
+	 *
155
+	 * @var string
156
+	 */
157
+	protected $_req_nonce = '';
158
+
159
+	/**
160
+	 * @var string
161
+	 */
162
+	protected $_search_btn_label = '';
163
+
164
+	/**
165
+	 * @var string
166
+	 */
167
+	protected $_search_box_callback = '';
168
+
169
+	/**
170
+	 * @var WP_Screen
171
+	 */
172
+	protected $_current_screen;
173
+
174
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
175
+	protected $_hook_obj;
176
+
177
+	// for holding incoming request data
178
+	protected $_req_data = [];
179
+
180
+	// yes / no array for admin form fields
181
+	protected $_yes_no_values = [];
182
+
183
+	// some default things shared by all child classes
184
+	protected $_default_espresso_metaboxes;
185
+
186
+	/**
187
+	 * @var EE_Registry
188
+	 */
189
+	protected $EE = null;
190
+
191
+
192
+	/**
193
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
194
+	 *
195
+	 * @var boolean
196
+	 */
197
+	protected $_is_caf = false;
198
+
199
+
200
+	/**
201
+	 * @Constructor
202
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
203
+	 * @throws EE_Error
204
+	 * @throws InvalidArgumentException
205
+	 * @throws ReflectionException
206
+	 * @throws InvalidDataTypeException
207
+	 * @throws InvalidInterfaceException
208
+	 */
209
+	public function __construct($routing = true)
210
+	{
211
+		$this->loader  = LoaderFactory::getLoader();
212
+		$this->request = $this->loader->getShared(RequestInterface::class);
213
+		$this->_routing = $routing;
214
+
215
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
216
+			$this->_is_caf = true;
217
+		}
218
+		$this->_yes_no_values = [
219
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
220
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
221
+		];
222
+		// set the _req_data property.
223
+		$this->_req_data = $this->request->requestParams();
224
+		// set initial page props (child method)
225
+		$this->_init_page_props();
226
+		// set global defaults
227
+		$this->_set_defaults();
228
+		// set early because incoming requests could be ajax related and we need to register those hooks.
229
+		$this->_global_ajax_hooks();
230
+		$this->_ajax_hooks();
231
+		// other_page_hooks have to be early too.
232
+		$this->_do_other_page_hooks();
233
+		// set up page dependencies
234
+		$this->_before_page_setup();
235
+		$this->_page_setup();
236
+		// die();
237
+	}
238
+
239
+
240
+	/**
241
+	 * _init_page_props
242
+	 * Child classes use to set at least the following properties:
243
+	 * $page_slug.
244
+	 * $page_label.
245
+	 *
246
+	 * @abstract
247
+	 * @return void
248
+	 */
249
+	abstract protected function _init_page_props();
250
+
251
+
252
+	/**
253
+	 * _ajax_hooks
254
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
255
+	 * Note: within the ajax callback methods.
256
+	 *
257
+	 * @abstract
258
+	 * @return void
259
+	 */
260
+	abstract protected function _ajax_hooks();
261
+
262
+
263
+	/**
264
+	 * _define_page_props
265
+	 * child classes define page properties in here.  Must include at least:
266
+	 * $_admin_base_url = base_url for all admin pages
267
+	 * $_admin_page_title = default admin_page_title for admin pages
268
+	 * $_labels = array of default labels for various automatically generated elements:
269
+	 *    array(
270
+	 *        'buttons' => array(
271
+	 *            'add' => esc_html__('label for add new button'),
272
+	 *            'edit' => esc_html__('label for edit button'),
273
+	 *            'delete' => esc_html__('label for delete button')
274
+	 *            )
275
+	 *        )
276
+	 *
277
+	 * @abstract
278
+	 * @return void
279
+	 */
280
+	abstract protected function _define_page_props();
281
+
282
+
283
+	/**
284
+	 * _set_page_routes
285
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
286
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
287
+	 * have a 'default' route. Here's the format
288
+	 * $this->_page_routes = array(
289
+	 *        'default' => array(
290
+	 *            'func' => '_default_method_handling_route',
291
+	 *            'args' => array('array','of','args'),
292
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
293
+	 *            ajax request, backend processing)
294
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
295
+	 *            headers route after.  The string you enter here should match the defined route reference for a
296
+	 *            headers sent route.
297
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
298
+	 *            this route.
299
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
300
+	 *            checks).
301
+	 *        ),
302
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
303
+	 *        handling method.
304
+	 *        )
305
+	 * )
306
+	 *
307
+	 * @abstract
308
+	 * @return void
309
+	 */
310
+	abstract protected function _set_page_routes();
311
+
312
+
313
+	/**
314
+	 * _set_page_config
315
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
316
+	 * array corresponds to the page_route for the loaded page. Format:
317
+	 * $this->_page_config = array(
318
+	 *        'default' => array(
319
+	 *            'labels' => array(
320
+	 *                'buttons' => array(
321
+	 *                    'add' => esc_html__('label for adding item'),
322
+	 *                    'edit' => esc_html__('label for editing item'),
323
+	 *                    'delete' => esc_html__('label for deleting item')
324
+	 *                ),
325
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
326
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
327
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
328
+	 *            _define_page_props() method
329
+	 *            'nav' => array(
330
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
331
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
332
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
333
+	 *                'order' => 10, //required to indicate tab position.
334
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
335
+	 *                displayed then add this parameter.
336
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
337
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
338
+	 *            metaboxes set for eventespresso admin pages.
339
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
340
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
341
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
342
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
343
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
344
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
345
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
346
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
347
+	 *            want to display.
348
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
349
+	 *                'tab_id' => array(
350
+	 *                    'title' => 'tab_title',
351
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
352
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
353
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
354
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
355
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
356
+	 *                    attempt to use the callback which should match the name of a method in the class
357
+	 *                    ),
358
+	 *                'tab2_id' => array(
359
+	 *                    'title' => 'tab2 title',
360
+	 *                    'filename' => 'file_name_2'
361
+	 *                    'callback' => 'callback_method_for_content',
362
+	 *                 ),
363
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
364
+	 *            help tab area on an admin page. @return void
365
+	 *
366
+	 * @link
367
+	 *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
368
+	 *                'help_tour' => array(
369
+	 *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
370
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
371
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
372
+	 *                ),
373
+	 *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
374
+	 *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
375
+	 *                visited just set
376
+	 *                'require_nonce' to FALSE
377
+	 *                )
378
+	 *                )
379
+	 *
380
+	 * @abstract
381
+	 */
382
+	abstract protected function _set_page_config();
383
+
384
+
385
+
386
+
387
+
388
+	/** end sample help_tour methods **/
389
+	/**
390
+	 * _add_screen_options
391
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
392
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
393
+	 * to a particular view.
394
+	 *
395
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
396
+	 *         see also WP_Screen object documents...
397
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
398
+	 * @abstract
399
+	 * @return void
400
+	 */
401
+	abstract protected function _add_screen_options();
402
+
403
+
404
+	/**
405
+	 * _add_feature_pointers
406
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
407
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
408
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
409
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
410
+	 * extended) also see:
411
+	 *
412
+	 * @link   http://eamann.com/tech/wordpress-portland/
413
+	 * @abstract
414
+	 * @return void
415
+	 */
416
+	abstract protected function _add_feature_pointers();
417
+
418
+
419
+	/**
420
+	 * load_scripts_styles
421
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
422
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
423
+	 * scripts/styles per view by putting them in a dynamic function in this format
424
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
425
+	 *
426
+	 * @abstract
427
+	 * @return void
428
+	 */
429
+	abstract public function load_scripts_styles();
430
+
431
+
432
+	/**
433
+	 * admin_init
434
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
435
+	 * all pages/views loaded by child class.
436
+	 *
437
+	 * @abstract
438
+	 * @return void
439
+	 */
440
+	abstract public function admin_init();
441
+
442
+
443
+	/**
444
+	 * admin_notices
445
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
446
+	 * all pages/views loaded by child class.
447
+	 *
448
+	 * @abstract
449
+	 * @return void
450
+	 */
451
+	abstract public function admin_notices();
452
+
453
+
454
+	/**
455
+	 * admin_footer_scripts
456
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
457
+	 * will apply to all pages/views loaded by child class.
458
+	 *
459
+	 * @return void
460
+	 */
461
+	abstract public function admin_footer_scripts();
462
+
463
+
464
+	/**
465
+	 * admin_footer
466
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
467
+	 * apply to all pages/views loaded by child class.
468
+	 *
469
+	 * @return void
470
+	 */
471
+	public function admin_footer()
472
+	{
473
+	}
474
+
475
+
476
+	/**
477
+	 * _global_ajax_hooks
478
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
479
+	 * Note: within the ajax callback methods.
480
+	 *
481
+	 * @abstract
482
+	 * @return void
483
+	 */
484
+	protected function _global_ajax_hooks()
485
+	{
486
+		// for lazy loading of metabox content
487
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
488
+	}
489
+
490
+
491
+	public function ajax_metabox_content()
492
+	{
493
+		$content_id  = $this->request->getRequestParam('contentid', '');
494
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
495
+		self::cached_rss_display($content_id, $content_url);
496
+		wp_die();
497
+	}
498
+
499
+
500
+	/**
501
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
502
+	 *
503
+	 * @return void
504
+	 */
505
+	protected function _before_page_setup()
506
+	{
507
+		// default is to do nothing
508
+	}
509
+
510
+
511
+	/**
512
+	 * Makes sure any things that need to be loaded early get handled.
513
+	 * We also escape early here if the page requested doesn't match the object.
514
+	 *
515
+	 * @final
516
+	 * @return void
517
+	 * @throws EE_Error
518
+	 * @throws InvalidArgumentException
519
+	 * @throws ReflectionException
520
+	 * @throws InvalidDataTypeException
521
+	 * @throws InvalidInterfaceException
522
+	 */
523
+	final protected function _page_setup()
524
+	{
525
+		// requires?
526
+		// admin_init stuff - global - we're setting this REALLY early
527
+		// so if EE_Admin pages have to hook into other WP pages they can.
528
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
529
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
530
+		// next verify if we need to load anything...
531
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
532
+		$this->page_folder   = strtolower(
533
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
534
+		);
535
+		global $ee_menu_slugs;
536
+		$ee_menu_slugs = (array) $ee_menu_slugs;
537
+		if (
538
+			! $this->request->isAjax()
539
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
540
+		) {
541
+			return;
542
+		}
543
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
544
+		// we need to copy the action from the second to the first
545
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
546
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
547
+		$action     = $action !== '-1' ? $action : $action2;
548
+		$req_action = $action !== '-1' ? $action : 'default';
549
+
550
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
551
+		// then let's use the route as the action.
552
+		// This covers cases where we're coming in from a list table that isn't on the default route.
553
+		$route = $this->request->getRequestParam('route');
554
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
555
+			? $route
556
+			: $req_action;
557
+
558
+		$this->_current_view = $this->_req_action;
559
+		$this->_req_nonce    = $this->_req_action . '_nonce';
560
+		$this->_define_page_props();
561
+		$this->_current_page_view_url = add_query_arg(
562
+			['page' => $this->_current_page, 'action' => $this->_current_view],
563
+			$this->_admin_base_url
564
+		);
565
+		// default things
566
+		$this->_default_espresso_metaboxes = [
567
+			'_espresso_news_post_box',
568
+			'_espresso_links_post_box',
569
+			'_espresso_ratings_request',
570
+			'_espresso_sponsors_post_box',
571
+		];
572
+		// set page configs
573
+		$this->_set_page_routes();
574
+		$this->_set_page_config();
575
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
576
+		if ($this->request->requestParamIsSet('wp_referer')) {
577
+			$this->_default_route_query_args['wp_referer'] = $this->request->getRequestParam(
578
+				'wp_referer',
579
+				null,
580
+				'url'
581
+			);
582
+		}
583
+		// for caffeinated and other extended functionality.
584
+		//  If there is a _extend_page_config method
585
+		// then let's run that to modify the all the various page configuration arrays
586
+		if (method_exists($this, '_extend_page_config')) {
587
+			$this->_extend_page_config();
588
+		}
589
+		// for CPT and other extended functionality.
590
+		// If there is an _extend_page_config_for_cpt
591
+		// then let's run that to modify all the various page configuration arrays.
592
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
593
+			$this->_extend_page_config_for_cpt();
594
+		}
595
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
596
+		$this->_page_routes = apply_filters(
597
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
598
+			$this->_page_routes,
599
+			$this
600
+		);
601
+		$this->_page_config = apply_filters(
602
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
603
+			$this->_page_config,
604
+			$this
605
+		);
606
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
607
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
608
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
609
+			add_action(
610
+				'AHEE__EE_Admin_Page__route_admin_request',
611
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
612
+				10,
613
+				2
614
+			);
615
+		}
616
+		// next route only if routing enabled
617
+		if ($this->_routing && ! $this->request->isAjax()) {
618
+			$this->_verify_routes();
619
+			// next let's just check user_access and kill if no access
620
+			$this->check_user_access();
621
+			if ($this->_is_UI_request) {
622
+				// admin_init stuff - global, all views for this page class, specific view
623
+				add_action('admin_init', [$this, 'admin_init'], 10);
624
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
625
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
626
+				}
627
+			} else {
628
+				// hijack regular WP loading and route admin request immediately
629
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
630
+				$this->route_admin_request();
631
+			}
632
+		}
633
+	}
634
+
635
+
636
+	/**
637
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
638
+	 *
639
+	 * @return void
640
+	 * @throws EE_Error
641
+	 */
642
+	private function _do_other_page_hooks()
643
+	{
644
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
645
+		foreach ($registered_pages as $page) {
646
+			// now let's setup the file name and class that should be present
647
+			$classname = str_replace('.class.php', '', $page);
648
+			// autoloaders should take care of loading file
649
+			if (! class_exists($classname)) {
650
+				$error_msg[] = sprintf(
651
+					esc_html__(
652
+						'Something went wrong with loading the %s admin hooks page.',
653
+						'event_espresso'
654
+					),
655
+					$page
656
+				);
657
+				$error_msg[] = $error_msg[0]
658
+							   . "\r\n"
659
+							   . sprintf(
660
+								   esc_html__(
661
+									   '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',
662
+									   'event_espresso'
663
+								   ),
664
+								   $page,
665
+								   '<br />',
666
+								   '<strong>' . $classname . '</strong>'
667
+							   );
668
+				throw new EE_Error(implode('||', $error_msg));
669
+			}
670
+			// notice we are passing the instance of this class to the hook object.
671
+			$this->loader->getShared($classname, [$this]);
672
+		}
673
+	}
674
+
675
+
676
+	/**
677
+	 * @throws ReflectionException
678
+	 * @throws EE_Error
679
+	 */
680
+	public function load_page_dependencies()
681
+	{
682
+		try {
683
+			$this->_load_page_dependencies();
684
+		} catch (EE_Error $e) {
685
+			$e->get_error();
686
+		}
687
+	}
688
+
689
+
690
+	/**
691
+	 * load_page_dependencies
692
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
693
+	 *
694
+	 * @return void
695
+	 * @throws DomainException
696
+	 * @throws EE_Error
697
+	 * @throws InvalidArgumentException
698
+	 * @throws InvalidDataTypeException
699
+	 * @throws InvalidInterfaceException
700
+	 */
701
+	protected function _load_page_dependencies()
702
+	{
703
+		// let's set the current_screen and screen options to override what WP set
704
+		$this->_current_screen = get_current_screen();
705
+		// load admin_notices - global, page class, and view specific
706
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
707
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
708
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
709
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
710
+		}
711
+		// load network admin_notices - global, page class, and view specific
712
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
713
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
714
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
715
+		}
716
+		// this will save any per_page screen options if they are present
717
+		$this->_set_per_page_screen_options();
718
+		// setup list table properties
719
+		$this->_set_list_table();
720
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
721
+		// However in some cases the metaboxes will need to be added within a route handling callback.
722
+		$this->_add_registered_meta_boxes();
723
+		$this->_add_screen_columns();
724
+		// add screen options - global, page child class, and view specific
725
+		$this->_add_global_screen_options();
726
+		$this->_add_screen_options();
727
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
728
+		if (method_exists($this, $add_screen_options)) {
729
+			$this->{$add_screen_options}();
730
+		}
731
+		// add help tab(s) and tours- set via page_config and qtips.
732
+		// $this->_add_help_tour();
733
+		$this->_add_help_tabs();
734
+		$this->_add_qtips();
735
+		// add feature_pointers - global, page child class, and view specific
736
+		$this->_add_feature_pointers();
737
+		$this->_add_global_feature_pointers();
738
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
739
+		if (method_exists($this, $add_feature_pointer)) {
740
+			$this->{$add_feature_pointer}();
741
+		}
742
+		// enqueue scripts/styles - global, page class, and view specific
743
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
744
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
745
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
746
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
747
+		}
748
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
749
+		// admin_print_footer_scripts - global, page child class, and view specific.
750
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
751
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
752
+		// is a good use case. Notice the late priority we're giving these
753
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
754
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
755
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
756
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
757
+		}
758
+		// admin footer scripts
759
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
760
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
761
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
762
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
763
+		}
764
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
765
+		// targeted hook
766
+		do_action(
767
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
768
+		);
769
+	}
770
+
771
+
772
+	/**
773
+	 * _set_defaults
774
+	 * This sets some global defaults for class properties.
775
+	 */
776
+	private function _set_defaults()
777
+	{
778
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
779
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
780
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
781
+		$this->_page_config          = $this->_default_route_query_args = [];
782
+		$this->_default_nav_tab_name = 'overview';
783
+		// init template args
784
+		$this->_template_args = [
785
+			'admin_page_header'  => '',
786
+			'admin_page_content' => '',
787
+			'post_body_content'  => '',
788
+			'before_list_table'  => '',
789
+			'after_list_table'   => '',
790
+		];
791
+	}
792
+
793
+
794
+	/**
795
+	 * route_admin_request
796
+	 *
797
+	 * @return void
798
+	 * @throws InvalidArgumentException
799
+	 * @throws InvalidInterfaceException
800
+	 * @throws InvalidDataTypeException
801
+	 * @throws EE_Error
802
+	 * @throws ReflectionException
803
+	 * @see    _route_admin_request()
804
+	 */
805
+	public function route_admin_request()
806
+	{
807
+		try {
808
+			$this->_route_admin_request();
809
+		} catch (EE_Error $e) {
810
+			$e->get_error();
811
+		}
812
+	}
813
+
814
+
815
+	public function set_wp_page_slug($wp_page_slug)
816
+	{
817
+		$this->_wp_page_slug = $wp_page_slug;
818
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
819
+		if (is_network_admin()) {
820
+			$this->_wp_page_slug .= '-network';
821
+		}
822
+	}
823
+
824
+
825
+	/**
826
+	 * _verify_routes
827
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
828
+	 * we know if we need to drop out.
829
+	 *
830
+	 * @return bool
831
+	 * @throws EE_Error
832
+	 */
833
+	protected function _verify_routes()
834
+	{
835
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
836
+		if (! $this->_current_page && ! $this->request->isAjax()) {
837
+			return false;
838
+		}
839
+		$this->_route = false;
840
+		// check that the page_routes array is not empty
841
+		if (empty($this->_page_routes)) {
842
+			// user error msg
843
+			$error_msg = sprintf(
844
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
845
+				$this->_admin_page_title
846
+			);
847
+			// developer error msg
848
+			$error_msg .= '||' . $error_msg
849
+						  . esc_html__(
850
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
851
+							  'event_espresso'
852
+						  );
853
+			throw new EE_Error($error_msg);
854
+		}
855
+		// and that the requested page route exists
856
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
857
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
858
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
859
+				? $this->_page_config[ $this->_req_action ]
860
+				: [];
861
+		} else {
862
+			// user error msg
863
+			$error_msg = sprintf(
864
+				esc_html__(
865
+					'The requested page route does not exist for the %s admin page.',
866
+					'event_espresso'
867
+				),
868
+				$this->_admin_page_title
869
+			);
870
+			// developer error msg
871
+			$error_msg .= '||' . $error_msg
872
+						  . sprintf(
873
+							  esc_html__(
874
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
875
+								  'event_espresso'
876
+							  ),
877
+							  $this->_req_action
878
+						  );
879
+			throw new EE_Error($error_msg);
880
+		}
881
+		// and that a default route exists
882
+		if (! array_key_exists('default', $this->_page_routes)) {
883
+			// user error msg
884
+			$error_msg = sprintf(
885
+				esc_html__(
886
+					'A default page route has not been set for the % admin page.',
887
+					'event_espresso'
888
+				),
889
+				$this->_admin_page_title
890
+			);
891
+			// developer error msg
892
+			$error_msg .= '||' . $error_msg
893
+						  . esc_html__(
894
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
895
+							  'event_espresso'
896
+						  );
897
+			throw new EE_Error($error_msg);
898
+		}
899
+		// first lets' catch if the UI request has EVER been set.
900
+		if ($this->_is_UI_request === null) {
901
+			// lets set if this is a UI request or not.
902
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
903
+			// wait a minute... we might have a noheader in the route array
904
+			$this->_is_UI_request = ! (
905
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
906
+			)
907
+				? $this->_is_UI_request
908
+				: false;
909
+		}
910
+		$this->_set_current_labels();
911
+		return true;
912
+	}
913
+
914
+
915
+	/**
916
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
917
+	 *
918
+	 * @param string $route the route name we're verifying
919
+	 * @return bool we'll throw an exception if this isn't a valid route.
920
+	 * @throws EE_Error
921
+	 */
922
+	protected function _verify_route($route)
923
+	{
924
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
925
+			return true;
926
+		}
927
+		// user error msg
928
+		$error_msg = sprintf(
929
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
930
+			$this->_admin_page_title
931
+		);
932
+		// developer error msg
933
+		$error_msg .= '||' . $error_msg
934
+					  . sprintf(
935
+						  esc_html__(
936
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
937
+							  'event_espresso'
938
+						  ),
939
+						  $route
940
+					  );
941
+		throw new EE_Error($error_msg);
942
+	}
943
+
944
+
945
+	/**
946
+	 * perform nonce verification
947
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
948
+	 * using this method (and save retyping!)
949
+	 *
950
+	 * @param string $nonce     The nonce sent
951
+	 * @param string $nonce_ref The nonce reference string (name0)
952
+	 * @return void
953
+	 * @throws EE_Error
954
+	 */
955
+	protected function _verify_nonce($nonce, $nonce_ref)
956
+	{
957
+		// verify nonce against expected value
958
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
959
+			// these are not the droids you are looking for !!!
960
+			$msg = sprintf(
961
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
962
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
963
+				'</a>'
964
+			);
965
+			if (WP_DEBUG) {
966
+				$msg .= "\n  ";
967
+				$msg .= sprintf(
968
+					esc_html__(
969
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
970
+						'event_espresso'
971
+					),
972
+					__CLASS__
973
+				);
974
+			}
975
+			if (! $this->request->isAjax()) {
976
+				wp_die($msg);
977
+			}
978
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
979
+			$this->_return_json();
980
+		}
981
+	}
982
+
983
+
984
+	/**
985
+	 * _route_admin_request()
986
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
987
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
988
+	 * in the page routes and then will try to load the corresponding method.
989
+	 *
990
+	 * @return void
991
+	 * @throws EE_Error
992
+	 * @throws InvalidArgumentException
993
+	 * @throws InvalidDataTypeException
994
+	 * @throws InvalidInterfaceException
995
+	 * @throws ReflectionException
996
+	 */
997
+	protected function _route_admin_request()
998
+	{
999
+		if (! $this->_is_UI_request) {
1000
+			$this->_verify_routes();
1001
+		}
1002
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1003
+		if ($this->_req_action !== 'default' && $nonce_check) {
1004
+			// set nonce from post data
1005
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
1006
+			$this->_verify_nonce($nonce, $this->_req_nonce);
1007
+		}
1008
+		// set the nav_tabs array but ONLY if this is  UI_request
1009
+		if ($this->_is_UI_request) {
1010
+			$this->_set_nav_tabs();
1011
+		}
1012
+		// grab callback function
1013
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
1014
+		// check if callback has args
1015
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1016
+		$error_msg = '';
1017
+		// action right before calling route
1018
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1019
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1020
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1021
+		}
1022
+		// right before calling the route, let's clean the _wp_http_referer
1023
+		$this->request->setServerParam(
1024
+			'REQUEST_URI',
1025
+			remove_query_arg(
1026
+				'_wp_http_referer',
1027
+				wp_unslash($this->request->getServerParam('REQUEST_URI'))
1028
+			)
1029
+		);
1030
+		if (! empty($func)) {
1031
+			if (is_array($func)) {
1032
+				list($class, $method) = $func;
1033
+			} elseif (strpos($func, '::') !== false) {
1034
+				list($class, $method) = explode('::', $func);
1035
+			} else {
1036
+				$class  = $this;
1037
+				$method = $func;
1038
+			}
1039
+			if (! (is_object($class) && $class === $this)) {
1040
+				// send along this admin page object for access by addons.
1041
+				$args['admin_page_object'] = $this;
1042
+			}
1043
+			if (
1044 1044
 // is it a method on a class that doesn't work?
1045
-                (
1046
-                    (
1047
-                        method_exists($class, $method)
1048
-                        && call_user_func_array([$class, $method], $args) === false
1049
-                    )
1050
-                    && (
1051
-                        // is it a standalone function that doesn't work?
1052
-                        function_exists($method)
1053
-                        && call_user_func_array(
1054
-                            $func,
1055
-                            array_merge(['admin_page_object' => $this], $args)
1056
-                        ) === false
1057
-                    )
1058
-                )
1059
-                || (
1060
-                    // is it neither a class method NOR a standalone function?
1061
-                    ! method_exists($class, $method)
1062
-                    && ! function_exists($method)
1063
-                )
1064
-            ) {
1065
-                // user error msg
1066
-                $error_msg = esc_html__(
1067
-                    'An error occurred. The  requested page route could not be found.',
1068
-                    'event_espresso'
1069
-                );
1070
-                // developer error msg
1071
-                $error_msg .= '||';
1072
-                $error_msg .= sprintf(
1073
-                    esc_html__(
1074
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1075
-                        'event_espresso'
1076
-                    ),
1077
-                    $method
1078
-                );
1079
-            }
1080
-            if (! empty($error_msg)) {
1081
-                throw new EE_Error($error_msg);
1082
-            }
1083
-        }
1084
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1085
-        // then we need to reset the routing properties to the new route.
1086
-        // 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.
1087
-        if (
1088
-            $this->_is_UI_request === false
1089
-            && is_array($this->_route)
1090
-            && ! empty($this->_route['headers_sent_route'])
1091
-        ) {
1092
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1093
-        }
1094
-    }
1095
-
1096
-
1097
-    /**
1098
-     * This method just allows the resetting of page properties in the case where a no headers
1099
-     * route redirects to a headers route in its route config.
1100
-     *
1101
-     * @param string $new_route New (non header) route to redirect to.
1102
-     * @return   void
1103
-     * @throws ReflectionException
1104
-     * @throws InvalidArgumentException
1105
-     * @throws InvalidInterfaceException
1106
-     * @throws InvalidDataTypeException
1107
-     * @throws EE_Error
1108
-     * @since   4.3.0
1109
-     */
1110
-    protected function _reset_routing_properties($new_route)
1111
-    {
1112
-        $this->_is_UI_request = true;
1113
-        // now we set the current route to whatever the headers_sent_route is set at
1114
-        $this->request->setRequestParam('action', $new_route);
1115
-        // rerun page setup
1116
-        $this->_page_setup();
1117
-    }
1118
-
1119
-
1120
-    /**
1121
-     * _add_query_arg
1122
-     * adds nonce to array of arguments then calls WP add_query_arg function
1123
-     *(internally just uses EEH_URL's function with the same name)
1124
-     *
1125
-     * @param array  $args
1126
-     * @param string $url
1127
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1128
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1129
-     *                                        Example usage: If the current page is:
1130
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1131
-     *                                        &action=default&event_id=20&month_range=March%202015
1132
-     *                                        &_wpnonce=5467821
1133
-     *                                        and you call:
1134
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1135
-     *                                        array(
1136
-     *                                        'action' => 'resend_something',
1137
-     *                                        'page=>espresso_registrations'
1138
-     *                                        ),
1139
-     *                                        $some_url,
1140
-     *                                        true
1141
-     *                                        );
1142
-     *                                        It will produce a url in this structure:
1143
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1144
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1145
-     *                                        month_range]=March%202015
1146
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1147
-     * @return string
1148
-     */
1149
-    public static function add_query_args_and_nonce(
1150
-        $args = [],
1151
-        $url = false,
1152
-        $sticky = false,
1153
-        $exclude_nonce = false
1154
-    ) {
1155
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1156
-        if ($sticky) {
1157
-            /** @var RequestInterface $request */
1158
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1159
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1160
-            foreach ($request->requestParams() as $key => $value) {
1161
-                // do not add nonces
1162
-                if (strpos($key, 'nonce') !== false) {
1163
-                    continue;
1164
-                }
1165
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1166
-            }
1167
-        }
1168
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1169
-    }
1170
-
1171
-
1172
-    /**
1173
-     * This returns a generated link that will load the related help tab.
1174
-     *
1175
-     * @param string $help_tab_id the id for the connected help tab
1176
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1177
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1178
-     * @return string              generated link
1179
-     * @uses EEH_Template::get_help_tab_link()
1180
-     */
1181
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1182
-    {
1183
-        return EEH_Template::get_help_tab_link(
1184
-            $help_tab_id,
1185
-            $this->page_slug,
1186
-            $this->_req_action,
1187
-            $icon_style,
1188
-            $help_text
1189
-        );
1190
-    }
1191
-
1192
-
1193
-    /**
1194
-     * _add_help_tabs
1195
-     * Note child classes define their help tabs within the page_config array.
1196
-     *
1197
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1198
-     * @return void
1199
-     * @throws DomainException
1200
-     * @throws EE_Error
1201
-     */
1202
-    protected function _add_help_tabs()
1203
-    {
1204
-        $tour_buttons = '';
1205
-        if (isset($this->_page_config[ $this->_req_action ])) {
1206
-            $config = $this->_page_config[ $this->_req_action ];
1207
-            // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1208
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1209
-            // if (isset($this->_help_tour[ $this->_req_action ])) {
1210
-            //     $tb = array();
1211
-            //     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1212
-            //     foreach ($this->_help_tour['tours'] as $tour) {
1213
-            //         // if this is the end tour then we don't need to setup a button
1214
-            //         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1215
-            //             continue;
1216
-            //         }
1217
-            //         $tb[] = '<button id="trigger-tour-'
1218
-            //                 . $tour->get_slug()
1219
-            //                 . '" class="button-primary trigger-ee-help-tour">'
1220
-            //                 . $tour->get_label()
1221
-            //                 . '</button>';
1222
-            //     }
1223
-            //     $tour_buttons .= implode('<br />', $tb);
1224
-            //     $tour_buttons .= '</div></div>';
1225
-            // }
1226
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1227
-            if (is_array($config) && isset($config['help_sidebar'])) {
1228
-                // check that the callback given is valid
1229
-                if (! method_exists($this, $config['help_sidebar'])) {
1230
-                    throw new EE_Error(
1231
-                        sprintf(
1232
-                            esc_html__(
1233
-                                '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',
1234
-                                'event_espresso'
1235
-                            ),
1236
-                            $config['help_sidebar'],
1237
-                            get_class($this)
1238
-                        )
1239
-                    );
1240
-                }
1241
-                $content = apply_filters(
1242
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1243
-                    $this->{$config['help_sidebar']}()
1244
-                );
1245
-                $content .= $tour_buttons; // add help tour buttons.
1246
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1247
-                $this->_current_screen->set_help_sidebar($content);
1248
-            }
1249
-            // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1250
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1251
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1252
-            }
1253
-            // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1254
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1255
-                $_ht['id']      = $this->page_slug;
1256
-                $_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1257
-                $_ht['content'] = '<p>'
1258
-                                  . esc_html__(
1259
-                                      'The buttons to the right allow you to start/restart any help tours available for this page',
1260
-                                      'event_espresso'
1261
-                                  ) . '</p>';
1262
-                $this->_current_screen->add_help_tab($_ht);
1263
-            }
1264
-            if (! isset($config['help_tabs'])) {
1265
-                return;
1266
-            } //no help tabs for this route
1267
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1268
-                // we're here so there ARE help tabs!
1269
-                // make sure we've got what we need
1270
-                if (! isset($cfg['title'])) {
1271
-                    throw new EE_Error(
1272
-                        esc_html__(
1273
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1274
-                            'event_espresso'
1275
-                        )
1276
-                    );
1277
-                }
1278
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1279
-                    throw new EE_Error(
1280
-                        esc_html__(
1281
-                            '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',
1282
-                            'event_espresso'
1283
-                        )
1284
-                    );
1285
-                }
1286
-                // first priority goes to content.
1287
-                if (! empty($cfg['content'])) {
1288
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1289
-                    // second priority goes to filename
1290
-                } elseif (! empty($cfg['filename'])) {
1291
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1292
-                    // 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)
1293
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1294
-                                                             . basename($this->_get_dir())
1295
-                                                             . '/help_tabs/'
1296
-                                                             . $cfg['filename']
1297
-                                                             . '.help_tab.php' : $file_path;
1298
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1299
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1300
-                        EE_Error::add_error(
1301
-                            sprintf(
1302
-                                esc_html__(
1303
-                                    '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',
1304
-                                    'event_espresso'
1305
-                                ),
1306
-                                $tab_id,
1307
-                                key($config),
1308
-                                $file_path
1309
-                            ),
1310
-                            __FILE__,
1311
-                            __FUNCTION__,
1312
-                            __LINE__
1313
-                        );
1314
-                        return;
1315
-                    }
1316
-                    $template_args['admin_page_obj'] = $this;
1317
-                    $content                         = EEH_Template::display_template(
1318
-                        $file_path,
1319
-                        $template_args,
1320
-                        true
1321
-                    );
1322
-                } else {
1323
-                    $content = '';
1324
-                }
1325
-                // check if callback is valid
1326
-                if (
1327
-                    empty($content)
1328
-                    && (
1329
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1330
-                    )
1331
-                ) {
1332
-                    EE_Error::add_error(
1333
-                        sprintf(
1334
-                            esc_html__(
1335
-                                '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.',
1336
-                                'event_espresso'
1337
-                            ),
1338
-                            $cfg['title']
1339
-                        ),
1340
-                        __FILE__,
1341
-                        __FUNCTION__,
1342
-                        __LINE__
1343
-                    );
1344
-                    return;
1345
-                }
1346
-                // setup config array for help tab method
1347
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1348
-                $_ht = [
1349
-                    'id'       => $id,
1350
-                    'title'    => $cfg['title'],
1351
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1352
-                    'content'  => $content,
1353
-                ];
1354
-                $this->_current_screen->add_help_tab($_ht);
1355
-            }
1356
-        }
1357
-    }
1358
-
1359
-
1360
-    /**
1361
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1362
-     * an array with properties for setting up usage of the joyride plugin
1363
-     *
1364
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1365
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1366
-     *         _set_page_config() comments
1367
-     * @return void
1368
-     * @throws InvalidArgumentException
1369
-     * @throws InvalidDataTypeException
1370
-     * @throws InvalidInterfaceException
1371
-     */
1372
-    protected function _add_help_tour()
1373
-    {
1374
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1375
-        // $tours = array();
1376
-        // $this->_help_tour = array();
1377
-        // // exit early if help tours are turned off globally
1378
-        // if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1379
-        //     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1380
-        // ) {
1381
-        //     return;
1382
-        // }
1383
-        // // loop through _page_config to find any help_tour defined
1384
-        // foreach ($this->_page_config as $route => $config) {
1385
-        //     // we're only going to set things up for this route
1386
-        //     if ($route !== $this->_req_action) {
1387
-        //         continue;
1388
-        //     }
1389
-        //     if (isset($config['help_tour'])) {
1390
-        //         foreach ($config['help_tour'] as $tour) {
1391
-        //             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1392
-        //             // let's see if we can get that file...
1393
-        //             // if not its possible this is a decaf route not set in caffeinated
1394
-        //             // so lets try and get the caffeinated equivalent
1395
-        //             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1396
-        //                                                      . basename($this->_get_dir())
1397
-        //                                                      . '/help_tours/'
1398
-        //                                                      . $tour
1399
-        //                                                      . '.class.php' : $file_path;
1400
-        //             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1401
-        //             if (! is_readable($file_path)) {
1402
-        //                 EE_Error::add_error(
1403
-        //                     sprintf(
1404
-        //                         esc_html__(
1405
-        //                             'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1406
-        //                             'event_espresso'
1407
-        //                         ),
1408
-        //                         $file_path,
1409
-        //                         $tour
1410
-        //                     ),
1411
-        //                     __FILE__,
1412
-        //                     __FUNCTION__,
1413
-        //                     __LINE__
1414
-        //                 );
1415
-        //                 return;
1416
-        //             }
1417
-        //             require_once $file_path;
1418
-        //             if (! class_exists($tour)) {
1419
-        //                 $error_msg[] = sprintf(
1420
-        //                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1421
-        //                     $tour
1422
-        //                 );
1423
-        //                 $error_msg[] = $error_msg[0] . "\r\n"
1424
-        //                                . sprintf(
1425
-        //                                    esc_html__(
1426
-        //                                        'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1427
-        //                                        'event_espresso'
1428
-        //                                    ),
1429
-        //                                    $tour,
1430
-        //                                    '<br />',
1431
-        //                                    $tour,
1432
-        //                                    $this->_req_action,
1433
-        //                                    get_class($this)
1434
-        //                                );
1435
-        //                 throw new EE_Error(implode('||', $error_msg));
1436
-        //             }
1437
-        //             $tour_obj = new $tour($this->_is_caf);
1438
-        //             $tours[] = $tour_obj;
1439
-        //             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1440
-        //         }
1441
-        //         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1442
-        //         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1443
-        //         $tours[] = $end_stop_tour;
1444
-        //         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1445
-        //     }
1446
-        // }
1447
-        //
1448
-        // if (! empty($tours)) {
1449
-        //     $this->_help_tour['tours'] = $tours;
1450
-        // }
1451
-        // // that's it!  Now that the $_help_tours property is set (or not)
1452
-        // // the scripts and html should be taken care of automatically.
1453
-        //
1454
-        // /**
1455
-        //  * Allow extending the help tours variable.
1456
-        //  *
1457
-        //  * @param Array $_help_tour The array containing all help tour information to be displayed.
1458
-        //  */
1459
-        // $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1460
-    }
1461
-
1462
-
1463
-    /**
1464
-     * This simply sets up any qtips that have been defined in the page config
1465
-     *
1466
-     * @return void
1467
-     */
1468
-    protected function _add_qtips()
1469
-    {
1470
-        if (isset($this->_route_config['qtips'])) {
1471
-            $qtips = (array) $this->_route_config['qtips'];
1472
-            // load qtip loader
1473
-            $path = [
1474
-                $this->_get_dir() . '/qtips/',
1475
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1476
-            ];
1477
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1478
-        }
1479
-    }
1480
-
1481
-
1482
-    /**
1483
-     * _set_nav_tabs
1484
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1485
-     * wish to add additional tabs or modify accordingly.
1486
-     *
1487
-     * @return void
1488
-     * @throws InvalidArgumentException
1489
-     * @throws InvalidInterfaceException
1490
-     * @throws InvalidDataTypeException
1491
-     */
1492
-    protected function _set_nav_tabs()
1493
-    {
1494
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1495
-        $i = 0;
1496
-        foreach ($this->_page_config as $slug => $config) {
1497
-            if (! is_array($config) || empty($config['nav'])) {
1498
-                continue;
1499
-            }
1500
-            // no nav tab for this config
1501
-            // check for persistent flag
1502
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1503
-                // nav tab is only to appear when route requested.
1504
-                continue;
1505
-            }
1506
-            if (! $this->check_user_access($slug, true)) {
1507
-                // no nav tab because current user does not have access.
1508
-                continue;
1509
-            }
1510
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1511
-            $this->_nav_tabs[ $slug ] = [
1512
-                'url'       => isset($config['nav']['url'])
1513
-                    ? $config['nav']['url']
1514
-                    : self::add_query_args_and_nonce(
1515
-                        ['action' => $slug],
1516
-                        $this->_admin_base_url
1517
-                    ),
1518
-                'link_text' => isset($config['nav']['label'])
1519
-                    ? $config['nav']['label']
1520
-                    : ucwords(
1521
-                        str_replace('_', ' ', $slug)
1522
-                    ),
1523
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1524
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1525
-            ];
1526
-            $i++;
1527
-        }
1528
-        // if $this->_nav_tabs is empty then lets set the default
1529
-        if (empty($this->_nav_tabs)) {
1530
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1531
-                'url'       => $this->_admin_base_url,
1532
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1533
-                'css_class' => 'nav-tab-active',
1534
-                'order'     => 10,
1535
-            ];
1536
-        }
1537
-        // now let's sort the tabs according to order
1538
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1539
-    }
1540
-
1541
-
1542
-    /**
1543
-     * _set_current_labels
1544
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1545
-     * property array
1546
-     *
1547
-     * @return void
1548
-     */
1549
-    private function _set_current_labels()
1550
-    {
1551
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1552
-            foreach ($this->_route_config['labels'] as $label => $text) {
1553
-                if (is_array($text)) {
1554
-                    foreach ($text as $sublabel => $subtext) {
1555
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1556
-                    }
1557
-                } else {
1558
-                    $this->_labels[ $label ] = $text;
1559
-                }
1560
-            }
1561
-        }
1562
-    }
1563
-
1564
-
1565
-    /**
1566
-     *        verifies user access for this admin page
1567
-     *
1568
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1569
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1570
-     *                               return false if verify fail.
1571
-     * @return bool
1572
-     * @throws InvalidArgumentException
1573
-     * @throws InvalidDataTypeException
1574
-     * @throws InvalidInterfaceException
1575
-     */
1576
-    public function check_user_access($route_to_check = '', $verify_only = false)
1577
-    {
1578
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1579
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1580
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1581
-                          && is_array(
1582
-                              $this->_page_routes[ $route_to_check ]
1583
-                          )
1584
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1585
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1586
-        if (empty($capability) && empty($route_to_check)) {
1587
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1588
-                : $this->_route['capability'];
1589
-        } else {
1590
-            $capability = empty($capability) ? 'manage_options' : $capability;
1591
-        }
1592
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1593
-        if (
1594
-            ! $this->request->isAjax()
1595
-            && (
1596
-                ! function_exists('is_admin')
1597
-                || ! EE_Registry::instance()->CAP->current_user_can(
1598
-                    $capability,
1599
-                    $this->page_slug
1600
-                    . '_'
1601
-                    . $route_to_check,
1602
-                    $id
1603
-                )
1604
-            )
1605
-        ) {
1606
-            if ($verify_only) {
1607
-                return false;
1608
-            }
1609
-            if (is_user_logged_in()) {
1610
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1611
-            } else {
1612
-                return false;
1613
-            }
1614
-        }
1615
-        return true;
1616
-    }
1617
-
1618
-
1619
-    /**
1620
-     * admin_init_global
1621
-     * This runs all the code that we want executed within the WP admin_init hook.
1622
-     * This method executes for ALL EE Admin pages.
1623
-     *
1624
-     * @return void
1625
-     */
1626
-    public function admin_init_global()
1627
-    {
1628
-    }
1629
-
1630
-
1631
-    /**
1632
-     * wp_loaded_global
1633
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1634
-     * EE_Admin page and will execute on every EE Admin Page load
1635
-     *
1636
-     * @return void
1637
-     */
1638
-    public function wp_loaded()
1639
-    {
1640
-    }
1641
-
1642
-
1643
-    /**
1644
-     * admin_notices
1645
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1646
-     * ALL EE_Admin pages.
1647
-     *
1648
-     * @return void
1649
-     */
1650
-    public function admin_notices_global()
1651
-    {
1652
-        $this->_display_no_javascript_warning();
1653
-        $this->_display_espresso_notices();
1654
-    }
1655
-
1656
-
1657
-    public function network_admin_notices_global()
1658
-    {
1659
-        $this->_display_no_javascript_warning();
1660
-        $this->_display_espresso_notices();
1661
-    }
1662
-
1663
-
1664
-    /**
1665
-     * admin_footer_scripts_global
1666
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1667
-     * will apply on ALL EE_Admin pages.
1668
-     *
1669
-     * @return void
1670
-     */
1671
-    public function admin_footer_scripts_global()
1672
-    {
1673
-        $this->_add_admin_page_ajax_loading_img();
1674
-        $this->_add_admin_page_overlay();
1675
-        // if metaboxes are present we need to add the nonce field
1676
-        if (
1677
-            isset($this->_route_config['metaboxes'])
1678
-            || isset($this->_route_config['list_table'])
1679
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1680
-        ) {
1681
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1682
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1683
-        }
1684
-    }
1685
-
1686
-
1687
-    /**
1688
-     * admin_footer_global
1689
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1690
-     * ALL EE_Admin Pages.
1691
-     *
1692
-     * @return void
1693
-     */
1694
-    public function admin_footer_global()
1695
-    {
1696
-        // dialog container for dialog helper
1697
-        echo '
1045
+				(
1046
+					(
1047
+						method_exists($class, $method)
1048
+						&& call_user_func_array([$class, $method], $args) === false
1049
+					)
1050
+					&& (
1051
+						// is it a standalone function that doesn't work?
1052
+						function_exists($method)
1053
+						&& call_user_func_array(
1054
+							$func,
1055
+							array_merge(['admin_page_object' => $this], $args)
1056
+						) === false
1057
+					)
1058
+				)
1059
+				|| (
1060
+					// is it neither a class method NOR a standalone function?
1061
+					! method_exists($class, $method)
1062
+					&& ! function_exists($method)
1063
+				)
1064
+			) {
1065
+				// user error msg
1066
+				$error_msg = esc_html__(
1067
+					'An error occurred. The  requested page route could not be found.',
1068
+					'event_espresso'
1069
+				);
1070
+				// developer error msg
1071
+				$error_msg .= '||';
1072
+				$error_msg .= sprintf(
1073
+					esc_html__(
1074
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1075
+						'event_espresso'
1076
+					),
1077
+					$method
1078
+				);
1079
+			}
1080
+			if (! empty($error_msg)) {
1081
+				throw new EE_Error($error_msg);
1082
+			}
1083
+		}
1084
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1085
+		// then we need to reset the routing properties to the new route.
1086
+		// 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.
1087
+		if (
1088
+			$this->_is_UI_request === false
1089
+			&& is_array($this->_route)
1090
+			&& ! empty($this->_route['headers_sent_route'])
1091
+		) {
1092
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1093
+		}
1094
+	}
1095
+
1096
+
1097
+	/**
1098
+	 * This method just allows the resetting of page properties in the case where a no headers
1099
+	 * route redirects to a headers route in its route config.
1100
+	 *
1101
+	 * @param string $new_route New (non header) route to redirect to.
1102
+	 * @return   void
1103
+	 * @throws ReflectionException
1104
+	 * @throws InvalidArgumentException
1105
+	 * @throws InvalidInterfaceException
1106
+	 * @throws InvalidDataTypeException
1107
+	 * @throws EE_Error
1108
+	 * @since   4.3.0
1109
+	 */
1110
+	protected function _reset_routing_properties($new_route)
1111
+	{
1112
+		$this->_is_UI_request = true;
1113
+		// now we set the current route to whatever the headers_sent_route is set at
1114
+		$this->request->setRequestParam('action', $new_route);
1115
+		// rerun page setup
1116
+		$this->_page_setup();
1117
+	}
1118
+
1119
+
1120
+	/**
1121
+	 * _add_query_arg
1122
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1123
+	 *(internally just uses EEH_URL's function with the same name)
1124
+	 *
1125
+	 * @param array  $args
1126
+	 * @param string $url
1127
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1128
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1129
+	 *                                        Example usage: If the current page is:
1130
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1131
+	 *                                        &action=default&event_id=20&month_range=March%202015
1132
+	 *                                        &_wpnonce=5467821
1133
+	 *                                        and you call:
1134
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1135
+	 *                                        array(
1136
+	 *                                        'action' => 'resend_something',
1137
+	 *                                        'page=>espresso_registrations'
1138
+	 *                                        ),
1139
+	 *                                        $some_url,
1140
+	 *                                        true
1141
+	 *                                        );
1142
+	 *                                        It will produce a url in this structure:
1143
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1144
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1145
+	 *                                        month_range]=March%202015
1146
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1147
+	 * @return string
1148
+	 */
1149
+	public static function add_query_args_and_nonce(
1150
+		$args = [],
1151
+		$url = false,
1152
+		$sticky = false,
1153
+		$exclude_nonce = false
1154
+	) {
1155
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1156
+		if ($sticky) {
1157
+			/** @var RequestInterface $request */
1158
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1159
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1160
+			foreach ($request->requestParams() as $key => $value) {
1161
+				// do not add nonces
1162
+				if (strpos($key, 'nonce') !== false) {
1163
+					continue;
1164
+				}
1165
+				$args[ 'wp_referer[' . $key . ']' ] = $value;
1166
+			}
1167
+		}
1168
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1169
+	}
1170
+
1171
+
1172
+	/**
1173
+	 * This returns a generated link that will load the related help tab.
1174
+	 *
1175
+	 * @param string $help_tab_id the id for the connected help tab
1176
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1177
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1178
+	 * @return string              generated link
1179
+	 * @uses EEH_Template::get_help_tab_link()
1180
+	 */
1181
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1182
+	{
1183
+		return EEH_Template::get_help_tab_link(
1184
+			$help_tab_id,
1185
+			$this->page_slug,
1186
+			$this->_req_action,
1187
+			$icon_style,
1188
+			$help_text
1189
+		);
1190
+	}
1191
+
1192
+
1193
+	/**
1194
+	 * _add_help_tabs
1195
+	 * Note child classes define their help tabs within the page_config array.
1196
+	 *
1197
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1198
+	 * @return void
1199
+	 * @throws DomainException
1200
+	 * @throws EE_Error
1201
+	 */
1202
+	protected function _add_help_tabs()
1203
+	{
1204
+		$tour_buttons = '';
1205
+		if (isset($this->_page_config[ $this->_req_action ])) {
1206
+			$config = $this->_page_config[ $this->_req_action ];
1207
+			// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1208
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1209
+			// if (isset($this->_help_tour[ $this->_req_action ])) {
1210
+			//     $tb = array();
1211
+			//     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1212
+			//     foreach ($this->_help_tour['tours'] as $tour) {
1213
+			//         // if this is the end tour then we don't need to setup a button
1214
+			//         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1215
+			//             continue;
1216
+			//         }
1217
+			//         $tb[] = '<button id="trigger-tour-'
1218
+			//                 . $tour->get_slug()
1219
+			//                 . '" class="button-primary trigger-ee-help-tour">'
1220
+			//                 . $tour->get_label()
1221
+			//                 . '</button>';
1222
+			//     }
1223
+			//     $tour_buttons .= implode('<br />', $tb);
1224
+			//     $tour_buttons .= '</div></div>';
1225
+			// }
1226
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1227
+			if (is_array($config) && isset($config['help_sidebar'])) {
1228
+				// check that the callback given is valid
1229
+				if (! method_exists($this, $config['help_sidebar'])) {
1230
+					throw new EE_Error(
1231
+						sprintf(
1232
+							esc_html__(
1233
+								'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',
1234
+								'event_espresso'
1235
+							),
1236
+							$config['help_sidebar'],
1237
+							get_class($this)
1238
+						)
1239
+					);
1240
+				}
1241
+				$content = apply_filters(
1242
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1243
+					$this->{$config['help_sidebar']}()
1244
+				);
1245
+				$content .= $tour_buttons; // add help tour buttons.
1246
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1247
+				$this->_current_screen->set_help_sidebar($content);
1248
+			}
1249
+			// if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1250
+			if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1251
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1252
+			}
1253
+			// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1254
+			if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1255
+				$_ht['id']      = $this->page_slug;
1256
+				$_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1257
+				$_ht['content'] = '<p>'
1258
+								  . esc_html__(
1259
+									  'The buttons to the right allow you to start/restart any help tours available for this page',
1260
+									  'event_espresso'
1261
+								  ) . '</p>';
1262
+				$this->_current_screen->add_help_tab($_ht);
1263
+			}
1264
+			if (! isset($config['help_tabs'])) {
1265
+				return;
1266
+			} //no help tabs for this route
1267
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1268
+				// we're here so there ARE help tabs!
1269
+				// make sure we've got what we need
1270
+				if (! isset($cfg['title'])) {
1271
+					throw new EE_Error(
1272
+						esc_html__(
1273
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1274
+							'event_espresso'
1275
+						)
1276
+					);
1277
+				}
1278
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1279
+					throw new EE_Error(
1280
+						esc_html__(
1281
+							'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',
1282
+							'event_espresso'
1283
+						)
1284
+					);
1285
+				}
1286
+				// first priority goes to content.
1287
+				if (! empty($cfg['content'])) {
1288
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1289
+					// second priority goes to filename
1290
+				} elseif (! empty($cfg['filename'])) {
1291
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1292
+					// 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)
1293
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1294
+															 . basename($this->_get_dir())
1295
+															 . '/help_tabs/'
1296
+															 . $cfg['filename']
1297
+															 . '.help_tab.php' : $file_path;
1298
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1299
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1300
+						EE_Error::add_error(
1301
+							sprintf(
1302
+								esc_html__(
1303
+									'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',
1304
+									'event_espresso'
1305
+								),
1306
+								$tab_id,
1307
+								key($config),
1308
+								$file_path
1309
+							),
1310
+							__FILE__,
1311
+							__FUNCTION__,
1312
+							__LINE__
1313
+						);
1314
+						return;
1315
+					}
1316
+					$template_args['admin_page_obj'] = $this;
1317
+					$content                         = EEH_Template::display_template(
1318
+						$file_path,
1319
+						$template_args,
1320
+						true
1321
+					);
1322
+				} else {
1323
+					$content = '';
1324
+				}
1325
+				// check if callback is valid
1326
+				if (
1327
+					empty($content)
1328
+					&& (
1329
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1330
+					)
1331
+				) {
1332
+					EE_Error::add_error(
1333
+						sprintf(
1334
+							esc_html__(
1335
+								'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.',
1336
+								'event_espresso'
1337
+							),
1338
+							$cfg['title']
1339
+						),
1340
+						__FILE__,
1341
+						__FUNCTION__,
1342
+						__LINE__
1343
+					);
1344
+					return;
1345
+				}
1346
+				// setup config array for help tab method
1347
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1348
+				$_ht = [
1349
+					'id'       => $id,
1350
+					'title'    => $cfg['title'],
1351
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1352
+					'content'  => $content,
1353
+				];
1354
+				$this->_current_screen->add_help_tab($_ht);
1355
+			}
1356
+		}
1357
+	}
1358
+
1359
+
1360
+	/**
1361
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1362
+	 * an array with properties for setting up usage of the joyride plugin
1363
+	 *
1364
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1365
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1366
+	 *         _set_page_config() comments
1367
+	 * @return void
1368
+	 * @throws InvalidArgumentException
1369
+	 * @throws InvalidDataTypeException
1370
+	 * @throws InvalidInterfaceException
1371
+	 */
1372
+	protected function _add_help_tour()
1373
+	{
1374
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1375
+		// $tours = array();
1376
+		// $this->_help_tour = array();
1377
+		// // exit early if help tours are turned off globally
1378
+		// if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1379
+		//     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1380
+		// ) {
1381
+		//     return;
1382
+		// }
1383
+		// // loop through _page_config to find any help_tour defined
1384
+		// foreach ($this->_page_config as $route => $config) {
1385
+		//     // we're only going to set things up for this route
1386
+		//     if ($route !== $this->_req_action) {
1387
+		//         continue;
1388
+		//     }
1389
+		//     if (isset($config['help_tour'])) {
1390
+		//         foreach ($config['help_tour'] as $tour) {
1391
+		//             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1392
+		//             // let's see if we can get that file...
1393
+		//             // if not its possible this is a decaf route not set in caffeinated
1394
+		//             // so lets try and get the caffeinated equivalent
1395
+		//             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1396
+		//                                                      . basename($this->_get_dir())
1397
+		//                                                      . '/help_tours/'
1398
+		//                                                      . $tour
1399
+		//                                                      . '.class.php' : $file_path;
1400
+		//             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1401
+		//             if (! is_readable($file_path)) {
1402
+		//                 EE_Error::add_error(
1403
+		//                     sprintf(
1404
+		//                         esc_html__(
1405
+		//                             'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1406
+		//                             'event_espresso'
1407
+		//                         ),
1408
+		//                         $file_path,
1409
+		//                         $tour
1410
+		//                     ),
1411
+		//                     __FILE__,
1412
+		//                     __FUNCTION__,
1413
+		//                     __LINE__
1414
+		//                 );
1415
+		//                 return;
1416
+		//             }
1417
+		//             require_once $file_path;
1418
+		//             if (! class_exists($tour)) {
1419
+		//                 $error_msg[] = sprintf(
1420
+		//                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1421
+		//                     $tour
1422
+		//                 );
1423
+		//                 $error_msg[] = $error_msg[0] . "\r\n"
1424
+		//                                . sprintf(
1425
+		//                                    esc_html__(
1426
+		//                                        'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1427
+		//                                        'event_espresso'
1428
+		//                                    ),
1429
+		//                                    $tour,
1430
+		//                                    '<br />',
1431
+		//                                    $tour,
1432
+		//                                    $this->_req_action,
1433
+		//                                    get_class($this)
1434
+		//                                );
1435
+		//                 throw new EE_Error(implode('||', $error_msg));
1436
+		//             }
1437
+		//             $tour_obj = new $tour($this->_is_caf);
1438
+		//             $tours[] = $tour_obj;
1439
+		//             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1440
+		//         }
1441
+		//         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1442
+		//         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1443
+		//         $tours[] = $end_stop_tour;
1444
+		//         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1445
+		//     }
1446
+		// }
1447
+		//
1448
+		// if (! empty($tours)) {
1449
+		//     $this->_help_tour['tours'] = $tours;
1450
+		// }
1451
+		// // that's it!  Now that the $_help_tours property is set (or not)
1452
+		// // the scripts and html should be taken care of automatically.
1453
+		//
1454
+		// /**
1455
+		//  * Allow extending the help tours variable.
1456
+		//  *
1457
+		//  * @param Array $_help_tour The array containing all help tour information to be displayed.
1458
+		//  */
1459
+		// $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1460
+	}
1461
+
1462
+
1463
+	/**
1464
+	 * This simply sets up any qtips that have been defined in the page config
1465
+	 *
1466
+	 * @return void
1467
+	 */
1468
+	protected function _add_qtips()
1469
+	{
1470
+		if (isset($this->_route_config['qtips'])) {
1471
+			$qtips = (array) $this->_route_config['qtips'];
1472
+			// load qtip loader
1473
+			$path = [
1474
+				$this->_get_dir() . '/qtips/',
1475
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1476
+			];
1477
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1478
+		}
1479
+	}
1480
+
1481
+
1482
+	/**
1483
+	 * _set_nav_tabs
1484
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1485
+	 * wish to add additional tabs or modify accordingly.
1486
+	 *
1487
+	 * @return void
1488
+	 * @throws InvalidArgumentException
1489
+	 * @throws InvalidInterfaceException
1490
+	 * @throws InvalidDataTypeException
1491
+	 */
1492
+	protected function _set_nav_tabs()
1493
+	{
1494
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1495
+		$i = 0;
1496
+		foreach ($this->_page_config as $slug => $config) {
1497
+			if (! is_array($config) || empty($config['nav'])) {
1498
+				continue;
1499
+			}
1500
+			// no nav tab for this config
1501
+			// check for persistent flag
1502
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1503
+				// nav tab is only to appear when route requested.
1504
+				continue;
1505
+			}
1506
+			if (! $this->check_user_access($slug, true)) {
1507
+				// no nav tab because current user does not have access.
1508
+				continue;
1509
+			}
1510
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1511
+			$this->_nav_tabs[ $slug ] = [
1512
+				'url'       => isset($config['nav']['url'])
1513
+					? $config['nav']['url']
1514
+					: self::add_query_args_and_nonce(
1515
+						['action' => $slug],
1516
+						$this->_admin_base_url
1517
+					),
1518
+				'link_text' => isset($config['nav']['label'])
1519
+					? $config['nav']['label']
1520
+					: ucwords(
1521
+						str_replace('_', ' ', $slug)
1522
+					),
1523
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1524
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1525
+			];
1526
+			$i++;
1527
+		}
1528
+		// if $this->_nav_tabs is empty then lets set the default
1529
+		if (empty($this->_nav_tabs)) {
1530
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1531
+				'url'       => $this->_admin_base_url,
1532
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1533
+				'css_class' => 'nav-tab-active',
1534
+				'order'     => 10,
1535
+			];
1536
+		}
1537
+		// now let's sort the tabs according to order
1538
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1539
+	}
1540
+
1541
+
1542
+	/**
1543
+	 * _set_current_labels
1544
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1545
+	 * property array
1546
+	 *
1547
+	 * @return void
1548
+	 */
1549
+	private function _set_current_labels()
1550
+	{
1551
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1552
+			foreach ($this->_route_config['labels'] as $label => $text) {
1553
+				if (is_array($text)) {
1554
+					foreach ($text as $sublabel => $subtext) {
1555
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1556
+					}
1557
+				} else {
1558
+					$this->_labels[ $label ] = $text;
1559
+				}
1560
+			}
1561
+		}
1562
+	}
1563
+
1564
+
1565
+	/**
1566
+	 *        verifies user access for this admin page
1567
+	 *
1568
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1569
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1570
+	 *                               return false if verify fail.
1571
+	 * @return bool
1572
+	 * @throws InvalidArgumentException
1573
+	 * @throws InvalidDataTypeException
1574
+	 * @throws InvalidInterfaceException
1575
+	 */
1576
+	public function check_user_access($route_to_check = '', $verify_only = false)
1577
+	{
1578
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1579
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1580
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1581
+						  && is_array(
1582
+							  $this->_page_routes[ $route_to_check ]
1583
+						  )
1584
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1585
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1586
+		if (empty($capability) && empty($route_to_check)) {
1587
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1588
+				: $this->_route['capability'];
1589
+		} else {
1590
+			$capability = empty($capability) ? 'manage_options' : $capability;
1591
+		}
1592
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1593
+		if (
1594
+			! $this->request->isAjax()
1595
+			&& (
1596
+				! function_exists('is_admin')
1597
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1598
+					$capability,
1599
+					$this->page_slug
1600
+					. '_'
1601
+					. $route_to_check,
1602
+					$id
1603
+				)
1604
+			)
1605
+		) {
1606
+			if ($verify_only) {
1607
+				return false;
1608
+			}
1609
+			if (is_user_logged_in()) {
1610
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1611
+			} else {
1612
+				return false;
1613
+			}
1614
+		}
1615
+		return true;
1616
+	}
1617
+
1618
+
1619
+	/**
1620
+	 * admin_init_global
1621
+	 * This runs all the code that we want executed within the WP admin_init hook.
1622
+	 * This method executes for ALL EE Admin pages.
1623
+	 *
1624
+	 * @return void
1625
+	 */
1626
+	public function admin_init_global()
1627
+	{
1628
+	}
1629
+
1630
+
1631
+	/**
1632
+	 * wp_loaded_global
1633
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1634
+	 * EE_Admin page and will execute on every EE Admin Page load
1635
+	 *
1636
+	 * @return void
1637
+	 */
1638
+	public function wp_loaded()
1639
+	{
1640
+	}
1641
+
1642
+
1643
+	/**
1644
+	 * admin_notices
1645
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1646
+	 * ALL EE_Admin pages.
1647
+	 *
1648
+	 * @return void
1649
+	 */
1650
+	public function admin_notices_global()
1651
+	{
1652
+		$this->_display_no_javascript_warning();
1653
+		$this->_display_espresso_notices();
1654
+	}
1655
+
1656
+
1657
+	public function network_admin_notices_global()
1658
+	{
1659
+		$this->_display_no_javascript_warning();
1660
+		$this->_display_espresso_notices();
1661
+	}
1662
+
1663
+
1664
+	/**
1665
+	 * admin_footer_scripts_global
1666
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1667
+	 * will apply on ALL EE_Admin pages.
1668
+	 *
1669
+	 * @return void
1670
+	 */
1671
+	public function admin_footer_scripts_global()
1672
+	{
1673
+		$this->_add_admin_page_ajax_loading_img();
1674
+		$this->_add_admin_page_overlay();
1675
+		// if metaboxes are present we need to add the nonce field
1676
+		if (
1677
+			isset($this->_route_config['metaboxes'])
1678
+			|| isset($this->_route_config['list_table'])
1679
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1680
+		) {
1681
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1682
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1683
+		}
1684
+	}
1685
+
1686
+
1687
+	/**
1688
+	 * admin_footer_global
1689
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1690
+	 * ALL EE_Admin Pages.
1691
+	 *
1692
+	 * @return void
1693
+	 */
1694
+	public function admin_footer_global()
1695
+	{
1696
+		// dialog container for dialog helper
1697
+		echo '
1698 1698
         <div class="ee-admin-dialog-container auto-hide hidden">
1699 1699
             <div class="ee-notices"></div>
1700 1700
             <div class="ee-admin-dialog-container-inner-content"></div>
1701 1701
         </div>
1702 1702
         ';
1703 1703
 
1704
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1705
-        // help tour stuff?
1706
-        // if (isset($this->_help_tour[ $this->_req_action ])) {
1707
-        //     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1708
-        // }
1709
-        // current set timezone for timezone js
1710
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1711
-    }
1712
-
1713
-
1714
-    /**
1715
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1716
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1717
-     * help popups then in your templates or your content you set "triggers" for the content using the
1718
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1719
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1720
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1721
-     * for the
1722
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1723
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1724
-     *    'help_trigger_id' => array(
1725
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1726
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1727
-     *    )
1728
-     * );
1729
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1730
-     *
1731
-     * @param array $help_array
1732
-     * @param bool  $display
1733
-     * @return string content
1734
-     * @throws DomainException
1735
-     * @throws EE_Error
1736
-     */
1737
-    protected function _set_help_popup_content($help_array = [], $display = false)
1738
-    {
1739
-        $content    = '';
1740
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1741
-        // loop through the array and setup content
1742
-        foreach ($help_array as $trigger => $help) {
1743
-            // make sure the array is setup properly
1744
-            if (! isset($help['title']) || ! isset($help['content'])) {
1745
-                throw new EE_Error(
1746
-                    esc_html__(
1747
-                        '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',
1748
-                        'event_espresso'
1749
-                    )
1750
-                );
1751
-            }
1752
-            // we're good so let'd setup the template vars and then assign parsed template content to our content.
1753
-            $template_args = [
1754
-                'help_popup_id'      => $trigger,
1755
-                'help_popup_title'   => $help['title'],
1756
-                'help_popup_content' => $help['content'],
1757
-            ];
1758
-            $content       .= EEH_Template::display_template(
1759
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1760
-                $template_args,
1761
-                true
1762
-            );
1763
-        }
1764
-        if ($display) {
1765
-            echo $content; // already escaped
1766
-            return '';
1767
-        }
1768
-        return $content;
1769
-    }
1770
-
1771
-
1772
-    /**
1773
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1774
-     *
1775
-     * @return array properly formatted array for help popup content
1776
-     * @throws EE_Error
1777
-     */
1778
-    private function _get_help_content()
1779
-    {
1780
-        // what is the method we're looking for?
1781
-        $method_name = '_help_popup_content_' . $this->_req_action;
1782
-        // if method doesn't exist let's get out.
1783
-        if (! method_exists($this, $method_name)) {
1784
-            return [];
1785
-        }
1786
-        // k we're good to go let's retrieve the help array
1787
-        $help_array = call_user_func([$this, $method_name]);
1788
-        // make sure we've got an array!
1789
-        if (! is_array($help_array)) {
1790
-            throw new EE_Error(
1791
-                esc_html__(
1792
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1793
-                    'event_espresso'
1794
-                )
1795
-            );
1796
-        }
1797
-        return $help_array;
1798
-    }
1799
-
1800
-
1801
-    /**
1802
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1803
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1804
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1805
-     *
1806
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1807
-     * @param boolean $display    if false then we return the trigger string
1808
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1809
-     * @return string
1810
-     * @throws DomainException
1811
-     * @throws EE_Error
1812
-     */
1813
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1814
-    {
1815
-        if ($this->request->isAjax()) {
1816
-            return '';
1817
-        }
1818
-        // 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
1819
-        $help_array   = $this->_get_help_content();
1820
-        $help_content = '';
1821
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1822
-            $help_array[ $trigger_id ] = [
1823
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1824
-                'content' => esc_html__(
1825
-                    '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.)',
1826
-                    'event_espresso'
1827
-                ),
1828
-            ];
1829
-            $help_content              = $this->_set_help_popup_content($help_array, false);
1830
-        }
1831
-        // let's setup the trigger
1832
-        $content = '<a class="ee-dialog" href="?height='
1833
-                   . esc_attr($dimensions[0])
1834
-                   . '&width='
1835
-                   . esc_attr($dimensions[1])
1836
-                   . '&inlineId='
1837
-                   . esc_attr($trigger_id)
1838
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1839
-        $content .= $help_content;
1840
-        if ($display) {
1841
-            echo $content; // already escaped
1842
-            return '';
1843
-        }
1844
-        return $content;
1845
-    }
1846
-
1847
-
1848
-    /**
1849
-     * _add_global_screen_options
1850
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1851
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1852
-     *
1853
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1854
-     *         see also WP_Screen object documents...
1855
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1856
-     * @abstract
1857
-     * @return void
1858
-     */
1859
-    private function _add_global_screen_options()
1860
-    {
1861
-    }
1862
-
1863
-
1864
-    /**
1865
-     * _add_global_feature_pointers
1866
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1867
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1868
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1869
-     *
1870
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1871
-     *         extended) also see:
1872
-     * @link   http://eamann.com/tech/wordpress-portland/
1873
-     * @abstract
1874
-     * @return void
1875
-     */
1876
-    private function _add_global_feature_pointers()
1877
-    {
1878
-    }
1879
-
1880
-
1881
-    /**
1882
-     * load_global_scripts_styles
1883
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1884
-     *
1885
-     * @return void
1886
-     */
1887
-    public function load_global_scripts_styles()
1888
-    {
1889
-        /** STYLES **/
1890
-        // add debugging styles
1891
-        if (WP_DEBUG) {
1892
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1893
-        }
1894
-        // register all styles
1895
-        wp_register_style(
1896
-            'espresso-ui-theme',
1897
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1898
-            [],
1899
-            EVENT_ESPRESSO_VERSION
1900
-        );
1901
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1902
-        // helpers styles
1903
-        wp_register_style(
1904
-            'ee-text-links',
1905
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1906
-            [],
1907
-            EVENT_ESPRESSO_VERSION
1908
-        );
1909
-        /** SCRIPTS **/
1910
-        // register all scripts
1911
-        wp_register_script(
1912
-            'ee-dialog',
1913
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1914
-            ['jquery', 'jquery-ui-draggable'],
1915
-            EVENT_ESPRESSO_VERSION,
1916
-            true
1917
-        );
1918
-        wp_register_script(
1919
-            'ee_admin_js',
1920
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1921
-            ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1922
-            EVENT_ESPRESSO_VERSION,
1923
-            true
1924
-        );
1925
-        wp_register_script(
1926
-            'jquery-ui-timepicker-addon',
1927
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1928
-            ['jquery-ui-datepicker', 'jquery-ui-slider'],
1929
-            EVENT_ESPRESSO_VERSION,
1930
-            true
1931
-        );
1932
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1933
-        // if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1934
-        //     add_filter('FHEE_load_joyride', '__return_true');
1935
-        // }
1936
-        // script for sorting tables
1937
-        wp_register_script(
1938
-            'espresso_ajax_table_sorting',
1939
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1940
-            ['ee_admin_js', 'jquery-ui-sortable'],
1941
-            EVENT_ESPRESSO_VERSION,
1942
-            true
1943
-        );
1944
-        // script for parsing uri's
1945
-        wp_register_script(
1946
-            'ee-parse-uri',
1947
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1948
-            [],
1949
-            EVENT_ESPRESSO_VERSION,
1950
-            true
1951
-        );
1952
-        // and parsing associative serialized form elements
1953
-        wp_register_script(
1954
-            'ee-serialize-full-array',
1955
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1956
-            ['jquery'],
1957
-            EVENT_ESPRESSO_VERSION,
1958
-            true
1959
-        );
1960
-        // helpers scripts
1961
-        wp_register_script(
1962
-            'ee-text-links',
1963
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1964
-            ['jquery'],
1965
-            EVENT_ESPRESSO_VERSION,
1966
-            true
1967
-        );
1968
-        wp_register_script(
1969
-            'ee-moment-core',
1970
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1971
-            [],
1972
-            EVENT_ESPRESSO_VERSION,
1973
-            true
1974
-        );
1975
-        wp_register_script(
1976
-            'ee-moment',
1977
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1978
-            ['ee-moment-core'],
1979
-            EVENT_ESPRESSO_VERSION,
1980
-            true
1981
-        );
1982
-        wp_register_script(
1983
-            'ee-datepicker',
1984
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1985
-            ['jquery-ui-timepicker-addon', 'ee-moment'],
1986
-            EVENT_ESPRESSO_VERSION,
1987
-            true
1988
-        );
1989
-        // google charts
1990
-        wp_register_script(
1991
-            'google-charts',
1992
-            'https://www.gstatic.com/charts/loader.js',
1993
-            [],
1994
-            EVENT_ESPRESSO_VERSION,
1995
-            false
1996
-        );
1997
-        // ENQUEUE ALL BASICS BY DEFAULT
1998
-        wp_enqueue_style('ee-admin-css');
1999
-        wp_enqueue_script('ee_admin_js');
2000
-        wp_enqueue_script('ee-accounting');
2001
-        wp_enqueue_script('jquery-validate');
2002
-        // taking care of metaboxes
2003
-        if (
2004
-            empty($this->_cpt_route)
2005
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2006
-        ) {
2007
-            wp_enqueue_script('dashboard');
2008
-        }
2009
-        // LOCALIZED DATA
2010
-        // localize script for ajax lazy loading
2011
-        $lazy_loader_container_ids = apply_filters(
2012
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2013
-            ['espresso_news_post_box_content']
2014
-        );
2015
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2016
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
2017
-        // /**
2018
-        //  * help tour stuff
2019
-        //  */
2020
-        // if (! empty($this->_help_tour)) {
2021
-        //     // register the js for kicking things off
2022
-        //     wp_enqueue_script(
2023
-        //         'ee-help-tour',
2024
-        //         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2025
-        //         array('jquery-joyride'),
2026
-        //         EVENT_ESPRESSO_VERSION,
2027
-        //         true
2028
-        //     );
2029
-        //     $tours = array();
2030
-        //     // setup tours for the js tour object
2031
-        //     foreach ($this->_help_tour['tours'] as $tour) {
2032
-        //         if ($tour instanceof EE_Help_Tour) {
2033
-        //             $tours[] = array(
2034
-        //                 'id'      => $tour->get_slug(),
2035
-        //                 'options' => $tour->get_options(),
2036
-        //             );
2037
-        //         }
2038
-        //     }
2039
-        //     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2040
-        //     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2041
-        // }
2042
-
2043
-        add_filter(
2044
-            'admin_body_class',
2045
-            function ($classes) {
2046
-                if (strpos($classes, 'espresso-admin') === false) {
2047
-                    $classes .= ' espresso-admin';
2048
-                }
2049
-                return $classes;
2050
-            }
2051
-        );
2052
-    }
2053
-
2054
-
2055
-    /**
2056
-     *        admin_footer_scripts_eei18n_js_strings
2057
-     *
2058
-     * @return        void
2059
-     */
2060
-    public function admin_footer_scripts_eei18n_js_strings()
2061
-    {
2062
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2063
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2064
-            __(
2065
-                '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!!!',
2066
-                'event_espresso'
2067
-            )
2068
-        );
2069
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2070
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2071
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2072
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2073
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2074
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2075
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2076
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2077
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2078
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2079
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2080
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2081
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2082
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2083
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2084
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2085
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2086
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2087
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2088
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2089
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2090
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2091
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2092
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2093
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2094
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2095
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2096
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2097
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2098
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2099
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2100
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2101
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2102
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2103
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2104
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2105
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2106
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2107
-    }
2108
-
2109
-
2110
-    /**
2111
-     *        load enhanced xdebug styles for ppl with failing eyesight
2112
-     *
2113
-     * @return        void
2114
-     */
2115
-    public function add_xdebug_style()
2116
-    {
2117
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2118
-    }
2119
-
2120
-
2121
-    /************************/
2122
-    /** LIST TABLE METHODS **/
2123
-    /************************/
2124
-    /**
2125
-     * this sets up the list table if the current view requires it.
2126
-     *
2127
-     * @return void
2128
-     * @throws EE_Error
2129
-     */
2130
-    protected function _set_list_table()
2131
-    {
2132
-        // first is this a list_table view?
2133
-        if (! isset($this->_route_config['list_table'])) {
2134
-            return;
2135
-        } //not a list_table view so get out.
2136
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2137
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2138
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2139
-            // user error msg
2140
-            $error_msg = esc_html__(
2141
-                'An error occurred. The requested list table views could not be found.',
2142
-                'event_espresso'
2143
-            );
2144
-            // developer error msg
2145
-            $error_msg .= '||'
2146
-                          . sprintf(
2147
-                              esc_html__(
2148
-                                  '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.',
2149
-                                  'event_espresso'
2150
-                              ),
2151
-                              $this->_req_action,
2152
-                              $list_table_view
2153
-                          );
2154
-            throw new EE_Error($error_msg);
2155
-        }
2156
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2157
-        $this->_views = apply_filters(
2158
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2159
-            $this->_views
2160
-        );
2161
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2162
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2163
-        $this->_set_list_table_view();
2164
-        $this->_set_list_table_object();
2165
-    }
2166
-
2167
-
2168
-    /**
2169
-     * set current view for List Table
2170
-     *
2171
-     * @return void
2172
-     */
2173
-    protected function _set_list_table_view()
2174
-    {
2175
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2176
-        $status = $this->request->getRequestParam('status', null, 'key');
2177
-        $this->_view = $status && array_key_exists($status, $this->_views)
2178
-            ? $status
2179
-            : $this->_view;
2180
-    }
2181
-
2182
-
2183
-    /**
2184
-     * _set_list_table_object
2185
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2186
-     *
2187
-     * @throws InvalidInterfaceException
2188
-     * @throws InvalidArgumentException
2189
-     * @throws InvalidDataTypeException
2190
-     * @throws EE_Error
2191
-     * @throws InvalidInterfaceException
2192
-     */
2193
-    protected function _set_list_table_object()
2194
-    {
2195
-        if (isset($this->_route_config['list_table'])) {
2196
-            if (! class_exists($this->_route_config['list_table'])) {
2197
-                throw new EE_Error(
2198
-                    sprintf(
2199
-                        esc_html__(
2200
-                            '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.',
2201
-                            'event_espresso'
2202
-                        ),
2203
-                        $this->_route_config['list_table'],
2204
-                        get_class($this)
2205
-                    )
2206
-                );
2207
-            }
2208
-            $this->_list_table_object = $this->loader->getShared(
2209
-                $this->_route_config['list_table'],
2210
-                [$this]
2211
-            );
2212
-        }
2213
-    }
2214
-
2215
-
2216
-    /**
2217
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2218
-     *
2219
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2220
-     *                                                    urls.  The array should be indexed by the view it is being
2221
-     *                                                    added to.
2222
-     * @return array
2223
-     */
2224
-    public function get_list_table_view_RLs($extra_query_args = [])
2225
-    {
2226
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2227
-        if (empty($this->_views)) {
2228
-            $this->_views = [];
2229
-        }
2230
-        // cycle thru views
2231
-        foreach ($this->_views as $key => $view) {
2232
-            $query_args = [];
2233
-            // check for current view
2234
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2235
-            $query_args['action']                        = $this->_req_action;
2236
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2237
-            $query_args['status']                        = $view['slug'];
2238
-            // merge any other arguments sent in.
2239
-            if (isset($extra_query_args[ $view['slug'] ])) {
2240
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2241
-            }
2242
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2243
-        }
2244
-        return $this->_views;
2245
-    }
2246
-
2247
-
2248
-    /**
2249
-     * _entries_per_page_dropdown
2250
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2251
-     *
2252
-     * @param int $max_entries total number of rows in the table
2253
-     * @return string
2254
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2255
-     *         WP does it.
2256
-     */
2257
-    protected function _entries_per_page_dropdown($max_entries = 0)
2258
-    {
2259
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2260
-        $values   = [10, 25, 50, 100];
2261
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2262
-        if ($max_entries) {
2263
-            $values[] = $max_entries;
2264
-            sort($values);
2265
-        }
2266
-        $entries_per_page_dropdown = '
1704
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1705
+		// help tour stuff?
1706
+		// if (isset($this->_help_tour[ $this->_req_action ])) {
1707
+		//     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1708
+		// }
1709
+		// current set timezone for timezone js
1710
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1711
+	}
1712
+
1713
+
1714
+	/**
1715
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1716
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1717
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1718
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1719
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1720
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1721
+	 * for the
1722
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1723
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1724
+	 *    'help_trigger_id' => array(
1725
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1726
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1727
+	 *    )
1728
+	 * );
1729
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1730
+	 *
1731
+	 * @param array $help_array
1732
+	 * @param bool  $display
1733
+	 * @return string content
1734
+	 * @throws DomainException
1735
+	 * @throws EE_Error
1736
+	 */
1737
+	protected function _set_help_popup_content($help_array = [], $display = false)
1738
+	{
1739
+		$content    = '';
1740
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1741
+		// loop through the array and setup content
1742
+		foreach ($help_array as $trigger => $help) {
1743
+			// make sure the array is setup properly
1744
+			if (! isset($help['title']) || ! isset($help['content'])) {
1745
+				throw new EE_Error(
1746
+					esc_html__(
1747
+						'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',
1748
+						'event_espresso'
1749
+					)
1750
+				);
1751
+			}
1752
+			// we're good so let'd setup the template vars and then assign parsed template content to our content.
1753
+			$template_args = [
1754
+				'help_popup_id'      => $trigger,
1755
+				'help_popup_title'   => $help['title'],
1756
+				'help_popup_content' => $help['content'],
1757
+			];
1758
+			$content       .= EEH_Template::display_template(
1759
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1760
+				$template_args,
1761
+				true
1762
+			);
1763
+		}
1764
+		if ($display) {
1765
+			echo $content; // already escaped
1766
+			return '';
1767
+		}
1768
+		return $content;
1769
+	}
1770
+
1771
+
1772
+	/**
1773
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1774
+	 *
1775
+	 * @return array properly formatted array for help popup content
1776
+	 * @throws EE_Error
1777
+	 */
1778
+	private function _get_help_content()
1779
+	{
1780
+		// what is the method we're looking for?
1781
+		$method_name = '_help_popup_content_' . $this->_req_action;
1782
+		// if method doesn't exist let's get out.
1783
+		if (! method_exists($this, $method_name)) {
1784
+			return [];
1785
+		}
1786
+		// k we're good to go let's retrieve the help array
1787
+		$help_array = call_user_func([$this, $method_name]);
1788
+		// make sure we've got an array!
1789
+		if (! is_array($help_array)) {
1790
+			throw new EE_Error(
1791
+				esc_html__(
1792
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1793
+					'event_espresso'
1794
+				)
1795
+			);
1796
+		}
1797
+		return $help_array;
1798
+	}
1799
+
1800
+
1801
+	/**
1802
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1803
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1804
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1805
+	 *
1806
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1807
+	 * @param boolean $display    if false then we return the trigger string
1808
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1809
+	 * @return string
1810
+	 * @throws DomainException
1811
+	 * @throws EE_Error
1812
+	 */
1813
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1814
+	{
1815
+		if ($this->request->isAjax()) {
1816
+			return '';
1817
+		}
1818
+		// 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
1819
+		$help_array   = $this->_get_help_content();
1820
+		$help_content = '';
1821
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1822
+			$help_array[ $trigger_id ] = [
1823
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1824
+				'content' => esc_html__(
1825
+					'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.)',
1826
+					'event_espresso'
1827
+				),
1828
+			];
1829
+			$help_content              = $this->_set_help_popup_content($help_array, false);
1830
+		}
1831
+		// let's setup the trigger
1832
+		$content = '<a class="ee-dialog" href="?height='
1833
+				   . esc_attr($dimensions[0])
1834
+				   . '&width='
1835
+				   . esc_attr($dimensions[1])
1836
+				   . '&inlineId='
1837
+				   . esc_attr($trigger_id)
1838
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1839
+		$content .= $help_content;
1840
+		if ($display) {
1841
+			echo $content; // already escaped
1842
+			return '';
1843
+		}
1844
+		return $content;
1845
+	}
1846
+
1847
+
1848
+	/**
1849
+	 * _add_global_screen_options
1850
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1851
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1852
+	 *
1853
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1854
+	 *         see also WP_Screen object documents...
1855
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1856
+	 * @abstract
1857
+	 * @return void
1858
+	 */
1859
+	private function _add_global_screen_options()
1860
+	{
1861
+	}
1862
+
1863
+
1864
+	/**
1865
+	 * _add_global_feature_pointers
1866
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1867
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1868
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1869
+	 *
1870
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1871
+	 *         extended) also see:
1872
+	 * @link   http://eamann.com/tech/wordpress-portland/
1873
+	 * @abstract
1874
+	 * @return void
1875
+	 */
1876
+	private function _add_global_feature_pointers()
1877
+	{
1878
+	}
1879
+
1880
+
1881
+	/**
1882
+	 * load_global_scripts_styles
1883
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1884
+	 *
1885
+	 * @return void
1886
+	 */
1887
+	public function load_global_scripts_styles()
1888
+	{
1889
+		/** STYLES **/
1890
+		// add debugging styles
1891
+		if (WP_DEBUG) {
1892
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1893
+		}
1894
+		// register all styles
1895
+		wp_register_style(
1896
+			'espresso-ui-theme',
1897
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1898
+			[],
1899
+			EVENT_ESPRESSO_VERSION
1900
+		);
1901
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1902
+		// helpers styles
1903
+		wp_register_style(
1904
+			'ee-text-links',
1905
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1906
+			[],
1907
+			EVENT_ESPRESSO_VERSION
1908
+		);
1909
+		/** SCRIPTS **/
1910
+		// register all scripts
1911
+		wp_register_script(
1912
+			'ee-dialog',
1913
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1914
+			['jquery', 'jquery-ui-draggable'],
1915
+			EVENT_ESPRESSO_VERSION,
1916
+			true
1917
+		);
1918
+		wp_register_script(
1919
+			'ee_admin_js',
1920
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1921
+			['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1922
+			EVENT_ESPRESSO_VERSION,
1923
+			true
1924
+		);
1925
+		wp_register_script(
1926
+			'jquery-ui-timepicker-addon',
1927
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1928
+			['jquery-ui-datepicker', 'jquery-ui-slider'],
1929
+			EVENT_ESPRESSO_VERSION,
1930
+			true
1931
+		);
1932
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1933
+		// if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1934
+		//     add_filter('FHEE_load_joyride', '__return_true');
1935
+		// }
1936
+		// script for sorting tables
1937
+		wp_register_script(
1938
+			'espresso_ajax_table_sorting',
1939
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1940
+			['ee_admin_js', 'jquery-ui-sortable'],
1941
+			EVENT_ESPRESSO_VERSION,
1942
+			true
1943
+		);
1944
+		// script for parsing uri's
1945
+		wp_register_script(
1946
+			'ee-parse-uri',
1947
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1948
+			[],
1949
+			EVENT_ESPRESSO_VERSION,
1950
+			true
1951
+		);
1952
+		// and parsing associative serialized form elements
1953
+		wp_register_script(
1954
+			'ee-serialize-full-array',
1955
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1956
+			['jquery'],
1957
+			EVENT_ESPRESSO_VERSION,
1958
+			true
1959
+		);
1960
+		// helpers scripts
1961
+		wp_register_script(
1962
+			'ee-text-links',
1963
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1964
+			['jquery'],
1965
+			EVENT_ESPRESSO_VERSION,
1966
+			true
1967
+		);
1968
+		wp_register_script(
1969
+			'ee-moment-core',
1970
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1971
+			[],
1972
+			EVENT_ESPRESSO_VERSION,
1973
+			true
1974
+		);
1975
+		wp_register_script(
1976
+			'ee-moment',
1977
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1978
+			['ee-moment-core'],
1979
+			EVENT_ESPRESSO_VERSION,
1980
+			true
1981
+		);
1982
+		wp_register_script(
1983
+			'ee-datepicker',
1984
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1985
+			['jquery-ui-timepicker-addon', 'ee-moment'],
1986
+			EVENT_ESPRESSO_VERSION,
1987
+			true
1988
+		);
1989
+		// google charts
1990
+		wp_register_script(
1991
+			'google-charts',
1992
+			'https://www.gstatic.com/charts/loader.js',
1993
+			[],
1994
+			EVENT_ESPRESSO_VERSION,
1995
+			false
1996
+		);
1997
+		// ENQUEUE ALL BASICS BY DEFAULT
1998
+		wp_enqueue_style('ee-admin-css');
1999
+		wp_enqueue_script('ee_admin_js');
2000
+		wp_enqueue_script('ee-accounting');
2001
+		wp_enqueue_script('jquery-validate');
2002
+		// taking care of metaboxes
2003
+		if (
2004
+			empty($this->_cpt_route)
2005
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2006
+		) {
2007
+			wp_enqueue_script('dashboard');
2008
+		}
2009
+		// LOCALIZED DATA
2010
+		// localize script for ajax lazy loading
2011
+		$lazy_loader_container_ids = apply_filters(
2012
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2013
+			['espresso_news_post_box_content']
2014
+		);
2015
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2016
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
2017
+		// /**
2018
+		//  * help tour stuff
2019
+		//  */
2020
+		// if (! empty($this->_help_tour)) {
2021
+		//     // register the js for kicking things off
2022
+		//     wp_enqueue_script(
2023
+		//         'ee-help-tour',
2024
+		//         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2025
+		//         array('jquery-joyride'),
2026
+		//         EVENT_ESPRESSO_VERSION,
2027
+		//         true
2028
+		//     );
2029
+		//     $tours = array();
2030
+		//     // setup tours for the js tour object
2031
+		//     foreach ($this->_help_tour['tours'] as $tour) {
2032
+		//         if ($tour instanceof EE_Help_Tour) {
2033
+		//             $tours[] = array(
2034
+		//                 'id'      => $tour->get_slug(),
2035
+		//                 'options' => $tour->get_options(),
2036
+		//             );
2037
+		//         }
2038
+		//     }
2039
+		//     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2040
+		//     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2041
+		// }
2042
+
2043
+		add_filter(
2044
+			'admin_body_class',
2045
+			function ($classes) {
2046
+				if (strpos($classes, 'espresso-admin') === false) {
2047
+					$classes .= ' espresso-admin';
2048
+				}
2049
+				return $classes;
2050
+			}
2051
+		);
2052
+	}
2053
+
2054
+
2055
+	/**
2056
+	 *        admin_footer_scripts_eei18n_js_strings
2057
+	 *
2058
+	 * @return        void
2059
+	 */
2060
+	public function admin_footer_scripts_eei18n_js_strings()
2061
+	{
2062
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2063
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2064
+			__(
2065
+				'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!!!',
2066
+				'event_espresso'
2067
+			)
2068
+		);
2069
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2070
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2071
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2072
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2073
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2074
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2075
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2076
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2077
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2078
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2079
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2080
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2081
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2082
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2083
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2084
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2085
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2086
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2087
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2088
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2089
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2090
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2091
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2092
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2093
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2094
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2095
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2096
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2097
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2098
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2099
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2100
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2101
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2102
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2103
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2104
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2105
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2106
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2107
+	}
2108
+
2109
+
2110
+	/**
2111
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2112
+	 *
2113
+	 * @return        void
2114
+	 */
2115
+	public function add_xdebug_style()
2116
+	{
2117
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2118
+	}
2119
+
2120
+
2121
+	/************************/
2122
+	/** LIST TABLE METHODS **/
2123
+	/************************/
2124
+	/**
2125
+	 * this sets up the list table if the current view requires it.
2126
+	 *
2127
+	 * @return void
2128
+	 * @throws EE_Error
2129
+	 */
2130
+	protected function _set_list_table()
2131
+	{
2132
+		// first is this a list_table view?
2133
+		if (! isset($this->_route_config['list_table'])) {
2134
+			return;
2135
+		} //not a list_table view so get out.
2136
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2137
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2138
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2139
+			// user error msg
2140
+			$error_msg = esc_html__(
2141
+				'An error occurred. The requested list table views could not be found.',
2142
+				'event_espresso'
2143
+			);
2144
+			// developer error msg
2145
+			$error_msg .= '||'
2146
+						  . sprintf(
2147
+							  esc_html__(
2148
+								  '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.',
2149
+								  'event_espresso'
2150
+							  ),
2151
+							  $this->_req_action,
2152
+							  $list_table_view
2153
+						  );
2154
+			throw new EE_Error($error_msg);
2155
+		}
2156
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2157
+		$this->_views = apply_filters(
2158
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2159
+			$this->_views
2160
+		);
2161
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2162
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2163
+		$this->_set_list_table_view();
2164
+		$this->_set_list_table_object();
2165
+	}
2166
+
2167
+
2168
+	/**
2169
+	 * set current view for List Table
2170
+	 *
2171
+	 * @return void
2172
+	 */
2173
+	protected function _set_list_table_view()
2174
+	{
2175
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2176
+		$status = $this->request->getRequestParam('status', null, 'key');
2177
+		$this->_view = $status && array_key_exists($status, $this->_views)
2178
+			? $status
2179
+			: $this->_view;
2180
+	}
2181
+
2182
+
2183
+	/**
2184
+	 * _set_list_table_object
2185
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2186
+	 *
2187
+	 * @throws InvalidInterfaceException
2188
+	 * @throws InvalidArgumentException
2189
+	 * @throws InvalidDataTypeException
2190
+	 * @throws EE_Error
2191
+	 * @throws InvalidInterfaceException
2192
+	 */
2193
+	protected function _set_list_table_object()
2194
+	{
2195
+		if (isset($this->_route_config['list_table'])) {
2196
+			if (! class_exists($this->_route_config['list_table'])) {
2197
+				throw new EE_Error(
2198
+					sprintf(
2199
+						esc_html__(
2200
+							'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.',
2201
+							'event_espresso'
2202
+						),
2203
+						$this->_route_config['list_table'],
2204
+						get_class($this)
2205
+					)
2206
+				);
2207
+			}
2208
+			$this->_list_table_object = $this->loader->getShared(
2209
+				$this->_route_config['list_table'],
2210
+				[$this]
2211
+			);
2212
+		}
2213
+	}
2214
+
2215
+
2216
+	/**
2217
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2218
+	 *
2219
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2220
+	 *                                                    urls.  The array should be indexed by the view it is being
2221
+	 *                                                    added to.
2222
+	 * @return array
2223
+	 */
2224
+	public function get_list_table_view_RLs($extra_query_args = [])
2225
+	{
2226
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2227
+		if (empty($this->_views)) {
2228
+			$this->_views = [];
2229
+		}
2230
+		// cycle thru views
2231
+		foreach ($this->_views as $key => $view) {
2232
+			$query_args = [];
2233
+			// check for current view
2234
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2235
+			$query_args['action']                        = $this->_req_action;
2236
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2237
+			$query_args['status']                        = $view['slug'];
2238
+			// merge any other arguments sent in.
2239
+			if (isset($extra_query_args[ $view['slug'] ])) {
2240
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2241
+			}
2242
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2243
+		}
2244
+		return $this->_views;
2245
+	}
2246
+
2247
+
2248
+	/**
2249
+	 * _entries_per_page_dropdown
2250
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2251
+	 *
2252
+	 * @param int $max_entries total number of rows in the table
2253
+	 * @return string
2254
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2255
+	 *         WP does it.
2256
+	 */
2257
+	protected function _entries_per_page_dropdown($max_entries = 0)
2258
+	{
2259
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2260
+		$values   = [10, 25, 50, 100];
2261
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2262
+		if ($max_entries) {
2263
+			$values[] = $max_entries;
2264
+			sort($values);
2265
+		}
2266
+		$entries_per_page_dropdown = '
2267 2267
 			<div id="entries-per-page-dv" class="alignleft actions">
2268 2268
 				<label class="hide-if-no-js">
2269 2269
 					Show
2270 2270
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2271
-        foreach ($values as $value) {
2272
-            if ($value < $max_entries) {
2273
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2274
-                $entries_per_page_dropdown .= '
2271
+		foreach ($values as $value) {
2272
+			if ($value < $max_entries) {
2273
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2274
+				$entries_per_page_dropdown .= '
2275 2275
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2276
-            }
2277
-        }
2278
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2279
-        $entries_per_page_dropdown .= '
2276
+			}
2277
+		}
2278
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2279
+		$entries_per_page_dropdown .= '
2280 2280
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2281
-        $entries_per_page_dropdown .= '
2281
+		$entries_per_page_dropdown .= '
2282 2282
 					</select>
2283 2283
 					entries
2284 2284
 				</label>
2285 2285
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2286 2286
 			</div>
2287 2287
 		';
2288
-        return $entries_per_page_dropdown;
2289
-    }
2290
-
2291
-
2292
-    /**
2293
-     *        _set_search_attributes
2294
-     *
2295
-     * @return        void
2296
-     */
2297
-    public function _set_search_attributes()
2298
-    {
2299
-        $this->_template_args['search']['btn_label'] = sprintf(
2300
-            esc_html__('Search %s', 'event_espresso'),
2301
-            empty($this->_search_btn_label) ? $this->page_label
2302
-                : $this->_search_btn_label
2303
-        );
2304
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2305
-    }
2306
-
2307
-
2308
-
2309
-    /*** END LIST TABLE METHODS **/
2310
-
2311
-
2312
-    /**
2313
-     * _add_registered_metaboxes
2314
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2315
-     *
2316
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2317
-     * @return void
2318
-     * @throws EE_Error
2319
-     */
2320
-    private function _add_registered_meta_boxes()
2321
-    {
2322
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2323
-        // we only add meta boxes if the page_route calls for it
2324
-        if (
2325
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2326
-            && is_array(
2327
-                $this->_route_config['metaboxes']
2328
-            )
2329
-        ) {
2330
-            // this simply loops through the callbacks provided
2331
-            // and checks if there is a corresponding callback registered by the child
2332
-            // if there is then we go ahead and process the metabox loader.
2333
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2334
-                // first check for Closures
2335
-                if ($metabox_callback instanceof Closure) {
2336
-                    $result = $metabox_callback();
2337
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2338
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2339
-                } else {
2340
-                    $result = call_user_func([$this, &$metabox_callback]);
2341
-                }
2342
-                if ($result === false) {
2343
-                    // user error msg
2344
-                    $error_msg = esc_html__(
2345
-                        'An error occurred. The  requested metabox could not be found.',
2346
-                        'event_espresso'
2347
-                    );
2348
-                    // developer error msg
2349
-                    $error_msg .= '||'
2350
-                                  . sprintf(
2351
-                                      esc_html__(
2352
-                                          '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.',
2353
-                                          'event_espresso'
2354
-                                      ),
2355
-                                      $metabox_callback
2356
-                                  );
2357
-                    throw new EE_Error($error_msg);
2358
-                }
2359
-            }
2360
-        }
2361
-    }
2362
-
2363
-
2364
-    /**
2365
-     * _add_screen_columns
2366
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2367
-     * the dynamic column template and we'll setup the column options for the page.
2368
-     *
2369
-     * @return void
2370
-     */
2371
-    private function _add_screen_columns()
2372
-    {
2373
-        if (
2374
-            is_array($this->_route_config)
2375
-            && isset($this->_route_config['columns'])
2376
-            && is_array($this->_route_config['columns'])
2377
-            && count($this->_route_config['columns']) === 2
2378
-        ) {
2379
-            add_screen_option(
2380
-                'layout_columns',
2381
-                [
2382
-                    'max'     => (int) $this->_route_config['columns'][0],
2383
-                    'default' => (int) $this->_route_config['columns'][1],
2384
-                ]
2385
-            );
2386
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2387
-            $screen_id                                           = $this->_current_screen->id;
2388
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2389
-            $total_columns                                       = ! empty($screen_columns)
2390
-                ? $screen_columns
2391
-                : $this->_route_config['columns'][1];
2392
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2393
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2394
-            $this->_template_args['screen']                      = $this->_current_screen;
2395
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2396
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2397
-            // finally if we don't have has_metaboxes set in the route config
2398
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2399
-            $this->_route_config['has_metaboxes'] = true;
2400
-        }
2401
-    }
2402
-
2403
-
2404
-
2405
-    /** GLOBALLY AVAILABLE METABOXES **/
2406
-
2407
-
2408
-    /**
2409
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2410
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2411
-     * these get loaded on.
2412
-     */
2413
-    private function _espresso_news_post_box()
2414
-    {
2415
-        $news_box_title = apply_filters(
2416
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2417
-            esc_html__('New @ Event Espresso', 'event_espresso')
2418
-        );
2419
-        add_meta_box(
2420
-            'espresso_news_post_box',
2421
-            $news_box_title,
2422
-            [
2423
-                $this,
2424
-                'espresso_news_post_box',
2425
-            ],
2426
-            $this->_wp_page_slug,
2427
-            'side'
2428
-        );
2429
-    }
2430
-
2431
-
2432
-    /**
2433
-     * Code for setting up espresso ratings request metabox.
2434
-     */
2435
-    protected function _espresso_ratings_request()
2436
-    {
2437
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2438
-            return;
2439
-        }
2440
-        $ratings_box_title = apply_filters(
2441
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2442
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2443
-        );
2444
-        add_meta_box(
2445
-            'espresso_ratings_request',
2446
-            $ratings_box_title,
2447
-            [
2448
-                $this,
2449
-                'espresso_ratings_request',
2450
-            ],
2451
-            $this->_wp_page_slug,
2452
-            'side'
2453
-        );
2454
-    }
2455
-
2456
-
2457
-    /**
2458
-     * Code for setting up espresso ratings request metabox content.
2459
-     *
2460
-     * @throws DomainException
2461
-     */
2462
-    public function espresso_ratings_request()
2463
-    {
2464
-        EEH_Template::display_template(
2465
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2466
-            []
2467
-        );
2468
-    }
2469
-
2470
-
2471
-    public static function cached_rss_display($rss_id, $url)
2472
-    {
2473
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2474
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2475
-                     . '</p><p class="hide-if-js">'
2476
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2477
-                     . '</p>';
2478
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2479
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2480
-        $post      = '</div>' . "\n";
2481
-        $cache_key = 'ee_rss_' . md5($rss_id);
2482
-        $output    = get_transient($cache_key);
2483
-        if ($output !== false) {
2484
-            echo $pre . $output . $post; // already escaped
2485
-            return true;
2486
-        }
2487
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2488
-            echo $pre . $loading . $post; // already escaped
2489
-            return false;
2490
-        }
2491
-        ob_start();
2492
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2493
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2494
-        return true;
2495
-    }
2496
-
2497
-
2498
-    public function espresso_news_post_box()
2499
-    {
2500
-        ?>
2288
+		return $entries_per_page_dropdown;
2289
+	}
2290
+
2291
+
2292
+	/**
2293
+	 *        _set_search_attributes
2294
+	 *
2295
+	 * @return        void
2296
+	 */
2297
+	public function _set_search_attributes()
2298
+	{
2299
+		$this->_template_args['search']['btn_label'] = sprintf(
2300
+			esc_html__('Search %s', 'event_espresso'),
2301
+			empty($this->_search_btn_label) ? $this->page_label
2302
+				: $this->_search_btn_label
2303
+		);
2304
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2305
+	}
2306
+
2307
+
2308
+
2309
+	/*** END LIST TABLE METHODS **/
2310
+
2311
+
2312
+	/**
2313
+	 * _add_registered_metaboxes
2314
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2315
+	 *
2316
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2317
+	 * @return void
2318
+	 * @throws EE_Error
2319
+	 */
2320
+	private function _add_registered_meta_boxes()
2321
+	{
2322
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2323
+		// we only add meta boxes if the page_route calls for it
2324
+		if (
2325
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2326
+			&& is_array(
2327
+				$this->_route_config['metaboxes']
2328
+			)
2329
+		) {
2330
+			// this simply loops through the callbacks provided
2331
+			// and checks if there is a corresponding callback registered by the child
2332
+			// if there is then we go ahead and process the metabox loader.
2333
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2334
+				// first check for Closures
2335
+				if ($metabox_callback instanceof Closure) {
2336
+					$result = $metabox_callback();
2337
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2338
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2339
+				} else {
2340
+					$result = call_user_func([$this, &$metabox_callback]);
2341
+				}
2342
+				if ($result === false) {
2343
+					// user error msg
2344
+					$error_msg = esc_html__(
2345
+						'An error occurred. The  requested metabox could not be found.',
2346
+						'event_espresso'
2347
+					);
2348
+					// developer error msg
2349
+					$error_msg .= '||'
2350
+								  . sprintf(
2351
+									  esc_html__(
2352
+										  '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.',
2353
+										  'event_espresso'
2354
+									  ),
2355
+									  $metabox_callback
2356
+								  );
2357
+					throw new EE_Error($error_msg);
2358
+				}
2359
+			}
2360
+		}
2361
+	}
2362
+
2363
+
2364
+	/**
2365
+	 * _add_screen_columns
2366
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2367
+	 * the dynamic column template and we'll setup the column options for the page.
2368
+	 *
2369
+	 * @return void
2370
+	 */
2371
+	private function _add_screen_columns()
2372
+	{
2373
+		if (
2374
+			is_array($this->_route_config)
2375
+			&& isset($this->_route_config['columns'])
2376
+			&& is_array($this->_route_config['columns'])
2377
+			&& count($this->_route_config['columns']) === 2
2378
+		) {
2379
+			add_screen_option(
2380
+				'layout_columns',
2381
+				[
2382
+					'max'     => (int) $this->_route_config['columns'][0],
2383
+					'default' => (int) $this->_route_config['columns'][1],
2384
+				]
2385
+			);
2386
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2387
+			$screen_id                                           = $this->_current_screen->id;
2388
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2389
+			$total_columns                                       = ! empty($screen_columns)
2390
+				? $screen_columns
2391
+				: $this->_route_config['columns'][1];
2392
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2393
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2394
+			$this->_template_args['screen']                      = $this->_current_screen;
2395
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2396
+																   . 'admin_details_metabox_column_wrapper.template.php';
2397
+			// finally if we don't have has_metaboxes set in the route config
2398
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2399
+			$this->_route_config['has_metaboxes'] = true;
2400
+		}
2401
+	}
2402
+
2403
+
2404
+
2405
+	/** GLOBALLY AVAILABLE METABOXES **/
2406
+
2407
+
2408
+	/**
2409
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2410
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2411
+	 * these get loaded on.
2412
+	 */
2413
+	private function _espresso_news_post_box()
2414
+	{
2415
+		$news_box_title = apply_filters(
2416
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2417
+			esc_html__('New @ Event Espresso', 'event_espresso')
2418
+		);
2419
+		add_meta_box(
2420
+			'espresso_news_post_box',
2421
+			$news_box_title,
2422
+			[
2423
+				$this,
2424
+				'espresso_news_post_box',
2425
+			],
2426
+			$this->_wp_page_slug,
2427
+			'side'
2428
+		);
2429
+	}
2430
+
2431
+
2432
+	/**
2433
+	 * Code for setting up espresso ratings request metabox.
2434
+	 */
2435
+	protected function _espresso_ratings_request()
2436
+	{
2437
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2438
+			return;
2439
+		}
2440
+		$ratings_box_title = apply_filters(
2441
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2442
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2443
+		);
2444
+		add_meta_box(
2445
+			'espresso_ratings_request',
2446
+			$ratings_box_title,
2447
+			[
2448
+				$this,
2449
+				'espresso_ratings_request',
2450
+			],
2451
+			$this->_wp_page_slug,
2452
+			'side'
2453
+		);
2454
+	}
2455
+
2456
+
2457
+	/**
2458
+	 * Code for setting up espresso ratings request metabox content.
2459
+	 *
2460
+	 * @throws DomainException
2461
+	 */
2462
+	public function espresso_ratings_request()
2463
+	{
2464
+		EEH_Template::display_template(
2465
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2466
+			[]
2467
+		);
2468
+	}
2469
+
2470
+
2471
+	public static function cached_rss_display($rss_id, $url)
2472
+	{
2473
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2474
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2475
+					 . '</p><p class="hide-if-js">'
2476
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2477
+					 . '</p>';
2478
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2479
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2480
+		$post      = '</div>' . "\n";
2481
+		$cache_key = 'ee_rss_' . md5($rss_id);
2482
+		$output    = get_transient($cache_key);
2483
+		if ($output !== false) {
2484
+			echo $pre . $output . $post; // already escaped
2485
+			return true;
2486
+		}
2487
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2488
+			echo $pre . $loading . $post; // already escaped
2489
+			return false;
2490
+		}
2491
+		ob_start();
2492
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2493
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2494
+		return true;
2495
+	}
2496
+
2497
+
2498
+	public function espresso_news_post_box()
2499
+	{
2500
+		?>
2501 2501
         <div class="padding">
2502 2502
             <div id="espresso_news_post_box_content" class="infolinks">
2503 2503
                 <?php
2504
-                // Get RSS Feed(s)
2505
-                self::cached_rss_display(
2506
-                    'espresso_news_post_box_content',
2507
-                    urlencode(
2508
-                        apply_filters(
2509
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2510
-                            'https://eventespresso.com/feed/'
2511
-                        )
2512
-                    )
2513
-                );
2514
-                ?>
2504
+				// Get RSS Feed(s)
2505
+				self::cached_rss_display(
2506
+					'espresso_news_post_box_content',
2507
+					urlencode(
2508
+						apply_filters(
2509
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2510
+							'https://eventespresso.com/feed/'
2511
+						)
2512
+					)
2513
+				);
2514
+				?>
2515 2515
             </div>
2516 2516
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2517 2517
         </div>
2518 2518
         <?php
2519
-    }
2520
-
2521
-
2522
-    private function _espresso_links_post_box()
2523
-    {
2524
-        // Hiding until we actually have content to put in here...
2525
-        // 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');
2526
-    }
2527
-
2528
-
2529
-    public function espresso_links_post_box()
2530
-    {
2531
-        // Hiding until we actually have content to put in here...
2532
-        // EEH_Template::display_template(
2533
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2534
-        // );
2535
-    }
2536
-
2537
-
2538
-    protected function _espresso_sponsors_post_box()
2539
-    {
2540
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2541
-            add_meta_box(
2542
-                'espresso_sponsors_post_box',
2543
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2544
-                [$this, 'espresso_sponsors_post_box'],
2545
-                $this->_wp_page_slug,
2546
-                'side'
2547
-            );
2548
-        }
2549
-    }
2550
-
2551
-
2552
-    public function espresso_sponsors_post_box()
2553
-    {
2554
-        EEH_Template::display_template(
2555
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2556
-        );
2557
-    }
2558
-
2559
-
2560
-    private function _publish_post_box()
2561
-    {
2562
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2563
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2564
-        // then we'll use that for the metabox label.
2565
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2566
-        if (! empty($this->_labels['publishbox'])) {
2567
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2568
-                : $this->_labels['publishbox'];
2569
-        } else {
2570
-            $box_label = esc_html__('Publish', 'event_espresso');
2571
-        }
2572
-        $box_label = apply_filters(
2573
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2574
-            $box_label,
2575
-            $this->_req_action,
2576
-            $this
2577
-        );
2578
-        add_meta_box(
2579
-            $meta_box_ref,
2580
-            $box_label,
2581
-            [$this, 'editor_overview'],
2582
-            $this->_current_screen->id,
2583
-            'side',
2584
-            'high'
2585
-        );
2586
-    }
2587
-
2588
-
2589
-    public function editor_overview()
2590
-    {
2591
-        // if we have extra content set let's add it in if not make sure its empty
2592
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2593
-            ? $this->_template_args['publish_box_extra_content']
2594
-            : '';
2595
-        echo EEH_Template::display_template(
2596
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2597
-            $this->_template_args,
2598
-            true
2599
-        );
2600
-    }
2601
-
2602
-
2603
-    /** end of globally available metaboxes section **/
2604
-
2605
-
2606
-    /**
2607
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2608
-     * protected method.
2609
-     *
2610
-     * @param string $name
2611
-     * @param int    $id
2612
-     * @param bool   $delete
2613
-     * @param string $save_close_redirect_URL
2614
-     * @param bool   $both_btns
2615
-     * @throws EE_Error
2616
-     * @throws InvalidArgumentException
2617
-     * @throws InvalidDataTypeException
2618
-     * @throws InvalidInterfaceException
2619
-     * @see   $this->_set_publish_post_box_vars for param details
2620
-     * @since 4.6.0
2621
-     */
2622
-    public function set_publish_post_box_vars(
2623
-        $name = '',
2624
-        $id = 0,
2625
-        $delete = false,
2626
-        $save_close_redirect_URL = '',
2627
-        $both_btns = true
2628
-    ) {
2629
-        $this->_set_publish_post_box_vars(
2630
-            $name,
2631
-            $id,
2632
-            $delete,
2633
-            $save_close_redirect_URL,
2634
-            $both_btns
2635
-        );
2636
-    }
2637
-
2638
-
2639
-    /**
2640
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2641
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2642
-     * save, and save and close buttons to work properly, then you will want to include a
2643
-     * values for the name and id arguments.
2644
-     *
2645
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2646
-     * @param int     $id                         id attached to the item published
2647
-     * @param string  $delete                     page route callback for the delete action
2648
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2649
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2650
-     *                                            the Save button
2651
-     * @throws EE_Error
2652
-     * @throws InvalidArgumentException
2653
-     * @throws InvalidDataTypeException
2654
-     * @throws InvalidInterfaceException
2655
-     * @todo  Add in validation for name/id arguments.
2656
-     */
2657
-    protected function _set_publish_post_box_vars(
2658
-        $name = '',
2659
-        $id = 0,
2660
-        $delete = '',
2661
-        $save_close_redirect_URL = '',
2662
-        $both_btns = true
2663
-    ) {
2664
-        // if Save & Close, use a custom redirect URL or default to the main page?
2665
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2666
-            ? $save_close_redirect_URL
2667
-            : $this->_admin_base_url;
2668
-        // create the Save & Close and Save buttons
2669
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2670
-        // if we have extra content set let's add it in if not make sure its empty
2671
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2672
-            ? $this->_template_args['publish_box_extra_content']
2673
-            : '';
2674
-        if ($delete && ! empty($id)) {
2675
-            // make sure we have a default if just true is sent.
2676
-            $delete           = ! empty($delete) ? $delete : 'delete';
2677
-            $delete_link_args = [$name => $id];
2678
-            $delete           = $this->get_action_link_or_button(
2679
-                $delete,
2680
-                $delete,
2681
-                $delete_link_args,
2682
-                'submitdelete deletion',
2683
-                '',
2684
-                false
2685
-            );
2686
-        }
2687
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2688
-        if (! empty($name) && ! empty($id)) {
2689
-            $hidden_field_arr[ $name ] = [
2690
-                'type'  => 'hidden',
2691
-                'value' => $id,
2692
-            ];
2693
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2694
-        } else {
2695
-            $hf = '';
2696
-        }
2697
-        // add hidden field
2698
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2699
-            ? $hf[ $name ]['field']
2700
-            : $hf;
2701
-    }
2702
-
2703
-
2704
-    /**
2705
-     * displays an error message to ppl who have javascript disabled
2706
-     *
2707
-     * @return void
2708
-     */
2709
-    private function _display_no_javascript_warning()
2710
-    {
2711
-        ?>
2519
+	}
2520
+
2521
+
2522
+	private function _espresso_links_post_box()
2523
+	{
2524
+		// Hiding until we actually have content to put in here...
2525
+		// 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');
2526
+	}
2527
+
2528
+
2529
+	public function espresso_links_post_box()
2530
+	{
2531
+		// Hiding until we actually have content to put in here...
2532
+		// EEH_Template::display_template(
2533
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2534
+		// );
2535
+	}
2536
+
2537
+
2538
+	protected function _espresso_sponsors_post_box()
2539
+	{
2540
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2541
+			add_meta_box(
2542
+				'espresso_sponsors_post_box',
2543
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2544
+				[$this, 'espresso_sponsors_post_box'],
2545
+				$this->_wp_page_slug,
2546
+				'side'
2547
+			);
2548
+		}
2549
+	}
2550
+
2551
+
2552
+	public function espresso_sponsors_post_box()
2553
+	{
2554
+		EEH_Template::display_template(
2555
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2556
+		);
2557
+	}
2558
+
2559
+
2560
+	private function _publish_post_box()
2561
+	{
2562
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2563
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2564
+		// then we'll use that for the metabox label.
2565
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2566
+		if (! empty($this->_labels['publishbox'])) {
2567
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2568
+				: $this->_labels['publishbox'];
2569
+		} else {
2570
+			$box_label = esc_html__('Publish', 'event_espresso');
2571
+		}
2572
+		$box_label = apply_filters(
2573
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2574
+			$box_label,
2575
+			$this->_req_action,
2576
+			$this
2577
+		);
2578
+		add_meta_box(
2579
+			$meta_box_ref,
2580
+			$box_label,
2581
+			[$this, 'editor_overview'],
2582
+			$this->_current_screen->id,
2583
+			'side',
2584
+			'high'
2585
+		);
2586
+	}
2587
+
2588
+
2589
+	public function editor_overview()
2590
+	{
2591
+		// if we have extra content set let's add it in if not make sure its empty
2592
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2593
+			? $this->_template_args['publish_box_extra_content']
2594
+			: '';
2595
+		echo EEH_Template::display_template(
2596
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2597
+			$this->_template_args,
2598
+			true
2599
+		);
2600
+	}
2601
+
2602
+
2603
+	/** end of globally available metaboxes section **/
2604
+
2605
+
2606
+	/**
2607
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2608
+	 * protected method.
2609
+	 *
2610
+	 * @param string $name
2611
+	 * @param int    $id
2612
+	 * @param bool   $delete
2613
+	 * @param string $save_close_redirect_URL
2614
+	 * @param bool   $both_btns
2615
+	 * @throws EE_Error
2616
+	 * @throws InvalidArgumentException
2617
+	 * @throws InvalidDataTypeException
2618
+	 * @throws InvalidInterfaceException
2619
+	 * @see   $this->_set_publish_post_box_vars for param details
2620
+	 * @since 4.6.0
2621
+	 */
2622
+	public function set_publish_post_box_vars(
2623
+		$name = '',
2624
+		$id = 0,
2625
+		$delete = false,
2626
+		$save_close_redirect_URL = '',
2627
+		$both_btns = true
2628
+	) {
2629
+		$this->_set_publish_post_box_vars(
2630
+			$name,
2631
+			$id,
2632
+			$delete,
2633
+			$save_close_redirect_URL,
2634
+			$both_btns
2635
+		);
2636
+	}
2637
+
2638
+
2639
+	/**
2640
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2641
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2642
+	 * save, and save and close buttons to work properly, then you will want to include a
2643
+	 * values for the name and id arguments.
2644
+	 *
2645
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2646
+	 * @param int     $id                         id attached to the item published
2647
+	 * @param string  $delete                     page route callback for the delete action
2648
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2649
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2650
+	 *                                            the Save button
2651
+	 * @throws EE_Error
2652
+	 * @throws InvalidArgumentException
2653
+	 * @throws InvalidDataTypeException
2654
+	 * @throws InvalidInterfaceException
2655
+	 * @todo  Add in validation for name/id arguments.
2656
+	 */
2657
+	protected function _set_publish_post_box_vars(
2658
+		$name = '',
2659
+		$id = 0,
2660
+		$delete = '',
2661
+		$save_close_redirect_URL = '',
2662
+		$both_btns = true
2663
+	) {
2664
+		// if Save & Close, use a custom redirect URL or default to the main page?
2665
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2666
+			? $save_close_redirect_URL
2667
+			: $this->_admin_base_url;
2668
+		// create the Save & Close and Save buttons
2669
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2670
+		// if we have extra content set let's add it in if not make sure its empty
2671
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2672
+			? $this->_template_args['publish_box_extra_content']
2673
+			: '';
2674
+		if ($delete && ! empty($id)) {
2675
+			// make sure we have a default if just true is sent.
2676
+			$delete           = ! empty($delete) ? $delete : 'delete';
2677
+			$delete_link_args = [$name => $id];
2678
+			$delete           = $this->get_action_link_or_button(
2679
+				$delete,
2680
+				$delete,
2681
+				$delete_link_args,
2682
+				'submitdelete deletion',
2683
+				'',
2684
+				false
2685
+			);
2686
+		}
2687
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2688
+		if (! empty($name) && ! empty($id)) {
2689
+			$hidden_field_arr[ $name ] = [
2690
+				'type'  => 'hidden',
2691
+				'value' => $id,
2692
+			];
2693
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2694
+		} else {
2695
+			$hf = '';
2696
+		}
2697
+		// add hidden field
2698
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2699
+			? $hf[ $name ]['field']
2700
+			: $hf;
2701
+	}
2702
+
2703
+
2704
+	/**
2705
+	 * displays an error message to ppl who have javascript disabled
2706
+	 *
2707
+	 * @return void
2708
+	 */
2709
+	private function _display_no_javascript_warning()
2710
+	{
2711
+		?>
2712 2712
         <noscript>
2713 2713
             <div id="no-js-message" class="error">
2714 2714
                 <p style="font-size:1.3em;">
2715 2715
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2716 2716
                     <?php esc_html_e(
2717
-                        '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.',
2718
-                        'event_espresso'
2719
-                    ); ?>
2717
+						'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.',
2718
+						'event_espresso'
2719
+					); ?>
2720 2720
                 </p>
2721 2721
             </div>
2722 2722
         </noscript>
2723 2723
         <?php
2724
-    }
2725
-
2726
-
2727
-    /**
2728
-     * displays espresso success and/or error notices
2729
-     *
2730
-     * @return void
2731
-     */
2732
-    private function _display_espresso_notices()
2733
-    {
2734
-        $notices = $this->_get_transient(true);
2735
-        echo stripslashes($notices);
2736
-    }
2737
-
2738
-
2739
-    /**
2740
-     * spinny things pacify the masses
2741
-     *
2742
-     * @return void
2743
-     */
2744
-    protected function _add_admin_page_ajax_loading_img()
2745
-    {
2746
-        ?>
2724
+	}
2725
+
2726
+
2727
+	/**
2728
+	 * displays espresso success and/or error notices
2729
+	 *
2730
+	 * @return void
2731
+	 */
2732
+	private function _display_espresso_notices()
2733
+	{
2734
+		$notices = $this->_get_transient(true);
2735
+		echo stripslashes($notices);
2736
+	}
2737
+
2738
+
2739
+	/**
2740
+	 * spinny things pacify the masses
2741
+	 *
2742
+	 * @return void
2743
+	 */
2744
+	protected function _add_admin_page_ajax_loading_img()
2745
+	{
2746
+		?>
2747 2747
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2748 2748
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2749
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2749
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2750 2750
         </div>
2751 2751
         <?php
2752
-    }
2752
+	}
2753 2753
 
2754 2754
 
2755
-    /**
2756
-     * add admin page overlay for modal boxes
2757
-     *
2758
-     * @return void
2759
-     */
2760
-    protected function _add_admin_page_overlay()
2761
-    {
2762
-        ?>
2755
+	/**
2756
+	 * add admin page overlay for modal boxes
2757
+	 *
2758
+	 * @return void
2759
+	 */
2760
+	protected function _add_admin_page_overlay()
2761
+	{
2762
+		?>
2763 2763
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2764 2764
         <?php
2765
-    }
2766
-
2767
-
2768
-    /**
2769
-     * facade for add_meta_box
2770
-     *
2771
-     * @param string  $action        where the metabox get's displayed
2772
-     * @param string  $title         Title of Metabox (output in metabox header)
2773
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2774
-     *                               instead of the one created in here.
2775
-     * @param array   $callback_args an array of args supplied for the metabox
2776
-     * @param string  $column        what metabox column
2777
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2778
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2779
-     *                               created but just set our own callback for wp's add_meta_box.
2780
-     * @throws DomainException
2781
-     */
2782
-    public function _add_admin_page_meta_box(
2783
-        $action,
2784
-        $title,
2785
-        $callback,
2786
-        $callback_args,
2787
-        $column = 'normal',
2788
-        $priority = 'high',
2789
-        $create_func = true
2790
-    ) {
2791
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2792
-        // 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.
2793
-        if (empty($callback_args) && $create_func) {
2794
-            $callback_args = [
2795
-                'template_path' => $this->_template_path,
2796
-                'template_args' => $this->_template_args,
2797
-            ];
2798
-        }
2799
-        // 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)
2800
-        $call_back_func = $create_func
2801
-            ? function ($post, $metabox) {
2802
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2803
-                echo EEH_Template::display_template(
2804
-                    $metabox['args']['template_path'],
2805
-                    $metabox['args']['template_args'],
2806
-                    true
2807
-                );
2808
-            }
2809
-            : $callback;
2810
-        add_meta_box(
2811
-            str_replace('_', '-', $action) . '-mbox',
2812
-            $title,
2813
-            $call_back_func,
2814
-            $this->_wp_page_slug,
2815
-            $column,
2816
-            $priority,
2817
-            $callback_args
2818
-        );
2819
-    }
2820
-
2821
-
2822
-    /**
2823
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2824
-     *
2825
-     * @throws DomainException
2826
-     * @throws EE_Error
2827
-     */
2828
-    public function display_admin_page_with_metabox_columns()
2829
-    {
2830
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2831
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2832
-            $this->_column_template_path,
2833
-            $this->_template_args,
2834
-            true
2835
-        );
2836
-        // the final wrapper
2837
-        $this->admin_page_wrapper();
2838
-    }
2839
-
2840
-
2841
-    /**
2842
-     * generates  HTML wrapper for an admin details page
2843
-     *
2844
-     * @return void
2845
-     * @throws EE_Error
2846
-     * @throws DomainException
2847
-     */
2848
-    public function display_admin_page_with_sidebar()
2849
-    {
2850
-        $this->_display_admin_page(true);
2851
-    }
2852
-
2853
-
2854
-    /**
2855
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2856
-     *
2857
-     * @return void
2858
-     * @throws EE_Error
2859
-     * @throws DomainException
2860
-     */
2861
-    public function display_admin_page_with_no_sidebar()
2862
-    {
2863
-        $this->_display_admin_page();
2864
-    }
2865
-
2866
-
2867
-    /**
2868
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2869
-     *
2870
-     * @return void
2871
-     * @throws EE_Error
2872
-     * @throws DomainException
2873
-     */
2874
-    public function display_about_admin_page()
2875
-    {
2876
-        $this->_display_admin_page(false, true);
2877
-    }
2878
-
2879
-
2880
-    /**
2881
-     * display_admin_page
2882
-     * contains the code for actually displaying an admin page
2883
-     *
2884
-     * @param boolean $sidebar true with sidebar, false without
2885
-     * @param boolean $about   use the about_admin_wrapper instead of the default.
2886
-     * @return void
2887
-     * @throws DomainException
2888
-     * @throws EE_Error
2889
-     */
2890
-    private function _display_admin_page($sidebar = false, $about = false)
2891
-    {
2892
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2893
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2894
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2895
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2896
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2897
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2898
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2899
-            ? 'poststuff'
2900
-            : 'espresso-default-admin';
2901
-        $template_path                                     = $sidebar
2902
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2903
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2904
-        if ($this->request->isAjax()) {
2905
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2906
-        }
2907
-        $template_path                                     = ! empty($this->_column_template_path)
2908
-            ? $this->_column_template_path : $template_path;
2909
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2910
-            ? $this->_template_args['admin_page_content']
2911
-            : '';
2912
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2913
-            ? $this->_template_args['before_admin_page_content']
2914
-            : '';
2915
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2916
-            ? $this->_template_args['after_admin_page_content']
2917
-            : '';
2918
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2919
-            $template_path,
2920
-            $this->_template_args,
2921
-            true
2922
-        );
2923
-        // the final template wrapper
2924
-        $this->admin_page_wrapper($about);
2925
-    }
2926
-
2927
-
2928
-    /**
2929
-     * This is used to display caf preview pages.
2930
-     *
2931
-     * @param string $utm_campaign_source what is the key used for google analytics link
2932
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2933
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2934
-     * @return void
2935
-     * @throws DomainException
2936
-     * @throws EE_Error
2937
-     * @throws InvalidArgumentException
2938
-     * @throws InvalidDataTypeException
2939
-     * @throws InvalidInterfaceException
2940
-     * @since 4.3.2
2941
-     */
2942
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2943
-    {
2944
-        // let's generate a default preview action button if there isn't one already present.
2945
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2946
-            'Upgrade to Event Espresso 4 Right Now',
2947
-            'event_espresso'
2948
-        );
2949
-        $buy_now_url                                   = add_query_arg(
2950
-            [
2951
-                'ee_ver'       => 'ee4',
2952
-                'utm_source'   => 'ee4_plugin_admin',
2953
-                'utm_medium'   => 'link',
2954
-                'utm_campaign' => $utm_campaign_source,
2955
-                'utm_content'  => 'buy_now_button',
2956
-            ],
2957
-            'https://eventespresso.com/pricing/'
2958
-        );
2959
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2960
-            ? $this->get_action_link_or_button(
2961
-                '',
2962
-                'buy_now',
2963
-                [],
2964
-                'button-primary button-large',
2965
-                esc_url_raw($buy_now_url),
2966
-                true
2967
-            )
2968
-            : $this->_template_args['preview_action_button'];
2969
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2970
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2971
-            $this->_template_args,
2972
-            true
2973
-        );
2974
-        $this->_display_admin_page($display_sidebar);
2975
-    }
2976
-
2977
-
2978
-    /**
2979
-     * display_admin_list_table_page_with_sidebar
2980
-     * generates HTML wrapper for an admin_page with list_table
2981
-     *
2982
-     * @return void
2983
-     * @throws EE_Error
2984
-     * @throws DomainException
2985
-     */
2986
-    public function display_admin_list_table_page_with_sidebar()
2987
-    {
2988
-        $this->_display_admin_list_table_page(true);
2989
-    }
2990
-
2991
-
2992
-    /**
2993
-     * display_admin_list_table_page_with_no_sidebar
2994
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2995
-     *
2996
-     * @return void
2997
-     * @throws EE_Error
2998
-     * @throws DomainException
2999
-     */
3000
-    public function display_admin_list_table_page_with_no_sidebar()
3001
-    {
3002
-        $this->_display_admin_list_table_page();
3003
-    }
3004
-
3005
-
3006
-    /**
3007
-     * generates html wrapper for an admin_list_table page
3008
-     *
3009
-     * @param boolean $sidebar whether to display with sidebar or not.
3010
-     * @return void
3011
-     * @throws DomainException
3012
-     * @throws EE_Error
3013
-     */
3014
-    private function _display_admin_list_table_page($sidebar = false)
3015
-    {
3016
-        // setup search attributes
3017
-        $this->_set_search_attributes();
3018
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
3019
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3020
-        $this->_template_args['table_url']        = $this->request->isAjax()
3021
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3022
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
3023
-        $this->_template_args['list_table']       = $this->_list_table_object;
3024
-        $this->_template_args['current_route']    = $this->_req_action;
3025
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3026
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3027
-        if (! empty($ajax_sorting_callback)) {
3028
-            $sortable_list_table_form_fields = wp_nonce_field(
3029
-                $ajax_sorting_callback . '_nonce',
3030
-                $ajax_sorting_callback . '_nonce',
3031
-                false,
3032
-                false
3033
-            );
3034
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3035
-                                                . $this->page_slug
3036
-                                                . '" />';
3037
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3038
-                                                . $ajax_sorting_callback
3039
-                                                . '" />';
3040
-        } else {
3041
-            $sortable_list_table_form_fields = '';
3042
-        }
3043
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3044
-        $hidden_form_fields                                      =
3045
-            isset($this->_template_args['list_table_hidden_fields'])
3046
-                ? $this->_template_args['list_table_hidden_fields']
3047
-                : '';
3048
-        $nonce_ref                                               = $this->_req_action . '_nonce';
3049
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
3050
-                                                                    . $nonce_ref
3051
-                                                                    . '" value="'
3052
-                                                                    . wp_create_nonce($nonce_ref)
3053
-                                                                    . '">';
3054
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3055
-        // display message about search results?
3056
-        $search = $this->request->getRequestParam('s');
3057
-        $this->_template_args['before_list_table'] .= ! empty($search)
3058
-            ? '<p class="ee-search-results">' . sprintf(
3059
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3060
-                trim($search, '%')
3061
-            ) . '</p>'
3062
-            : '';
3063
-        // filter before_list_table template arg
3064
-        $this->_template_args['before_list_table'] = apply_filters(
3065
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3066
-            $this->_template_args['before_list_table'],
3067
-            $this->page_slug,
3068
-            $this->request->requestParams(),
3069
-            $this->_req_action
3070
-        );
3071
-        // convert to array and filter again
3072
-        // arrays are easier to inject new items in a specific location,
3073
-        // but would not be backwards compatible, so we have to add a new filter
3074
-        $this->_template_args['before_list_table'] = implode(
3075
-            " \n",
3076
-            (array) apply_filters(
3077
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3078
-                (array) $this->_template_args['before_list_table'],
3079
-                $this->page_slug,
3080
-                $this->request->requestParams(),
3081
-                $this->_req_action
3082
-            )
3083
-        );
3084
-        // filter after_list_table template arg
3085
-        $this->_template_args['after_list_table'] = apply_filters(
3086
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3087
-            $this->_template_args['after_list_table'],
3088
-            $this->page_slug,
3089
-            $this->request->requestParams(),
3090
-            $this->_req_action
3091
-        );
3092
-        // convert to array and filter again
3093
-        // arrays are easier to inject new items in a specific location,
3094
-        // but would not be backwards compatible, so we have to add a new filter
3095
-        $this->_template_args['after_list_table']   = implode(
3096
-            " \n",
3097
-            (array) apply_filters(
3098
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3099
-                (array) $this->_template_args['after_list_table'],
3100
-                $this->page_slug,
3101
-                $this->request->requestParams(),
3102
-                $this->_req_action
3103
-            )
3104
-        );
3105
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3106
-            $template_path,
3107
-            $this->_template_args,
3108
-            true
3109
-        );
3110
-        // the final template wrapper
3111
-        if ($sidebar) {
3112
-            $this->display_admin_page_with_sidebar();
3113
-        } else {
3114
-            $this->display_admin_page_with_no_sidebar();
3115
-        }
3116
-    }
3117
-
3118
-
3119
-    /**
3120
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3121
-     * html string for the legend.
3122
-     * $items are expected in an array in the following format:
3123
-     * $legend_items = array(
3124
-     *        'item_id' => array(
3125
-     *            'icon' => 'http://url_to_icon_being_described.png',
3126
-     *            'desc' => esc_html__('localized description of item');
3127
-     *        )
3128
-     * );
3129
-     *
3130
-     * @param array $items see above for format of array
3131
-     * @return string html string of legend
3132
-     * @throws DomainException
3133
-     */
3134
-    protected function _display_legend($items)
3135
-    {
3136
-        $this->_template_args['items'] = apply_filters(
3137
-            'FHEE__EE_Admin_Page___display_legend__items',
3138
-            (array) $items,
3139
-            $this
3140
-        );
3141
-        return EEH_Template::display_template(
3142
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3143
-            $this->_template_args,
3144
-            true
3145
-        );
3146
-    }
3147
-
3148
-
3149
-    /**
3150
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3151
-     * The returned json object is created from an array in the following format:
3152
-     * array(
3153
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3154
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3155
-     *  'notices' => '', // - contains any EE_Error formatted notices
3156
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3157
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3158
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3159
-     *  that might be included in here)
3160
-     * )
3161
-     * The json object is populated by whatever is set in the $_template_args property.
3162
-     *
3163
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3164
-     *                                 instead of displayed.
3165
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3166
-     * @return void
3167
-     * @throws EE_Error
3168
-     */
3169
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
3170
-    {
3171
-        // make sure any EE_Error notices have been handled.
3172
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3173
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3174
-        unset($this->_template_args['data']);
3175
-        $json = [
3176
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3177
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3178
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3179
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3180
-            'notices'   => EE_Error::get_notices(),
3181
-            'content'   => isset($this->_template_args['admin_page_content'])
3182
-                ? $this->_template_args['admin_page_content'] : '',
3183
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3184
-            'isEEajax'  => true
3185
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3186
-        ];
3187
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3188
-        if (null === error_get_last() || ! headers_sent()) {
3189
-            header('Content-Type: application/json; charset=UTF-8');
3190
-        }
3191
-        echo wp_json_encode($json);
3192
-        exit();
3193
-    }
3194
-
3195
-
3196
-    /**
3197
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3198
-     *
3199
-     * @return void
3200
-     * @throws EE_Error
3201
-     */
3202
-    public function return_json()
3203
-    {
3204
-        if ($this->request->isAjax()) {
3205
-            $this->_return_json();
3206
-        } else {
3207
-            throw new EE_Error(
3208
-                sprintf(
3209
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3210
-                    __FUNCTION__
3211
-                )
3212
-            );
3213
-        }
3214
-    }
3215
-
3216
-
3217
-    /**
3218
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3219
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3220
-     *
3221
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3222
-     */
3223
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3224
-    {
3225
-        $this->_hook_obj = $hook_obj;
3226
-    }
3227
-
3228
-
3229
-    /**
3230
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3231
-     *
3232
-     * @param boolean $about whether to use the special about page wrapper or default.
3233
-     * @return void
3234
-     * @throws DomainException
3235
-     * @throws EE_Error
3236
-     */
3237
-    public function admin_page_wrapper($about = false)
3238
-    {
3239
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3240
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3241
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3242
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3243
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3244
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3245
-            isset($this->_template_args['before_admin_page_content'])
3246
-                ? $this->_template_args['before_admin_page_content']
3247
-                : ''
3248
-        );
3249
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3250
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3251
-            isset($this->_template_args['after_admin_page_content'])
3252
-                ? $this->_template_args['after_admin_page_content']
3253
-                : ''
3254
-        );
3255
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3256
-        // load settings page wrapper template
3257
-        $template_path = ! $this->request->isAjax()
3258
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3259
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
3260
-        // about page?
3261
-        $template_path = $about
3262
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3263
-            : $template_path;
3264
-        if ($this->request->isAjax()) {
3265
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3266
-                $template_path,
3267
-                $this->_template_args,
3268
-                true
3269
-            );
3270
-            $this->_return_json();
3271
-        } else {
3272
-            EEH_Template::display_template($template_path, $this->_template_args);
3273
-        }
3274
-    }
3275
-
3276
-
3277
-    /**
3278
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3279
-     *
3280
-     * @return string html
3281
-     * @throws EE_Error
3282
-     */
3283
-    protected function _get_main_nav_tabs()
3284
-    {
3285
-        // let's generate the html using the EEH_Tabbed_Content helper.
3286
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3287
-        // (rather than setting in the page_routes array)
3288
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3289
-    }
3290
-
3291
-
3292
-    /**
3293
-     *        sort nav tabs
3294
-     *
3295
-     * @param $a
3296
-     * @param $b
3297
-     * @return int
3298
-     */
3299
-    private function _sort_nav_tabs($a, $b)
3300
-    {
3301
-        if ($a['order'] === $b['order']) {
3302
-            return 0;
3303
-        }
3304
-        return ($a['order'] < $b['order']) ? -1 : 1;
3305
-    }
3306
-
3307
-
3308
-    /**
3309
-     *    generates HTML for the forms used on admin pages
3310
-     *
3311
-     * @param array  $input_vars   - array of input field details
3312
-     * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3313
-     *                             use)
3314
-     * @param bool   $id
3315
-     * @return string
3316
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3317
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3318
-     */
3319
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3320
-    {
3321
-        return $generator === 'string'
3322
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3323
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3324
-    }
3325
-
3326
-
3327
-    /**
3328
-     * generates the "Save" and "Save & Close" buttons for edit forms
3329
-     *
3330
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3331
-     *                                   Close" button.
3332
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3333
-     *                                   'Save', [1] => 'save & close')
3334
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3335
-     *                                   via the "name" value in the button).  We can also use this to just dump
3336
-     *                                   default actions by submitting some other value.
3337
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3338
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3339
-     *                                   close (normal form handling).
3340
-     */
3341
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3342
-    {
3343
-        // make sure $text and $actions are in an array
3344
-        $text          = (array) $text;
3345
-        $actions       = (array) $actions;
3346
-        $referrer_url  = empty($referrer)
3347
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3348
-              . $this->request->getServerParam('REQUEST_URI')
3349
-              . '" />'
3350
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3351
-              . $referrer
3352
-              . '" />';
3353
-        $button_text   = ! empty($text)
3354
-            ? $text
3355
-            : [
3356
-                esc_html__('Save', 'event_espresso'),
3357
-                esc_html__('Save and Close', 'event_espresso'),
3358
-            ];
3359
-        $default_names = ['save', 'save_and_close'];
3360
-        // add in a hidden index for the current page (so save and close redirects properly)
3361
-        $this->_template_args['save_buttons'] = $referrer_url;
3362
-        foreach ($button_text as $key => $button) {
3363
-            $ref                                  = $default_names[ $key ];
3364
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3365
-                                                     . $ref
3366
-                                                     . '" value="'
3367
-                                                     . $button
3368
-                                                     . '" name="'
3369
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3370
-                                                     . '" id="'
3371
-                                                     . $this->_current_view . '_' . $ref
3372
-                                                     . '" />';
3373
-            if (! $both) {
3374
-                break;
3375
-            }
3376
-        }
3377
-    }
3378
-
3379
-
3380
-    /**
3381
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3382
-     *
3383
-     * @param string $route
3384
-     * @param array  $additional_hidden_fields
3385
-     * @see   $this->_set_add_edit_form_tags() for details on params
3386
-     * @since 4.6.0
3387
-     */
3388
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3389
-    {
3390
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3391
-    }
3392
-
3393
-
3394
-    /**
3395
-     * set form open and close tags on add/edit pages.
3396
-     *
3397
-     * @param string $route                    the route you want the form to direct to
3398
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3399
-     * @return void
3400
-     */
3401
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3402
-    {
3403
-        if (empty($route)) {
3404
-            $user_msg = esc_html__(
3405
-                'An error occurred. No action was set for this page\'s form.',
3406
-                'event_espresso'
3407
-            );
3408
-            $dev_msg  = $user_msg . "\n"
3409
-                        . sprintf(
3410
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3411
-                            __FUNCTION__,
3412
-                            __CLASS__
3413
-                        );
3414
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3415
-        }
3416
-        // open form
3417
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3418
-                                                             . $this->_admin_base_url
3419
-                                                             . '" id="'
3420
-                                                             . $route
3421
-                                                             . '_event_form" >';
3422
-        // add nonce
3423
-        $nonce                                             =
3424
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3425
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3426
-        // add REQUIRED form action
3427
-        $hidden_fields = [
3428
-            'action' => ['type' => 'hidden', 'value' => $route],
3429
-        ];
3430
-        // merge arrays
3431
-        $hidden_fields = is_array($additional_hidden_fields)
3432
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3433
-            : $hidden_fields;
3434
-        // generate form fields
3435
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3436
-        // add fields to form
3437
-        foreach ((array) $form_fields as $field_name => $form_field) {
3438
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3439
-        }
3440
-        // close form
3441
-        $this->_template_args['after_admin_page_content'] = '</form>';
3442
-    }
3443
-
3444
-
3445
-    /**
3446
-     * Public Wrapper for _redirect_after_action() method since its
3447
-     * discovered it would be useful for external code to have access.
3448
-     *
3449
-     * @param bool   $success
3450
-     * @param string $what
3451
-     * @param string $action_desc
3452
-     * @param array  $query_args
3453
-     * @param bool   $override_overwrite
3454
-     * @throws EE_Error
3455
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3456
-     * @since 4.5.0
3457
-     */
3458
-    public function redirect_after_action(
3459
-        $success = false,
3460
-        $what = 'item',
3461
-        $action_desc = 'processed',
3462
-        $query_args = [],
3463
-        $override_overwrite = false
3464
-    ) {
3465
-        $this->_redirect_after_action(
3466
-            $success,
3467
-            $what,
3468
-            $action_desc,
3469
-            $query_args,
3470
-            $override_overwrite
3471
-        );
3472
-    }
3473
-
3474
-
3475
-    /**
3476
-     * Helper method for merging existing request data with the returned redirect url.
3477
-     *
3478
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3479
-     * filters are still applied.
3480
-     *
3481
-     * @param array $new_route_data
3482
-     * @return array
3483
-     */
3484
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3485
-    {
3486
-        foreach ($this->request->requestParams() as $ref => $value) {
3487
-            // unset nonces
3488
-            if (strpos($ref, 'nonce') !== false) {
3489
-                $this->request->unSetRequestParam($ref);
3490
-                continue;
3491
-            }
3492
-            // urlencode values.
3493
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3494
-            $this->request->setRequestParam($ref, $value);
3495
-        }
3496
-        return array_merge($this->request->requestParams(), $new_route_data);
3497
-    }
3498
-
3499
-
3500
-    /**
3501
-     *    _redirect_after_action
3502
-     *
3503
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3504
-     * @param string $what               - what the action was performed on
3505
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3506
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3507
-     *                                   action is completed
3508
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3509
-     *                                   override this so that they show.
3510
-     * @return void
3511
-     * @throws EE_Error
3512
-     */
3513
-    protected function _redirect_after_action(
3514
-        $success = 0,
3515
-        $what = 'item',
3516
-        $action_desc = 'processed',
3517
-        $query_args = [],
3518
-        $override_overwrite = false
3519
-    ) {
3520
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3521
-        // class name for actions/filters.
3522
-        $classname = get_class($this);
3523
-        // set redirect url.
3524
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3525
-        // otherwise we go with whatever is set as the _admin_base_url
3526
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3527
-        $notices      = EE_Error::get_notices(false);
3528
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3529
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3530
-            EE_Error::overwrite_success();
3531
-        }
3532
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3533
-            // how many records affected ? more than one record ? or just one ?
3534
-            if ($success > 1) {
3535
-                // set plural msg
3536
-                EE_Error::add_success(
3537
-                    sprintf(
3538
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3539
-                        $what,
3540
-                        $action_desc
3541
-                    ),
3542
-                    __FILE__,
3543
-                    __FUNCTION__,
3544
-                    __LINE__
3545
-                );
3546
-            } elseif ($success === 1) {
3547
-                // set singular msg
3548
-                EE_Error::add_success(
3549
-                    sprintf(
3550
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3551
-                        $what,
3552
-                        $action_desc
3553
-                    ),
3554
-                    __FILE__,
3555
-                    __FUNCTION__,
3556
-                    __LINE__
3557
-                );
3558
-            }
3559
-        }
3560
-        // check that $query_args isn't something crazy
3561
-        if (! is_array($query_args)) {
3562
-            $query_args = [];
3563
-        }
3564
-        /**
3565
-         * Allow injecting actions before the query_args are modified for possible different
3566
-         * redirections on save and close actions
3567
-         *
3568
-         * @param array $query_args       The original query_args array coming into the
3569
-         *                                method.
3570
-         * @since 4.2.0
3571
-         */
3572
-        do_action(
3573
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3574
-            $query_args
3575
-        );
3576
-        // calculate where we're going (if we have a "save and close" button pushed)
3577
-
3578
-        if (
3579
-            $this->request->requestParamIsSet('save_and_close')
3580
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3581
-        ) {
3582
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3583
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3584
-            // regenerate query args array from referrer URL
3585
-            parse_str($parsed_url['query'], $query_args);
3586
-            // correct page and action will be in the query args now
3587
-            $redirect_url = admin_url('admin.php');
3588
-        }
3589
-        // merge any default query_args set in _default_route_query_args property
3590
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3591
-            $args_to_merge = [];
3592
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3593
-                // is there a wp_referer array in our _default_route_query_args property?
3594
-                if ($query_param === 'wp_referer') {
3595
-                    $query_value = (array) $query_value;
3596
-                    foreach ($query_value as $reference => $value) {
3597
-                        if (strpos($reference, 'nonce') !== false) {
3598
-                            continue;
3599
-                        }
3600
-                        // finally we will override any arguments in the referer with
3601
-                        // what might be set on the _default_route_query_args array.
3602
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3603
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3604
-                        } else {
3605
-                            $args_to_merge[ $reference ] = urlencode($value);
3606
-                        }
3607
-                    }
3608
-                    continue;
3609
-                }
3610
-                $args_to_merge[ $query_param ] = $query_value;
3611
-            }
3612
-            // now let's merge these arguments but override with what was specifically sent in to the
3613
-            // redirect.
3614
-            $query_args = array_merge($args_to_merge, $query_args);
3615
-        }
3616
-        $this->_process_notices($query_args);
3617
-        // generate redirect url
3618
-        // if redirecting to anything other than the main page, add a nonce
3619
-        if (isset($query_args['action'])) {
3620
-            // manually generate wp_nonce and merge that with the query vars
3621
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3622
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3623
-        }
3624
-        // we're adding some hooks and filters in here for processing any things just before redirects
3625
-        // (example: an admin page has done an insert or update and we want to run something after that).
3626
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3627
-        $redirect_url = apply_filters(
3628
-            'FHEE_redirect_' . $classname . $this->_req_action,
3629
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3630
-            $query_args
3631
-        );
3632
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3633
-        if ($this->request->isAjax()) {
3634
-            $default_data                    = [
3635
-                'close'        => true,
3636
-                'redirect_url' => $redirect_url,
3637
-                'where'        => 'main',
3638
-                'what'         => 'append',
3639
-            ];
3640
-            $this->_template_args['success'] = $success;
3641
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3642
-                $default_data,
3643
-                $this->_template_args['data']
3644
-            ) : $default_data;
3645
-            $this->_return_json();
3646
-        }
3647
-        wp_safe_redirect($redirect_url);
3648
-        exit();
3649
-    }
3650
-
3651
-
3652
-    /**
3653
-     * process any notices before redirecting (or returning ajax request)
3654
-     * This method sets the $this->_template_args['notices'] attribute;
3655
-     *
3656
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3657
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3658
-     *                                  page_routes haven't been defined yet.
3659
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3660
-     *                                  still save a transient for the notice.
3661
-     * @return void
3662
-     * @throws EE_Error
3663
-     */
3664
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3665
-    {
3666
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3667
-        if ($this->request->isAjax()) {
3668
-            $notices = EE_Error::get_notices(false);
3669
-            if (empty($this->_template_args['success'])) {
3670
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3671
-            }
3672
-            if (empty($this->_template_args['errors'])) {
3673
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3674
-            }
3675
-            if (empty($this->_template_args['attention'])) {
3676
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3677
-            }
3678
-        }
3679
-        $this->_template_args['notices'] = EE_Error::get_notices();
3680
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3681
-        if (! $this->request->isAjax() || $sticky_notices) {
3682
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3683
-            $this->_add_transient(
3684
-                $route,
3685
-                $this->_template_args['notices'],
3686
-                true,
3687
-                $skip_route_verify
3688
-            );
3689
-        }
3690
-    }
3691
-
3692
-
3693
-    /**
3694
-     * get_action_link_or_button
3695
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3696
-     *
3697
-     * @param string $action        use this to indicate which action the url is generated with.
3698
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3699
-     *                              property.
3700
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3701
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3702
-     * @param string $base_url      If this is not provided
3703
-     *                              the _admin_base_url will be used as the default for the button base_url.
3704
-     *                              Otherwise this value will be used.
3705
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3706
-     * @return string
3707
-     * @throws InvalidArgumentException
3708
-     * @throws InvalidInterfaceException
3709
-     * @throws InvalidDataTypeException
3710
-     * @throws EE_Error
3711
-     */
3712
-    public function get_action_link_or_button(
3713
-        $action,
3714
-        $type = 'add',
3715
-        $extra_request = [],
3716
-        $class = 'button-primary',
3717
-        $base_url = '',
3718
-        $exclude_nonce = false
3719
-    ) {
3720
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3721
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3722
-            throw new EE_Error(
3723
-                sprintf(
3724
-                    esc_html__(
3725
-                        'There is no page route for given action for the button.  This action was given: %s',
3726
-                        'event_espresso'
3727
-                    ),
3728
-                    $action
3729
-                )
3730
-            );
3731
-        }
3732
-        if (! isset($this->_labels['buttons'][ $type ])) {
3733
-            throw new EE_Error(
3734
-                sprintf(
3735
-                    esc_html__(
3736
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3737
-                        'event_espresso'
3738
-                    ),
3739
-                    $type
3740
-                )
3741
-            );
3742
-        }
3743
-        // finally check user access for this button.
3744
-        $has_access = $this->check_user_access($action, true);
3745
-        if (! $has_access) {
3746
-            return '';
3747
-        }
3748
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3749
-        $query_args = [
3750
-            'action' => $action,
3751
-        ];
3752
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3753
-        if (! empty($extra_request)) {
3754
-            $query_args = array_merge($extra_request, $query_args);
3755
-        }
3756
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3757
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3758
-    }
3759
-
3760
-
3761
-    /**
3762
-     * _per_page_screen_option
3763
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3764
-     *
3765
-     * @return void
3766
-     * @throws InvalidArgumentException
3767
-     * @throws InvalidInterfaceException
3768
-     * @throws InvalidDataTypeException
3769
-     */
3770
-    protected function _per_page_screen_option()
3771
-    {
3772
-        $option = 'per_page';
3773
-        $args   = [
3774
-            'label'   => apply_filters(
3775
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3776
-                $this->_admin_page_title,
3777
-                $this
3778
-            ),
3779
-            'default' => (int) apply_filters(
3780
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3781
-                20
3782
-            ),
3783
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3784
-        ];
3785
-        // ONLY add the screen option if the user has access to it.
3786
-        if ($this->check_user_access($this->_current_view, true)) {
3787
-            add_screen_option($option, $args);
3788
-        }
3789
-    }
3790
-
3791
-
3792
-    /**
3793
-     * set_per_page_screen_option
3794
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3795
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3796
-     * admin_menu.
3797
-     *
3798
-     * @return void
3799
-     */
3800
-    private function _set_per_page_screen_options()
3801
-    {
3802
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3803
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3804
-            if (! $user = wp_get_current_user()) {
3805
-                return;
3806
-            }
3807
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3808
-            if (! $option) {
3809
-                return;
3810
-            }
3811
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3812
-            $map_option = $option;
3813
-            $option     = str_replace('-', '_', $option);
3814
-            switch ($map_option) {
3815
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3816
-                    $max_value = apply_filters(
3817
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3818
-                        999,
3819
-                        $this->_current_page,
3820
-                        $this->_current_view
3821
-                    );
3822
-                    if ($value < 1) {
3823
-                        return;
3824
-                    }
3825
-                    $value = min($value, $max_value);
3826
-                    break;
3827
-                default:
3828
-                    $value = apply_filters(
3829
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3830
-                        false,
3831
-                        $option,
3832
-                        $value
3833
-                    );
3834
-                    if (false === $value) {
3835
-                        return;
3836
-                    }
3837
-                    break;
3838
-            }
3839
-            update_user_meta($user->ID, $option, $value);
3840
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3841
-            exit;
3842
-        }
3843
-    }
3844
-
3845
-
3846
-    /**
3847
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3848
-     *
3849
-     * @param array $data array that will be assigned to template args.
3850
-     */
3851
-    public function set_template_args($data)
3852
-    {
3853
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3854
-    }
3855
-
3856
-
3857
-    /**
3858
-     * This makes available the WP transient system for temporarily moving data between routes
3859
-     *
3860
-     * @param string $route             the route that should receive the transient
3861
-     * @param array  $data              the data that gets sent
3862
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3863
-     *                                  normal route transient.
3864
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3865
-     *                                  when we are adding a transient before page_routes have been defined.
3866
-     * @return void
3867
-     * @throws EE_Error
3868
-     */
3869
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3870
-    {
3871
-        $user_id = get_current_user_id();
3872
-        if (! $skip_route_verify) {
3873
-            $this->_verify_route($route);
3874
-        }
3875
-        // now let's set the string for what kind of transient we're setting
3876
-        $transient = $notices
3877
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3878
-            : 'rte_tx_' . $route . '_' . $user_id;
3879
-        $data      = $notices ? ['notices' => $data] : $data;
3880
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3881
-        $existing = is_multisite() && is_network_admin()
3882
-            ? get_site_transient($transient)
3883
-            : get_transient($transient);
3884
-        if ($existing) {
3885
-            $data = array_merge((array) $data, (array) $existing);
3886
-        }
3887
-        if (is_multisite() && is_network_admin()) {
3888
-            set_site_transient($transient, $data, 8);
3889
-        } else {
3890
-            set_transient($transient, $data, 8);
3891
-        }
3892
-    }
3893
-
3894
-
3895
-    /**
3896
-     * this retrieves the temporary transient that has been set for moving data between routes.
3897
-     *
3898
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3899
-     * @param string $route
3900
-     * @return mixed data
3901
-     */
3902
-    protected function _get_transient($notices = false, $route = '')
3903
-    {
3904
-        $user_id   = get_current_user_id();
3905
-        $route     = ! $route ? $this->_req_action : $route;
3906
-        $transient = $notices
3907
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3908
-            : 'rte_tx_' . $route . '_' . $user_id;
3909
-        $data      = is_multisite() && is_network_admin()
3910
-            ? get_site_transient($transient)
3911
-            : get_transient($transient);
3912
-        // delete transient after retrieval (just in case it hasn't expired);
3913
-        if (is_multisite() && is_network_admin()) {
3914
-            delete_site_transient($transient);
3915
-        } else {
3916
-            delete_transient($transient);
3917
-        }
3918
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3919
-    }
3920
-
3921
-
3922
-    /**
3923
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3924
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3925
-     * default route callback on the EE_Admin page you want it run.)
3926
-     *
3927
-     * @return void
3928
-     */
3929
-    protected function _transient_garbage_collection()
3930
-    {
3931
-        global $wpdb;
3932
-        // retrieve all existing transients
3933
-        $query =
3934
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3935
-        if ($results = $wpdb->get_results($query)) {
3936
-            foreach ($results as $result) {
3937
-                $transient = str_replace('_transient_', '', $result->option_name);
3938
-                get_transient($transient);
3939
-                if (is_multisite() && is_network_admin()) {
3940
-                    get_site_transient($transient);
3941
-                }
3942
-            }
3943
-        }
3944
-    }
3945
-
3946
-
3947
-    /**
3948
-     * get_view
3949
-     *
3950
-     * @return string content of _view property
3951
-     */
3952
-    public function get_view()
3953
-    {
3954
-        return $this->_view;
3955
-    }
3956
-
3957
-
3958
-    /**
3959
-     * getter for the protected $_views property
3960
-     *
3961
-     * @return array
3962
-     */
3963
-    public function get_views()
3964
-    {
3965
-        return $this->_views;
3966
-    }
3967
-
3968
-
3969
-    /**
3970
-     * get_current_page
3971
-     *
3972
-     * @return string _current_page property value
3973
-     */
3974
-    public function get_current_page()
3975
-    {
3976
-        return $this->_current_page;
3977
-    }
3978
-
3979
-
3980
-    /**
3981
-     * get_current_view
3982
-     *
3983
-     * @return string _current_view property value
3984
-     */
3985
-    public function get_current_view()
3986
-    {
3987
-        return $this->_current_view;
3988
-    }
3989
-
3990
-
3991
-    /**
3992
-     * get_current_screen
3993
-     *
3994
-     * @return object The current WP_Screen object
3995
-     */
3996
-    public function get_current_screen()
3997
-    {
3998
-        return $this->_current_screen;
3999
-    }
4000
-
4001
-
4002
-    /**
4003
-     * get_current_page_view_url
4004
-     *
4005
-     * @return string This returns the url for the current_page_view.
4006
-     */
4007
-    public function get_current_page_view_url()
4008
-    {
4009
-        return $this->_current_page_view_url;
4010
-    }
4011
-
4012
-
4013
-    /**
4014
-     * just returns the Request
4015
-     *
4016
-     * @return RequestInterface
4017
-     */
4018
-    public function get_request()
4019
-    {
4020
-        return $this->request;
4021
-    }
4022
-
4023
-
4024
-    /**
4025
-     * just returns the _req_data property
4026
-     *
4027
-     * @return array
4028
-     */
4029
-    public function get_request_data()
4030
-    {
4031
-        return $this->request->requestParams();
4032
-    }
4033
-
4034
-
4035
-    /**
4036
-     * returns the _req_data protected property
4037
-     *
4038
-     * @return string
4039
-     */
4040
-    public function get_req_action()
4041
-    {
4042
-        return $this->_req_action;
4043
-    }
4044
-
4045
-
4046
-    /**
4047
-     * @return bool  value of $_is_caf property
4048
-     */
4049
-    public function is_caf()
4050
-    {
4051
-        return $this->_is_caf;
4052
-    }
4053
-
4054
-
4055
-    /**
4056
-     * @return mixed
4057
-     */
4058
-    public function default_espresso_metaboxes()
4059
-    {
4060
-        return $this->_default_espresso_metaboxes;
4061
-    }
4062
-
4063
-
4064
-    /**
4065
-     * @return mixed
4066
-     */
4067
-    public function admin_base_url()
4068
-    {
4069
-        return $this->_admin_base_url;
4070
-    }
4071
-
4072
-
4073
-    /**
4074
-     * @return mixed
4075
-     */
4076
-    public function wp_page_slug()
4077
-    {
4078
-        return $this->_wp_page_slug;
4079
-    }
4080
-
4081
-
4082
-    /**
4083
-     * updates  espresso configuration settings
4084
-     *
4085
-     * @param string                   $tab
4086
-     * @param EE_Config_Base|EE_Config $config
4087
-     * @param string                   $file file where error occurred
4088
-     * @param string                   $func function  where error occurred
4089
-     * @param string                   $line line no where error occurred
4090
-     * @return boolean
4091
-     */
4092
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4093
-    {
4094
-        // remove any options that are NOT going to be saved with the config settings.
4095
-        if (isset($config->core->ee_ueip_optin)) {
4096
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4097
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4098
-            update_option('ee_ueip_has_notified', true);
4099
-        }
4100
-        // and save it (note we're also doing the network save here)
4101
-        $net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4102
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4103
-        if ($config_saved && $net_saved) {
4104
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4105
-            return true;
4106
-        }
4107
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4108
-        return false;
4109
-    }
4110
-
4111
-
4112
-    /**
4113
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4114
-     *
4115
-     * @return array
4116
-     */
4117
-    public function get_yes_no_values()
4118
-    {
4119
-        return $this->_yes_no_values;
4120
-    }
4121
-
4122
-
4123
-    protected function _get_dir()
4124
-    {
4125
-        $reflector = new ReflectionClass(get_class($this));
4126
-        return dirname($reflector->getFileName());
4127
-    }
4128
-
4129
-
4130
-    /**
4131
-     * A helper for getting a "next link".
4132
-     *
4133
-     * @param string $url   The url to link to
4134
-     * @param string $class The class to use.
4135
-     * @return string
4136
-     */
4137
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4138
-    {
4139
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4140
-    }
4141
-
4142
-
4143
-    /**
4144
-     * A helper for getting a "previous link".
4145
-     *
4146
-     * @param string $url   The url to link to
4147
-     * @param string $class The class to use.
4148
-     * @return string
4149
-     */
4150
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4151
-    {
4152
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4153
-    }
4154
-
4155
-
4156
-
4157
-
4158
-
4159
-
4160
-
4161
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4162
-
4163
-
4164
-    /**
4165
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4166
-     * 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
4167
-     * _req_data array.
4168
-     *
4169
-     * @return bool success/fail
4170
-     * @throws EE_Error
4171
-     * @throws InvalidArgumentException
4172
-     * @throws ReflectionException
4173
-     * @throws InvalidDataTypeException
4174
-     * @throws InvalidInterfaceException
4175
-     */
4176
-    protected function _process_resend_registration()
4177
-    {
4178
-        $this->_template_args['success'] = EED_Messages::process_resend($this->request->requestParams());
4179
-        do_action(
4180
-            'AHEE__EE_Admin_Page___process_resend_registration',
4181
-            $this->_template_args['success'],
4182
-            $this->request->requestParams()
4183
-        );
4184
-        return $this->_template_args['success'];
4185
-    }
4186
-
4187
-
4188
-    /**
4189
-     * This automatically processes any payment message notifications when manual payment has been applied.
4190
-     *
4191
-     * @param EE_Payment $payment
4192
-     * @return bool success/fail
4193
-     */
4194
-    protected function _process_payment_notification(EE_Payment $payment)
4195
-    {
4196
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4197
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4198
-        $this->_template_args['success'] = apply_filters(
4199
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4200
-            false,
4201
-            $payment
4202
-        );
4203
-        return $this->_template_args['success'];
4204
-    }
2765
+	}
2766
+
2767
+
2768
+	/**
2769
+	 * facade for add_meta_box
2770
+	 *
2771
+	 * @param string  $action        where the metabox get's displayed
2772
+	 * @param string  $title         Title of Metabox (output in metabox header)
2773
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2774
+	 *                               instead of the one created in here.
2775
+	 * @param array   $callback_args an array of args supplied for the metabox
2776
+	 * @param string  $column        what metabox column
2777
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2778
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2779
+	 *                               created but just set our own callback for wp's add_meta_box.
2780
+	 * @throws DomainException
2781
+	 */
2782
+	public function _add_admin_page_meta_box(
2783
+		$action,
2784
+		$title,
2785
+		$callback,
2786
+		$callback_args,
2787
+		$column = 'normal',
2788
+		$priority = 'high',
2789
+		$create_func = true
2790
+	) {
2791
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2792
+		// 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.
2793
+		if (empty($callback_args) && $create_func) {
2794
+			$callback_args = [
2795
+				'template_path' => $this->_template_path,
2796
+				'template_args' => $this->_template_args,
2797
+			];
2798
+		}
2799
+		// 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)
2800
+		$call_back_func = $create_func
2801
+			? function ($post, $metabox) {
2802
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2803
+				echo EEH_Template::display_template(
2804
+					$metabox['args']['template_path'],
2805
+					$metabox['args']['template_args'],
2806
+					true
2807
+				);
2808
+			}
2809
+			: $callback;
2810
+		add_meta_box(
2811
+			str_replace('_', '-', $action) . '-mbox',
2812
+			$title,
2813
+			$call_back_func,
2814
+			$this->_wp_page_slug,
2815
+			$column,
2816
+			$priority,
2817
+			$callback_args
2818
+		);
2819
+	}
2820
+
2821
+
2822
+	/**
2823
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2824
+	 *
2825
+	 * @throws DomainException
2826
+	 * @throws EE_Error
2827
+	 */
2828
+	public function display_admin_page_with_metabox_columns()
2829
+	{
2830
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2831
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2832
+			$this->_column_template_path,
2833
+			$this->_template_args,
2834
+			true
2835
+		);
2836
+		// the final wrapper
2837
+		$this->admin_page_wrapper();
2838
+	}
2839
+
2840
+
2841
+	/**
2842
+	 * generates  HTML wrapper for an admin details page
2843
+	 *
2844
+	 * @return void
2845
+	 * @throws EE_Error
2846
+	 * @throws DomainException
2847
+	 */
2848
+	public function display_admin_page_with_sidebar()
2849
+	{
2850
+		$this->_display_admin_page(true);
2851
+	}
2852
+
2853
+
2854
+	/**
2855
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2856
+	 *
2857
+	 * @return void
2858
+	 * @throws EE_Error
2859
+	 * @throws DomainException
2860
+	 */
2861
+	public function display_admin_page_with_no_sidebar()
2862
+	{
2863
+		$this->_display_admin_page();
2864
+	}
2865
+
2866
+
2867
+	/**
2868
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2869
+	 *
2870
+	 * @return void
2871
+	 * @throws EE_Error
2872
+	 * @throws DomainException
2873
+	 */
2874
+	public function display_about_admin_page()
2875
+	{
2876
+		$this->_display_admin_page(false, true);
2877
+	}
2878
+
2879
+
2880
+	/**
2881
+	 * display_admin_page
2882
+	 * contains the code for actually displaying an admin page
2883
+	 *
2884
+	 * @param boolean $sidebar true with sidebar, false without
2885
+	 * @param boolean $about   use the about_admin_wrapper instead of the default.
2886
+	 * @return void
2887
+	 * @throws DomainException
2888
+	 * @throws EE_Error
2889
+	 */
2890
+	private function _display_admin_page($sidebar = false, $about = false)
2891
+	{
2892
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2893
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2894
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2895
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2896
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2897
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2898
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2899
+			? 'poststuff'
2900
+			: 'espresso-default-admin';
2901
+		$template_path                                     = $sidebar
2902
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2903
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2904
+		if ($this->request->isAjax()) {
2905
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2906
+		}
2907
+		$template_path                                     = ! empty($this->_column_template_path)
2908
+			? $this->_column_template_path : $template_path;
2909
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2910
+			? $this->_template_args['admin_page_content']
2911
+			: '';
2912
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2913
+			? $this->_template_args['before_admin_page_content']
2914
+			: '';
2915
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2916
+			? $this->_template_args['after_admin_page_content']
2917
+			: '';
2918
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2919
+			$template_path,
2920
+			$this->_template_args,
2921
+			true
2922
+		);
2923
+		// the final template wrapper
2924
+		$this->admin_page_wrapper($about);
2925
+	}
2926
+
2927
+
2928
+	/**
2929
+	 * This is used to display caf preview pages.
2930
+	 *
2931
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2932
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2933
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2934
+	 * @return void
2935
+	 * @throws DomainException
2936
+	 * @throws EE_Error
2937
+	 * @throws InvalidArgumentException
2938
+	 * @throws InvalidDataTypeException
2939
+	 * @throws InvalidInterfaceException
2940
+	 * @since 4.3.2
2941
+	 */
2942
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2943
+	{
2944
+		// let's generate a default preview action button if there isn't one already present.
2945
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2946
+			'Upgrade to Event Espresso 4 Right Now',
2947
+			'event_espresso'
2948
+		);
2949
+		$buy_now_url                                   = add_query_arg(
2950
+			[
2951
+				'ee_ver'       => 'ee4',
2952
+				'utm_source'   => 'ee4_plugin_admin',
2953
+				'utm_medium'   => 'link',
2954
+				'utm_campaign' => $utm_campaign_source,
2955
+				'utm_content'  => 'buy_now_button',
2956
+			],
2957
+			'https://eventespresso.com/pricing/'
2958
+		);
2959
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2960
+			? $this->get_action_link_or_button(
2961
+				'',
2962
+				'buy_now',
2963
+				[],
2964
+				'button-primary button-large',
2965
+				esc_url_raw($buy_now_url),
2966
+				true
2967
+			)
2968
+			: $this->_template_args['preview_action_button'];
2969
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2970
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2971
+			$this->_template_args,
2972
+			true
2973
+		);
2974
+		$this->_display_admin_page($display_sidebar);
2975
+	}
2976
+
2977
+
2978
+	/**
2979
+	 * display_admin_list_table_page_with_sidebar
2980
+	 * generates HTML wrapper for an admin_page with list_table
2981
+	 *
2982
+	 * @return void
2983
+	 * @throws EE_Error
2984
+	 * @throws DomainException
2985
+	 */
2986
+	public function display_admin_list_table_page_with_sidebar()
2987
+	{
2988
+		$this->_display_admin_list_table_page(true);
2989
+	}
2990
+
2991
+
2992
+	/**
2993
+	 * display_admin_list_table_page_with_no_sidebar
2994
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2995
+	 *
2996
+	 * @return void
2997
+	 * @throws EE_Error
2998
+	 * @throws DomainException
2999
+	 */
3000
+	public function display_admin_list_table_page_with_no_sidebar()
3001
+	{
3002
+		$this->_display_admin_list_table_page();
3003
+	}
3004
+
3005
+
3006
+	/**
3007
+	 * generates html wrapper for an admin_list_table page
3008
+	 *
3009
+	 * @param boolean $sidebar whether to display with sidebar or not.
3010
+	 * @return void
3011
+	 * @throws DomainException
3012
+	 * @throws EE_Error
3013
+	 */
3014
+	private function _display_admin_list_table_page($sidebar = false)
3015
+	{
3016
+		// setup search attributes
3017
+		$this->_set_search_attributes();
3018
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
3019
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3020
+		$this->_template_args['table_url']        = $this->request->isAjax()
3021
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3022
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
3023
+		$this->_template_args['list_table']       = $this->_list_table_object;
3024
+		$this->_template_args['current_route']    = $this->_req_action;
3025
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3026
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3027
+		if (! empty($ajax_sorting_callback)) {
3028
+			$sortable_list_table_form_fields = wp_nonce_field(
3029
+				$ajax_sorting_callback . '_nonce',
3030
+				$ajax_sorting_callback . '_nonce',
3031
+				false,
3032
+				false
3033
+			);
3034
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3035
+												. $this->page_slug
3036
+												. '" />';
3037
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3038
+												. $ajax_sorting_callback
3039
+												. '" />';
3040
+		} else {
3041
+			$sortable_list_table_form_fields = '';
3042
+		}
3043
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3044
+		$hidden_form_fields                                      =
3045
+			isset($this->_template_args['list_table_hidden_fields'])
3046
+				? $this->_template_args['list_table_hidden_fields']
3047
+				: '';
3048
+		$nonce_ref                                               = $this->_req_action . '_nonce';
3049
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
3050
+																	. $nonce_ref
3051
+																	. '" value="'
3052
+																	. wp_create_nonce($nonce_ref)
3053
+																	. '">';
3054
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3055
+		// display message about search results?
3056
+		$search = $this->request->getRequestParam('s');
3057
+		$this->_template_args['before_list_table'] .= ! empty($search)
3058
+			? '<p class="ee-search-results">' . sprintf(
3059
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3060
+				trim($search, '%')
3061
+			) . '</p>'
3062
+			: '';
3063
+		// filter before_list_table template arg
3064
+		$this->_template_args['before_list_table'] = apply_filters(
3065
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3066
+			$this->_template_args['before_list_table'],
3067
+			$this->page_slug,
3068
+			$this->request->requestParams(),
3069
+			$this->_req_action
3070
+		);
3071
+		// convert to array and filter again
3072
+		// arrays are easier to inject new items in a specific location,
3073
+		// but would not be backwards compatible, so we have to add a new filter
3074
+		$this->_template_args['before_list_table'] = implode(
3075
+			" \n",
3076
+			(array) apply_filters(
3077
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3078
+				(array) $this->_template_args['before_list_table'],
3079
+				$this->page_slug,
3080
+				$this->request->requestParams(),
3081
+				$this->_req_action
3082
+			)
3083
+		);
3084
+		// filter after_list_table template arg
3085
+		$this->_template_args['after_list_table'] = apply_filters(
3086
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3087
+			$this->_template_args['after_list_table'],
3088
+			$this->page_slug,
3089
+			$this->request->requestParams(),
3090
+			$this->_req_action
3091
+		);
3092
+		// convert to array and filter again
3093
+		// arrays are easier to inject new items in a specific location,
3094
+		// but would not be backwards compatible, so we have to add a new filter
3095
+		$this->_template_args['after_list_table']   = implode(
3096
+			" \n",
3097
+			(array) apply_filters(
3098
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3099
+				(array) $this->_template_args['after_list_table'],
3100
+				$this->page_slug,
3101
+				$this->request->requestParams(),
3102
+				$this->_req_action
3103
+			)
3104
+		);
3105
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3106
+			$template_path,
3107
+			$this->_template_args,
3108
+			true
3109
+		);
3110
+		// the final template wrapper
3111
+		if ($sidebar) {
3112
+			$this->display_admin_page_with_sidebar();
3113
+		} else {
3114
+			$this->display_admin_page_with_no_sidebar();
3115
+		}
3116
+	}
3117
+
3118
+
3119
+	/**
3120
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3121
+	 * html string for the legend.
3122
+	 * $items are expected in an array in the following format:
3123
+	 * $legend_items = array(
3124
+	 *        'item_id' => array(
3125
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3126
+	 *            'desc' => esc_html__('localized description of item');
3127
+	 *        )
3128
+	 * );
3129
+	 *
3130
+	 * @param array $items see above for format of array
3131
+	 * @return string html string of legend
3132
+	 * @throws DomainException
3133
+	 */
3134
+	protected function _display_legend($items)
3135
+	{
3136
+		$this->_template_args['items'] = apply_filters(
3137
+			'FHEE__EE_Admin_Page___display_legend__items',
3138
+			(array) $items,
3139
+			$this
3140
+		);
3141
+		return EEH_Template::display_template(
3142
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3143
+			$this->_template_args,
3144
+			true
3145
+		);
3146
+	}
3147
+
3148
+
3149
+	/**
3150
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3151
+	 * The returned json object is created from an array in the following format:
3152
+	 * array(
3153
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3154
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3155
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3156
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3157
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3158
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3159
+	 *  that might be included in here)
3160
+	 * )
3161
+	 * The json object is populated by whatever is set in the $_template_args property.
3162
+	 *
3163
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3164
+	 *                                 instead of displayed.
3165
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3166
+	 * @return void
3167
+	 * @throws EE_Error
3168
+	 */
3169
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
3170
+	{
3171
+		// make sure any EE_Error notices have been handled.
3172
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3173
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3174
+		unset($this->_template_args['data']);
3175
+		$json = [
3176
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3177
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3178
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3179
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3180
+			'notices'   => EE_Error::get_notices(),
3181
+			'content'   => isset($this->_template_args['admin_page_content'])
3182
+				? $this->_template_args['admin_page_content'] : '',
3183
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3184
+			'isEEajax'  => true
3185
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3186
+		];
3187
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3188
+		if (null === error_get_last() || ! headers_sent()) {
3189
+			header('Content-Type: application/json; charset=UTF-8');
3190
+		}
3191
+		echo wp_json_encode($json);
3192
+		exit();
3193
+	}
3194
+
3195
+
3196
+	/**
3197
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3198
+	 *
3199
+	 * @return void
3200
+	 * @throws EE_Error
3201
+	 */
3202
+	public function return_json()
3203
+	{
3204
+		if ($this->request->isAjax()) {
3205
+			$this->_return_json();
3206
+		} else {
3207
+			throw new EE_Error(
3208
+				sprintf(
3209
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3210
+					__FUNCTION__
3211
+				)
3212
+			);
3213
+		}
3214
+	}
3215
+
3216
+
3217
+	/**
3218
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3219
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3220
+	 *
3221
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3222
+	 */
3223
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3224
+	{
3225
+		$this->_hook_obj = $hook_obj;
3226
+	}
3227
+
3228
+
3229
+	/**
3230
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3231
+	 *
3232
+	 * @param boolean $about whether to use the special about page wrapper or default.
3233
+	 * @return void
3234
+	 * @throws DomainException
3235
+	 * @throws EE_Error
3236
+	 */
3237
+	public function admin_page_wrapper($about = false)
3238
+	{
3239
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3240
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3241
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3242
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3243
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3244
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3245
+			isset($this->_template_args['before_admin_page_content'])
3246
+				? $this->_template_args['before_admin_page_content']
3247
+				: ''
3248
+		);
3249
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3250
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3251
+			isset($this->_template_args['after_admin_page_content'])
3252
+				? $this->_template_args['after_admin_page_content']
3253
+				: ''
3254
+		);
3255
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3256
+		// load settings page wrapper template
3257
+		$template_path = ! $this->request->isAjax()
3258
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3259
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
3260
+		// about page?
3261
+		$template_path = $about
3262
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3263
+			: $template_path;
3264
+		if ($this->request->isAjax()) {
3265
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3266
+				$template_path,
3267
+				$this->_template_args,
3268
+				true
3269
+			);
3270
+			$this->_return_json();
3271
+		} else {
3272
+			EEH_Template::display_template($template_path, $this->_template_args);
3273
+		}
3274
+	}
3275
+
3276
+
3277
+	/**
3278
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3279
+	 *
3280
+	 * @return string html
3281
+	 * @throws EE_Error
3282
+	 */
3283
+	protected function _get_main_nav_tabs()
3284
+	{
3285
+		// let's generate the html using the EEH_Tabbed_Content helper.
3286
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3287
+		// (rather than setting in the page_routes array)
3288
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3289
+	}
3290
+
3291
+
3292
+	/**
3293
+	 *        sort nav tabs
3294
+	 *
3295
+	 * @param $a
3296
+	 * @param $b
3297
+	 * @return int
3298
+	 */
3299
+	private function _sort_nav_tabs($a, $b)
3300
+	{
3301
+		if ($a['order'] === $b['order']) {
3302
+			return 0;
3303
+		}
3304
+		return ($a['order'] < $b['order']) ? -1 : 1;
3305
+	}
3306
+
3307
+
3308
+	/**
3309
+	 *    generates HTML for the forms used on admin pages
3310
+	 *
3311
+	 * @param array  $input_vars   - array of input field details
3312
+	 * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3313
+	 *                             use)
3314
+	 * @param bool   $id
3315
+	 * @return string
3316
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3317
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3318
+	 */
3319
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3320
+	{
3321
+		return $generator === 'string'
3322
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3323
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3324
+	}
3325
+
3326
+
3327
+	/**
3328
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3329
+	 *
3330
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3331
+	 *                                   Close" button.
3332
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3333
+	 *                                   'Save', [1] => 'save & close')
3334
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3335
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3336
+	 *                                   default actions by submitting some other value.
3337
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3338
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3339
+	 *                                   close (normal form handling).
3340
+	 */
3341
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3342
+	{
3343
+		// make sure $text and $actions are in an array
3344
+		$text          = (array) $text;
3345
+		$actions       = (array) $actions;
3346
+		$referrer_url  = empty($referrer)
3347
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3348
+			  . $this->request->getServerParam('REQUEST_URI')
3349
+			  . '" />'
3350
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3351
+			  . $referrer
3352
+			  . '" />';
3353
+		$button_text   = ! empty($text)
3354
+			? $text
3355
+			: [
3356
+				esc_html__('Save', 'event_espresso'),
3357
+				esc_html__('Save and Close', 'event_espresso'),
3358
+			];
3359
+		$default_names = ['save', 'save_and_close'];
3360
+		// add in a hidden index for the current page (so save and close redirects properly)
3361
+		$this->_template_args['save_buttons'] = $referrer_url;
3362
+		foreach ($button_text as $key => $button) {
3363
+			$ref                                  = $default_names[ $key ];
3364
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3365
+													 . $ref
3366
+													 . '" value="'
3367
+													 . $button
3368
+													 . '" name="'
3369
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3370
+													 . '" id="'
3371
+													 . $this->_current_view . '_' . $ref
3372
+													 . '" />';
3373
+			if (! $both) {
3374
+				break;
3375
+			}
3376
+		}
3377
+	}
3378
+
3379
+
3380
+	/**
3381
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3382
+	 *
3383
+	 * @param string $route
3384
+	 * @param array  $additional_hidden_fields
3385
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3386
+	 * @since 4.6.0
3387
+	 */
3388
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3389
+	{
3390
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3391
+	}
3392
+
3393
+
3394
+	/**
3395
+	 * set form open and close tags on add/edit pages.
3396
+	 *
3397
+	 * @param string $route                    the route you want the form to direct to
3398
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3399
+	 * @return void
3400
+	 */
3401
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3402
+	{
3403
+		if (empty($route)) {
3404
+			$user_msg = esc_html__(
3405
+				'An error occurred. No action was set for this page\'s form.',
3406
+				'event_espresso'
3407
+			);
3408
+			$dev_msg  = $user_msg . "\n"
3409
+						. sprintf(
3410
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3411
+							__FUNCTION__,
3412
+							__CLASS__
3413
+						);
3414
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3415
+		}
3416
+		// open form
3417
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3418
+															 . $this->_admin_base_url
3419
+															 . '" id="'
3420
+															 . $route
3421
+															 . '_event_form" >';
3422
+		// add nonce
3423
+		$nonce                                             =
3424
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3425
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3426
+		// add REQUIRED form action
3427
+		$hidden_fields = [
3428
+			'action' => ['type' => 'hidden', 'value' => $route],
3429
+		];
3430
+		// merge arrays
3431
+		$hidden_fields = is_array($additional_hidden_fields)
3432
+			? array_merge($hidden_fields, $additional_hidden_fields)
3433
+			: $hidden_fields;
3434
+		// generate form fields
3435
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3436
+		// add fields to form
3437
+		foreach ((array) $form_fields as $field_name => $form_field) {
3438
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3439
+		}
3440
+		// close form
3441
+		$this->_template_args['after_admin_page_content'] = '</form>';
3442
+	}
3443
+
3444
+
3445
+	/**
3446
+	 * Public Wrapper for _redirect_after_action() method since its
3447
+	 * discovered it would be useful for external code to have access.
3448
+	 *
3449
+	 * @param bool   $success
3450
+	 * @param string $what
3451
+	 * @param string $action_desc
3452
+	 * @param array  $query_args
3453
+	 * @param bool   $override_overwrite
3454
+	 * @throws EE_Error
3455
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3456
+	 * @since 4.5.0
3457
+	 */
3458
+	public function redirect_after_action(
3459
+		$success = false,
3460
+		$what = 'item',
3461
+		$action_desc = 'processed',
3462
+		$query_args = [],
3463
+		$override_overwrite = false
3464
+	) {
3465
+		$this->_redirect_after_action(
3466
+			$success,
3467
+			$what,
3468
+			$action_desc,
3469
+			$query_args,
3470
+			$override_overwrite
3471
+		);
3472
+	}
3473
+
3474
+
3475
+	/**
3476
+	 * Helper method for merging existing request data with the returned redirect url.
3477
+	 *
3478
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3479
+	 * filters are still applied.
3480
+	 *
3481
+	 * @param array $new_route_data
3482
+	 * @return array
3483
+	 */
3484
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3485
+	{
3486
+		foreach ($this->request->requestParams() as $ref => $value) {
3487
+			// unset nonces
3488
+			if (strpos($ref, 'nonce') !== false) {
3489
+				$this->request->unSetRequestParam($ref);
3490
+				continue;
3491
+			}
3492
+			// urlencode values.
3493
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3494
+			$this->request->setRequestParam($ref, $value);
3495
+		}
3496
+		return array_merge($this->request->requestParams(), $new_route_data);
3497
+	}
3498
+
3499
+
3500
+	/**
3501
+	 *    _redirect_after_action
3502
+	 *
3503
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3504
+	 * @param string $what               - what the action was performed on
3505
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3506
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3507
+	 *                                   action is completed
3508
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3509
+	 *                                   override this so that they show.
3510
+	 * @return void
3511
+	 * @throws EE_Error
3512
+	 */
3513
+	protected function _redirect_after_action(
3514
+		$success = 0,
3515
+		$what = 'item',
3516
+		$action_desc = 'processed',
3517
+		$query_args = [],
3518
+		$override_overwrite = false
3519
+	) {
3520
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3521
+		// class name for actions/filters.
3522
+		$classname = get_class($this);
3523
+		// set redirect url.
3524
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3525
+		// otherwise we go with whatever is set as the _admin_base_url
3526
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3527
+		$notices      = EE_Error::get_notices(false);
3528
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3529
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3530
+			EE_Error::overwrite_success();
3531
+		}
3532
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3533
+			// how many records affected ? more than one record ? or just one ?
3534
+			if ($success > 1) {
3535
+				// set plural msg
3536
+				EE_Error::add_success(
3537
+					sprintf(
3538
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3539
+						$what,
3540
+						$action_desc
3541
+					),
3542
+					__FILE__,
3543
+					__FUNCTION__,
3544
+					__LINE__
3545
+				);
3546
+			} elseif ($success === 1) {
3547
+				// set singular msg
3548
+				EE_Error::add_success(
3549
+					sprintf(
3550
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3551
+						$what,
3552
+						$action_desc
3553
+					),
3554
+					__FILE__,
3555
+					__FUNCTION__,
3556
+					__LINE__
3557
+				);
3558
+			}
3559
+		}
3560
+		// check that $query_args isn't something crazy
3561
+		if (! is_array($query_args)) {
3562
+			$query_args = [];
3563
+		}
3564
+		/**
3565
+		 * Allow injecting actions before the query_args are modified for possible different
3566
+		 * redirections on save and close actions
3567
+		 *
3568
+		 * @param array $query_args       The original query_args array coming into the
3569
+		 *                                method.
3570
+		 * @since 4.2.0
3571
+		 */
3572
+		do_action(
3573
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3574
+			$query_args
3575
+		);
3576
+		// calculate where we're going (if we have a "save and close" button pushed)
3577
+
3578
+		if (
3579
+			$this->request->requestParamIsSet('save_and_close')
3580
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3581
+		) {
3582
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3583
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3584
+			// regenerate query args array from referrer URL
3585
+			parse_str($parsed_url['query'], $query_args);
3586
+			// correct page and action will be in the query args now
3587
+			$redirect_url = admin_url('admin.php');
3588
+		}
3589
+		// merge any default query_args set in _default_route_query_args property
3590
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3591
+			$args_to_merge = [];
3592
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3593
+				// is there a wp_referer array in our _default_route_query_args property?
3594
+				if ($query_param === 'wp_referer') {
3595
+					$query_value = (array) $query_value;
3596
+					foreach ($query_value as $reference => $value) {
3597
+						if (strpos($reference, 'nonce') !== false) {
3598
+							continue;
3599
+						}
3600
+						// finally we will override any arguments in the referer with
3601
+						// what might be set on the _default_route_query_args array.
3602
+						if (isset($this->_default_route_query_args[ $reference ])) {
3603
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3604
+						} else {
3605
+							$args_to_merge[ $reference ] = urlencode($value);
3606
+						}
3607
+					}
3608
+					continue;
3609
+				}
3610
+				$args_to_merge[ $query_param ] = $query_value;
3611
+			}
3612
+			// now let's merge these arguments but override with what was specifically sent in to the
3613
+			// redirect.
3614
+			$query_args = array_merge($args_to_merge, $query_args);
3615
+		}
3616
+		$this->_process_notices($query_args);
3617
+		// generate redirect url
3618
+		// if redirecting to anything other than the main page, add a nonce
3619
+		if (isset($query_args['action'])) {
3620
+			// manually generate wp_nonce and merge that with the query vars
3621
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3622
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3623
+		}
3624
+		// we're adding some hooks and filters in here for processing any things just before redirects
3625
+		// (example: an admin page has done an insert or update and we want to run something after that).
3626
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3627
+		$redirect_url = apply_filters(
3628
+			'FHEE_redirect_' . $classname . $this->_req_action,
3629
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3630
+			$query_args
3631
+		);
3632
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3633
+		if ($this->request->isAjax()) {
3634
+			$default_data                    = [
3635
+				'close'        => true,
3636
+				'redirect_url' => $redirect_url,
3637
+				'where'        => 'main',
3638
+				'what'         => 'append',
3639
+			];
3640
+			$this->_template_args['success'] = $success;
3641
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3642
+				$default_data,
3643
+				$this->_template_args['data']
3644
+			) : $default_data;
3645
+			$this->_return_json();
3646
+		}
3647
+		wp_safe_redirect($redirect_url);
3648
+		exit();
3649
+	}
3650
+
3651
+
3652
+	/**
3653
+	 * process any notices before redirecting (or returning ajax request)
3654
+	 * This method sets the $this->_template_args['notices'] attribute;
3655
+	 *
3656
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3657
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3658
+	 *                                  page_routes haven't been defined yet.
3659
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3660
+	 *                                  still save a transient for the notice.
3661
+	 * @return void
3662
+	 * @throws EE_Error
3663
+	 */
3664
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3665
+	{
3666
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3667
+		if ($this->request->isAjax()) {
3668
+			$notices = EE_Error::get_notices(false);
3669
+			if (empty($this->_template_args['success'])) {
3670
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3671
+			}
3672
+			if (empty($this->_template_args['errors'])) {
3673
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3674
+			}
3675
+			if (empty($this->_template_args['attention'])) {
3676
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3677
+			}
3678
+		}
3679
+		$this->_template_args['notices'] = EE_Error::get_notices();
3680
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3681
+		if (! $this->request->isAjax() || $sticky_notices) {
3682
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3683
+			$this->_add_transient(
3684
+				$route,
3685
+				$this->_template_args['notices'],
3686
+				true,
3687
+				$skip_route_verify
3688
+			);
3689
+		}
3690
+	}
3691
+
3692
+
3693
+	/**
3694
+	 * get_action_link_or_button
3695
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3696
+	 *
3697
+	 * @param string $action        use this to indicate which action the url is generated with.
3698
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3699
+	 *                              property.
3700
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3701
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3702
+	 * @param string $base_url      If this is not provided
3703
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3704
+	 *                              Otherwise this value will be used.
3705
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3706
+	 * @return string
3707
+	 * @throws InvalidArgumentException
3708
+	 * @throws InvalidInterfaceException
3709
+	 * @throws InvalidDataTypeException
3710
+	 * @throws EE_Error
3711
+	 */
3712
+	public function get_action_link_or_button(
3713
+		$action,
3714
+		$type = 'add',
3715
+		$extra_request = [],
3716
+		$class = 'button-primary',
3717
+		$base_url = '',
3718
+		$exclude_nonce = false
3719
+	) {
3720
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3721
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3722
+			throw new EE_Error(
3723
+				sprintf(
3724
+					esc_html__(
3725
+						'There is no page route for given action for the button.  This action was given: %s',
3726
+						'event_espresso'
3727
+					),
3728
+					$action
3729
+				)
3730
+			);
3731
+		}
3732
+		if (! isset($this->_labels['buttons'][ $type ])) {
3733
+			throw new EE_Error(
3734
+				sprintf(
3735
+					esc_html__(
3736
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3737
+						'event_espresso'
3738
+					),
3739
+					$type
3740
+				)
3741
+			);
3742
+		}
3743
+		// finally check user access for this button.
3744
+		$has_access = $this->check_user_access($action, true);
3745
+		if (! $has_access) {
3746
+			return '';
3747
+		}
3748
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3749
+		$query_args = [
3750
+			'action' => $action,
3751
+		];
3752
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3753
+		if (! empty($extra_request)) {
3754
+			$query_args = array_merge($extra_request, $query_args);
3755
+		}
3756
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3757
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3758
+	}
3759
+
3760
+
3761
+	/**
3762
+	 * _per_page_screen_option
3763
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3764
+	 *
3765
+	 * @return void
3766
+	 * @throws InvalidArgumentException
3767
+	 * @throws InvalidInterfaceException
3768
+	 * @throws InvalidDataTypeException
3769
+	 */
3770
+	protected function _per_page_screen_option()
3771
+	{
3772
+		$option = 'per_page';
3773
+		$args   = [
3774
+			'label'   => apply_filters(
3775
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3776
+				$this->_admin_page_title,
3777
+				$this
3778
+			),
3779
+			'default' => (int) apply_filters(
3780
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3781
+				20
3782
+			),
3783
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3784
+		];
3785
+		// ONLY add the screen option if the user has access to it.
3786
+		if ($this->check_user_access($this->_current_view, true)) {
3787
+			add_screen_option($option, $args);
3788
+		}
3789
+	}
3790
+
3791
+
3792
+	/**
3793
+	 * set_per_page_screen_option
3794
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3795
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3796
+	 * admin_menu.
3797
+	 *
3798
+	 * @return void
3799
+	 */
3800
+	private function _set_per_page_screen_options()
3801
+	{
3802
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3803
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3804
+			if (! $user = wp_get_current_user()) {
3805
+				return;
3806
+			}
3807
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3808
+			if (! $option) {
3809
+				return;
3810
+			}
3811
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3812
+			$map_option = $option;
3813
+			$option     = str_replace('-', '_', $option);
3814
+			switch ($map_option) {
3815
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3816
+					$max_value = apply_filters(
3817
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3818
+						999,
3819
+						$this->_current_page,
3820
+						$this->_current_view
3821
+					);
3822
+					if ($value < 1) {
3823
+						return;
3824
+					}
3825
+					$value = min($value, $max_value);
3826
+					break;
3827
+				default:
3828
+					$value = apply_filters(
3829
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3830
+						false,
3831
+						$option,
3832
+						$value
3833
+					);
3834
+					if (false === $value) {
3835
+						return;
3836
+					}
3837
+					break;
3838
+			}
3839
+			update_user_meta($user->ID, $option, $value);
3840
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3841
+			exit;
3842
+		}
3843
+	}
3844
+
3845
+
3846
+	/**
3847
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3848
+	 *
3849
+	 * @param array $data array that will be assigned to template args.
3850
+	 */
3851
+	public function set_template_args($data)
3852
+	{
3853
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3854
+	}
3855
+
3856
+
3857
+	/**
3858
+	 * This makes available the WP transient system for temporarily moving data between routes
3859
+	 *
3860
+	 * @param string $route             the route that should receive the transient
3861
+	 * @param array  $data              the data that gets sent
3862
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3863
+	 *                                  normal route transient.
3864
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3865
+	 *                                  when we are adding a transient before page_routes have been defined.
3866
+	 * @return void
3867
+	 * @throws EE_Error
3868
+	 */
3869
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3870
+	{
3871
+		$user_id = get_current_user_id();
3872
+		if (! $skip_route_verify) {
3873
+			$this->_verify_route($route);
3874
+		}
3875
+		// now let's set the string for what kind of transient we're setting
3876
+		$transient = $notices
3877
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3878
+			: 'rte_tx_' . $route . '_' . $user_id;
3879
+		$data      = $notices ? ['notices' => $data] : $data;
3880
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3881
+		$existing = is_multisite() && is_network_admin()
3882
+			? get_site_transient($transient)
3883
+			: get_transient($transient);
3884
+		if ($existing) {
3885
+			$data = array_merge((array) $data, (array) $existing);
3886
+		}
3887
+		if (is_multisite() && is_network_admin()) {
3888
+			set_site_transient($transient, $data, 8);
3889
+		} else {
3890
+			set_transient($transient, $data, 8);
3891
+		}
3892
+	}
3893
+
3894
+
3895
+	/**
3896
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3897
+	 *
3898
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3899
+	 * @param string $route
3900
+	 * @return mixed data
3901
+	 */
3902
+	protected function _get_transient($notices = false, $route = '')
3903
+	{
3904
+		$user_id   = get_current_user_id();
3905
+		$route     = ! $route ? $this->_req_action : $route;
3906
+		$transient = $notices
3907
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3908
+			: 'rte_tx_' . $route . '_' . $user_id;
3909
+		$data      = is_multisite() && is_network_admin()
3910
+			? get_site_transient($transient)
3911
+			: get_transient($transient);
3912
+		// delete transient after retrieval (just in case it hasn't expired);
3913
+		if (is_multisite() && is_network_admin()) {
3914
+			delete_site_transient($transient);
3915
+		} else {
3916
+			delete_transient($transient);
3917
+		}
3918
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3919
+	}
3920
+
3921
+
3922
+	/**
3923
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3924
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3925
+	 * default route callback on the EE_Admin page you want it run.)
3926
+	 *
3927
+	 * @return void
3928
+	 */
3929
+	protected function _transient_garbage_collection()
3930
+	{
3931
+		global $wpdb;
3932
+		// retrieve all existing transients
3933
+		$query =
3934
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3935
+		if ($results = $wpdb->get_results($query)) {
3936
+			foreach ($results as $result) {
3937
+				$transient = str_replace('_transient_', '', $result->option_name);
3938
+				get_transient($transient);
3939
+				if (is_multisite() && is_network_admin()) {
3940
+					get_site_transient($transient);
3941
+				}
3942
+			}
3943
+		}
3944
+	}
3945
+
3946
+
3947
+	/**
3948
+	 * get_view
3949
+	 *
3950
+	 * @return string content of _view property
3951
+	 */
3952
+	public function get_view()
3953
+	{
3954
+		return $this->_view;
3955
+	}
3956
+
3957
+
3958
+	/**
3959
+	 * getter for the protected $_views property
3960
+	 *
3961
+	 * @return array
3962
+	 */
3963
+	public function get_views()
3964
+	{
3965
+		return $this->_views;
3966
+	}
3967
+
3968
+
3969
+	/**
3970
+	 * get_current_page
3971
+	 *
3972
+	 * @return string _current_page property value
3973
+	 */
3974
+	public function get_current_page()
3975
+	{
3976
+		return $this->_current_page;
3977
+	}
3978
+
3979
+
3980
+	/**
3981
+	 * get_current_view
3982
+	 *
3983
+	 * @return string _current_view property value
3984
+	 */
3985
+	public function get_current_view()
3986
+	{
3987
+		return $this->_current_view;
3988
+	}
3989
+
3990
+
3991
+	/**
3992
+	 * get_current_screen
3993
+	 *
3994
+	 * @return object The current WP_Screen object
3995
+	 */
3996
+	public function get_current_screen()
3997
+	{
3998
+		return $this->_current_screen;
3999
+	}
4000
+
4001
+
4002
+	/**
4003
+	 * get_current_page_view_url
4004
+	 *
4005
+	 * @return string This returns the url for the current_page_view.
4006
+	 */
4007
+	public function get_current_page_view_url()
4008
+	{
4009
+		return $this->_current_page_view_url;
4010
+	}
4011
+
4012
+
4013
+	/**
4014
+	 * just returns the Request
4015
+	 *
4016
+	 * @return RequestInterface
4017
+	 */
4018
+	public function get_request()
4019
+	{
4020
+		return $this->request;
4021
+	}
4022
+
4023
+
4024
+	/**
4025
+	 * just returns the _req_data property
4026
+	 *
4027
+	 * @return array
4028
+	 */
4029
+	public function get_request_data()
4030
+	{
4031
+		return $this->request->requestParams();
4032
+	}
4033
+
4034
+
4035
+	/**
4036
+	 * returns the _req_data protected property
4037
+	 *
4038
+	 * @return string
4039
+	 */
4040
+	public function get_req_action()
4041
+	{
4042
+		return $this->_req_action;
4043
+	}
4044
+
4045
+
4046
+	/**
4047
+	 * @return bool  value of $_is_caf property
4048
+	 */
4049
+	public function is_caf()
4050
+	{
4051
+		return $this->_is_caf;
4052
+	}
4053
+
4054
+
4055
+	/**
4056
+	 * @return mixed
4057
+	 */
4058
+	public function default_espresso_metaboxes()
4059
+	{
4060
+		return $this->_default_espresso_metaboxes;
4061
+	}
4062
+
4063
+
4064
+	/**
4065
+	 * @return mixed
4066
+	 */
4067
+	public function admin_base_url()
4068
+	{
4069
+		return $this->_admin_base_url;
4070
+	}
4071
+
4072
+
4073
+	/**
4074
+	 * @return mixed
4075
+	 */
4076
+	public function wp_page_slug()
4077
+	{
4078
+		return $this->_wp_page_slug;
4079
+	}
4080
+
4081
+
4082
+	/**
4083
+	 * updates  espresso configuration settings
4084
+	 *
4085
+	 * @param string                   $tab
4086
+	 * @param EE_Config_Base|EE_Config $config
4087
+	 * @param string                   $file file where error occurred
4088
+	 * @param string                   $func function  where error occurred
4089
+	 * @param string                   $line line no where error occurred
4090
+	 * @return boolean
4091
+	 */
4092
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4093
+	{
4094
+		// remove any options that are NOT going to be saved with the config settings.
4095
+		if (isset($config->core->ee_ueip_optin)) {
4096
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4097
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4098
+			update_option('ee_ueip_has_notified', true);
4099
+		}
4100
+		// and save it (note we're also doing the network save here)
4101
+		$net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4102
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4103
+		if ($config_saved && $net_saved) {
4104
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4105
+			return true;
4106
+		}
4107
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4108
+		return false;
4109
+	}
4110
+
4111
+
4112
+	/**
4113
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4114
+	 *
4115
+	 * @return array
4116
+	 */
4117
+	public function get_yes_no_values()
4118
+	{
4119
+		return $this->_yes_no_values;
4120
+	}
4121
+
4122
+
4123
+	protected function _get_dir()
4124
+	{
4125
+		$reflector = new ReflectionClass(get_class($this));
4126
+		return dirname($reflector->getFileName());
4127
+	}
4128
+
4129
+
4130
+	/**
4131
+	 * A helper for getting a "next link".
4132
+	 *
4133
+	 * @param string $url   The url to link to
4134
+	 * @param string $class The class to use.
4135
+	 * @return string
4136
+	 */
4137
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4138
+	{
4139
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4140
+	}
4141
+
4142
+
4143
+	/**
4144
+	 * A helper for getting a "previous link".
4145
+	 *
4146
+	 * @param string $url   The url to link to
4147
+	 * @param string $class The class to use.
4148
+	 * @return string
4149
+	 */
4150
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4151
+	{
4152
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4153
+	}
4154
+
4155
+
4156
+
4157
+
4158
+
4159
+
4160
+
4161
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4162
+
4163
+
4164
+	/**
4165
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4166
+	 * 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
4167
+	 * _req_data array.
4168
+	 *
4169
+	 * @return bool success/fail
4170
+	 * @throws EE_Error
4171
+	 * @throws InvalidArgumentException
4172
+	 * @throws ReflectionException
4173
+	 * @throws InvalidDataTypeException
4174
+	 * @throws InvalidInterfaceException
4175
+	 */
4176
+	protected function _process_resend_registration()
4177
+	{
4178
+		$this->_template_args['success'] = EED_Messages::process_resend($this->request->requestParams());
4179
+		do_action(
4180
+			'AHEE__EE_Admin_Page___process_resend_registration',
4181
+			$this->_template_args['success'],
4182
+			$this->request->requestParams()
4183
+		);
4184
+		return $this->_template_args['success'];
4185
+	}
4186
+
4187
+
4188
+	/**
4189
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4190
+	 *
4191
+	 * @param EE_Payment $payment
4192
+	 * @return bool success/fail
4193
+	 */
4194
+	protected function _process_payment_notification(EE_Payment $payment)
4195
+	{
4196
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4197
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4198
+		$this->_template_args['success'] = apply_filters(
4199
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4200
+			false,
4201
+			$payment
4202
+		);
4203
+		return $this->_template_args['success'];
4204
+	}
4205 4205
 }
Please login to merge, or discard this patch.
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
         $ee_menu_slugs = (array) $ee_menu_slugs;
537 537
         if (
538 538
             ! $this->request->isAjax()
539
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
539
+            && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))
540 540
         ) {
541 541
             return;
542 542
         }
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
             : $req_action;
557 557
 
558 558
         $this->_current_view = $this->_req_action;
559
-        $this->_req_nonce    = $this->_req_action . '_nonce';
559
+        $this->_req_nonce    = $this->_req_action.'_nonce';
560 560
         $this->_define_page_props();
561 561
         $this->_current_page_view_url = add_query_arg(
562 562
             ['page' => $this->_current_page, 'action' => $this->_current_view],
@@ -594,21 +594,21 @@  discard block
 block discarded – undo
594 594
         }
595 595
         // filter routes and page_config so addons can add their stuff. Filtering done per class
596 596
         $this->_page_routes = apply_filters(
597
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
597
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
598 598
             $this->_page_routes,
599 599
             $this
600 600
         );
601 601
         $this->_page_config = apply_filters(
602
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
602
+            'FHEE__'.get_class($this).'__page_setup__page_config',
603 603
             $this->_page_config,
604 604
             $this
605 605
         );
606 606
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
607 607
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
608
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
608
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
609 609
             add_action(
610 610
                 'AHEE__EE_Admin_Page__route_admin_request',
611
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
611
+                [$this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view],
612 612
                 10,
613 613
                 2
614 614
             );
@@ -621,8 +621,8 @@  discard block
 block discarded – undo
621 621
             if ($this->_is_UI_request) {
622 622
                 // admin_init stuff - global, all views for this page class, specific view
623 623
                 add_action('admin_init', [$this, 'admin_init'], 10);
624
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
625
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
624
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
625
+                    add_action('admin_init', [$this, 'admin_init_'.$this->_current_view], 15);
626 626
                 }
627 627
             } else {
628 628
                 // hijack regular WP loading and route admin request immediately
@@ -641,12 +641,12 @@  discard block
 block discarded – undo
641 641
      */
642 642
     private function _do_other_page_hooks()
643 643
     {
644
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
644
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, []);
645 645
         foreach ($registered_pages as $page) {
646 646
             // now let's setup the file name and class that should be present
647 647
             $classname = str_replace('.class.php', '', $page);
648 648
             // autoloaders should take care of loading file
649
-            if (! class_exists($classname)) {
649
+            if ( ! class_exists($classname)) {
650 650
                 $error_msg[] = sprintf(
651 651
                     esc_html__(
652 652
                         'Something went wrong with loading the %s admin hooks page.',
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
                                    ),
664 664
                                    $page,
665 665
                                    '<br />',
666
-                                   '<strong>' . $classname . '</strong>'
666
+                                   '<strong>'.$classname.'</strong>'
667 667
                                );
668 668
                 throw new EE_Error(implode('||', $error_msg));
669 669
             }
@@ -705,13 +705,13 @@  discard block
 block discarded – undo
705 705
         // load admin_notices - global, page class, and view specific
706 706
         add_action('admin_notices', [$this, 'admin_notices_global'], 5);
707 707
         add_action('admin_notices', [$this, 'admin_notices'], 10);
708
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
709
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
708
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
709
+            add_action('admin_notices', [$this, 'admin_notices_'.$this->_current_view], 15);
710 710
         }
711 711
         // load network admin_notices - global, page class, and view specific
712 712
         add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
713
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
714
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
713
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
714
+            add_action('network_admin_notices', [$this, 'network_admin_notices_'.$this->_current_view]);
715 715
         }
716 716
         // this will save any per_page screen options if they are present
717 717
         $this->_set_per_page_screen_options();
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
     protected function _verify_routes()
834 834
     {
835 835
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
836
-        if (! $this->_current_page && ! $this->request->isAjax()) {
836
+        if ( ! $this->_current_page && ! $this->request->isAjax()) {
837 837
             return false;
838 838
         }
839 839
         $this->_route = false;
@@ -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
                           . esc_html__(
850 850
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
851 851
                               'event_espresso'
@@ -854,9 +854,9 @@  discard block
 block discarded – undo
854 854
         }
855 855
         // and that the requested page route exists
856 856
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
857
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
858
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
859
-                ? $this->_page_config[ $this->_req_action ]
857
+            $this->_route        = $this->_page_routes[$this->_req_action];
858
+            $this->_route_config = isset($this->_page_config[$this->_req_action])
859
+                ? $this->_page_config[$this->_req_action]
860 860
                 : [];
861 861
         } else {
862 862
             // user error msg
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
                 $this->_admin_page_title
869 869
             );
870 870
             // developer error msg
871
-            $error_msg .= '||' . $error_msg
871
+            $error_msg .= '||'.$error_msg
872 872
                           . sprintf(
873 873
                               esc_html__(
874 874
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
             throw new EE_Error($error_msg);
880 880
         }
881 881
         // and that a default route exists
882
-        if (! array_key_exists('default', $this->_page_routes)) {
882
+        if ( ! array_key_exists('default', $this->_page_routes)) {
883 883
             // user error msg
884 884
             $error_msg = sprintf(
885 885
                 esc_html__(
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
                 $this->_admin_page_title
890 890
             );
891 891
             // developer error msg
892
-            $error_msg .= '||' . $error_msg
892
+            $error_msg .= '||'.$error_msg
893 893
                           . esc_html__(
894 894
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
895 895
                               'event_espresso'
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
             $this->_admin_page_title
931 931
         );
932 932
         // developer error msg
933
-        $error_msg .= '||' . $error_msg
933
+        $error_msg .= '||'.$error_msg
934 934
                       . sprintf(
935 935
                           esc_html__(
936 936
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
     protected function _verify_nonce($nonce, $nonce_ref)
956 956
     {
957 957
         // verify nonce against expected value
958
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
958
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
959 959
             // these are not the droids you are looking for !!!
960 960
             $msg = sprintf(
961 961
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
                     __CLASS__
973 973
                 );
974 974
             }
975
-            if (! $this->request->isAjax()) {
975
+            if ( ! $this->request->isAjax()) {
976 976
                 wp_die($msg);
977 977
             }
978 978
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -996,7 +996,7 @@  discard block
 block discarded – undo
996 996
      */
997 997
     protected function _route_admin_request()
998 998
     {
999
-        if (! $this->_is_UI_request) {
999
+        if ( ! $this->_is_UI_request) {
1000 1000
             $this->_verify_routes();
1001 1001
         }
1002 1002
         $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
@@ -1016,7 +1016,7 @@  discard block
 block discarded – undo
1016 1016
         $error_msg = '';
1017 1017
         // action right before calling route
1018 1018
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1019
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1019
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1020 1020
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1021 1021
         }
1022 1022
         // right before calling the route, let's clean the _wp_http_referer
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
                 wp_unslash($this->request->getServerParam('REQUEST_URI'))
1028 1028
             )
1029 1029
         );
1030
-        if (! empty($func)) {
1030
+        if ( ! empty($func)) {
1031 1031
             if (is_array($func)) {
1032 1032
                 list($class, $method) = $func;
1033 1033
             } elseif (strpos($func, '::') !== false) {
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
                 $class  = $this;
1037 1037
                 $method = $func;
1038 1038
             }
1039
-            if (! (is_object($class) && $class === $this)) {
1039
+            if ( ! (is_object($class) && $class === $this)) {
1040 1040
                 // send along this admin page object for access by addons.
1041 1041
                 $args['admin_page_object'] = $this;
1042 1042
             }
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
                     $method
1078 1078
                 );
1079 1079
             }
1080
-            if (! empty($error_msg)) {
1080
+            if ( ! empty($error_msg)) {
1081 1081
                 throw new EE_Error($error_msg);
1082 1082
             }
1083 1083
         }
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
                 if (strpos($key, 'nonce') !== false) {
1163 1163
                     continue;
1164 1164
                 }
1165
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1165
+                $args['wp_referer['.$key.']'] = $value;
1166 1166
             }
1167 1167
         }
1168 1168
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1202,8 +1202,8 @@  discard block
 block discarded – undo
1202 1202
     protected function _add_help_tabs()
1203 1203
     {
1204 1204
         $tour_buttons = '';
1205
-        if (isset($this->_page_config[ $this->_req_action ])) {
1206
-            $config = $this->_page_config[ $this->_req_action ];
1205
+        if (isset($this->_page_config[$this->_req_action])) {
1206
+            $config = $this->_page_config[$this->_req_action];
1207 1207
             // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1208 1208
             // is there a help tour for the current route?  if there is let's setup the tour buttons
1209 1209
             // if (isset($this->_help_tour[ $this->_req_action ])) {
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1227 1227
             if (is_array($config) && isset($config['help_sidebar'])) {
1228 1228
                 // check that the callback given is valid
1229
-                if (! method_exists($this, $config['help_sidebar'])) {
1229
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1230 1230
                     throw new EE_Error(
1231 1231
                         sprintf(
1232 1232
                             esc_html__(
@@ -1239,7 +1239,7 @@  discard block
 block discarded – undo
1239 1239
                     );
1240 1240
                 }
1241 1241
                 $content = apply_filters(
1242
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1242
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1243 1243
                     $this->{$config['help_sidebar']}()
1244 1244
                 );
1245 1245
                 $content .= $tour_buttons; // add help tour buttons.
@@ -1247,27 +1247,27 @@  discard block
 block discarded – undo
1247 1247
                 $this->_current_screen->set_help_sidebar($content);
1248 1248
             }
1249 1249
             // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1250
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1250
+            if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1251 1251
                 $this->_current_screen->set_help_sidebar($tour_buttons);
1252 1252
             }
1253 1253
             // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1254
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1254
+            if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1255 1255
                 $_ht['id']      = $this->page_slug;
1256 1256
                 $_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1257 1257
                 $_ht['content'] = '<p>'
1258 1258
                                   . esc_html__(
1259 1259
                                       'The buttons to the right allow you to start/restart any help tours available for this page',
1260 1260
                                       'event_espresso'
1261
-                                  ) . '</p>';
1261
+                                  ).'</p>';
1262 1262
                 $this->_current_screen->add_help_tab($_ht);
1263 1263
             }
1264
-            if (! isset($config['help_tabs'])) {
1264
+            if ( ! isset($config['help_tabs'])) {
1265 1265
                 return;
1266 1266
             } //no help tabs for this route
1267 1267
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1268 1268
                 // we're here so there ARE help tabs!
1269 1269
                 // make sure we've got what we need
1270
-                if (! isset($cfg['title'])) {
1270
+                if ( ! isset($cfg['title'])) {
1271 1271
                     throw new EE_Error(
1272 1272
                         esc_html__(
1273 1273
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
                         )
1276 1276
                     );
1277 1277
                 }
1278
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1278
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1279 1279
                     throw new EE_Error(
1280 1280
                         esc_html__(
1281 1281
                             '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',
@@ -1284,11 +1284,11 @@  discard block
 block discarded – undo
1284 1284
                     );
1285 1285
                 }
1286 1286
                 // first priority goes to content.
1287
-                if (! empty($cfg['content'])) {
1287
+                if ( ! empty($cfg['content'])) {
1288 1288
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1289 1289
                     // second priority goes to filename
1290
-                } elseif (! empty($cfg['filename'])) {
1291
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1290
+                } elseif ( ! empty($cfg['filename'])) {
1291
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1292 1292
                     // 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)
1293 1293
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1294 1294
                                                              . basename($this->_get_dir())
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
                                                              . $cfg['filename']
1297 1297
                                                              . '.help_tab.php' : $file_path;
1298 1298
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1299
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1299
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1300 1300
                         EE_Error::add_error(
1301 1301
                             sprintf(
1302 1302
                                 esc_html__(
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
                     return;
1345 1345
                 }
1346 1346
                 // setup config array for help tab method
1347
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1347
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1348 1348
                 $_ht = [
1349 1349
                     'id'       => $id,
1350 1350
                     'title'    => $cfg['title'],
@@ -1471,8 +1471,8 @@  discard block
 block discarded – undo
1471 1471
             $qtips = (array) $this->_route_config['qtips'];
1472 1472
             // load qtip loader
1473 1473
             $path = [
1474
-                $this->_get_dir() . '/qtips/',
1475
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1474
+                $this->_get_dir().'/qtips/',
1475
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1476 1476
             ];
1477 1477
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1478 1478
         }
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1495 1495
         $i = 0;
1496 1496
         foreach ($this->_page_config as $slug => $config) {
1497
-            if (! is_array($config) || empty($config['nav'])) {
1497
+            if ( ! is_array($config) || empty($config['nav'])) {
1498 1498
                 continue;
1499 1499
             }
1500 1500
             // no nav tab for this config
@@ -1503,12 +1503,12 @@  discard block
 block discarded – undo
1503 1503
                 // nav tab is only to appear when route requested.
1504 1504
                 continue;
1505 1505
             }
1506
-            if (! $this->check_user_access($slug, true)) {
1506
+            if ( ! $this->check_user_access($slug, true)) {
1507 1507
                 // no nav tab because current user does not have access.
1508 1508
                 continue;
1509 1509
             }
1510
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1511
-            $this->_nav_tabs[ $slug ] = [
1510
+            $css_class                = isset($config['css_class']) ? $config['css_class'].' ' : '';
1511
+            $this->_nav_tabs[$slug] = [
1512 1512
                 'url'       => isset($config['nav']['url'])
1513 1513
                     ? $config['nav']['url']
1514 1514
                     : self::add_query_args_and_nonce(
@@ -1520,14 +1520,14 @@  discard block
 block discarded – undo
1520 1520
                     : ucwords(
1521 1521
                         str_replace('_', ' ', $slug)
1522 1522
                     ),
1523
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1523
+                'css_class' => $this->_req_action === $slug ? $css_class.'nav-tab-active' : $css_class,
1524 1524
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1525 1525
             ];
1526 1526
             $i++;
1527 1527
         }
1528 1528
         // if $this->_nav_tabs is empty then lets set the default
1529 1529
         if (empty($this->_nav_tabs)) {
1530
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1530
+            $this->_nav_tabs[$this->_default_nav_tab_name] = [
1531 1531
                 'url'       => $this->_admin_base_url,
1532 1532
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1533 1533
                 'css_class' => 'nav-tab-active',
@@ -1552,10 +1552,10 @@  discard block
 block discarded – undo
1552 1552
             foreach ($this->_route_config['labels'] as $label => $text) {
1553 1553
                 if (is_array($text)) {
1554 1554
                     foreach ($text as $sublabel => $subtext) {
1555
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1555
+                        $this->_labels[$label][$sublabel] = $subtext;
1556 1556
                     }
1557 1557
                 } else {
1558
-                    $this->_labels[ $label ] = $text;
1558
+                    $this->_labels[$label] = $text;
1559 1559
                 }
1560 1560
             }
1561 1561
         }
@@ -1577,12 +1577,12 @@  discard block
 block discarded – undo
1577 1577
     {
1578 1578
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1579 1579
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1580
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1580
+        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1581 1581
                           && is_array(
1582
-                              $this->_page_routes[ $route_to_check ]
1582
+                              $this->_page_routes[$route_to_check]
1583 1583
                           )
1584
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1585
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1584
+                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1585
+            ? $this->_page_routes[$route_to_check]['capability'] : null;
1586 1586
         if (empty($capability) && empty($route_to_check)) {
1587 1587
             $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1588 1588
                 : $this->_route['capability'];
@@ -1707,7 +1707,7 @@  discard block
 block discarded – undo
1707 1707
         //     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1708 1708
         // }
1709 1709
         // current set timezone for timezone js
1710
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1710
+        echo '<span id="current_timezone" class="hidden">'.esc_html(EEH_DTT_Helper::get_timezone()).'</span>';
1711 1711
     }
1712 1712
 
1713 1713
 
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
         // loop through the array and setup content
1742 1742
         foreach ($help_array as $trigger => $help) {
1743 1743
             // make sure the array is setup properly
1744
-            if (! isset($help['title']) || ! isset($help['content'])) {
1744
+            if ( ! isset($help['title']) || ! isset($help['content'])) {
1745 1745
                 throw new EE_Error(
1746 1746
                     esc_html__(
1747 1747
                         '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',
@@ -1755,8 +1755,8 @@  discard block
 block discarded – undo
1755 1755
                 'help_popup_title'   => $help['title'],
1756 1756
                 'help_popup_content' => $help['content'],
1757 1757
             ];
1758
-            $content       .= EEH_Template::display_template(
1759
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1758
+            $content .= EEH_Template::display_template(
1759
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1760 1760
                 $template_args,
1761 1761
                 true
1762 1762
             );
@@ -1778,15 +1778,15 @@  discard block
 block discarded – undo
1778 1778
     private function _get_help_content()
1779 1779
     {
1780 1780
         // what is the method we're looking for?
1781
-        $method_name = '_help_popup_content_' . $this->_req_action;
1781
+        $method_name = '_help_popup_content_'.$this->_req_action;
1782 1782
         // if method doesn't exist let's get out.
1783
-        if (! method_exists($this, $method_name)) {
1783
+        if ( ! method_exists($this, $method_name)) {
1784 1784
             return [];
1785 1785
         }
1786 1786
         // k we're good to go let's retrieve the help array
1787 1787
         $help_array = call_user_func([$this, $method_name]);
1788 1788
         // make sure we've got an array!
1789
-        if (! is_array($help_array)) {
1789
+        if ( ! is_array($help_array)) {
1790 1790
             throw new EE_Error(
1791 1791
                 esc_html__(
1792 1792
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1818,15 +1818,15 @@  discard block
 block discarded – undo
1818 1818
         // 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
1819 1819
         $help_array   = $this->_get_help_content();
1820 1820
         $help_content = '';
1821
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1822
-            $help_array[ $trigger_id ] = [
1821
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1822
+            $help_array[$trigger_id] = [
1823 1823
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1824 1824
                 'content' => esc_html__(
1825 1825
                     '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.)',
1826 1826
                     'event_espresso'
1827 1827
                 ),
1828 1828
             ];
1829
-            $help_content              = $this->_set_help_popup_content($help_array, false);
1829
+            $help_content = $this->_set_help_popup_content($help_array, false);
1830 1830
         }
1831 1831
         // let's setup the trigger
1832 1832
         $content = '<a class="ee-dialog" href="?height='
@@ -1894,15 +1894,15 @@  discard block
 block discarded – undo
1894 1894
         // register all styles
1895 1895
         wp_register_style(
1896 1896
             'espresso-ui-theme',
1897
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1897
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1898 1898
             [],
1899 1899
             EVENT_ESPRESSO_VERSION
1900 1900
         );
1901
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1901
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1902 1902
         // helpers styles
1903 1903
         wp_register_style(
1904 1904
             'ee-text-links',
1905
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1905
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css',
1906 1906
             [],
1907 1907
             EVENT_ESPRESSO_VERSION
1908 1908
         );
@@ -1910,21 +1910,21 @@  discard block
 block discarded – undo
1910 1910
         // register all scripts
1911 1911
         wp_register_script(
1912 1912
             'ee-dialog',
1913
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1913
+            EE_ADMIN_URL.'assets/ee-dialog-helper.js',
1914 1914
             ['jquery', 'jquery-ui-draggable'],
1915 1915
             EVENT_ESPRESSO_VERSION,
1916 1916
             true
1917 1917
         );
1918 1918
         wp_register_script(
1919 1919
             'ee_admin_js',
1920
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1920
+            EE_ADMIN_URL.'assets/ee-admin-page.js',
1921 1921
             ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1922 1922
             EVENT_ESPRESSO_VERSION,
1923 1923
             true
1924 1924
         );
1925 1925
         wp_register_script(
1926 1926
             'jquery-ui-timepicker-addon',
1927
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1927
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js',
1928 1928
             ['jquery-ui-datepicker', 'jquery-ui-slider'],
1929 1929
             EVENT_ESPRESSO_VERSION,
1930 1930
             true
@@ -1936,7 +1936,7 @@  discard block
 block discarded – undo
1936 1936
         // script for sorting tables
1937 1937
         wp_register_script(
1938 1938
             'espresso_ajax_table_sorting',
1939
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1939
+            EE_ADMIN_URL.'assets/espresso_ajax_table_sorting.js',
1940 1940
             ['ee_admin_js', 'jquery-ui-sortable'],
1941 1941
             EVENT_ESPRESSO_VERSION,
1942 1942
             true
@@ -1944,7 +1944,7 @@  discard block
 block discarded – undo
1944 1944
         // script for parsing uri's
1945 1945
         wp_register_script(
1946 1946
             'ee-parse-uri',
1947
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1947
+            EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js',
1948 1948
             [],
1949 1949
             EVENT_ESPRESSO_VERSION,
1950 1950
             true
@@ -1952,7 +1952,7 @@  discard block
 block discarded – undo
1952 1952
         // and parsing associative serialized form elements
1953 1953
         wp_register_script(
1954 1954
             'ee-serialize-full-array',
1955
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1955
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js',
1956 1956
             ['jquery'],
1957 1957
             EVENT_ESPRESSO_VERSION,
1958 1958
             true
@@ -1960,28 +1960,28 @@  discard block
 block discarded – undo
1960 1960
         // helpers scripts
1961 1961
         wp_register_script(
1962 1962
             'ee-text-links',
1963
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1963
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js',
1964 1964
             ['jquery'],
1965 1965
             EVENT_ESPRESSO_VERSION,
1966 1966
             true
1967 1967
         );
1968 1968
         wp_register_script(
1969 1969
             'ee-moment-core',
1970
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1970
+            EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js',
1971 1971
             [],
1972 1972
             EVENT_ESPRESSO_VERSION,
1973 1973
             true
1974 1974
         );
1975 1975
         wp_register_script(
1976 1976
             'ee-moment',
1977
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1977
+            EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js',
1978 1978
             ['ee-moment-core'],
1979 1979
             EVENT_ESPRESSO_VERSION,
1980 1980
             true
1981 1981
         );
1982 1982
         wp_register_script(
1983 1983
             'ee-datepicker',
1984
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1984
+            EE_ADMIN_URL.'assets/ee-datepicker.js',
1985 1985
             ['jquery-ui-timepicker-addon', 'ee-moment'],
1986 1986
             EVENT_ESPRESSO_VERSION,
1987 1987
             true
@@ -2042,7 +2042,7 @@  discard block
 block discarded – undo
2042 2042
 
2043 2043
         add_filter(
2044 2044
             'admin_body_class',
2045
-            function ($classes) {
2045
+            function($classes) {
2046 2046
                 if (strpos($classes, 'espresso-admin') === false) {
2047 2047
                     $classes .= ' espresso-admin';
2048 2048
                 }
@@ -2130,12 +2130,12 @@  discard block
 block discarded – undo
2130 2130
     protected function _set_list_table()
2131 2131
     {
2132 2132
         // first is this a list_table view?
2133
-        if (! isset($this->_route_config['list_table'])) {
2133
+        if ( ! isset($this->_route_config['list_table'])) {
2134 2134
             return;
2135 2135
         } //not a list_table view so get out.
2136 2136
         // list table functions are per view specific (because some admin pages might have more than one list table!)
2137
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2138
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2137
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
2138
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2139 2139
             // user error msg
2140 2140
             $error_msg = esc_html__(
2141 2141
                 'An error occurred. The requested list table views could not be found.',
@@ -2155,10 +2155,10 @@  discard block
 block discarded – undo
2155 2155
         }
2156 2156
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2157 2157
         $this->_views = apply_filters(
2158
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2158
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
2159 2159
             $this->_views
2160 2160
         );
2161
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2161
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
2162 2162
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2163 2163
         $this->_set_list_table_view();
2164 2164
         $this->_set_list_table_object();
@@ -2193,7 +2193,7 @@  discard block
 block discarded – undo
2193 2193
     protected function _set_list_table_object()
2194 2194
     {
2195 2195
         if (isset($this->_route_config['list_table'])) {
2196
-            if (! class_exists($this->_route_config['list_table'])) {
2196
+            if ( ! class_exists($this->_route_config['list_table'])) {
2197 2197
                 throw new EE_Error(
2198 2198
                     sprintf(
2199 2199
                         esc_html__(
@@ -2231,15 +2231,15 @@  discard block
 block discarded – undo
2231 2231
         foreach ($this->_views as $key => $view) {
2232 2232
             $query_args = [];
2233 2233
             // check for current view
2234
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2234
+            $this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2235 2235
             $query_args['action']                        = $this->_req_action;
2236
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2236
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2237 2237
             $query_args['status']                        = $view['slug'];
2238 2238
             // merge any other arguments sent in.
2239
-            if (isset($extra_query_args[ $view['slug'] ])) {
2240
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2239
+            if (isset($extra_query_args[$view['slug']])) {
2240
+                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2241 2241
             }
2242
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2242
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2243 2243
         }
2244 2244
         return $this->_views;
2245 2245
     }
@@ -2270,14 +2270,14 @@  discard block
 block discarded – undo
2270 2270
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2271 2271
         foreach ($values as $value) {
2272 2272
             if ($value < $max_entries) {
2273
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2273
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2274 2274
                 $entries_per_page_dropdown .= '
2275
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2275
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2276 2276
             }
2277 2277
         }
2278
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2278
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2279 2279
         $entries_per_page_dropdown .= '
2280
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2280
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2281 2281
         $entries_per_page_dropdown .= '
2282 2282
 					</select>
2283 2283
 					entries
@@ -2301,7 +2301,7 @@  discard block
 block discarded – undo
2301 2301
             empty($this->_search_btn_label) ? $this->page_label
2302 2302
                 : $this->_search_btn_label
2303 2303
         );
2304
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2304
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2305 2305
     }
2306 2306
 
2307 2307
 
@@ -2389,7 +2389,7 @@  discard block
 block discarded – undo
2389 2389
             $total_columns                                       = ! empty($screen_columns)
2390 2390
                 ? $screen_columns
2391 2391
                 : $this->_route_config['columns'][1];
2392
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2392
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2393 2393
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2394 2394
             $this->_template_args['screen']                      = $this->_current_screen;
2395 2395
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2434,7 +2434,7 @@  discard block
 block discarded – undo
2434 2434
      */
2435 2435
     protected function _espresso_ratings_request()
2436 2436
     {
2437
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2437
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2438 2438
             return;
2439 2439
         }
2440 2440
         $ratings_box_title = apply_filters(
@@ -2462,7 +2462,7 @@  discard block
 block discarded – undo
2462 2462
     public function espresso_ratings_request()
2463 2463
     {
2464 2464
         EEH_Template::display_template(
2465
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2465
+            EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php',
2466 2466
             []
2467 2467
         );
2468 2468
     }
@@ -2470,22 +2470,22 @@  discard block
 block discarded – undo
2470 2470
 
2471 2471
     public static function cached_rss_display($rss_id, $url)
2472 2472
     {
2473
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2473
+        $loading = '<p class="widget-loading hide-if-no-js">'
2474 2474
                      . esc_html__('Loading&#8230;', 'event_espresso')
2475 2475
                      . '</p><p class="hide-if-js">'
2476 2476
                      . esc_html__('This widget requires JavaScript.', 'event_espresso')
2477 2477
                      . '</p>';
2478
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2479
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2480
-        $post      = '</div>' . "\n";
2481
-        $cache_key = 'ee_rss_' . md5($rss_id);
2478
+        $pre       = '<div class="espresso-rss-display">'."\n\t";
2479
+        $pre .= '<span id="'.esc_attr($rss_id).'_url" class="hidden">'.esc_url_raw($url).'</span>';
2480
+        $post      = '</div>'."\n";
2481
+        $cache_key = 'ee_rss_'.md5($rss_id);
2482 2482
         $output    = get_transient($cache_key);
2483 2483
         if ($output !== false) {
2484
-            echo $pre . $output . $post; // already escaped
2484
+            echo $pre.$output.$post; // already escaped
2485 2485
             return true;
2486 2486
         }
2487
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2488
-            echo $pre . $loading . $post; // already escaped
2487
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2488
+            echo $pre.$loading.$post; // already escaped
2489 2489
             return false;
2490 2490
         }
2491 2491
         ob_start();
@@ -2552,19 +2552,19 @@  discard block
 block discarded – undo
2552 2552
     public function espresso_sponsors_post_box()
2553 2553
     {
2554 2554
         EEH_Template::display_template(
2555
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2555
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2556 2556
         );
2557 2557
     }
2558 2558
 
2559 2559
 
2560 2560
     private function _publish_post_box()
2561 2561
     {
2562
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2562
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2563 2563
         // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2564 2564
         // then we'll use that for the metabox label.
2565 2565
         // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2566
-        if (! empty($this->_labels['publishbox'])) {
2567
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2566
+        if ( ! empty($this->_labels['publishbox'])) {
2567
+            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2568 2568
                 : $this->_labels['publishbox'];
2569 2569
         } else {
2570 2570
             $box_label = esc_html__('Publish', 'event_espresso');
@@ -2593,7 +2593,7 @@  discard block
 block discarded – undo
2593 2593
             ? $this->_template_args['publish_box_extra_content']
2594 2594
             : '';
2595 2595
         echo EEH_Template::display_template(
2596
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2596
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2597 2597
             $this->_template_args,
2598 2598
             true
2599 2599
         );
@@ -2685,18 +2685,18 @@  discard block
 block discarded – undo
2685 2685
             );
2686 2686
         }
2687 2687
         $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2688
-        if (! empty($name) && ! empty($id)) {
2689
-            $hidden_field_arr[ $name ] = [
2688
+        if ( ! empty($name) && ! empty($id)) {
2689
+            $hidden_field_arr[$name] = [
2690 2690
                 'type'  => 'hidden',
2691 2691
                 'value' => $id,
2692 2692
             ];
2693
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2693
+            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2694 2694
         } else {
2695 2695
             $hf = '';
2696 2696
         }
2697 2697
         // add hidden field
2698 2698
         $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2699
-            ? $hf[ $name ]['field']
2699
+            ? $hf[$name]['field']
2700 2700
             : $hf;
2701 2701
     }
2702 2702
 
@@ -2798,7 +2798,7 @@  discard block
 block discarded – undo
2798 2798
         }
2799 2799
         // 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)
2800 2800
         $call_back_func = $create_func
2801
-            ? function ($post, $metabox) {
2801
+            ? function($post, $metabox) {
2802 2802
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2803 2803
                 echo EEH_Template::display_template(
2804 2804
                     $metabox['args']['template_path'],
@@ -2808,7 +2808,7 @@  discard block
 block discarded – undo
2808 2808
             }
2809 2809
             : $callback;
2810 2810
         add_meta_box(
2811
-            str_replace('_', '-', $action) . '-mbox',
2811
+            str_replace('_', '-', $action).'-mbox',
2812 2812
             $title,
2813 2813
             $call_back_func,
2814 2814
             $this->_wp_page_slug,
@@ -2900,9 +2900,9 @@  discard block
 block discarded – undo
2900 2900
             : 'espresso-default-admin';
2901 2901
         $template_path                                     = $sidebar
2902 2902
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2903
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2903
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2904 2904
         if ($this->request->isAjax()) {
2905
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2905
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2906 2906
         }
2907 2907
         $template_path                                     = ! empty($this->_column_template_path)
2908 2908
             ? $this->_column_template_path : $template_path;
@@ -2942,11 +2942,11 @@  discard block
 block discarded – undo
2942 2942
     public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2943 2943
     {
2944 2944
         // let's generate a default preview action button if there isn't one already present.
2945
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2945
+        $this->_labels['buttons']['buy_now'] = esc_html__(
2946 2946
             'Upgrade to Event Espresso 4 Right Now',
2947 2947
             'event_espresso'
2948 2948
         );
2949
-        $buy_now_url                                   = add_query_arg(
2949
+        $buy_now_url = add_query_arg(
2950 2950
             [
2951 2951
                 'ee_ver'       => 'ee4',
2952 2952
                 'utm_source'   => 'ee4_plugin_admin',
@@ -2966,8 +2966,8 @@  discard block
 block discarded – undo
2966 2966
                 true
2967 2967
             )
2968 2968
             : $this->_template_args['preview_action_button'];
2969
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2970
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2969
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2970
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2971 2971
             $this->_template_args,
2972 2972
             true
2973 2973
         );
@@ -3016,7 +3016,7 @@  discard block
 block discarded – undo
3016 3016
         // setup search attributes
3017 3017
         $this->_set_search_attributes();
3018 3018
         $this->_template_args['current_page']     = $this->_wp_page_slug;
3019
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3019
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
3020 3020
         $this->_template_args['table_url']        = $this->request->isAjax()
3021 3021
             ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3022 3022
             : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
@@ -3024,10 +3024,10 @@  discard block
 block discarded – undo
3024 3024
         $this->_template_args['current_route']    = $this->_req_action;
3025 3025
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3026 3026
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3027
-        if (! empty($ajax_sorting_callback)) {
3027
+        if ( ! empty($ajax_sorting_callback)) {
3028 3028
             $sortable_list_table_form_fields = wp_nonce_field(
3029
-                $ajax_sorting_callback . '_nonce',
3030
-                $ajax_sorting_callback . '_nonce',
3029
+                $ajax_sorting_callback.'_nonce',
3030
+                $ajax_sorting_callback.'_nonce',
3031 3031
                 false,
3032 3032
                 false
3033 3033
             );
@@ -3045,20 +3045,20 @@  discard block
 block discarded – undo
3045 3045
             isset($this->_template_args['list_table_hidden_fields'])
3046 3046
                 ? $this->_template_args['list_table_hidden_fields']
3047 3047
                 : '';
3048
-        $nonce_ref                                               = $this->_req_action . '_nonce';
3049
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
3048
+        $nonce_ref = $this->_req_action.'_nonce';
3049
+        $hidden_form_fields .= '<input type="hidden" name="'
3050 3050
                                                                     . $nonce_ref
3051 3051
                                                                     . '" value="'
3052 3052
                                                                     . wp_create_nonce($nonce_ref)
3053 3053
                                                                     . '">';
3054
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3054
+        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3055 3055
         // display message about search results?
3056 3056
         $search = $this->request->getRequestParam('s');
3057 3057
         $this->_template_args['before_list_table'] .= ! empty($search)
3058
-            ? '<p class="ee-search-results">' . sprintf(
3058
+            ? '<p class="ee-search-results">'.sprintf(
3059 3059
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3060 3060
                 trim($search, '%')
3061
-            ) . '</p>'
3061
+            ).'</p>'
3062 3062
             : '';
3063 3063
         // filter before_list_table template arg
3064 3064
         $this->_template_args['before_list_table'] = apply_filters(
@@ -3092,7 +3092,7 @@  discard block
 block discarded – undo
3092 3092
         // convert to array and filter again
3093 3093
         // arrays are easier to inject new items in a specific location,
3094 3094
         // but would not be backwards compatible, so we have to add a new filter
3095
-        $this->_template_args['after_list_table']   = implode(
3095
+        $this->_template_args['after_list_table'] = implode(
3096 3096
             " \n",
3097 3097
             (array) apply_filters(
3098 3098
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
@@ -3139,7 +3139,7 @@  discard block
 block discarded – undo
3139 3139
             $this
3140 3140
         );
3141 3141
         return EEH_Template::display_template(
3142
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3142
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
3143 3143
             $this->_template_args,
3144 3144
             true
3145 3145
         );
@@ -3246,17 +3246,17 @@  discard block
 block discarded – undo
3246 3246
                 ? $this->_template_args['before_admin_page_content']
3247 3247
                 : ''
3248 3248
         );
3249
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3249
+        $this->_template_args['after_admin_page_content'] = apply_filters(
3250 3250
             "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3251 3251
             isset($this->_template_args['after_admin_page_content'])
3252 3252
                 ? $this->_template_args['after_admin_page_content']
3253 3253
                 : ''
3254 3254
         );
3255
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3255
+        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3256 3256
         // load settings page wrapper template
3257 3257
         $template_path = ! $this->request->isAjax()
3258 3258
             ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3259
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
3259
+            : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php';
3260 3260
         // about page?
3261 3261
         $template_path = $about
3262 3262
             ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
@@ -3350,7 +3350,7 @@  discard block
 block discarded – undo
3350 3350
             : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3351 3351
               . $referrer
3352 3352
               . '" />';
3353
-        $button_text   = ! empty($text)
3353
+        $button_text = ! empty($text)
3354 3354
             ? $text
3355 3355
             : [
3356 3356
                 esc_html__('Save', 'event_espresso'),
@@ -3360,17 +3360,17 @@  discard block
 block discarded – undo
3360 3360
         // add in a hidden index for the current page (so save and close redirects properly)
3361 3361
         $this->_template_args['save_buttons'] = $referrer_url;
3362 3362
         foreach ($button_text as $key => $button) {
3363
-            $ref                                  = $default_names[ $key ];
3363
+            $ref = $default_names[$key];
3364 3364
             $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3365 3365
                                                      . $ref
3366 3366
                                                      . '" value="'
3367 3367
                                                      . $button
3368 3368
                                                      . '" name="'
3369
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3369
+                                                     . ( ! empty($actions) ? $actions[$key] : $ref)
3370 3370
                                                      . '" id="'
3371
-                                                     . $this->_current_view . '_' . $ref
3371
+                                                     . $this->_current_view.'_'.$ref
3372 3372
                                                      . '" />';
3373
-            if (! $both) {
3373
+            if ( ! $both) {
3374 3374
                 break;
3375 3375
             }
3376 3376
         }
@@ -3405,13 +3405,13 @@  discard block
 block discarded – undo
3405 3405
                 'An error occurred. No action was set for this page\'s form.',
3406 3406
                 'event_espresso'
3407 3407
             );
3408
-            $dev_msg  = $user_msg . "\n"
3408
+            $dev_msg = $user_msg."\n"
3409 3409
                         . sprintf(
3410 3410
                             esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3411 3411
                             __FUNCTION__,
3412 3412
                             __CLASS__
3413 3413
                         );
3414
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3414
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3415 3415
         }
3416 3416
         // open form
3417 3417
         $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
@@ -3420,9 +3420,9 @@  discard block
 block discarded – undo
3420 3420
                                                              . $route
3421 3421
                                                              . '_event_form" >';
3422 3422
         // add nonce
3423
-        $nonce                                             =
3424
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3425
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3423
+        $nonce =
3424
+            wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3425
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3426 3426
         // add REQUIRED form action
3427 3427
         $hidden_fields = [
3428 3428
             'action' => ['type' => 'hidden', 'value' => $route],
@@ -3435,7 +3435,7 @@  discard block
 block discarded – undo
3435 3435
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3436 3436
         // add fields to form
3437 3437
         foreach ((array) $form_fields as $field_name => $form_field) {
3438
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3438
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3439 3439
         }
3440 3440
         // close form
3441 3441
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3526,10 +3526,10 @@  discard block
 block discarded – undo
3526 3526
         $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3527 3527
         $notices      = EE_Error::get_notices(false);
3528 3528
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3529
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3529
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3530 3530
             EE_Error::overwrite_success();
3531 3531
         }
3532
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3532
+        if ( ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3533 3533
             // how many records affected ? more than one record ? or just one ?
3534 3534
             if ($success > 1) {
3535 3535
                 // set plural msg
@@ -3558,7 +3558,7 @@  discard block
 block discarded – undo
3558 3558
             }
3559 3559
         }
3560 3560
         // check that $query_args isn't something crazy
3561
-        if (! is_array($query_args)) {
3561
+        if ( ! is_array($query_args)) {
3562 3562
             $query_args = [];
3563 3563
         }
3564 3564
         /**
@@ -3587,7 +3587,7 @@  discard block
 block discarded – undo
3587 3587
             $redirect_url = admin_url('admin.php');
3588 3588
         }
3589 3589
         // merge any default query_args set in _default_route_query_args property
3590
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3590
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3591 3591
             $args_to_merge = [];
3592 3592
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3593 3593
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3599,15 +3599,15 @@  discard block
 block discarded – undo
3599 3599
                         }
3600 3600
                         // finally we will override any arguments in the referer with
3601 3601
                         // what might be set on the _default_route_query_args array.
3602
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3603
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3602
+                        if (isset($this->_default_route_query_args[$reference])) {
3603
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3604 3604
                         } else {
3605
-                            $args_to_merge[ $reference ] = urlencode($value);
3605
+                            $args_to_merge[$reference] = urlencode($value);
3606 3606
                         }
3607 3607
                     }
3608 3608
                     continue;
3609 3609
                 }
3610
-                $args_to_merge[ $query_param ] = $query_value;
3610
+                $args_to_merge[$query_param] = $query_value;
3611 3611
             }
3612 3612
             // now let's merge these arguments but override with what was specifically sent in to the
3613 3613
             // redirect.
@@ -3619,19 +3619,19 @@  discard block
 block discarded – undo
3619 3619
         if (isset($query_args['action'])) {
3620 3620
             // manually generate wp_nonce and merge that with the query vars
3621 3621
             // becuz the wp_nonce_url function wrecks havoc on some vars
3622
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3622
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3623 3623
         }
3624 3624
         // we're adding some hooks and filters in here for processing any things just before redirects
3625 3625
         // (example: an admin page has done an insert or update and we want to run something after that).
3626
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3626
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3627 3627
         $redirect_url = apply_filters(
3628
-            'FHEE_redirect_' . $classname . $this->_req_action,
3628
+            'FHEE_redirect_'.$classname.$this->_req_action,
3629 3629
             self::add_query_args_and_nonce($query_args, $redirect_url),
3630 3630
             $query_args
3631 3631
         );
3632 3632
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3633 3633
         if ($this->request->isAjax()) {
3634
-            $default_data                    = [
3634
+            $default_data = [
3635 3635
                 'close'        => true,
3636 3636
                 'redirect_url' => $redirect_url,
3637 3637
                 'where'        => 'main',
@@ -3678,7 +3678,7 @@  discard block
 block discarded – undo
3678 3678
         }
3679 3679
         $this->_template_args['notices'] = EE_Error::get_notices();
3680 3680
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3681
-        if (! $this->request->isAjax() || $sticky_notices) {
3681
+        if ( ! $this->request->isAjax() || $sticky_notices) {
3682 3682
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3683 3683
             $this->_add_transient(
3684 3684
                 $route,
@@ -3718,7 +3718,7 @@  discard block
 block discarded – undo
3718 3718
         $exclude_nonce = false
3719 3719
     ) {
3720 3720
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3721
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3721
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3722 3722
             throw new EE_Error(
3723 3723
                 sprintf(
3724 3724
                     esc_html__(
@@ -3729,7 +3729,7 @@  discard block
 block discarded – undo
3729 3729
                 )
3730 3730
             );
3731 3731
         }
3732
-        if (! isset($this->_labels['buttons'][ $type ])) {
3732
+        if ( ! isset($this->_labels['buttons'][$type])) {
3733 3733
             throw new EE_Error(
3734 3734
                 sprintf(
3735 3735
                     esc_html__(
@@ -3742,7 +3742,7 @@  discard block
 block discarded – undo
3742 3742
         }
3743 3743
         // finally check user access for this button.
3744 3744
         $has_access = $this->check_user_access($action, true);
3745
-        if (! $has_access) {
3745
+        if ( ! $has_access) {
3746 3746
             return '';
3747 3747
         }
3748 3748
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3750,11 +3750,11 @@  discard block
 block discarded – undo
3750 3750
             'action' => $action,
3751 3751
         ];
3752 3752
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3753
-        if (! empty($extra_request)) {
3753
+        if ( ! empty($extra_request)) {
3754 3754
             $query_args = array_merge($extra_request, $query_args);
3755 3755
         }
3756 3756
         $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3757
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3757
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3758 3758
     }
3759 3759
 
3760 3760
 
@@ -3780,7 +3780,7 @@  discard block
 block discarded – undo
3780 3780
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3781 3781
                 20
3782 3782
             ),
3783
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3783
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3784 3784
         ];
3785 3785
         // ONLY add the screen option if the user has access to it.
3786 3786
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3801,18 +3801,18 @@  discard block
 block discarded – undo
3801 3801
     {
3802 3802
         if ($this->request->requestParamIsSet('wp_screen_options')) {
3803 3803
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3804
-            if (! $user = wp_get_current_user()) {
3804
+            if ( ! $user = wp_get_current_user()) {
3805 3805
                 return;
3806 3806
             }
3807 3807
             $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3808
-            if (! $option) {
3808
+            if ( ! $option) {
3809 3809
                 return;
3810 3810
             }
3811
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3811
+            $value = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3812 3812
             $map_option = $option;
3813 3813
             $option     = str_replace('-', '_', $option);
3814 3814
             switch ($map_option) {
3815
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3815
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3816 3816
                     $max_value = apply_filters(
3817 3817
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3818 3818
                         999,
@@ -3869,13 +3869,13 @@  discard block
 block discarded – undo
3869 3869
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3870 3870
     {
3871 3871
         $user_id = get_current_user_id();
3872
-        if (! $skip_route_verify) {
3872
+        if ( ! $skip_route_verify) {
3873 3873
             $this->_verify_route($route);
3874 3874
         }
3875 3875
         // now let's set the string for what kind of transient we're setting
3876 3876
         $transient = $notices
3877
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3878
-            : 'rte_tx_' . $route . '_' . $user_id;
3877
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3878
+            : 'rte_tx_'.$route.'_'.$user_id;
3879 3879
         $data      = $notices ? ['notices' => $data] : $data;
3880 3880
         // is there already a transient for this route?  If there is then let's ADD to that transient
3881 3881
         $existing = is_multisite() && is_network_admin()
@@ -3904,8 +3904,8 @@  discard block
 block discarded – undo
3904 3904
         $user_id   = get_current_user_id();
3905 3905
         $route     = ! $route ? $this->_req_action : $route;
3906 3906
         $transient = $notices
3907
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3908
-            : 'rte_tx_' . $route . '_' . $user_id;
3907
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3908
+            : 'rte_tx_'.$route.'_'.$user_id;
3909 3909
         $data      = is_multisite() && is_network_admin()
3910 3910
             ? get_site_transient($transient)
3911 3911
             : get_transient($transient);
@@ -4136,7 +4136,7 @@  discard block
 block discarded – undo
4136 4136
      */
4137 4137
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4138 4138
     {
4139
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4139
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4140 4140
     }
4141 4141
 
4142 4142
 
@@ -4149,7 +4149,7 @@  discard block
 block discarded – undo
4149 4149
      */
4150 4150
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4151 4151
     {
4152
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4152
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4153 4153
     }
4154 4154
 
4155 4155
 
Please login to merge, or discard this patch.
core/admin/EE_Admin_Hooks.core.php 2 patches
Indentation   +754 added lines, -754 removed lines patch added patch discarded remove patch
@@ -16,758 +16,758 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * we're just going to use this to hold the name of the caller class (child class name)
21
-     *
22
-     * @var string
23
-     */
24
-    public $caller;
25
-
26
-
27
-    /**
28
-     * this is just a flag set automatically to indicate whether we've got an extended hook class running (i.e.
29
-     * espresso_events_Registration_Form_Hooks_Extend extends espresso_events_Registration_Form_Hooks).  This flag is
30
-     * used later to make sure we require the needed files.
31
-     *
32
-     * @var bool
33
-     */
34
-    protected $_extend;
35
-
36
-
37
-    /**
38
-     * child classes MUST set this property so that the page object can be loaded correctly
39
-     *
40
-     * @var string
41
-     */
42
-    protected $_name;
43
-
44
-
45
-    /**
46
-     * This is set by child classes and is an associative array of ajax hooks in the format:
47
-     * array(
48
-     *    'ajax_action_ref' => 'executing_method'; //must be public
49
-     * )
50
-     *
51
-     * @var array
52
-     */
53
-    protected $_ajax_func;
54
-
55
-
56
-    /**
57
-     * This is an array of methods that get executed on a page routes admin_init hook. Use the following format:
58
-     * array(
59
-     *    'page_route' => 'executing_method' //must be public
60
-     * )
61
-     *
62
-     * @var array
63
-     */
64
-    protected $_init_func;
65
-
66
-
67
-    /**
68
-     * This is an array of methods that output metabox content for the given page route.  Use the following format:
69
-     * [
70
-     *      0 => [
71
-     *          'page_route' => 'string_for_page_route',    must correspond to a page route in the class being connected
72
-     *                                                      with (i.e. "edit_event") If this is in an array then the
73
-     *                                                      same params below will be used but the metabox will be
74
-     *                                                      added to each route.
75
-     *          'func' =>  'executing_method',              must be public (i.e. public function executing_method
76
-     *                                                      ($post, $callback_args){} ).
77
-     *                                                      Note if you include callback args in the array then you
78
-     *                                                      need to declare them in the method arguments.
79
-     *          'id' => 'identifier_for_metabox',           so it can be removed by addons
80
-     *                                                      (optional, class will set it automatically)
81
-     *          'priority' => 'default',                    default 'default' (optional)
82
-     *          'label' => esc_html__('Localized Title', 'event_espresso'),
83
-     *          'context' => 'advanced'                     advanced is default (optional),
84
-     *      ]
85
-     *      'callback_args' => array() //any callback args to include (optional)
86
-     * ]
87
-     * Why are we indexing numerically?  Because it's possible there may be more than one metabox per page_route.
88
-     *
89
-     * @var array
90
-     */
91
-    protected $_metaboxes;
92
-
93
-
94
-    /**
95
-     * This is an array of values that indicate any metaboxes we want removed from a given page route.  Usually this is
96
-     * used when caffeinated functionality is replacing decaffeinated functionality.  Use the following format for the
97
-     * array: array(
98
-     *    0 => array(
99
-     *        'page_route' => 'string_for_page_route' //can be string or array of strings that match a page_route(s)
100
-     *        that are in the class being connected with (i.e. 'edit', or 'create_new').
101
-     *        'id' => 'identifier_for_metabox', //what the id is of the metabox being removed
102
-     *        'context' => 'normal', //the context for the metabox being removed (has to match)
103
-     *        'screen' => 'screen_id', //(optional), if not included then this class will attempt to remove the metabox
104
-     *        using the currently loaded screen object->id  however, there may be cases where you have to specify the
105
-     *        id for the screen the metabox is on.
106
-     *    )
107
-     * )
108
-     *
109
-     * @var array
110
-     */
111
-    protected $_remove_metaboxes;
112
-
113
-
114
-    /**
115
-     * This parent class takes care of loading the scripts and styles if the child class has set the properties for
116
-     * them in the following format.  Note, the first array index ('register') is for defining all the registers.  The
117
-     * second array index is for indicating what routes each script/style loads on. array(
118
-     * 'registers' => array(
119
-     *        'script_ref' => array( // if more than one script is to be loaded its best to use the 'dependency'
120
-     *        argument to link scripts together.
121
-     *            'type' => 'js' // 'js' or 'css' (defaults to js).  This tells us what type of wp_function to use
122
-     *            'url' => 'http://urltoscript.css.js',
123
-     *            'depends' => array('jquery'), //an array of dependencies for the scripts. REMEMBER, if a script has
124
-     *            already been registered elsewhere in the system.  You can just use the depends array to make sure it
125
-     *            gets loaded before the one you are setting here.
126
-     *            'footer' => TRUE //defaults to true (styles don't use this parameter)
127
-     *        ),
128
-     *    'enqueues' => array( //this time each key corresponds to the script ref followed by an array of page routes
129
-     *    the script gets enqueued on.
130
-     *        'script_ref' => array('route_one', 'route_two')
131
-     *    ),
132
-     *    'localize' => array( //this allows you to set a localized object.  Indicate which script the object is being
133
-     *    attached to and then include an array indexed by the name of the object and the array of key/value pairs for
134
-     *    the object.
135
-     *        'scrip_ref' => array(
136
-     *            'NAME_OF_JS_OBJECT' => array(
137
-     *                'translate_ref' => esc_html__('localized_string', 'event_espresso'),
138
-     *                'some_data' => 5
139
-     *            )
140
-     *        )
141
-     *    )
142
-     * )
143
-     *
144
-     * @var array
145
-     */
146
-    protected $_scripts_styles;
147
-
148
-
149
-    /**
150
-     * This is a property that will contain the current route.
151
-     *
152
-     * @var string;
153
-     */
154
-    protected $_current_route;
155
-
156
-
157
-    /**
158
-     * this optional property can be set by child classes to override the priority for the automatic action/filter hook
159
-     * loading in the `_load_routed_hooks()` method.  Please follow this format: array(
160
-     *    'wp_hook_reference' => 1
161
-     *    )
162
-     * )
163
-     *
164
-     * @var array
165
-     */
166
-    protected $_wp_action_filters_priority;
167
-
168
-
169
-    /**
170
-     * This just holds a merged array of the request vars
171
-     *
172
-     * @var array
173
-     */
174
-    protected $_req_data;
175
-
176
-    /**
177
-     * @var array
178
-     */
179
-    protected $_scripts;
180
-
181
-    /**
182
-     * @var array
183
-     */
184
-    protected $_styles;
185
-
186
-    /**
187
-     * This just holds an instance of the page object for this hook
188
-     *
189
-     * @var EE_Admin_Page
190
-     */
191
-    protected $_page_object;
192
-
193
-
194
-    /**
195
-     * This holds the EE_Admin_Page object from the calling admin page that this object hooks into.
196
-     *
197
-     * @var EE_Admin_Page|EE_Admin_Page_CPT
198
-     */
199
-    protected $_adminpage_obj;
200
-
201
-
202
-    /**
203
-     * Holds EE_Registry object
204
-     *
205
-     * @var EE_Registry
206
-     */
207
-    protected $EE = null;
208
-
209
-    /**
210
-     * @var RequestInterface
211
-     */
212
-    protected $request;
213
-
214
-
215
-    /**
216
-     * constructor
217
-     *
218
-     * @param EE_Admin_Page $admin_page
219
-     * @throws EE_Error
220
-     */
221
-    public function __construct(EE_Admin_Page $admin_page)
222
-    {
223
-        $this->_adminpage_obj = $admin_page;
224
-        $this->request        = LoaderFactory::getLoader()->getShared(RequestInterface::class);
225
-        $this->_req_data      = $this->request->requestParams();
226
-        $this->_set_defaults();
227
-        $this->_set_hooks_properties();
228
-        // first let's verify we're on the right page
229
-        if (! isset($this->_req_data['page']) || $this->_req_data['page'] !== $this->_adminpage_obj->page_slug) {
230
-            return;
231
-        }
232
-        // get out nothing more to be done here.
233
-        // allow for extends to modify properties
234
-        if (method_exists($this, '_extend_properties')) {
235
-            $this->_extend_properties();
236
-        }
237
-        $this->_set_page_object();
238
-        $this->_init_hooks();
239
-        $this->_load_custom_methods();
240
-        $this->_load_routed_hooks();
241
-        add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts_styles']);
242
-        add_action('admin_enqueue_scripts', [$this, 'add_metaboxes'], 20);
243
-        add_action('admin_enqueue_scripts', [$this, 'remove_metaboxes'], 15);
244
-        $this->_ajax_hooks();
245
-    }
246
-
247
-
248
-    /**
249
-     * used by child classes to set the following properties:
250
-     * $_ajax_func (optional)
251
-     * $_init_func (optional)
252
-     * $_metaboxes (optional)
253
-     * $_scripts (optional)
254
-     * $_styles (optional)
255
-     * $_name (required)
256
-     * Also in this method will be registered any scripts or styles loaded on the targeted page (as indicated in the
257
-     * _scripts/_styles properties) Also children should place in this method any filters/actions that have to happen
258
-     * really early on page load (just after admin_init) if they want to have them registered for handling early.
259
-     *
260
-     * @abstract
261
-     * @return void
262
-     */
263
-    abstract protected function _set_hooks_properties();
264
-
265
-
266
-    /**
267
-     * The hooks for enqueue_scripts and enqueue_styles will be run in here.  Child classes need to define their
268
-     * scripts and styles in the relevant $_scripts and $_styles properties.  Child classes must have also already
269
-     * registered the scripts and styles using wp_register_script and wp_register_style functions.
270
-     *
271
-     * @return void
272
-     * @throws EE_Error
273
-     */
274
-    public function enqueue_scripts_styles()
275
-    {
276
-
277
-        if (! empty($this->_scripts_styles)) {
278
-            // first let's do all the registrations
279
-            if (! isset($this->_scripts_styles['registers'])) {
280
-                $msg[] = esc_html__(
281
-                    'There is no "registers" index in the <code>$this->_scripts_styles</code> property.',
282
-                    'event_espresso'
283
-                );
284
-                $msg[] = sprintf(
285
-                    esc_html__(
286
-                        'Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child',
287
-                        'event_espresso'
288
-                    ),
289
-                    '<strong>' . $this->caller . '</strong>'
290
-                );
291
-                throw new EE_Error(implode('||', $msg));
292
-            }
293
-            $defaults = [
294
-                'type'    => 'js',
295
-                'url'     => '',
296
-                'depends' => [],
297
-                'version' => EVENT_ESPRESSO_VERSION,
298
-                'footer'  => true,
299
-            ];
300
-            foreach ($this->_scripts_styles['registers'] as $ref => $details) {
301
-                $details = wp_parse_args($details, $defaults);
302
-                $type    = $details['type'];
303
-                $url     = $details['url'];
304
-                $depends = $details['depends'];
305
-                $version = $details['version'];
306
-                $footer  = $details['footer'];
307
-                // let's make sure that we set the 'registers' type if it's not set!
308
-                // We need it later to determine which enqueue we do
309
-                $this->_scripts_styles['registers'][ $ref ]['type'] = $type;
310
-                // let's make sure we're not missing any REQUIRED parameters
311
-                if (empty($url)) {
312
-                    $msg[] = sprintf(
313
-                        esc_html__('Missing the url for the requested %s', 'event_espresso'),
314
-                        $type == 'js' ? 'script' : 'stylesheet'
315
-                    );
316
-                    $msg[] = sprintf(
317
-                        esc_html__(
318
-                            'Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref',
319
-                            'event_espresso'
320
-                        ),
321
-                        '<strong>' . $this->caller . '</strong>',
322
-                        $ref
323
-                    );
324
-                    throw new EE_Error(implode('||', $msg));
325
-                }
326
-                // made it here so let's do the appropriate registration
327
-                $type == 'js'
328
-                    ? wp_register_script($ref, $url, $depends, $version, $footer)
329
-                    : wp_register_style(
330
-                        $ref,
331
-                        $url,
332
-                        $depends,
333
-                        $version
334
-                    );
335
-            }
336
-            // k now let's do the enqueues
337
-            if (! isset($this->_scripts_styles['enqueues'])) {
338
-                return;
339
-            }  //not sure if we should throw an error here or not.
340
-
341
-            foreach ($this->_scripts_styles['enqueues'] as $ref => $routes) {
342
-                // make sure $routes is an array
343
-                $routes = (array) $routes;
344
-                if (in_array($this->_current_route, $routes)) {
345
-                    $this->_scripts_styles['registers'][ $ref ]['type'] == 'js' ? wp_enqueue_script($ref)
346
-                        : wp_enqueue_style($ref);
347
-                    // if we have a localization for the script let's do that too.
348
-                    if (isset($this->_scripts_styles['localize'][ $ref ])) {
349
-                        foreach ($this->_scripts_styles['localize'][ $ref ] as $object_name => $indexes) {
350
-                            wp_localize_script(
351
-                                $ref,
352
-                                $object_name,
353
-                                $this->_scripts_styles['localize'][ $ref ][ $object_name ]
354
-                            );
355
-                        }
356
-                    }
357
-                }
358
-            }
359
-            // let's do the deregisters
360
-            if (! isset($this->_scripts_styles['deregisters'])) {
361
-                return;
362
-            }
363
-            foreach ($this->_scripts_styles['deregisters'] as $ref => $details) {
364
-                $defaults = ['type' => 'js'];
365
-                $details  = wp_parse_args($details, $defaults);
366
-                $details['type'] === 'js' ? wp_deregister_script($ref) : wp_deregister_style($ref);
367
-            }
368
-        }
369
-    }
370
-
371
-
372
-    /**
373
-     * just set the defaults for the hooks properties.
374
-     *
375
-     * @return void
376
-     */
377
-    private function _set_defaults()
378
-    {
379
-        $this->_ajax_func                  = [];
380
-        $this->_init_func                  = [];
381
-        $this->_metaboxes                  = [];
382
-        $this->_scripts                    = [];
383
-        $this->_styles                     = [];
384
-        $this->_wp_action_filters_priority = [];
385
-        $this->_current_route              = $this->getCurrentRoute();
386
-        $this->caller                      = get_class($this);
387
-        $this->_extend                     = (bool) stripos($this->caller, 'Extend');
388
-    }
389
-
390
-
391
-    /**
392
-     * A helper for determining the current route.
393
-     *
394
-     * @return string
395
-     */
396
-    private function getCurrentRoute()
397
-    {
398
-        $action = $this->request->getRequestParam('action');
399
-        // list tables do something else with 'action' for bulk actions.
400
-        $action = $action !== '-1' && $action !== '' ? $action : 'default';
401
-        $route  = $this->request->getRequestParam('route');
402
-        // we set a 'route' variable in some cases where action is being used by something else.
403
-        return $action === 'default' && $route !== '' ? $route : $action;
404
-    }
405
-
406
-
407
-    /**
408
-     * this sets the _page_object property
409
-     *
410
-     * @return void
411
-     * @throws EE_Error
412
-     */
413
-    protected function _set_page_object()
414
-    {
415
-        // first make sure $this->_name is set
416
-        if (empty($this->_name)) {
417
-            $msg[] = esc_html__('We can\'t load the page object', 'event_espresso');
418
-            $msg[] = sprintf(
419
-                esc_html__("This is because the %s child class has not set the '_name' property", 'event_espresso'),
420
-                $this->caller
421
-            );
422
-            throw new EE_Error(implode('||', $msg));
423
-        }
424
-        // change "the_message" to "the message"
425
-        $class_name = str_replace('_', ' ', $this->_name);
426
-        // change "the message" to "The_Message_Admin_Page"
427
-        $class_name = str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page';
428
-        // first default file (if exists)
429
-        $decaf_file = EE_ADMIN_PAGES . $this->_name . '/' . $class_name . '.core.php';
430
-        if (is_readable($decaf_file)) {
431
-            require_once($decaf_file);
432
-        }
433
-        // now we have to do require for extended file (if needed)
434
-        if ($this->_extend) {
435
-            require_once(EE_CORE_CAF_ADMIN_EXTEND . $this->_name . '/Extend_' . $class_name . '.core.php');
436
-            // and extend the class name as well
437
-            $class_name = 'Extend_' . $class_name;
438
-        }
439
-        // let's make sure the class exists
440
-        if (! class_exists($class_name)) {
441
-            $msg[] = esc_html__('We can\'t load the page object', 'event_espresso');
442
-            $msg[] = sprintf(
443
-                esc_html__(
444
-                    'The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class',
445
-                    'event_espresso'
446
-                ),
447
-                $class_name
448
-            );
449
-            throw new EE_Error(implode('||', $msg));
450
-        }
451
-        $this->_page_object = LoaderFactory::getLoader()->getShared($class_name, [false]);
452
-    }
453
-
454
-
455
-    /**
456
-     * Child "hook" classes can declare any methods that they want executed when a specific page route is loaded.  The
457
-     * advantage of this is when doing things like running our own db interactions on saves etc.  Remember that
458
-     * $this->_req_data (all the _POST and _GET data) is available to your methods.
459
-     *
460
-     * @return void
461
-     */
462
-    private function _load_custom_methods()
463
-    {
464
-        /**
465
-         * method cannot be named 'default' (@see http://us3.php
466
-         * .net/manual/en/reserved.keywords.php) so need to
467
-         * handle routes that are "default"
468
-         *
469
-         * @since 4.3.0
470
-         */
471
-        $method_callback = $this->_current_route == 'default' ? 'default_callback' : $this->_current_route;
472
-        // these run before the Admin_Page route executes.
473
-        if (method_exists($this, $method_callback)) {
474
-            call_user_func([$this, $method_callback]);
475
-        }
476
-        // these run via the _redirect_after_action method in EE_Admin_Page which usually happens after non_UI methods in EE_Admin_Page classes.  There are two redirect actions, the first fires before $query_args might be manipulated by "save and close" actions and the seond fires right before the actual redirect happens.
477
-        // first the actions
478
-        // note that these action hooks will have the $query_args value available.
479
-        $admin_class_name = get_class($this->_adminpage_obj);
480
-        if (method_exists($this, '_redirect_action_early_' . $this->_current_route)) {
481
-            add_action(
482
-                'AHEE__'
483
-                . $admin_class_name
484
-                . '___redirect_after_action__before_redirect_modification_'
485
-                . $this->_current_route,
486
-                [$this, '_redirect_action_early_' . $this->_current_route],
487
-                10
488
-            );
489
-        }
490
-        if (method_exists($this, '_redirect_action_' . $this->_current_route)) {
491
-            add_action(
492
-                'AHEE_redirect_' . $admin_class_name . $this->_current_route,
493
-                [$this, '_redirect_action_' . $this->_current_route],
494
-                10
495
-            );
496
-        }
497
-        // let's hook into the _redirect itself and allow for changing where the user goes after redirect.  This will have $query_args and $redirect_url available.
498
-        if (method_exists($this, '_redirect_filter_' . $this->_current_route)) {
499
-            add_filter(
500
-                'FHEE_redirect_' . $admin_class_name . $this->_current_route,
501
-                [$this, '_redirect_filter_' . $this->_current_route],
502
-                10,
503
-                2
504
-            );
505
-        }
506
-    }
507
-
508
-
509
-    /**
510
-     * This method will search for a corresponding method with a name matching the route and the wp_hook to run.  This
511
-     * allows child hook classes to target hooking into a specific wp action or filter hook ONLY on a certain route.
512
-     * just remember, methods MUST be public Future hooks should be added in here to be access by child classes.
513
-     *
514
-     * @return void
515
-     */
516
-    private function _load_routed_hooks()
517
-    {
518
-
519
-        // this array provides the hook action names that will be referenced.  Key is the action. Value is an array with the type (action or filter) and the number of parameters for the hook.  We'll default all priorities for automatic hooks to 10.
520
-        $hook_filter_array = [
521
-            'admin_footer'                                                                            => [
522
-                'type'     => 'action',
523
-                'argnum'   => 1,
524
-                'priority' => 10,
525
-            ],
526
-            'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => [
527
-                'type'     => 'filter',
528
-                'argnum'   => 1,
529
-                'priority' => 10,
530
-            ],
531
-            'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug                               => [
532
-                'type'     => 'filter',
533
-                'argnum'   => 1,
534
-                'priority' => 10,
535
-            ],
536
-            'FHEE_list_table_views'                                                                   => [
537
-                'type'     => 'filter',
538
-                'argnum'   => 1,
539
-                'priority' => 10,
540
-            ],
541
-            'AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes'                              => [
542
-                'type'     => 'action',
543
-                'argnum'   => 1,
544
-                'priority' => 10,
545
-            ],
546
-        ];
547
-        foreach ($hook_filter_array as $hook => $args) {
548
-            if (method_exists($this, $this->_current_route . '_' . $hook)) {
549
-                if (isset($this->_wp_action_filters_priority[ $hook ])) {
550
-                    $args['priority'] = $this->_wp_action_filters_priority[ $hook ];
551
-                }
552
-                if ($args['type'] == 'action') {
553
-                    add_action(
554
-                        $hook,
555
-                        [$this, $this->_current_route . '_' . $hook],
556
-                        $args['priority'],
557
-                        $args['argnum']
558
-                    );
559
-                } else {
560
-                    add_filter(
561
-                        $hook,
562
-                        [$this, $this->_current_route . '_' . $hook],
563
-                        $args['priority'],
564
-                        $args['argnum']
565
-                    );
566
-                }
567
-            }
568
-        }
569
-    }
570
-
571
-
572
-    /**
573
-     * Loop throught the $_ajax_func array and add_actions for the array.
574
-     *
575
-     * @return void
576
-     * @throws EE_Error
577
-     */
578
-    private function _ajax_hooks()
579
-    {
580
-
581
-        if (empty($this->_ajax_func)) {
582
-            return;
583
-        } //get out there's nothing to take care of.
584
-        foreach ($this->_ajax_func as $action => $method) {
585
-            // make sure method exists
586
-            if (! method_exists($this, $method)) {
587
-                $msg[] = esc_html__(
588
-                    'There is no corresponding method for the hook labeled in the _ajax_func array',
589
-                    'event_espresso'
590
-                ) . '<br />';
591
-                $msg[] = sprintf(
592
-                    esc_html__(
593
-                        'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
594
-                        'event_espresso'
595
-                    ),
596
-                    $method,
597
-                    $this->caller
598
-                );
599
-                throw new EE_Error(implode('||', $msg));
600
-            }
601
-            add_action('wp_ajax_' . $action, [$this, $method]);
602
-        }
603
-    }
604
-
605
-
606
-    /**
607
-     * Loop throught the $_init_func array and add_actions for the array.
608
-     *
609
-     * @return void
610
-     * @throws EE_Error
611
-     */
612
-    protected function _init_hooks()
613
-    {
614
-        if (empty($this->_init_func)) {
615
-            return;
616
-        }
617
-        // get out there's nothing to take care of.
618
-        // We need to determine what page_route we are on!
619
-        foreach ($this->_init_func as $route => $method) {
620
-            // make sure method exists
621
-            if (! method_exists($this, $method)) {
622
-                $msg[] = esc_html__(
623
-                    'There is no corresponding method for the hook labeled in the _init_func array',
624
-                    'event_espresso'
625
-                ) . '<br />';
626
-                $msg[] = sprintf(
627
-                    esc_html__(
628
-                        'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
629
-                        'event_espresso'
630
-                    ),
631
-                    $method,
632
-                    $this->caller
633
-                );
634
-                throw new EE_Error(implode('||', $msg));
635
-            }
636
-            if ($route == $this->_current_route) {
637
-                add_action('admin_init', [$this, $method]);
638
-            }
639
-        }
640
-    }
641
-
642
-
643
-    /**
644
-     * Loop through the _metaboxes property and add_metaboxes accordingly
645
-     * //todo we could eventually make this a config component class (i.e. new EE_Metabox);
646
-     *
647
-     * @return void
648
-     * @throws EE_Error
649
-     */
650
-    public function add_metaboxes()
651
-    {
652
-        if (empty($this->_metaboxes)) {
653
-            return;
654
-        } //get out we don't have any metaboxes to set for this connection
655
-        $this->_handle_metabox_array($this->_metaboxes);
656
-    }
657
-
658
-
659
-    /**
660
-     * @param array $boxes
661
-     * @param bool  $add
662
-     * @throws EE_Error
663
-     */
664
-    private function _handle_metabox_array(array $boxes, $add = true)
665
-    {
666
-
667
-        foreach ($boxes as $box) {
668
-            if (! isset($box['page_route'])) {
669
-                continue;
670
-            }
671
-            // we don't have a valid array
672
-            // let's make sure $box['page_route'] is an array so the "foreach" will work.
673
-            $box['page_route'] = (array) $box['page_route'];
674
-            foreach ($box['page_route'] as $route) {
675
-                if ($route != $this->_current_route) {
676
-                    continue;
677
-                } //get out we only add metaboxes for set route.
678
-                if ($add) {
679
-                    $this->_add_metabox($box);
680
-                } else {
681
-                    $this->_remove_metabox($box);
682
-                }
683
-            }
684
-        }
685
-    }
686
-
687
-
688
-    /**
689
-     * Loop through the _remove_metaboxes property and remove metaboxes accordingly.
690
-     *
691
-     * @return void
692
-     * @throws EE_Error
693
-     */
694
-    public function remove_metaboxes()
695
-    {
696
-
697
-        if (empty($this->_remove_metaboxes)) {
698
-            return;
699
-        } //get out there are no metaboxes to remove
700
-        $this->_handle_metabox_array($this->_remove_metaboxes, false);
701
-    }
702
-
703
-
704
-    /**
705
-     * This just handles adding a metabox
706
-     *
707
-     * @param array $args an array of args that have been set for this metabox by the child class
708
-     * @throws EE_Error
709
-     */
710
-    private function _add_metabox($args)
711
-    {
712
-        $current_screen = get_current_screen();
713
-        $screen_id      = is_object($current_screen) ? $current_screen->id : null;
714
-        $func           = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
715
-        // set defaults
716
-        $defaults      = [
717
-            'callback_args' => [],
718
-            'context'       => 'advanced',
719
-            'func'          => $func,
720
-            'id'            => $this->caller . '_' . $func . '_metabox',
721
-            'label'         => $this->caller,
722
-            'page'          => isset($args['page']) ? $args['page'] : $screen_id,
723
-            'priority'      => 'default',
724
-        ];
725
-        $args          = wp_parse_args($args, $defaults);
726
-        $callback_args = $args['callback_args'];
727
-        $context       = $args['context'];
728
-        $func          = $args['func'];
729
-        $id            = $args['id'];
730
-        $label         = $args['label'];
731
-        $page          = $args['page'];
732
-        $priority      = $args['priority'];
733
-        // make sure method exists
734
-        if (! method_exists($this, $func)) {
735
-            $msg[] =
736
-                esc_html__('There is no corresponding method to display the metabox content', 'event_espresso')
737
-                . '<br />';
738
-            $msg[] = sprintf(
739
-                esc_html__(
740
-                    'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
741
-                    'event_espresso'
742
-                ),
743
-                $func,
744
-                $this->caller
745
-            );
746
-            throw new EE_Error(implode('||', $msg));
747
-        }
748
-        // everything checks out so let's add the metabox
749
-        add_meta_box($id, $label, [$this, $func], $page, $context, $priority, $callback_args);
750
-    }
751
-
752
-
753
-    private function _remove_metabox($args)
754
-    {
755
-        $current_screen = get_current_screen();
756
-        $screen_id      = is_object($current_screen) ? $current_screen->id : null;
757
-        $func           = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
758
-        // set defaults
759
-        $defaults = [
760
-            'context' => 'default',
761
-            'id'      => isset($args['id'])
762
-                ? $args['id']
763
-                : $this->_current_route . '_' . $this->caller . '_' . $func . '_metabox',
764
-            'screen'  => isset($args['screen']) ? $args['screen'] : $screen_id,
765
-        ];
766
-        $args     = wp_parse_args($args, $defaults);
767
-        $context  = $args['context'];
768
-        $id       = $args['id'];
769
-        $screen   = $args['screen'];
770
-        // everything checks out so lets remove the box!
771
-        remove_meta_box($id, $screen, $context);
772
-    }
19
+	/**
20
+	 * we're just going to use this to hold the name of the caller class (child class name)
21
+	 *
22
+	 * @var string
23
+	 */
24
+	public $caller;
25
+
26
+
27
+	/**
28
+	 * this is just a flag set automatically to indicate whether we've got an extended hook class running (i.e.
29
+	 * espresso_events_Registration_Form_Hooks_Extend extends espresso_events_Registration_Form_Hooks).  This flag is
30
+	 * used later to make sure we require the needed files.
31
+	 *
32
+	 * @var bool
33
+	 */
34
+	protected $_extend;
35
+
36
+
37
+	/**
38
+	 * child classes MUST set this property so that the page object can be loaded correctly
39
+	 *
40
+	 * @var string
41
+	 */
42
+	protected $_name;
43
+
44
+
45
+	/**
46
+	 * This is set by child classes and is an associative array of ajax hooks in the format:
47
+	 * array(
48
+	 *    'ajax_action_ref' => 'executing_method'; //must be public
49
+	 * )
50
+	 *
51
+	 * @var array
52
+	 */
53
+	protected $_ajax_func;
54
+
55
+
56
+	/**
57
+	 * This is an array of methods that get executed on a page routes admin_init hook. Use the following format:
58
+	 * array(
59
+	 *    'page_route' => 'executing_method' //must be public
60
+	 * )
61
+	 *
62
+	 * @var array
63
+	 */
64
+	protected $_init_func;
65
+
66
+
67
+	/**
68
+	 * This is an array of methods that output metabox content for the given page route.  Use the following format:
69
+	 * [
70
+	 *      0 => [
71
+	 *          'page_route' => 'string_for_page_route',    must correspond to a page route in the class being connected
72
+	 *                                                      with (i.e. "edit_event") If this is in an array then the
73
+	 *                                                      same params below will be used but the metabox will be
74
+	 *                                                      added to each route.
75
+	 *          'func' =>  'executing_method',              must be public (i.e. public function executing_method
76
+	 *                                                      ($post, $callback_args){} ).
77
+	 *                                                      Note if you include callback args in the array then you
78
+	 *                                                      need to declare them in the method arguments.
79
+	 *          'id' => 'identifier_for_metabox',           so it can be removed by addons
80
+	 *                                                      (optional, class will set it automatically)
81
+	 *          'priority' => 'default',                    default 'default' (optional)
82
+	 *          'label' => esc_html__('Localized Title', 'event_espresso'),
83
+	 *          'context' => 'advanced'                     advanced is default (optional),
84
+	 *      ]
85
+	 *      'callback_args' => array() //any callback args to include (optional)
86
+	 * ]
87
+	 * Why are we indexing numerically?  Because it's possible there may be more than one metabox per page_route.
88
+	 *
89
+	 * @var array
90
+	 */
91
+	protected $_metaboxes;
92
+
93
+
94
+	/**
95
+	 * This is an array of values that indicate any metaboxes we want removed from a given page route.  Usually this is
96
+	 * used when caffeinated functionality is replacing decaffeinated functionality.  Use the following format for the
97
+	 * array: array(
98
+	 *    0 => array(
99
+	 *        'page_route' => 'string_for_page_route' //can be string or array of strings that match a page_route(s)
100
+	 *        that are in the class being connected with (i.e. 'edit', or 'create_new').
101
+	 *        'id' => 'identifier_for_metabox', //what the id is of the metabox being removed
102
+	 *        'context' => 'normal', //the context for the metabox being removed (has to match)
103
+	 *        'screen' => 'screen_id', //(optional), if not included then this class will attempt to remove the metabox
104
+	 *        using the currently loaded screen object->id  however, there may be cases where you have to specify the
105
+	 *        id for the screen the metabox is on.
106
+	 *    )
107
+	 * )
108
+	 *
109
+	 * @var array
110
+	 */
111
+	protected $_remove_metaboxes;
112
+
113
+
114
+	/**
115
+	 * This parent class takes care of loading the scripts and styles if the child class has set the properties for
116
+	 * them in the following format.  Note, the first array index ('register') is for defining all the registers.  The
117
+	 * second array index is for indicating what routes each script/style loads on. array(
118
+	 * 'registers' => array(
119
+	 *        'script_ref' => array( // if more than one script is to be loaded its best to use the 'dependency'
120
+	 *        argument to link scripts together.
121
+	 *            'type' => 'js' // 'js' or 'css' (defaults to js).  This tells us what type of wp_function to use
122
+	 *            'url' => 'http://urltoscript.css.js',
123
+	 *            'depends' => array('jquery'), //an array of dependencies for the scripts. REMEMBER, if a script has
124
+	 *            already been registered elsewhere in the system.  You can just use the depends array to make sure it
125
+	 *            gets loaded before the one you are setting here.
126
+	 *            'footer' => TRUE //defaults to true (styles don't use this parameter)
127
+	 *        ),
128
+	 *    'enqueues' => array( //this time each key corresponds to the script ref followed by an array of page routes
129
+	 *    the script gets enqueued on.
130
+	 *        'script_ref' => array('route_one', 'route_two')
131
+	 *    ),
132
+	 *    'localize' => array( //this allows you to set a localized object.  Indicate which script the object is being
133
+	 *    attached to and then include an array indexed by the name of the object and the array of key/value pairs for
134
+	 *    the object.
135
+	 *        'scrip_ref' => array(
136
+	 *            'NAME_OF_JS_OBJECT' => array(
137
+	 *                'translate_ref' => esc_html__('localized_string', 'event_espresso'),
138
+	 *                'some_data' => 5
139
+	 *            )
140
+	 *        )
141
+	 *    )
142
+	 * )
143
+	 *
144
+	 * @var array
145
+	 */
146
+	protected $_scripts_styles;
147
+
148
+
149
+	/**
150
+	 * This is a property that will contain the current route.
151
+	 *
152
+	 * @var string;
153
+	 */
154
+	protected $_current_route;
155
+
156
+
157
+	/**
158
+	 * this optional property can be set by child classes to override the priority for the automatic action/filter hook
159
+	 * loading in the `_load_routed_hooks()` method.  Please follow this format: array(
160
+	 *    'wp_hook_reference' => 1
161
+	 *    )
162
+	 * )
163
+	 *
164
+	 * @var array
165
+	 */
166
+	protected $_wp_action_filters_priority;
167
+
168
+
169
+	/**
170
+	 * This just holds a merged array of the request vars
171
+	 *
172
+	 * @var array
173
+	 */
174
+	protected $_req_data;
175
+
176
+	/**
177
+	 * @var array
178
+	 */
179
+	protected $_scripts;
180
+
181
+	/**
182
+	 * @var array
183
+	 */
184
+	protected $_styles;
185
+
186
+	/**
187
+	 * This just holds an instance of the page object for this hook
188
+	 *
189
+	 * @var EE_Admin_Page
190
+	 */
191
+	protected $_page_object;
192
+
193
+
194
+	/**
195
+	 * This holds the EE_Admin_Page object from the calling admin page that this object hooks into.
196
+	 *
197
+	 * @var EE_Admin_Page|EE_Admin_Page_CPT
198
+	 */
199
+	protected $_adminpage_obj;
200
+
201
+
202
+	/**
203
+	 * Holds EE_Registry object
204
+	 *
205
+	 * @var EE_Registry
206
+	 */
207
+	protected $EE = null;
208
+
209
+	/**
210
+	 * @var RequestInterface
211
+	 */
212
+	protected $request;
213
+
214
+
215
+	/**
216
+	 * constructor
217
+	 *
218
+	 * @param EE_Admin_Page $admin_page
219
+	 * @throws EE_Error
220
+	 */
221
+	public function __construct(EE_Admin_Page $admin_page)
222
+	{
223
+		$this->_adminpage_obj = $admin_page;
224
+		$this->request        = LoaderFactory::getLoader()->getShared(RequestInterface::class);
225
+		$this->_req_data      = $this->request->requestParams();
226
+		$this->_set_defaults();
227
+		$this->_set_hooks_properties();
228
+		// first let's verify we're on the right page
229
+		if (! isset($this->_req_data['page']) || $this->_req_data['page'] !== $this->_adminpage_obj->page_slug) {
230
+			return;
231
+		}
232
+		// get out nothing more to be done here.
233
+		// allow for extends to modify properties
234
+		if (method_exists($this, '_extend_properties')) {
235
+			$this->_extend_properties();
236
+		}
237
+		$this->_set_page_object();
238
+		$this->_init_hooks();
239
+		$this->_load_custom_methods();
240
+		$this->_load_routed_hooks();
241
+		add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts_styles']);
242
+		add_action('admin_enqueue_scripts', [$this, 'add_metaboxes'], 20);
243
+		add_action('admin_enqueue_scripts', [$this, 'remove_metaboxes'], 15);
244
+		$this->_ajax_hooks();
245
+	}
246
+
247
+
248
+	/**
249
+	 * used by child classes to set the following properties:
250
+	 * $_ajax_func (optional)
251
+	 * $_init_func (optional)
252
+	 * $_metaboxes (optional)
253
+	 * $_scripts (optional)
254
+	 * $_styles (optional)
255
+	 * $_name (required)
256
+	 * Also in this method will be registered any scripts or styles loaded on the targeted page (as indicated in the
257
+	 * _scripts/_styles properties) Also children should place in this method any filters/actions that have to happen
258
+	 * really early on page load (just after admin_init) if they want to have them registered for handling early.
259
+	 *
260
+	 * @abstract
261
+	 * @return void
262
+	 */
263
+	abstract protected function _set_hooks_properties();
264
+
265
+
266
+	/**
267
+	 * The hooks for enqueue_scripts and enqueue_styles will be run in here.  Child classes need to define their
268
+	 * scripts and styles in the relevant $_scripts and $_styles properties.  Child classes must have also already
269
+	 * registered the scripts and styles using wp_register_script and wp_register_style functions.
270
+	 *
271
+	 * @return void
272
+	 * @throws EE_Error
273
+	 */
274
+	public function enqueue_scripts_styles()
275
+	{
276
+
277
+		if (! empty($this->_scripts_styles)) {
278
+			// first let's do all the registrations
279
+			if (! isset($this->_scripts_styles['registers'])) {
280
+				$msg[] = esc_html__(
281
+					'There is no "registers" index in the <code>$this->_scripts_styles</code> property.',
282
+					'event_espresso'
283
+				);
284
+				$msg[] = sprintf(
285
+					esc_html__(
286
+						'Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child',
287
+						'event_espresso'
288
+					),
289
+					'<strong>' . $this->caller . '</strong>'
290
+				);
291
+				throw new EE_Error(implode('||', $msg));
292
+			}
293
+			$defaults = [
294
+				'type'    => 'js',
295
+				'url'     => '',
296
+				'depends' => [],
297
+				'version' => EVENT_ESPRESSO_VERSION,
298
+				'footer'  => true,
299
+			];
300
+			foreach ($this->_scripts_styles['registers'] as $ref => $details) {
301
+				$details = wp_parse_args($details, $defaults);
302
+				$type    = $details['type'];
303
+				$url     = $details['url'];
304
+				$depends = $details['depends'];
305
+				$version = $details['version'];
306
+				$footer  = $details['footer'];
307
+				// let's make sure that we set the 'registers' type if it's not set!
308
+				// We need it later to determine which enqueue we do
309
+				$this->_scripts_styles['registers'][ $ref ]['type'] = $type;
310
+				// let's make sure we're not missing any REQUIRED parameters
311
+				if (empty($url)) {
312
+					$msg[] = sprintf(
313
+						esc_html__('Missing the url for the requested %s', 'event_espresso'),
314
+						$type == 'js' ? 'script' : 'stylesheet'
315
+					);
316
+					$msg[] = sprintf(
317
+						esc_html__(
318
+							'Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref',
319
+							'event_espresso'
320
+						),
321
+						'<strong>' . $this->caller . '</strong>',
322
+						$ref
323
+					);
324
+					throw new EE_Error(implode('||', $msg));
325
+				}
326
+				// made it here so let's do the appropriate registration
327
+				$type == 'js'
328
+					? wp_register_script($ref, $url, $depends, $version, $footer)
329
+					: wp_register_style(
330
+						$ref,
331
+						$url,
332
+						$depends,
333
+						$version
334
+					);
335
+			}
336
+			// k now let's do the enqueues
337
+			if (! isset($this->_scripts_styles['enqueues'])) {
338
+				return;
339
+			}  //not sure if we should throw an error here or not.
340
+
341
+			foreach ($this->_scripts_styles['enqueues'] as $ref => $routes) {
342
+				// make sure $routes is an array
343
+				$routes = (array) $routes;
344
+				if (in_array($this->_current_route, $routes)) {
345
+					$this->_scripts_styles['registers'][ $ref ]['type'] == 'js' ? wp_enqueue_script($ref)
346
+						: wp_enqueue_style($ref);
347
+					// if we have a localization for the script let's do that too.
348
+					if (isset($this->_scripts_styles['localize'][ $ref ])) {
349
+						foreach ($this->_scripts_styles['localize'][ $ref ] as $object_name => $indexes) {
350
+							wp_localize_script(
351
+								$ref,
352
+								$object_name,
353
+								$this->_scripts_styles['localize'][ $ref ][ $object_name ]
354
+							);
355
+						}
356
+					}
357
+				}
358
+			}
359
+			// let's do the deregisters
360
+			if (! isset($this->_scripts_styles['deregisters'])) {
361
+				return;
362
+			}
363
+			foreach ($this->_scripts_styles['deregisters'] as $ref => $details) {
364
+				$defaults = ['type' => 'js'];
365
+				$details  = wp_parse_args($details, $defaults);
366
+				$details['type'] === 'js' ? wp_deregister_script($ref) : wp_deregister_style($ref);
367
+			}
368
+		}
369
+	}
370
+
371
+
372
+	/**
373
+	 * just set the defaults for the hooks properties.
374
+	 *
375
+	 * @return void
376
+	 */
377
+	private function _set_defaults()
378
+	{
379
+		$this->_ajax_func                  = [];
380
+		$this->_init_func                  = [];
381
+		$this->_metaboxes                  = [];
382
+		$this->_scripts                    = [];
383
+		$this->_styles                     = [];
384
+		$this->_wp_action_filters_priority = [];
385
+		$this->_current_route              = $this->getCurrentRoute();
386
+		$this->caller                      = get_class($this);
387
+		$this->_extend                     = (bool) stripos($this->caller, 'Extend');
388
+	}
389
+
390
+
391
+	/**
392
+	 * A helper for determining the current route.
393
+	 *
394
+	 * @return string
395
+	 */
396
+	private function getCurrentRoute()
397
+	{
398
+		$action = $this->request->getRequestParam('action');
399
+		// list tables do something else with 'action' for bulk actions.
400
+		$action = $action !== '-1' && $action !== '' ? $action : 'default';
401
+		$route  = $this->request->getRequestParam('route');
402
+		// we set a 'route' variable in some cases where action is being used by something else.
403
+		return $action === 'default' && $route !== '' ? $route : $action;
404
+	}
405
+
406
+
407
+	/**
408
+	 * this sets the _page_object property
409
+	 *
410
+	 * @return void
411
+	 * @throws EE_Error
412
+	 */
413
+	protected function _set_page_object()
414
+	{
415
+		// first make sure $this->_name is set
416
+		if (empty($this->_name)) {
417
+			$msg[] = esc_html__('We can\'t load the page object', 'event_espresso');
418
+			$msg[] = sprintf(
419
+				esc_html__("This is because the %s child class has not set the '_name' property", 'event_espresso'),
420
+				$this->caller
421
+			);
422
+			throw new EE_Error(implode('||', $msg));
423
+		}
424
+		// change "the_message" to "the message"
425
+		$class_name = str_replace('_', ' ', $this->_name);
426
+		// change "the message" to "The_Message_Admin_Page"
427
+		$class_name = str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page';
428
+		// first default file (if exists)
429
+		$decaf_file = EE_ADMIN_PAGES . $this->_name . '/' . $class_name . '.core.php';
430
+		if (is_readable($decaf_file)) {
431
+			require_once($decaf_file);
432
+		}
433
+		// now we have to do require for extended file (if needed)
434
+		if ($this->_extend) {
435
+			require_once(EE_CORE_CAF_ADMIN_EXTEND . $this->_name . '/Extend_' . $class_name . '.core.php');
436
+			// and extend the class name as well
437
+			$class_name = 'Extend_' . $class_name;
438
+		}
439
+		// let's make sure the class exists
440
+		if (! class_exists($class_name)) {
441
+			$msg[] = esc_html__('We can\'t load the page object', 'event_espresso');
442
+			$msg[] = sprintf(
443
+				esc_html__(
444
+					'The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class',
445
+					'event_espresso'
446
+				),
447
+				$class_name
448
+			);
449
+			throw new EE_Error(implode('||', $msg));
450
+		}
451
+		$this->_page_object = LoaderFactory::getLoader()->getShared($class_name, [false]);
452
+	}
453
+
454
+
455
+	/**
456
+	 * Child "hook" classes can declare any methods that they want executed when a specific page route is loaded.  The
457
+	 * advantage of this is when doing things like running our own db interactions on saves etc.  Remember that
458
+	 * $this->_req_data (all the _POST and _GET data) is available to your methods.
459
+	 *
460
+	 * @return void
461
+	 */
462
+	private function _load_custom_methods()
463
+	{
464
+		/**
465
+		 * method cannot be named 'default' (@see http://us3.php
466
+		 * .net/manual/en/reserved.keywords.php) so need to
467
+		 * handle routes that are "default"
468
+		 *
469
+		 * @since 4.3.0
470
+		 */
471
+		$method_callback = $this->_current_route == 'default' ? 'default_callback' : $this->_current_route;
472
+		// these run before the Admin_Page route executes.
473
+		if (method_exists($this, $method_callback)) {
474
+			call_user_func([$this, $method_callback]);
475
+		}
476
+		// these run via the _redirect_after_action method in EE_Admin_Page which usually happens after non_UI methods in EE_Admin_Page classes.  There are two redirect actions, the first fires before $query_args might be manipulated by "save and close" actions and the seond fires right before the actual redirect happens.
477
+		// first the actions
478
+		// note that these action hooks will have the $query_args value available.
479
+		$admin_class_name = get_class($this->_adminpage_obj);
480
+		if (method_exists($this, '_redirect_action_early_' . $this->_current_route)) {
481
+			add_action(
482
+				'AHEE__'
483
+				. $admin_class_name
484
+				. '___redirect_after_action__before_redirect_modification_'
485
+				. $this->_current_route,
486
+				[$this, '_redirect_action_early_' . $this->_current_route],
487
+				10
488
+			);
489
+		}
490
+		if (method_exists($this, '_redirect_action_' . $this->_current_route)) {
491
+			add_action(
492
+				'AHEE_redirect_' . $admin_class_name . $this->_current_route,
493
+				[$this, '_redirect_action_' . $this->_current_route],
494
+				10
495
+			);
496
+		}
497
+		// let's hook into the _redirect itself and allow for changing where the user goes after redirect.  This will have $query_args and $redirect_url available.
498
+		if (method_exists($this, '_redirect_filter_' . $this->_current_route)) {
499
+			add_filter(
500
+				'FHEE_redirect_' . $admin_class_name . $this->_current_route,
501
+				[$this, '_redirect_filter_' . $this->_current_route],
502
+				10,
503
+				2
504
+			);
505
+		}
506
+	}
507
+
508
+
509
+	/**
510
+	 * This method will search for a corresponding method with a name matching the route and the wp_hook to run.  This
511
+	 * allows child hook classes to target hooking into a specific wp action or filter hook ONLY on a certain route.
512
+	 * just remember, methods MUST be public Future hooks should be added in here to be access by child classes.
513
+	 *
514
+	 * @return void
515
+	 */
516
+	private function _load_routed_hooks()
517
+	{
518
+
519
+		// this array provides the hook action names that will be referenced.  Key is the action. Value is an array with the type (action or filter) and the number of parameters for the hook.  We'll default all priorities for automatic hooks to 10.
520
+		$hook_filter_array = [
521
+			'admin_footer'                                                                            => [
522
+				'type'     => 'action',
523
+				'argnum'   => 1,
524
+				'priority' => 10,
525
+			],
526
+			'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => [
527
+				'type'     => 'filter',
528
+				'argnum'   => 1,
529
+				'priority' => 10,
530
+			],
531
+			'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug                               => [
532
+				'type'     => 'filter',
533
+				'argnum'   => 1,
534
+				'priority' => 10,
535
+			],
536
+			'FHEE_list_table_views'                                                                   => [
537
+				'type'     => 'filter',
538
+				'argnum'   => 1,
539
+				'priority' => 10,
540
+			],
541
+			'AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes'                              => [
542
+				'type'     => 'action',
543
+				'argnum'   => 1,
544
+				'priority' => 10,
545
+			],
546
+		];
547
+		foreach ($hook_filter_array as $hook => $args) {
548
+			if (method_exists($this, $this->_current_route . '_' . $hook)) {
549
+				if (isset($this->_wp_action_filters_priority[ $hook ])) {
550
+					$args['priority'] = $this->_wp_action_filters_priority[ $hook ];
551
+				}
552
+				if ($args['type'] == 'action') {
553
+					add_action(
554
+						$hook,
555
+						[$this, $this->_current_route . '_' . $hook],
556
+						$args['priority'],
557
+						$args['argnum']
558
+					);
559
+				} else {
560
+					add_filter(
561
+						$hook,
562
+						[$this, $this->_current_route . '_' . $hook],
563
+						$args['priority'],
564
+						$args['argnum']
565
+					);
566
+				}
567
+			}
568
+		}
569
+	}
570
+
571
+
572
+	/**
573
+	 * Loop throught the $_ajax_func array and add_actions for the array.
574
+	 *
575
+	 * @return void
576
+	 * @throws EE_Error
577
+	 */
578
+	private function _ajax_hooks()
579
+	{
580
+
581
+		if (empty($this->_ajax_func)) {
582
+			return;
583
+		} //get out there's nothing to take care of.
584
+		foreach ($this->_ajax_func as $action => $method) {
585
+			// make sure method exists
586
+			if (! method_exists($this, $method)) {
587
+				$msg[] = esc_html__(
588
+					'There is no corresponding method for the hook labeled in the _ajax_func array',
589
+					'event_espresso'
590
+				) . '<br />';
591
+				$msg[] = sprintf(
592
+					esc_html__(
593
+						'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
594
+						'event_espresso'
595
+					),
596
+					$method,
597
+					$this->caller
598
+				);
599
+				throw new EE_Error(implode('||', $msg));
600
+			}
601
+			add_action('wp_ajax_' . $action, [$this, $method]);
602
+		}
603
+	}
604
+
605
+
606
+	/**
607
+	 * Loop throught the $_init_func array and add_actions for the array.
608
+	 *
609
+	 * @return void
610
+	 * @throws EE_Error
611
+	 */
612
+	protected function _init_hooks()
613
+	{
614
+		if (empty($this->_init_func)) {
615
+			return;
616
+		}
617
+		// get out there's nothing to take care of.
618
+		// We need to determine what page_route we are on!
619
+		foreach ($this->_init_func as $route => $method) {
620
+			// make sure method exists
621
+			if (! method_exists($this, $method)) {
622
+				$msg[] = esc_html__(
623
+					'There is no corresponding method for the hook labeled in the _init_func array',
624
+					'event_espresso'
625
+				) . '<br />';
626
+				$msg[] = sprintf(
627
+					esc_html__(
628
+						'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
629
+						'event_espresso'
630
+					),
631
+					$method,
632
+					$this->caller
633
+				);
634
+				throw new EE_Error(implode('||', $msg));
635
+			}
636
+			if ($route == $this->_current_route) {
637
+				add_action('admin_init', [$this, $method]);
638
+			}
639
+		}
640
+	}
641
+
642
+
643
+	/**
644
+	 * Loop through the _metaboxes property and add_metaboxes accordingly
645
+	 * //todo we could eventually make this a config component class (i.e. new EE_Metabox);
646
+	 *
647
+	 * @return void
648
+	 * @throws EE_Error
649
+	 */
650
+	public function add_metaboxes()
651
+	{
652
+		if (empty($this->_metaboxes)) {
653
+			return;
654
+		} //get out we don't have any metaboxes to set for this connection
655
+		$this->_handle_metabox_array($this->_metaboxes);
656
+	}
657
+
658
+
659
+	/**
660
+	 * @param array $boxes
661
+	 * @param bool  $add
662
+	 * @throws EE_Error
663
+	 */
664
+	private function _handle_metabox_array(array $boxes, $add = true)
665
+	{
666
+
667
+		foreach ($boxes as $box) {
668
+			if (! isset($box['page_route'])) {
669
+				continue;
670
+			}
671
+			// we don't have a valid array
672
+			// let's make sure $box['page_route'] is an array so the "foreach" will work.
673
+			$box['page_route'] = (array) $box['page_route'];
674
+			foreach ($box['page_route'] as $route) {
675
+				if ($route != $this->_current_route) {
676
+					continue;
677
+				} //get out we only add metaboxes for set route.
678
+				if ($add) {
679
+					$this->_add_metabox($box);
680
+				} else {
681
+					$this->_remove_metabox($box);
682
+				}
683
+			}
684
+		}
685
+	}
686
+
687
+
688
+	/**
689
+	 * Loop through the _remove_metaboxes property and remove metaboxes accordingly.
690
+	 *
691
+	 * @return void
692
+	 * @throws EE_Error
693
+	 */
694
+	public function remove_metaboxes()
695
+	{
696
+
697
+		if (empty($this->_remove_metaboxes)) {
698
+			return;
699
+		} //get out there are no metaboxes to remove
700
+		$this->_handle_metabox_array($this->_remove_metaboxes, false);
701
+	}
702
+
703
+
704
+	/**
705
+	 * This just handles adding a metabox
706
+	 *
707
+	 * @param array $args an array of args that have been set for this metabox by the child class
708
+	 * @throws EE_Error
709
+	 */
710
+	private function _add_metabox($args)
711
+	{
712
+		$current_screen = get_current_screen();
713
+		$screen_id      = is_object($current_screen) ? $current_screen->id : null;
714
+		$func           = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
715
+		// set defaults
716
+		$defaults      = [
717
+			'callback_args' => [],
718
+			'context'       => 'advanced',
719
+			'func'          => $func,
720
+			'id'            => $this->caller . '_' . $func . '_metabox',
721
+			'label'         => $this->caller,
722
+			'page'          => isset($args['page']) ? $args['page'] : $screen_id,
723
+			'priority'      => 'default',
724
+		];
725
+		$args          = wp_parse_args($args, $defaults);
726
+		$callback_args = $args['callback_args'];
727
+		$context       = $args['context'];
728
+		$func          = $args['func'];
729
+		$id            = $args['id'];
730
+		$label         = $args['label'];
731
+		$page          = $args['page'];
732
+		$priority      = $args['priority'];
733
+		// make sure method exists
734
+		if (! method_exists($this, $func)) {
735
+			$msg[] =
736
+				esc_html__('There is no corresponding method to display the metabox content', 'event_espresso')
737
+				. '<br />';
738
+			$msg[] = sprintf(
739
+				esc_html__(
740
+					'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
741
+					'event_espresso'
742
+				),
743
+				$func,
744
+				$this->caller
745
+			);
746
+			throw new EE_Error(implode('||', $msg));
747
+		}
748
+		// everything checks out so let's add the metabox
749
+		add_meta_box($id, $label, [$this, $func], $page, $context, $priority, $callback_args);
750
+	}
751
+
752
+
753
+	private function _remove_metabox($args)
754
+	{
755
+		$current_screen = get_current_screen();
756
+		$screen_id      = is_object($current_screen) ? $current_screen->id : null;
757
+		$func           = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
758
+		// set defaults
759
+		$defaults = [
760
+			'context' => 'default',
761
+			'id'      => isset($args['id'])
762
+				? $args['id']
763
+				: $this->_current_route . '_' . $this->caller . '_' . $func . '_metabox',
764
+			'screen'  => isset($args['screen']) ? $args['screen'] : $screen_id,
765
+		];
766
+		$args     = wp_parse_args($args, $defaults);
767
+		$context  = $args['context'];
768
+		$id       = $args['id'];
769
+		$screen   = $args['screen'];
770
+		// everything checks out so lets remove the box!
771
+		remove_meta_box($id, $screen, $context);
772
+	}
773 773
 }
Please login to merge, or discard this patch.
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
         $this->_set_defaults();
227 227
         $this->_set_hooks_properties();
228 228
         // first let's verify we're on the right page
229
-        if (! isset($this->_req_data['page']) || $this->_req_data['page'] !== $this->_adminpage_obj->page_slug) {
229
+        if ( ! isset($this->_req_data['page']) || $this->_req_data['page'] !== $this->_adminpage_obj->page_slug) {
230 230
             return;
231 231
         }
232 232
         // get out nothing more to be done here.
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
     public function enqueue_scripts_styles()
275 275
     {
276 276
 
277
-        if (! empty($this->_scripts_styles)) {
277
+        if ( ! empty($this->_scripts_styles)) {
278 278
             // first let's do all the registrations
279
-            if (! isset($this->_scripts_styles['registers'])) {
279
+            if ( ! isset($this->_scripts_styles['registers'])) {
280 280
                 $msg[] = esc_html__(
281 281
                     'There is no "registers" index in the <code>$this->_scripts_styles</code> property.',
282 282
                     'event_espresso'
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
                         'Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child',
287 287
                         'event_espresso'
288 288
                     ),
289
-                    '<strong>' . $this->caller . '</strong>'
289
+                    '<strong>'.$this->caller.'</strong>'
290 290
                 );
291 291
                 throw new EE_Error(implode('||', $msg));
292 292
             }
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
                 $footer  = $details['footer'];
307 307
                 // let's make sure that we set the 'registers' type if it's not set!
308 308
                 // We need it later to determine which enqueue we do
309
-                $this->_scripts_styles['registers'][ $ref ]['type'] = $type;
309
+                $this->_scripts_styles['registers'][$ref]['type'] = $type;
310 310
                 // let's make sure we're not missing any REQUIRED parameters
311 311
                 if (empty($url)) {
312 312
                     $msg[] = sprintf(
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
                             'Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref',
319 319
                             'event_espresso'
320 320
                         ),
321
-                        '<strong>' . $this->caller . '</strong>',
321
+                        '<strong>'.$this->caller.'</strong>',
322 322
                         $ref
323 323
                     );
324 324
                     throw new EE_Error(implode('||', $msg));
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
                     );
335 335
             }
336 336
             // k now let's do the enqueues
337
-            if (! isset($this->_scripts_styles['enqueues'])) {
337
+            if ( ! isset($this->_scripts_styles['enqueues'])) {
338 338
                 return;
339 339
             }  //not sure if we should throw an error here or not.
340 340
 
@@ -342,22 +342,22 @@  discard block
 block discarded – undo
342 342
                 // make sure $routes is an array
343 343
                 $routes = (array) $routes;
344 344
                 if (in_array($this->_current_route, $routes)) {
345
-                    $this->_scripts_styles['registers'][ $ref ]['type'] == 'js' ? wp_enqueue_script($ref)
345
+                    $this->_scripts_styles['registers'][$ref]['type'] == 'js' ? wp_enqueue_script($ref)
346 346
                         : wp_enqueue_style($ref);
347 347
                     // if we have a localization for the script let's do that too.
348
-                    if (isset($this->_scripts_styles['localize'][ $ref ])) {
349
-                        foreach ($this->_scripts_styles['localize'][ $ref ] as $object_name => $indexes) {
348
+                    if (isset($this->_scripts_styles['localize'][$ref])) {
349
+                        foreach ($this->_scripts_styles['localize'][$ref] as $object_name => $indexes) {
350 350
                             wp_localize_script(
351 351
                                 $ref,
352 352
                                 $object_name,
353
-                                $this->_scripts_styles['localize'][ $ref ][ $object_name ]
353
+                                $this->_scripts_styles['localize'][$ref][$object_name]
354 354
                             );
355 355
                         }
356 356
                     }
357 357
                 }
358 358
             }
359 359
             // let's do the deregisters
360
-            if (! isset($this->_scripts_styles['deregisters'])) {
360
+            if ( ! isset($this->_scripts_styles['deregisters'])) {
361 361
                 return;
362 362
             }
363 363
             foreach ($this->_scripts_styles['deregisters'] as $ref => $details) {
@@ -424,20 +424,20 @@  discard block
 block discarded – undo
424 424
         // change "the_message" to "the message"
425 425
         $class_name = str_replace('_', ' ', $this->_name);
426 426
         // change "the message" to "The_Message_Admin_Page"
427
-        $class_name = str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page';
427
+        $class_name = str_replace(' ', '_', ucwords($class_name)).'_Admin_Page';
428 428
         // first default file (if exists)
429
-        $decaf_file = EE_ADMIN_PAGES . $this->_name . '/' . $class_name . '.core.php';
429
+        $decaf_file = EE_ADMIN_PAGES.$this->_name.'/'.$class_name.'.core.php';
430 430
         if (is_readable($decaf_file)) {
431 431
             require_once($decaf_file);
432 432
         }
433 433
         // now we have to do require for extended file (if needed)
434 434
         if ($this->_extend) {
435
-            require_once(EE_CORE_CAF_ADMIN_EXTEND . $this->_name . '/Extend_' . $class_name . '.core.php');
435
+            require_once(EE_CORE_CAF_ADMIN_EXTEND.$this->_name.'/Extend_'.$class_name.'.core.php');
436 436
             // and extend the class name as well
437
-            $class_name = 'Extend_' . $class_name;
437
+            $class_name = 'Extend_'.$class_name;
438 438
         }
439 439
         // let's make sure the class exists
440
-        if (! class_exists($class_name)) {
440
+        if ( ! class_exists($class_name)) {
441 441
             $msg[] = esc_html__('We can\'t load the page object', 'event_espresso');
442 442
             $msg[] = sprintf(
443 443
                 esc_html__(
@@ -477,28 +477,28 @@  discard block
 block discarded – undo
477 477
         // first the actions
478 478
         // note that these action hooks will have the $query_args value available.
479 479
         $admin_class_name = get_class($this->_adminpage_obj);
480
-        if (method_exists($this, '_redirect_action_early_' . $this->_current_route)) {
480
+        if (method_exists($this, '_redirect_action_early_'.$this->_current_route)) {
481 481
             add_action(
482 482
                 'AHEE__'
483 483
                 . $admin_class_name
484 484
                 . '___redirect_after_action__before_redirect_modification_'
485 485
                 . $this->_current_route,
486
-                [$this, '_redirect_action_early_' . $this->_current_route],
486
+                [$this, '_redirect_action_early_'.$this->_current_route],
487 487
                 10
488 488
             );
489 489
         }
490
-        if (method_exists($this, '_redirect_action_' . $this->_current_route)) {
490
+        if (method_exists($this, '_redirect_action_'.$this->_current_route)) {
491 491
             add_action(
492
-                'AHEE_redirect_' . $admin_class_name . $this->_current_route,
493
-                [$this, '_redirect_action_' . $this->_current_route],
492
+                'AHEE_redirect_'.$admin_class_name.$this->_current_route,
493
+                [$this, '_redirect_action_'.$this->_current_route],
494 494
                 10
495 495
             );
496 496
         }
497 497
         // let's hook into the _redirect itself and allow for changing where the user goes after redirect.  This will have $query_args and $redirect_url available.
498
-        if (method_exists($this, '_redirect_filter_' . $this->_current_route)) {
498
+        if (method_exists($this, '_redirect_filter_'.$this->_current_route)) {
499 499
             add_filter(
500
-                'FHEE_redirect_' . $admin_class_name . $this->_current_route,
501
-                [$this, '_redirect_filter_' . $this->_current_route],
500
+                'FHEE_redirect_'.$admin_class_name.$this->_current_route,
501
+                [$this, '_redirect_filter_'.$this->_current_route],
502 502
                 10,
503 503
                 2
504 504
             );
@@ -523,12 +523,12 @@  discard block
 block discarded – undo
523 523
                 'argnum'   => 1,
524 524
                 'priority' => 10,
525 525
             ],
526
-            'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => [
526
+            'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug.'_'.$this->_current_route => [
527 527
                 'type'     => 'filter',
528 528
                 'argnum'   => 1,
529 529
                 'priority' => 10,
530 530
             ],
531
-            'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug                               => [
531
+            'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug                               => [
532 532
                 'type'     => 'filter',
533 533
                 'argnum'   => 1,
534 534
                 'priority' => 10,
@@ -545,21 +545,21 @@  discard block
 block discarded – undo
545 545
             ],
546 546
         ];
547 547
         foreach ($hook_filter_array as $hook => $args) {
548
-            if (method_exists($this, $this->_current_route . '_' . $hook)) {
549
-                if (isset($this->_wp_action_filters_priority[ $hook ])) {
550
-                    $args['priority'] = $this->_wp_action_filters_priority[ $hook ];
548
+            if (method_exists($this, $this->_current_route.'_'.$hook)) {
549
+                if (isset($this->_wp_action_filters_priority[$hook])) {
550
+                    $args['priority'] = $this->_wp_action_filters_priority[$hook];
551 551
                 }
552 552
                 if ($args['type'] == 'action') {
553 553
                     add_action(
554 554
                         $hook,
555
-                        [$this, $this->_current_route . '_' . $hook],
555
+                        [$this, $this->_current_route.'_'.$hook],
556 556
                         $args['priority'],
557 557
                         $args['argnum']
558 558
                     );
559 559
                 } else {
560 560
                     add_filter(
561 561
                         $hook,
562
-                        [$this, $this->_current_route . '_' . $hook],
562
+                        [$this, $this->_current_route.'_'.$hook],
563 563
                         $args['priority'],
564 564
                         $args['argnum']
565 565
                     );
@@ -583,11 +583,11 @@  discard block
 block discarded – undo
583 583
         } //get out there's nothing to take care of.
584 584
         foreach ($this->_ajax_func as $action => $method) {
585 585
             // make sure method exists
586
-            if (! method_exists($this, $method)) {
586
+            if ( ! method_exists($this, $method)) {
587 587
                 $msg[] = esc_html__(
588 588
                     'There is no corresponding method for the hook labeled in the _ajax_func array',
589 589
                     'event_espresso'
590
-                ) . '<br />';
590
+                ).'<br />';
591 591
                 $msg[] = sprintf(
592 592
                     esc_html__(
593 593
                         'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
                 );
599 599
                 throw new EE_Error(implode('||', $msg));
600 600
             }
601
-            add_action('wp_ajax_' . $action, [$this, $method]);
601
+            add_action('wp_ajax_'.$action, [$this, $method]);
602 602
         }
603 603
     }
604 604
 
@@ -618,11 +618,11 @@  discard block
 block discarded – undo
618 618
         // We need to determine what page_route we are on!
619 619
         foreach ($this->_init_func as $route => $method) {
620 620
             // make sure method exists
621
-            if (! method_exists($this, $method)) {
621
+            if ( ! method_exists($this, $method)) {
622 622
                 $msg[] = esc_html__(
623 623
                     'There is no corresponding method for the hook labeled in the _init_func array',
624 624
                     'event_espresso'
625
-                ) . '<br />';
625
+                ).'<br />';
626 626
                 $msg[] = sprintf(
627 627
                     esc_html__(
628 628
                         'The method name given in the array is %s, check the spelling and make sure it exists in the %s class',
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
     {
666 666
 
667 667
         foreach ($boxes as $box) {
668
-            if (! isset($box['page_route'])) {
668
+            if ( ! isset($box['page_route'])) {
669 669
                 continue;
670 670
             }
671 671
             // we don't have a valid array
@@ -713,11 +713,11 @@  discard block
 block discarded – undo
713 713
         $screen_id      = is_object($current_screen) ? $current_screen->id : null;
714 714
         $func           = isset($args['func']) ? $args['func'] : 'some_invalid_callback';
715 715
         // set defaults
716
-        $defaults      = [
716
+        $defaults = [
717 717
             'callback_args' => [],
718 718
             'context'       => 'advanced',
719 719
             'func'          => $func,
720
-            'id'            => $this->caller . '_' . $func . '_metabox',
720
+            'id'            => $this->caller.'_'.$func.'_metabox',
721 721
             'label'         => $this->caller,
722 722
             'page'          => isset($args['page']) ? $args['page'] : $screen_id,
723 723
             'priority'      => 'default',
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
         $page          = $args['page'];
732 732
         $priority      = $args['priority'];
733 733
         // make sure method exists
734
-        if (! method_exists($this, $func)) {
734
+        if ( ! method_exists($this, $func)) {
735 735
             $msg[] =
736 736
                 esc_html__('There is no corresponding method to display the metabox content', 'event_espresso')
737 737
                 . '<br />';
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
             'context' => 'default',
761 761
             'id'      => isset($args['id'])
762 762
                 ? $args['id']
763
-                : $this->_current_route . '_' . $this->caller . '_' . $func . '_metabox',
763
+                : $this->_current_route.'_'.$this->caller.'_'.$func.'_metabox',
764 764
             'screen'  => isset($args['screen']) ? $args['screen'] : $screen_id,
765 765
         ];
766 766
         $args     = wp_parse_args($args, $defaults);
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_Loader.core.php 2 patches
Indentation   +661 added lines, -661 removed lines patch added patch discarded remove patch
@@ -14,665 +14,665 @@
 block discarded – undo
14 14
 class EE_Admin_Page_Loader
15 15
 {
16 16
 
17
-    /**
18
-     * _installed_pages
19
-     * objects for page_init objects detected and loaded
20
-     *
21
-     * @access private
22
-     * @var EE_Admin_Page_Init[]
23
-     */
24
-    private $_installed_pages = [];
25
-
26
-
27
-    /**
28
-     * this is used to hold the registry of menu slugs for all the installed admin pages
29
-     *
30
-     * @var array
31
-     */
32
-    private $_menu_slugs = [];
33
-
34
-
35
-    /**
36
-     * _caffeinated_extends
37
-     * This array is the generated configuration array for which core EE_Admin pages are extended (and the bits and
38
-     * pieces needed to do so).  This property is defined in the _set_caffeinated method.
39
-     *
40
-     * @var array
41
-     */
42
-    private $_caffeinated_extends = [];
43
-
44
-    /**
45
-     * _prepped_menu_maps
46
-     * This is the prepared array of EE_Admin_Page_Menu_Maps for adding to the admin_menu.
47
-     *
48
-     * @since  4.4.0
49
-     * @var EE_Admin_Page_Menu_Map[]
50
-     */
51
-    private $_prepped_menu_maps = [];
52
-
53
-
54
-    /**
55
-     * _admin_menu_groups
56
-     * array that holds the group headings and details for
57
-     *
58
-     * @access private
59
-     * @var array
60
-     */
61
-    private $_admin_menu_groups = [];
62
-
63
-
64
-    /**
65
-     * This property will hold the hook file for setting up the filter that does all the connections between admin
66
-     * pages.
67
-     *
68
-     * @var string
69
-     */
70
-    public $hook_file;
71
-
72
-    /**
73
-     * @var LoaderInterface
74
-     */
75
-    protected $loader;
76
-
77
-
78
-    /**
79
-     * @throws EE_Error
80
-     */
81
-    public function __construct(LoaderInterface $loader)
82
-    {
83
-        $this->loader = $loader;
84
-        // define the default "groups" for the admin_pages
85
-        $this->_set_menu_groups();
86
-        // let's do a scan and see what installed pages we have
87
-        $this->_get_installed_pages();
88
-        // set menus (has to be done on every load - we're not actually loading the page just setting the menus and where they point to).
89
-        add_action('admin_menu', [$this, 'set_menus']);
90
-        add_action('network_admin_menu', [$this, 'set_network_menus']);
91
-    }
92
-
93
-
94
-    /**
95
-     * When caffeinated system is detected, this method is called to setup the caffeinated directory constants used by
96
-     * files in the caffeinated folder.
97
-     *
98
-     * @access private
99
-     * @return void
100
-     */
101
-    private function _define_caffeinated_constants()
102
-    {
103
-        if (! defined('EE_CORE_CAF_ADMIN')) {
104
-            define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/');
105
-            define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/');
106
-            define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/');
107
-            define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/');
108
-            define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/');
109
-            define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/');
110
-        }
111
-    }
112
-
113
-
114
-    /**
115
-     * _set_menu_groups
116
-     * sets the filterable _admin_menu_groups property (list of various "groupings" within the EE admin menu array)
117
-     *
118
-     * @access private
119
-     * @return void
120
-     */
121
-    private function _set_menu_groups()
122
-    {
123
-        // set array of EE_Admin_Page_Menu_Group objects
124
-        $this->_admin_menu_groups = apply_filters(
125
-            'FHEE__EE_Admin_Page_Loader___set_menu_groups__admin_menu_groups',
126
-            [
127
-                'main'       => $this->loader->getNew(
128
-                    'EE_Admin_Page_Menu_Group',
129
-                    [
130
-                        'menu_label'   => esc_html__('Main', 'event_espresso'),
131
-                        'show_on_menu' => EE_Admin_Page_Menu_Map::NONE,
132
-                        'menu_slug'    => 'main',
133
-                        'capability'   => 'ee_read_ee',
134
-                        'menu_order'   => 0,
135
-                        'parent_slug'  => 'espresso_events',
136
-                    ]
137
-                ),
138
-                'management' => $this->loader->getNew(
139
-                    'EE_Admin_Page_Menu_Group',
140
-                    [
141
-                        'menu_label'   => esc_html__('Management', 'event_espresso'),
142
-                        'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
143
-                        'menu_slug'    => 'management',
144
-                        'capability'   => 'ee_read_ee',
145
-                        'menu_order'   => 10,
146
-                        'parent_slug'  => 'espresso_events',
147
-                    ]
148
-                ),
149
-                'settings'   => $this->loader->getNew(
150
-                    'EE_Admin_Page_Menu_Group',
151
-                    [
152
-                        'menu_label'   => esc_html__('Settings', 'event_espresso'),
153
-                        'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
154
-                        'menu_slug'    => 'settings',
155
-                        'capability'   => 'ee_read_ee',
156
-                        'menu_order'   => 30,
157
-                        'parent_slug'  => 'espresso_events',
158
-                    ]
159
-                ),
160
-                'templates'  => $this->loader->getNew(
161
-                    'EE_Admin_Page_Menu_Group',
162
-                    [
163
-                        'menu_label'   => esc_html__('Templates', 'event_espresso'),
164
-                        'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
165
-                        'menu_slug'    => 'templates',
166
-                        'capability'   => 'ee_read_ee',
167
-                        'menu_order'   => 40,
168
-                        'parent_slug'  => 'espresso_events',
169
-                    ]
170
-                ),
171
-                'extras'     => $this->loader->getNew(
172
-                    'EE_Admin_Page_Menu_Group',
173
-                    [
174
-                        'menu_label'              => esc_html__('Extras', 'event_espresso'),
175
-                        'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
176
-                        'menu_slug'               => 'extras',
177
-                        'capability'              => 'ee_read_ee',
178
-                        'menu_order'              => 50,
179
-                        'parent_slug'             => 'espresso_events',
180
-                        'maintenance_mode_parent' => 'espresso_maintenance_settings',
181
-                    ]
182
-                ),
183
-                'tools'      => $this->loader->getNew(
184
-                    'EE_Admin_Page_Menu_Group',
185
-                    [
186
-                        'menu_label'   => esc_html__('Tools', 'event_espresso'),
187
-                        'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
188
-                        'menu_slug'    => 'tools',
189
-                        'capability'   => 'ee_read_ee',
190
-                        'menu_order'   => 60,
191
-                        'parent_slug'  => 'espresso_events',
192
-                    ]
193
-                ),
194
-                'addons'     => $this->loader->getNew(
195
-                    'EE_Admin_Page_Menu_Group',
196
-                    [
197
-                        'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
198
-                        'menu_label'   => esc_html__('Add-ons', 'event_espresso'),
199
-                        'menu_slug'    => 'addons',
200
-                        'capability'   => 'ee_read_ee',
201
-                        'menu_order'   => 20,
202
-                        'parent_slug'  => 'espresso_events',
203
-                    ]
204
-                ),
205
-            ]
206
-        );
207
-    }
208
-
209
-
210
-    /**
211
-     * This takes all the groups in the _admin_menu_groups array and returns the array indexed by group
212
-     * slug.  The other utility with this function is it validates that all the groups are instances of
213
-     * EE_Admin_Page_Menu_Group (cause some invalid things might have slipped in via addons).
214
-     *
215
-     * @return EE_Admin_Page_Menu_Group[]
216
-     * @throws EE_Error
217
-     * @since  4.4.0
218
-     */
219
-    private function _rearrange_menu_groups()
220
-    {
221
-        $groups = [];
222
-        // first let's order the menu groups by their internal menu order (note usort type hinting to ensure the incoming array is EE_Admin_Page_Menu_Map objects )
223
-        usort($this->_admin_menu_groups, [$this, '_sort_menu_maps']);
224
-        foreach ($this->_admin_menu_groups as $group) {
225
-            if (! $group instanceof EE_Admin_Page_Menu_Group) {
226
-                throw new EE_Error(
227
-                    sprintf(
228
-                        esc_html__(
229
-                            'Unable to continue sorting the menu groups array because there is an invalid value for the menu groups.  All values in this array are required to be a EE_Admin_Page_Menu_Group object.  Instead there was: %s',
230
-                            'event_espresso'
231
-                        ),
232
-                        print_r($group, true)
233
-                    )
234
-                );
235
-            }
236
-            $groups[ $group->menu_slug ] = $group;
237
-        }
238
-        return $groups;
239
-    }
240
-
241
-
242
-    /**
243
-     * _get_installed_pages
244
-     * This just gets the list of installed EE_Admin_pages.
245
-     *
246
-     * @access private
247
-     * @return void
248
-     * @throws EE_Error
249
-     */
250
-    private function _get_installed_pages()
251
-    {
252
-        $installed_refs = [];
253
-        $exclude        = ['assets', 'templates'];
254
-        // grab everything in the  admin core directory
255
-        $admin_screens = glob(EE_ADMIN_PAGES . '*', GLOB_ONLYDIR);
256
-        if ($admin_screens) {
257
-            foreach ($admin_screens as $admin_screen) {
258
-                // files and anything in the exclude array need not apply
259
-                if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) {
260
-                    // these folders represent the different EE admin pages
261
-                    $installed_refs[ basename($admin_screen) ] = $admin_screen;
262
-                }
263
-            }
264
-        }
265
-        if (empty($installed_refs)) {
266
-            $error_msg[] = esc_html__(
267
-                'There are no EE_Admin pages detected, it looks like EE did not install properly',
268
-                'event_espresso'
269
-            );
270
-            $error_msg[] = $error_msg[0] . "\r\n"
271
-                           . sprintf(
272
-                               esc_html__(
273
-                                   'Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.',
274
-                                   'event_espresso'
275
-                               ),
276
-                               EE_ADMIN_PAGES
277
-                           );
278
-            throw new EE_Error(implode('||', $error_msg));
279
-        }
280
-        // this just checks the caffeinated folder and takes care of setting up any caffeinated stuff.
281
-        $installed_refs = $this->_set_caffeinated($installed_refs);
282
-        // allow plugins to add in their own pages (note at this point they will need to have an autoloader defined for their class) OR hook into EEH_Autoloader::load_admin_page() to add their path.;
283
-        $installed_refs             = apply_filters(
284
-            'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs',
285
-            $installed_refs
286
-        );
287
-        $this->_caffeinated_extends = apply_filters(
288
-            'FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends',
289
-            $this->_caffeinated_extends
290
-        );
291
-        // loop through admin pages and setup the $_installed_pages array.
292
-        $hooks_ref = [];
293
-        foreach ($installed_refs as $page => $path) {
294
-            // set autoloaders for our admin page classes based on included path information
295
-            EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($path);
296
-            // build list of installed pages
297
-            $admin_init_page = $this->_load_admin_page($page);
298
-            // verify returned object
299
-            if ($admin_init_page instanceof EE_Admin_Page_Init) {
300
-                $this->_installed_pages[ $page ] = $admin_init_page;
301
-                if (! $admin_init_page->get_menu_map() instanceof EE_Admin_Page_Menu_Map) {
302
-                    continue;
303
-                }
304
-                // skip if in full maintenance mode and maintenance_mode_parent is set
305
-                $maintenance_mode_parent = $admin_init_page->get_menu_map()->maintenance_mode_parent;
306
-                if (
307
-                    empty($maintenance_mode_parent)
308
-                    && EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance
309
-                ) {
310
-                    unset($installed_refs[ $page ]);
311
-                    continue;
312
-                }
313
-                $menu_slug                       = $admin_init_page->get_menu_map()->menu_slug;
314
-                $this->_menu_slugs[ $menu_slug ] = $page;
315
-                // flag for register hooks on extended pages b/c extended pages use the default INIT.
316
-                $extend = false;
317
-                // now that we've got the admin_init objects... lets see if there are any caffeinated pages extending the originals.  If there are then let's hook into the init admin filter and load our extend instead.
318
-                if (isset($this->_caffeinated_extends[ $page ])) {
319
-                    $admin_page_name = $admin_init_page->get_admin_page_name();
320
-                    $caf_path        = $this->_caffeinated_extends[ $page ]['path'];
321
-                    $caf_admin_page  = $this->_caffeinated_extends[ $page ]['admin_page'];
322
-                    add_filter(
323
-                        "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$menu_slug}_{$admin_page_name}",
324
-                        function ($path_to_file) use ($caf_path) {
325
-                            return $caf_path;
326
-                        }
327
-                    );
328
-                    add_filter(
329
-                        "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$menu_slug}_{$admin_page_name}",
330
-                        function ($admin_page) use ($caf_admin_page) {
331
-                            return $caf_admin_page;
332
-                        }
333
-                    );
334
-                    $extend = true;
335
-                }
336
-                // let's do the registered hooks
337
-                $extended_hooks = $admin_init_page->register_hooks($extend);
338
-                $hooks_ref      = array_merge($hooks_ref, $extended_hooks);
339
-            }
340
-        }
341
-        // the hooks_ref is all the pages where we have $extended _Hooks files
342
-        // that will extend a class in a different folder.
343
-        // So we want to make sure we load the file for the parent.
344
-        // first make sure we've got unique values
345
-        $hooks_ref = array_unique($hooks_ref);
346
-        // now let's loop and require!
347
-        foreach ($hooks_ref as $path) {
348
-            require_once($path);
349
-        }
350
-        // make sure we have menu slugs global setup. Used in EE_Admin_Page->page_setup() to ensure we don't do a full class load for an admin page that isn't requested.
351
-        global $ee_menu_slugs;
352
-        $ee_menu_slugs = $this->_menu_slugs;
353
-        // we need to loop again to run any early code
354
-        foreach ($installed_refs as $page => $path) {
355
-            $this->_installed_pages[ $page ]->do_initial_loads();
356
-        }
357
-        do_action('AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages);
358
-    }
359
-
360
-
361
-    /**
362
-     * get_admin_page_object
363
-     *
364
-     * @param string $page_slug
365
-     * @return EE_Admin_Page
366
-     */
367
-    public function get_admin_page_object($page_slug = '')
368
-    {
369
-        if (isset($this->_installed_pages[ $page_slug ])) {
370
-            return $this->_installed_pages[ $page_slug ]->loaded_page_object();
371
-        }
372
-        return null;
373
-    }
374
-
375
-
376
-    /**
377
-     * _get_classname_for_admin_page
378
-     * generates an "Admin Page" class based on the directory  name
379
-     *
380
-     * @param $dir_name
381
-     * @return string
382
-     */
383
-    private function _get_classname_for_admin_page($dir_name = '')
384
-    {
385
-        $class_name = str_replace('_', ' ', strtolower($dir_name));
386
-        return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page';
387
-    }
388
-
389
-
390
-    /**
391
-     * _get_classname_for_admin_init_page
392
-     * generates an "Admin Page Init" class based on the directory  name
393
-     *
394
-     * @param $dir_name
395
-     * @return string
396
-     */
397
-    private function _get_classname_for_admin_init_page($dir_name = '')
398
-    {
399
-        $class_name = str_replace('_', ' ', strtolower($dir_name));
400
-        return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page_Init';
401
-    }
402
-
403
-
404
-    /**
405
-     * _load_admin_page
406
-     * Loads and instantiates page_init object for a single EE_admin page.
407
-     *
408
-     * @param string $page page_reference
409
-     * @return object|bool  return page object if valid, bool false if not.
410
-     * @throws EE_Error
411
-     */
412
-    private function _load_admin_page($page = '')
413
-    {
414
-        $class_name = $this->_get_classname_for_admin_init_page($page);
415
-        if (class_exists($class_name)) {
416
-            return $this->loader->getShared($class_name);
417
-        }
418
-        $error_msg = sprintf(
419
-            esc_html__('Something went wrong with loading the %s admin page.', 'event_espresso'),
420
-            $page
421
-        );
422
-        $error_msg .= '||'; // separates public from developer messages
423
-        $error_msg .= "\r\n";
424
-        $error_msg .= sprintf(
425
-            esc_html__('There is no Init class in place for the %s admin page.', 'event_espresso'),
426
-            $page
427
-        );
428
-        $error_msg .= '<br />';
429
-        $error_msg .= sprintf(
430
-            esc_html__(
431
-                'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
432
-                'event_espresso'
433
-            ),
434
-            '<strong>' . $class_name . '</strong>'
435
-        );
436
-        throw new EE_Error($error_msg);
437
-    }
438
-
439
-
440
-    /**
441
-     * set_menus
442
-     * This method sets up the menus for EE Admin Pages
443
-     *
444
-     * @access private
445
-     * @return void
446
-     * @throws EE_Error
447
-     */
448
-    public function set_menus($network_admin = false)
449
-    {
450
-        // prep the menu pages (sort, group.)
451
-        $this->_prep_pages();
452
-        foreach ($this->_prepped_menu_maps as $menu_map) {
453
-            if (EE_Registry::instance()->CAP->current_user_can($menu_map->capability, $menu_map->menu_slug)) {
454
-                $menu_map->add_menu_page($network_admin);
455
-            }
456
-        }
457
-    }
458
-
459
-
460
-    /**
461
-     * set_network_menus
462
-     * This method sets up the menus for network EE Admin Pages.
463
-     * Almost identical to EE_Admin_Page_Loader::set_menus() except pages
464
-     * are only added to the menu map if they are intended for the admin menu
465
-     *
466
-     * @return void
467
-     * @throws EE_Error
468
-     */
469
-    public function set_network_menus()
470
-    {
471
-        $this->set_menus(true);
472
-    }
473
-
474
-
475
-    /**
476
-     * _prep_pages
477
-     * sets the _prepped_menu_maps property
478
-     *
479
-     * @access private
480
-     * @return void
481
-     * @throws EE_Error
482
-     */
483
-    private function _prep_pages()
484
-    {
485
-        $pages_array = [];
486
-        // rearrange _admin_menu_groups to be indexed by group slug.
487
-        $menu_groups = $this->_rearrange_menu_groups();
488
-        foreach ($this->_installed_pages as $page) {
489
-            if ($page instanceof EE_Admin_page_Init) {
490
-                $page_map = $page->get_menu_map();
491
-                // if we've got an array then the menu map is in the old format so let's throw a persistent notice that the admin system isn't setup correctly for this item.
492
-                if (is_array($page_map) || empty($page_map)) {
493
-                    new PersistentAdminNotice(
494
-                        'menu_map_warning_' . str_replace(' ', '_', $page->label) . '_' . EVENT_ESPRESSO_VERSION,
495
-                        sprintf(
496
-                            esc_html__(
497
-                                'The admin page for %s was not correctly setup because it is using an older method for integrating with Event Espresso Core.  This means that full functionality for this component is not available.  This error message usually appears with an Add-on that is out of date.  Make sure you update all your Event Espresso 4 add-ons to the latest version to ensure they have necessary compatibility updates in place.',
498
-                                'event_espresso'
499
-                            ),
500
-                            $page->label
501
-                        )
502
-                    );
503
-                    continue;
504
-                }
505
-                // if page map is NOT a EE_Admin_Page_Menu_Map object then throw error.
506
-                if (! $page_map instanceof EE_Admin_Page_Menu_Map) {
507
-                    throw new EE_Error(
508
-                        sprintf(
509
-                            esc_html__(
510
-                                'The menu map for %s must be an EE_Admin_Page_Menu_Map object.  Instead it is %s.  Please double check that the menu map has been configured correctly.',
511
-                                'event_espresso'
512
-                            ),
513
-                            $page->label,
514
-                            $page_map
515
-                        )
516
-                    );
517
-                }
518
-                // use the maintenance_mode_parent property and maintenance mode status to determine if this page even gets added to array.
519
-                if (
520
-                    empty($page_map->maintenance_mode_parent)
521
-                    && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance
522
-                ) {
523
-                    continue;
524
-                }
525
-                // assign to group (remember $page_map has the admin page stored in it).
526
-                $pages_array[ $page_map->menu_group ][] = $page_map;
527
-            }
528
-        }
529
-        if (empty($pages_array)) {
530
-            throw new EE_Error(esc_html__('Something went wrong when prepping the admin pages', 'event_espresso'));
531
-        }
532
-        // let's sort the groups, make sure it's a valid group, add header (if to show).
533
-        foreach ($pages_array as $group => $menu_maps) {
534
-            // valid_group?
535
-            if (! array_key_exists($group, $menu_groups)) {
536
-                continue;
537
-            }
538
-            // sort pages.
539
-            usort($menu_maps, [$this, '_sort_menu_maps']);
540
-            // prepend header
541
-            array_unshift($menu_maps, $menu_groups[ $group ]);
542
-            // reset $pages_array with prepped data
543
-            $pages_array[ $group ] = $menu_maps;
544
-        }
545
-        // now let's setup the _prepped_menu_maps property
546
-        foreach ($menu_groups as $group => $group_objs) {
547
-            if (isset($pages_array[ $group ])) {
548
-                $this->_prepped_menu_maps = array_merge($this->_prepped_menu_maps, $pages_array[ $group ]);
549
-            }
550
-        }/**/
551
-    }
552
-
553
-
554
-    /**
555
-     * This method is the "workhorse" for detecting and setting up caffeinated functionality.
556
-     * In this method there are three checks being done:
557
-     * 1. Do we have any NEW admin page sets.  If we do, lets add them into the menu setup (via the $installed_refs
558
-     * array) etc.  (new page sets are found in caffeinated/new/{page})
559
-     * 2. Do we have any EXTENDED page sets.  Basically an extended EE_Admin Page extends the core {child}_Admin_Page
560
-     * class.  eg. would be caffeinated/extend/events/Extend_Events_Admin_Page.core.php and in there would be a class:
561
-     * Extend_Events_Admin_Page extends Events_Admin_Page.
562
-     * 3. Do we have any files just for setting up hooks into other core pages.  The files can be any name in
563
-     * "caffeinated/hooks" EXCEPT they need a ".class.php" extension and the file name must correspond with the
564
-     * classname inside.  These classes are instantiated really early so that any hooks in them are run before the
565
-     * corresponding apply_filters/do_actions that are found in any future loaded EE_Admin pages (INCLUDING caffeinated
566
-     * admin_pages)
567
-     *
568
-     * @param array $installed_refs the original installed_refs array that may contain our NEW EE_Admin_Pages to be
569
-     *                              loaded.
570
-     * @return array
571
-     * @throws EE_Error
572
-     * @throws EE_Error
573
-     */
574
-    private function _set_caffeinated($installed_refs)
575
-    {
576
-
577
-        // first let's check if there IS a caffeinated folder. If there is not then lets get out.
578
-        if (! is_dir(EE_PLUGIN_DIR_PATH . 'caffeinated/admin') || (defined('EE_DECAF') && EE_DECAF)) {
579
-            return $installed_refs;
580
-        }
581
-        $this->_define_caffeinated_constants();
582
-        $exclude = ['tickets'];
583
-        // okay let's setup an "New" pages first (we'll return installed refs later)
584
-        $new_admin_screens = glob(EE_CORE_CAF_ADMIN . 'new/*', GLOB_ONLYDIR);
585
-        if ($new_admin_screens) {
586
-            foreach ($new_admin_screens as $admin_screen) {
587
-                // files and anything in the exclude array need not apply
588
-                if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) {
589
-                    // these folders represent the different NEW EE admin pages
590
-                    $installed_refs[ basename($admin_screen) ] = $admin_screen;
591
-                    // set autoloaders for our admin page classes based on included path information
592
-                    EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($admin_screen);
593
-                }
594
-            }
595
-        }
596
-        // let's see if there are any EXTENDS to setup in the $_caffeinated_extends array (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page)
597
-        $extends = glob(EE_CORE_CAF_ADMIN . 'extend/*', GLOB_ONLYDIR);
598
-        if ($extends) {
599
-            foreach ($extends as $extend) {
600
-                if (is_dir($extend)) {
601
-                    $extend_ref = basename($extend);
602
-                    // now let's make sure there is a file that matches the expected format
603
-                    $filename                                                = str_replace(
604
-                        ' ',
605
-                        '_',
606
-                        ucwords(
607
-                            str_replace(
608
-                                '_',
609
-                                ' ',
610
-                                $extend_ref
611
-                            )
612
-                        )
613
-                    );
614
-                    $filename                                                = 'Extend_' . $filename . '_Admin_Page';
615
-                    $this->_caffeinated_extends[ $extend_ref ]['path']       = str_replace(
616
-                        ['\\', '/'],
617
-                        '/',
618
-                        EE_CORE_CAF_ADMIN
619
-                        . 'extend/'
620
-                        . $extend_ref
621
-                        . '/'
622
-                        . $filename
623
-                        . '.core.php'
624
-                    );
625
-                    $this->_caffeinated_extends[ $extend_ref ]['admin_page'] = $filename;
626
-                    // set autoloaders for our admin page classes based on included path information
627
-                    EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($extend);
628
-                }
629
-            }
630
-        }
631
-        // let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!).
632
-        $ee_admin_hooks = [];
633
-        $hooks          = glob(EE_CORE_CAF_ADMIN . 'hooks/*.class.php');
634
-        if ($hooks) {
635
-            foreach ($hooks as $hook) {
636
-                if (is_readable($hook)) {
637
-                    require_once $hook;
638
-                    $classname = str_replace(EE_CORE_CAF_ADMIN . 'hooks/', '', $hook);
639
-                    $classname = str_replace('.class.php', '', $classname);
640
-                    if (class_exists($classname)) {
641
-                        $ee_admin_hooks[] = $this->loader->getShared($classname);
642
-                    }
643
-                }
644
-            }
645
-        }
646
-        apply_filters('FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks);
647
-        return $installed_refs;
648
-    }
649
-
650
-
651
-    /**
652
-     * Utility method for sorting the _menu_maps (callback for usort php function)
653
-     *
654
-     * @param EE_Admin_Page_Menu_Map $a menu_map object
655
-     * @param EE_Admin_Page_Menu_Map $b being compared to
656
-     * @return int    sort order
657
-     * @since  4.4.0
658
-     */
659
-    private function _sort_menu_maps(EE_Admin_Page_Menu_Map $a, EE_Admin_Page_Menu_Map $b)
660
-    {
661
-        if ($a->menu_order == $b->menu_order) {
662
-            return 0;
663
-        }
664
-        return ($a->menu_order < $b->menu_order) ? -1 : 1;
665
-    }
666
-
667
-
668
-    /**
669
-     * _default_header_link
670
-     * This is just a dummy method to use with header submenu items
671
-     *
672
-     * @return bool false
673
-     */
674
-    public function _default_header_link()
675
-    {
676
-        return false;
677
-    }
17
+	/**
18
+	 * _installed_pages
19
+	 * objects for page_init objects detected and loaded
20
+	 *
21
+	 * @access private
22
+	 * @var EE_Admin_Page_Init[]
23
+	 */
24
+	private $_installed_pages = [];
25
+
26
+
27
+	/**
28
+	 * this is used to hold the registry of menu slugs for all the installed admin pages
29
+	 *
30
+	 * @var array
31
+	 */
32
+	private $_menu_slugs = [];
33
+
34
+
35
+	/**
36
+	 * _caffeinated_extends
37
+	 * This array is the generated configuration array for which core EE_Admin pages are extended (and the bits and
38
+	 * pieces needed to do so).  This property is defined in the _set_caffeinated method.
39
+	 *
40
+	 * @var array
41
+	 */
42
+	private $_caffeinated_extends = [];
43
+
44
+	/**
45
+	 * _prepped_menu_maps
46
+	 * This is the prepared array of EE_Admin_Page_Menu_Maps for adding to the admin_menu.
47
+	 *
48
+	 * @since  4.4.0
49
+	 * @var EE_Admin_Page_Menu_Map[]
50
+	 */
51
+	private $_prepped_menu_maps = [];
52
+
53
+
54
+	/**
55
+	 * _admin_menu_groups
56
+	 * array that holds the group headings and details for
57
+	 *
58
+	 * @access private
59
+	 * @var array
60
+	 */
61
+	private $_admin_menu_groups = [];
62
+
63
+
64
+	/**
65
+	 * This property will hold the hook file for setting up the filter that does all the connections between admin
66
+	 * pages.
67
+	 *
68
+	 * @var string
69
+	 */
70
+	public $hook_file;
71
+
72
+	/**
73
+	 * @var LoaderInterface
74
+	 */
75
+	protected $loader;
76
+
77
+
78
+	/**
79
+	 * @throws EE_Error
80
+	 */
81
+	public function __construct(LoaderInterface $loader)
82
+	{
83
+		$this->loader = $loader;
84
+		// define the default "groups" for the admin_pages
85
+		$this->_set_menu_groups();
86
+		// let's do a scan and see what installed pages we have
87
+		$this->_get_installed_pages();
88
+		// set menus (has to be done on every load - we're not actually loading the page just setting the menus and where they point to).
89
+		add_action('admin_menu', [$this, 'set_menus']);
90
+		add_action('network_admin_menu', [$this, 'set_network_menus']);
91
+	}
92
+
93
+
94
+	/**
95
+	 * When caffeinated system is detected, this method is called to setup the caffeinated directory constants used by
96
+	 * files in the caffeinated folder.
97
+	 *
98
+	 * @access private
99
+	 * @return void
100
+	 */
101
+	private function _define_caffeinated_constants()
102
+	{
103
+		if (! defined('EE_CORE_CAF_ADMIN')) {
104
+			define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/');
105
+			define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/');
106
+			define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/');
107
+			define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/');
108
+			define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/');
109
+			define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/');
110
+		}
111
+	}
112
+
113
+
114
+	/**
115
+	 * _set_menu_groups
116
+	 * sets the filterable _admin_menu_groups property (list of various "groupings" within the EE admin menu array)
117
+	 *
118
+	 * @access private
119
+	 * @return void
120
+	 */
121
+	private function _set_menu_groups()
122
+	{
123
+		// set array of EE_Admin_Page_Menu_Group objects
124
+		$this->_admin_menu_groups = apply_filters(
125
+			'FHEE__EE_Admin_Page_Loader___set_menu_groups__admin_menu_groups',
126
+			[
127
+				'main'       => $this->loader->getNew(
128
+					'EE_Admin_Page_Menu_Group',
129
+					[
130
+						'menu_label'   => esc_html__('Main', 'event_espresso'),
131
+						'show_on_menu' => EE_Admin_Page_Menu_Map::NONE,
132
+						'menu_slug'    => 'main',
133
+						'capability'   => 'ee_read_ee',
134
+						'menu_order'   => 0,
135
+						'parent_slug'  => 'espresso_events',
136
+					]
137
+				),
138
+				'management' => $this->loader->getNew(
139
+					'EE_Admin_Page_Menu_Group',
140
+					[
141
+						'menu_label'   => esc_html__('Management', 'event_espresso'),
142
+						'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
143
+						'menu_slug'    => 'management',
144
+						'capability'   => 'ee_read_ee',
145
+						'menu_order'   => 10,
146
+						'parent_slug'  => 'espresso_events',
147
+					]
148
+				),
149
+				'settings'   => $this->loader->getNew(
150
+					'EE_Admin_Page_Menu_Group',
151
+					[
152
+						'menu_label'   => esc_html__('Settings', 'event_espresso'),
153
+						'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
154
+						'menu_slug'    => 'settings',
155
+						'capability'   => 'ee_read_ee',
156
+						'menu_order'   => 30,
157
+						'parent_slug'  => 'espresso_events',
158
+					]
159
+				),
160
+				'templates'  => $this->loader->getNew(
161
+					'EE_Admin_Page_Menu_Group',
162
+					[
163
+						'menu_label'   => esc_html__('Templates', 'event_espresso'),
164
+						'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
165
+						'menu_slug'    => 'templates',
166
+						'capability'   => 'ee_read_ee',
167
+						'menu_order'   => 40,
168
+						'parent_slug'  => 'espresso_events',
169
+					]
170
+				),
171
+				'extras'     => $this->loader->getNew(
172
+					'EE_Admin_Page_Menu_Group',
173
+					[
174
+						'menu_label'              => esc_html__('Extras', 'event_espresso'),
175
+						'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
176
+						'menu_slug'               => 'extras',
177
+						'capability'              => 'ee_read_ee',
178
+						'menu_order'              => 50,
179
+						'parent_slug'             => 'espresso_events',
180
+						'maintenance_mode_parent' => 'espresso_maintenance_settings',
181
+					]
182
+				),
183
+				'tools'      => $this->loader->getNew(
184
+					'EE_Admin_Page_Menu_Group',
185
+					[
186
+						'menu_label'   => esc_html__('Tools', 'event_espresso'),
187
+						'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
188
+						'menu_slug'    => 'tools',
189
+						'capability'   => 'ee_read_ee',
190
+						'menu_order'   => 60,
191
+						'parent_slug'  => 'espresso_events',
192
+					]
193
+				),
194
+				'addons'     => $this->loader->getNew(
195
+					'EE_Admin_Page_Menu_Group',
196
+					[
197
+						'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN,
198
+						'menu_label'   => esc_html__('Add-ons', 'event_espresso'),
199
+						'menu_slug'    => 'addons',
200
+						'capability'   => 'ee_read_ee',
201
+						'menu_order'   => 20,
202
+						'parent_slug'  => 'espresso_events',
203
+					]
204
+				),
205
+			]
206
+		);
207
+	}
208
+
209
+
210
+	/**
211
+	 * This takes all the groups in the _admin_menu_groups array and returns the array indexed by group
212
+	 * slug.  The other utility with this function is it validates that all the groups are instances of
213
+	 * EE_Admin_Page_Menu_Group (cause some invalid things might have slipped in via addons).
214
+	 *
215
+	 * @return EE_Admin_Page_Menu_Group[]
216
+	 * @throws EE_Error
217
+	 * @since  4.4.0
218
+	 */
219
+	private function _rearrange_menu_groups()
220
+	{
221
+		$groups = [];
222
+		// first let's order the menu groups by their internal menu order (note usort type hinting to ensure the incoming array is EE_Admin_Page_Menu_Map objects )
223
+		usort($this->_admin_menu_groups, [$this, '_sort_menu_maps']);
224
+		foreach ($this->_admin_menu_groups as $group) {
225
+			if (! $group instanceof EE_Admin_Page_Menu_Group) {
226
+				throw new EE_Error(
227
+					sprintf(
228
+						esc_html__(
229
+							'Unable to continue sorting the menu groups array because there is an invalid value for the menu groups.  All values in this array are required to be a EE_Admin_Page_Menu_Group object.  Instead there was: %s',
230
+							'event_espresso'
231
+						),
232
+						print_r($group, true)
233
+					)
234
+				);
235
+			}
236
+			$groups[ $group->menu_slug ] = $group;
237
+		}
238
+		return $groups;
239
+	}
240
+
241
+
242
+	/**
243
+	 * _get_installed_pages
244
+	 * This just gets the list of installed EE_Admin_pages.
245
+	 *
246
+	 * @access private
247
+	 * @return void
248
+	 * @throws EE_Error
249
+	 */
250
+	private function _get_installed_pages()
251
+	{
252
+		$installed_refs = [];
253
+		$exclude        = ['assets', 'templates'];
254
+		// grab everything in the  admin core directory
255
+		$admin_screens = glob(EE_ADMIN_PAGES . '*', GLOB_ONLYDIR);
256
+		if ($admin_screens) {
257
+			foreach ($admin_screens as $admin_screen) {
258
+				// files and anything in the exclude array need not apply
259
+				if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) {
260
+					// these folders represent the different EE admin pages
261
+					$installed_refs[ basename($admin_screen) ] = $admin_screen;
262
+				}
263
+			}
264
+		}
265
+		if (empty($installed_refs)) {
266
+			$error_msg[] = esc_html__(
267
+				'There are no EE_Admin pages detected, it looks like EE did not install properly',
268
+				'event_espresso'
269
+			);
270
+			$error_msg[] = $error_msg[0] . "\r\n"
271
+						   . sprintf(
272
+							   esc_html__(
273
+								   'Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.',
274
+								   'event_espresso'
275
+							   ),
276
+							   EE_ADMIN_PAGES
277
+						   );
278
+			throw new EE_Error(implode('||', $error_msg));
279
+		}
280
+		// this just checks the caffeinated folder and takes care of setting up any caffeinated stuff.
281
+		$installed_refs = $this->_set_caffeinated($installed_refs);
282
+		// allow plugins to add in their own pages (note at this point they will need to have an autoloader defined for their class) OR hook into EEH_Autoloader::load_admin_page() to add their path.;
283
+		$installed_refs             = apply_filters(
284
+			'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs',
285
+			$installed_refs
286
+		);
287
+		$this->_caffeinated_extends = apply_filters(
288
+			'FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends',
289
+			$this->_caffeinated_extends
290
+		);
291
+		// loop through admin pages and setup the $_installed_pages array.
292
+		$hooks_ref = [];
293
+		foreach ($installed_refs as $page => $path) {
294
+			// set autoloaders for our admin page classes based on included path information
295
+			EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($path);
296
+			// build list of installed pages
297
+			$admin_init_page = $this->_load_admin_page($page);
298
+			// verify returned object
299
+			if ($admin_init_page instanceof EE_Admin_Page_Init) {
300
+				$this->_installed_pages[ $page ] = $admin_init_page;
301
+				if (! $admin_init_page->get_menu_map() instanceof EE_Admin_Page_Menu_Map) {
302
+					continue;
303
+				}
304
+				// skip if in full maintenance mode and maintenance_mode_parent is set
305
+				$maintenance_mode_parent = $admin_init_page->get_menu_map()->maintenance_mode_parent;
306
+				if (
307
+					empty($maintenance_mode_parent)
308
+					&& EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance
309
+				) {
310
+					unset($installed_refs[ $page ]);
311
+					continue;
312
+				}
313
+				$menu_slug                       = $admin_init_page->get_menu_map()->menu_slug;
314
+				$this->_menu_slugs[ $menu_slug ] = $page;
315
+				// flag for register hooks on extended pages b/c extended pages use the default INIT.
316
+				$extend = false;
317
+				// now that we've got the admin_init objects... lets see if there are any caffeinated pages extending the originals.  If there are then let's hook into the init admin filter and load our extend instead.
318
+				if (isset($this->_caffeinated_extends[ $page ])) {
319
+					$admin_page_name = $admin_init_page->get_admin_page_name();
320
+					$caf_path        = $this->_caffeinated_extends[ $page ]['path'];
321
+					$caf_admin_page  = $this->_caffeinated_extends[ $page ]['admin_page'];
322
+					add_filter(
323
+						"FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$menu_slug}_{$admin_page_name}",
324
+						function ($path_to_file) use ($caf_path) {
325
+							return $caf_path;
326
+						}
327
+					);
328
+					add_filter(
329
+						"FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$menu_slug}_{$admin_page_name}",
330
+						function ($admin_page) use ($caf_admin_page) {
331
+							return $caf_admin_page;
332
+						}
333
+					);
334
+					$extend = true;
335
+				}
336
+				// let's do the registered hooks
337
+				$extended_hooks = $admin_init_page->register_hooks($extend);
338
+				$hooks_ref      = array_merge($hooks_ref, $extended_hooks);
339
+			}
340
+		}
341
+		// the hooks_ref is all the pages where we have $extended _Hooks files
342
+		// that will extend a class in a different folder.
343
+		// So we want to make sure we load the file for the parent.
344
+		// first make sure we've got unique values
345
+		$hooks_ref = array_unique($hooks_ref);
346
+		// now let's loop and require!
347
+		foreach ($hooks_ref as $path) {
348
+			require_once($path);
349
+		}
350
+		// make sure we have menu slugs global setup. Used in EE_Admin_Page->page_setup() to ensure we don't do a full class load for an admin page that isn't requested.
351
+		global $ee_menu_slugs;
352
+		$ee_menu_slugs = $this->_menu_slugs;
353
+		// we need to loop again to run any early code
354
+		foreach ($installed_refs as $page => $path) {
355
+			$this->_installed_pages[ $page ]->do_initial_loads();
356
+		}
357
+		do_action('AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages);
358
+	}
359
+
360
+
361
+	/**
362
+	 * get_admin_page_object
363
+	 *
364
+	 * @param string $page_slug
365
+	 * @return EE_Admin_Page
366
+	 */
367
+	public function get_admin_page_object($page_slug = '')
368
+	{
369
+		if (isset($this->_installed_pages[ $page_slug ])) {
370
+			return $this->_installed_pages[ $page_slug ]->loaded_page_object();
371
+		}
372
+		return null;
373
+	}
374
+
375
+
376
+	/**
377
+	 * _get_classname_for_admin_page
378
+	 * generates an "Admin Page" class based on the directory  name
379
+	 *
380
+	 * @param $dir_name
381
+	 * @return string
382
+	 */
383
+	private function _get_classname_for_admin_page($dir_name = '')
384
+	{
385
+		$class_name = str_replace('_', ' ', strtolower($dir_name));
386
+		return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page';
387
+	}
388
+
389
+
390
+	/**
391
+	 * _get_classname_for_admin_init_page
392
+	 * generates an "Admin Page Init" class based on the directory  name
393
+	 *
394
+	 * @param $dir_name
395
+	 * @return string
396
+	 */
397
+	private function _get_classname_for_admin_init_page($dir_name = '')
398
+	{
399
+		$class_name = str_replace('_', ' ', strtolower($dir_name));
400
+		return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page_Init';
401
+	}
402
+
403
+
404
+	/**
405
+	 * _load_admin_page
406
+	 * Loads and instantiates page_init object for a single EE_admin page.
407
+	 *
408
+	 * @param string $page page_reference
409
+	 * @return object|bool  return page object if valid, bool false if not.
410
+	 * @throws EE_Error
411
+	 */
412
+	private function _load_admin_page($page = '')
413
+	{
414
+		$class_name = $this->_get_classname_for_admin_init_page($page);
415
+		if (class_exists($class_name)) {
416
+			return $this->loader->getShared($class_name);
417
+		}
418
+		$error_msg = sprintf(
419
+			esc_html__('Something went wrong with loading the %s admin page.', 'event_espresso'),
420
+			$page
421
+		);
422
+		$error_msg .= '||'; // separates public from developer messages
423
+		$error_msg .= "\r\n";
424
+		$error_msg .= sprintf(
425
+			esc_html__('There is no Init class in place for the %s admin page.', 'event_espresso'),
426
+			$page
427
+		);
428
+		$error_msg .= '<br />';
429
+		$error_msg .= sprintf(
430
+			esc_html__(
431
+				'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
432
+				'event_espresso'
433
+			),
434
+			'<strong>' . $class_name . '</strong>'
435
+		);
436
+		throw new EE_Error($error_msg);
437
+	}
438
+
439
+
440
+	/**
441
+	 * set_menus
442
+	 * This method sets up the menus for EE Admin Pages
443
+	 *
444
+	 * @access private
445
+	 * @return void
446
+	 * @throws EE_Error
447
+	 */
448
+	public function set_menus($network_admin = false)
449
+	{
450
+		// prep the menu pages (sort, group.)
451
+		$this->_prep_pages();
452
+		foreach ($this->_prepped_menu_maps as $menu_map) {
453
+			if (EE_Registry::instance()->CAP->current_user_can($menu_map->capability, $menu_map->menu_slug)) {
454
+				$menu_map->add_menu_page($network_admin);
455
+			}
456
+		}
457
+	}
458
+
459
+
460
+	/**
461
+	 * set_network_menus
462
+	 * This method sets up the menus for network EE Admin Pages.
463
+	 * Almost identical to EE_Admin_Page_Loader::set_menus() except pages
464
+	 * are only added to the menu map if they are intended for the admin menu
465
+	 *
466
+	 * @return void
467
+	 * @throws EE_Error
468
+	 */
469
+	public function set_network_menus()
470
+	{
471
+		$this->set_menus(true);
472
+	}
473
+
474
+
475
+	/**
476
+	 * _prep_pages
477
+	 * sets the _prepped_menu_maps property
478
+	 *
479
+	 * @access private
480
+	 * @return void
481
+	 * @throws EE_Error
482
+	 */
483
+	private function _prep_pages()
484
+	{
485
+		$pages_array = [];
486
+		// rearrange _admin_menu_groups to be indexed by group slug.
487
+		$menu_groups = $this->_rearrange_menu_groups();
488
+		foreach ($this->_installed_pages as $page) {
489
+			if ($page instanceof EE_Admin_page_Init) {
490
+				$page_map = $page->get_menu_map();
491
+				// if we've got an array then the menu map is in the old format so let's throw a persistent notice that the admin system isn't setup correctly for this item.
492
+				if (is_array($page_map) || empty($page_map)) {
493
+					new PersistentAdminNotice(
494
+						'menu_map_warning_' . str_replace(' ', '_', $page->label) . '_' . EVENT_ESPRESSO_VERSION,
495
+						sprintf(
496
+							esc_html__(
497
+								'The admin page for %s was not correctly setup because it is using an older method for integrating with Event Espresso Core.  This means that full functionality for this component is not available.  This error message usually appears with an Add-on that is out of date.  Make sure you update all your Event Espresso 4 add-ons to the latest version to ensure they have necessary compatibility updates in place.',
498
+								'event_espresso'
499
+							),
500
+							$page->label
501
+						)
502
+					);
503
+					continue;
504
+				}
505
+				// if page map is NOT a EE_Admin_Page_Menu_Map object then throw error.
506
+				if (! $page_map instanceof EE_Admin_Page_Menu_Map) {
507
+					throw new EE_Error(
508
+						sprintf(
509
+							esc_html__(
510
+								'The menu map for %s must be an EE_Admin_Page_Menu_Map object.  Instead it is %s.  Please double check that the menu map has been configured correctly.',
511
+								'event_espresso'
512
+							),
513
+							$page->label,
514
+							$page_map
515
+						)
516
+					);
517
+				}
518
+				// use the maintenance_mode_parent property and maintenance mode status to determine if this page even gets added to array.
519
+				if (
520
+					empty($page_map->maintenance_mode_parent)
521
+					&& EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance
522
+				) {
523
+					continue;
524
+				}
525
+				// assign to group (remember $page_map has the admin page stored in it).
526
+				$pages_array[ $page_map->menu_group ][] = $page_map;
527
+			}
528
+		}
529
+		if (empty($pages_array)) {
530
+			throw new EE_Error(esc_html__('Something went wrong when prepping the admin pages', 'event_espresso'));
531
+		}
532
+		// let's sort the groups, make sure it's a valid group, add header (if to show).
533
+		foreach ($pages_array as $group => $menu_maps) {
534
+			// valid_group?
535
+			if (! array_key_exists($group, $menu_groups)) {
536
+				continue;
537
+			}
538
+			// sort pages.
539
+			usort($menu_maps, [$this, '_sort_menu_maps']);
540
+			// prepend header
541
+			array_unshift($menu_maps, $menu_groups[ $group ]);
542
+			// reset $pages_array with prepped data
543
+			$pages_array[ $group ] = $menu_maps;
544
+		}
545
+		// now let's setup the _prepped_menu_maps property
546
+		foreach ($menu_groups as $group => $group_objs) {
547
+			if (isset($pages_array[ $group ])) {
548
+				$this->_prepped_menu_maps = array_merge($this->_prepped_menu_maps, $pages_array[ $group ]);
549
+			}
550
+		}/**/
551
+	}
552
+
553
+
554
+	/**
555
+	 * This method is the "workhorse" for detecting and setting up caffeinated functionality.
556
+	 * In this method there are three checks being done:
557
+	 * 1. Do we have any NEW admin page sets.  If we do, lets add them into the menu setup (via the $installed_refs
558
+	 * array) etc.  (new page sets are found in caffeinated/new/{page})
559
+	 * 2. Do we have any EXTENDED page sets.  Basically an extended EE_Admin Page extends the core {child}_Admin_Page
560
+	 * class.  eg. would be caffeinated/extend/events/Extend_Events_Admin_Page.core.php and in there would be a class:
561
+	 * Extend_Events_Admin_Page extends Events_Admin_Page.
562
+	 * 3. Do we have any files just for setting up hooks into other core pages.  The files can be any name in
563
+	 * "caffeinated/hooks" EXCEPT they need a ".class.php" extension and the file name must correspond with the
564
+	 * classname inside.  These classes are instantiated really early so that any hooks in them are run before the
565
+	 * corresponding apply_filters/do_actions that are found in any future loaded EE_Admin pages (INCLUDING caffeinated
566
+	 * admin_pages)
567
+	 *
568
+	 * @param array $installed_refs the original installed_refs array that may contain our NEW EE_Admin_Pages to be
569
+	 *                              loaded.
570
+	 * @return array
571
+	 * @throws EE_Error
572
+	 * @throws EE_Error
573
+	 */
574
+	private function _set_caffeinated($installed_refs)
575
+	{
576
+
577
+		// first let's check if there IS a caffeinated folder. If there is not then lets get out.
578
+		if (! is_dir(EE_PLUGIN_DIR_PATH . 'caffeinated/admin') || (defined('EE_DECAF') && EE_DECAF)) {
579
+			return $installed_refs;
580
+		}
581
+		$this->_define_caffeinated_constants();
582
+		$exclude = ['tickets'];
583
+		// okay let's setup an "New" pages first (we'll return installed refs later)
584
+		$new_admin_screens = glob(EE_CORE_CAF_ADMIN . 'new/*', GLOB_ONLYDIR);
585
+		if ($new_admin_screens) {
586
+			foreach ($new_admin_screens as $admin_screen) {
587
+				// files and anything in the exclude array need not apply
588
+				if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) {
589
+					// these folders represent the different NEW EE admin pages
590
+					$installed_refs[ basename($admin_screen) ] = $admin_screen;
591
+					// set autoloaders for our admin page classes based on included path information
592
+					EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($admin_screen);
593
+				}
594
+			}
595
+		}
596
+		// let's see if there are any EXTENDS to setup in the $_caffeinated_extends array (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page)
597
+		$extends = glob(EE_CORE_CAF_ADMIN . 'extend/*', GLOB_ONLYDIR);
598
+		if ($extends) {
599
+			foreach ($extends as $extend) {
600
+				if (is_dir($extend)) {
601
+					$extend_ref = basename($extend);
602
+					// now let's make sure there is a file that matches the expected format
603
+					$filename                                                = str_replace(
604
+						' ',
605
+						'_',
606
+						ucwords(
607
+							str_replace(
608
+								'_',
609
+								' ',
610
+								$extend_ref
611
+							)
612
+						)
613
+					);
614
+					$filename                                                = 'Extend_' . $filename . '_Admin_Page';
615
+					$this->_caffeinated_extends[ $extend_ref ]['path']       = str_replace(
616
+						['\\', '/'],
617
+						'/',
618
+						EE_CORE_CAF_ADMIN
619
+						. 'extend/'
620
+						. $extend_ref
621
+						. '/'
622
+						. $filename
623
+						. '.core.php'
624
+					);
625
+					$this->_caffeinated_extends[ $extend_ref ]['admin_page'] = $filename;
626
+					// set autoloaders for our admin page classes based on included path information
627
+					EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($extend);
628
+				}
629
+			}
630
+		}
631
+		// let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!).
632
+		$ee_admin_hooks = [];
633
+		$hooks          = glob(EE_CORE_CAF_ADMIN . 'hooks/*.class.php');
634
+		if ($hooks) {
635
+			foreach ($hooks as $hook) {
636
+				if (is_readable($hook)) {
637
+					require_once $hook;
638
+					$classname = str_replace(EE_CORE_CAF_ADMIN . 'hooks/', '', $hook);
639
+					$classname = str_replace('.class.php', '', $classname);
640
+					if (class_exists($classname)) {
641
+						$ee_admin_hooks[] = $this->loader->getShared($classname);
642
+					}
643
+				}
644
+			}
645
+		}
646
+		apply_filters('FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks);
647
+		return $installed_refs;
648
+	}
649
+
650
+
651
+	/**
652
+	 * Utility method for sorting the _menu_maps (callback for usort php function)
653
+	 *
654
+	 * @param EE_Admin_Page_Menu_Map $a menu_map object
655
+	 * @param EE_Admin_Page_Menu_Map $b being compared to
656
+	 * @return int    sort order
657
+	 * @since  4.4.0
658
+	 */
659
+	private function _sort_menu_maps(EE_Admin_Page_Menu_Map $a, EE_Admin_Page_Menu_Map $b)
660
+	{
661
+		if ($a->menu_order == $b->menu_order) {
662
+			return 0;
663
+		}
664
+		return ($a->menu_order < $b->menu_order) ? -1 : 1;
665
+	}
666
+
667
+
668
+	/**
669
+	 * _default_header_link
670
+	 * This is just a dummy method to use with header submenu items
671
+	 *
672
+	 * @return bool false
673
+	 */
674
+	public function _default_header_link()
675
+	{
676
+		return false;
677
+	}
678 678
 }
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
      */
101 101
     private function _define_caffeinated_constants()
102 102
     {
103
-        if (! defined('EE_CORE_CAF_ADMIN')) {
104
-            define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/');
105
-            define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/');
106
-            define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/');
107
-            define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/');
108
-            define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/');
109
-            define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/');
103
+        if ( ! defined('EE_CORE_CAF_ADMIN')) {
104
+            define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH.'caffeinated/admin/');
105
+            define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL.'caffeinated/admin/');
106
+            define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN.'new/');
107
+            define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN.'extend/');
108
+            define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL.'extend/');
109
+            define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN.'hooks/');
110 110
         }
111 111
     }
112 112
 
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
         // first let's order the menu groups by their internal menu order (note usort type hinting to ensure the incoming array is EE_Admin_Page_Menu_Map objects )
223 223
         usort($this->_admin_menu_groups, [$this, '_sort_menu_maps']);
224 224
         foreach ($this->_admin_menu_groups as $group) {
225
-            if (! $group instanceof EE_Admin_Page_Menu_Group) {
225
+            if ( ! $group instanceof EE_Admin_Page_Menu_Group) {
226 226
                 throw new EE_Error(
227 227
                     sprintf(
228 228
                         esc_html__(
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
                     )
234 234
                 );
235 235
             }
236
-            $groups[ $group->menu_slug ] = $group;
236
+            $groups[$group->menu_slug] = $group;
237 237
         }
238 238
         return $groups;
239 239
     }
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
         $installed_refs = [];
253 253
         $exclude        = ['assets', 'templates'];
254 254
         // grab everything in the  admin core directory
255
-        $admin_screens = glob(EE_ADMIN_PAGES . '*', GLOB_ONLYDIR);
255
+        $admin_screens = glob(EE_ADMIN_PAGES.'*', GLOB_ONLYDIR);
256 256
         if ($admin_screens) {
257 257
             foreach ($admin_screens as $admin_screen) {
258 258
                 // files and anything in the exclude array need not apply
259 259
                 if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) {
260 260
                     // these folders represent the different EE admin pages
261
-                    $installed_refs[ basename($admin_screen) ] = $admin_screen;
261
+                    $installed_refs[basename($admin_screen)] = $admin_screen;
262 262
                 }
263 263
             }
264 264
         }
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
                 'There are no EE_Admin pages detected, it looks like EE did not install properly',
268 268
                 'event_espresso'
269 269
             );
270
-            $error_msg[] = $error_msg[0] . "\r\n"
270
+            $error_msg[] = $error_msg[0]."\r\n"
271 271
                            . sprintf(
272 272
                                esc_html__(
273 273
                                    'Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.',
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
         // this just checks the caffeinated folder and takes care of setting up any caffeinated stuff.
281 281
         $installed_refs = $this->_set_caffeinated($installed_refs);
282 282
         // allow plugins to add in their own pages (note at this point they will need to have an autoloader defined for their class) OR hook into EEH_Autoloader::load_admin_page() to add their path.;
283
-        $installed_refs             = apply_filters(
283
+        $installed_refs = apply_filters(
284 284
             'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs',
285 285
             $installed_refs
286 286
         );
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
             $admin_init_page = $this->_load_admin_page($page);
298 298
             // verify returned object
299 299
             if ($admin_init_page instanceof EE_Admin_Page_Init) {
300
-                $this->_installed_pages[ $page ] = $admin_init_page;
301
-                if (! $admin_init_page->get_menu_map() instanceof EE_Admin_Page_Menu_Map) {
300
+                $this->_installed_pages[$page] = $admin_init_page;
301
+                if ( ! $admin_init_page->get_menu_map() instanceof EE_Admin_Page_Menu_Map) {
302 302
                     continue;
303 303
                 }
304 304
                 // skip if in full maintenance mode and maintenance_mode_parent is set
@@ -307,27 +307,27 @@  discard block
 block discarded – undo
307 307
                     empty($maintenance_mode_parent)
308 308
                     && EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance
309 309
                 ) {
310
-                    unset($installed_refs[ $page ]);
310
+                    unset($installed_refs[$page]);
311 311
                     continue;
312 312
                 }
313 313
                 $menu_slug                       = $admin_init_page->get_menu_map()->menu_slug;
314
-                $this->_menu_slugs[ $menu_slug ] = $page;
314
+                $this->_menu_slugs[$menu_slug] = $page;
315 315
                 // flag for register hooks on extended pages b/c extended pages use the default INIT.
316 316
                 $extend = false;
317 317
                 // now that we've got the admin_init objects... lets see if there are any caffeinated pages extending the originals.  If there are then let's hook into the init admin filter and load our extend instead.
318
-                if (isset($this->_caffeinated_extends[ $page ])) {
318
+                if (isset($this->_caffeinated_extends[$page])) {
319 319
                     $admin_page_name = $admin_init_page->get_admin_page_name();
320
-                    $caf_path        = $this->_caffeinated_extends[ $page ]['path'];
321
-                    $caf_admin_page  = $this->_caffeinated_extends[ $page ]['admin_page'];
320
+                    $caf_path        = $this->_caffeinated_extends[$page]['path'];
321
+                    $caf_admin_page  = $this->_caffeinated_extends[$page]['admin_page'];
322 322
                     add_filter(
323 323
                         "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$menu_slug}_{$admin_page_name}",
324
-                        function ($path_to_file) use ($caf_path) {
324
+                        function($path_to_file) use ($caf_path) {
325 325
                             return $caf_path;
326 326
                         }
327 327
                     );
328 328
                     add_filter(
329 329
                         "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$menu_slug}_{$admin_page_name}",
330
-                        function ($admin_page) use ($caf_admin_page) {
330
+                        function($admin_page) use ($caf_admin_page) {
331 331
                             return $caf_admin_page;
332 332
                         }
333 333
                     );
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
         $ee_menu_slugs = $this->_menu_slugs;
353 353
         // we need to loop again to run any early code
354 354
         foreach ($installed_refs as $page => $path) {
355
-            $this->_installed_pages[ $page ]->do_initial_loads();
355
+            $this->_installed_pages[$page]->do_initial_loads();
356 356
         }
357 357
         do_action('AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages);
358 358
     }
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
      */
367 367
     public function get_admin_page_object($page_slug = '')
368 368
     {
369
-        if (isset($this->_installed_pages[ $page_slug ])) {
370
-            return $this->_installed_pages[ $page_slug ]->loaded_page_object();
369
+        if (isset($this->_installed_pages[$page_slug])) {
370
+            return $this->_installed_pages[$page_slug]->loaded_page_object();
371 371
         }
372 372
         return null;
373 373
     }
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
     private function _get_classname_for_admin_page($dir_name = '')
384 384
     {
385 385
         $class_name = str_replace('_', ' ', strtolower($dir_name));
386
-        return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page';
386
+        return str_replace(' ', '_', ucwords($class_name)).'_Admin_Page';
387 387
     }
388 388
 
389 389
 
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
     private function _get_classname_for_admin_init_page($dir_name = '')
398 398
     {
399 399
         $class_name = str_replace('_', ' ', strtolower($dir_name));
400
-        return str_replace(' ', '_', ucwords($class_name)) . '_Admin_Page_Init';
400
+        return str_replace(' ', '_', ucwords($class_name)).'_Admin_Page_Init';
401 401
     }
402 402
 
403 403
 
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
                 'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
432 432
                 'event_espresso'
433 433
             ),
434
-            '<strong>' . $class_name . '</strong>'
434
+            '<strong>'.$class_name.'</strong>'
435 435
         );
436 436
         throw new EE_Error($error_msg);
437 437
     }
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
                 // if we've got an array then the menu map is in the old format so let's throw a persistent notice that the admin system isn't setup correctly for this item.
492 492
                 if (is_array($page_map) || empty($page_map)) {
493 493
                     new PersistentAdminNotice(
494
-                        'menu_map_warning_' . str_replace(' ', '_', $page->label) . '_' . EVENT_ESPRESSO_VERSION,
494
+                        'menu_map_warning_'.str_replace(' ', '_', $page->label).'_'.EVENT_ESPRESSO_VERSION,
495 495
                         sprintf(
496 496
                             esc_html__(
497 497
                                 'The admin page for %s was not correctly setup because it is using an older method for integrating with Event Espresso Core.  This means that full functionality for this component is not available.  This error message usually appears with an Add-on that is out of date.  Make sure you update all your Event Espresso 4 add-ons to the latest version to ensure they have necessary compatibility updates in place.',
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
                     continue;
504 504
                 }
505 505
                 // if page map is NOT a EE_Admin_Page_Menu_Map object then throw error.
506
-                if (! $page_map instanceof EE_Admin_Page_Menu_Map) {
506
+                if ( ! $page_map instanceof EE_Admin_Page_Menu_Map) {
507 507
                     throw new EE_Error(
508 508
                         sprintf(
509 509
                             esc_html__(
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
                     continue;
524 524
                 }
525 525
                 // assign to group (remember $page_map has the admin page stored in it).
526
-                $pages_array[ $page_map->menu_group ][] = $page_map;
526
+                $pages_array[$page_map->menu_group][] = $page_map;
527 527
             }
528 528
         }
529 529
         if (empty($pages_array)) {
@@ -532,20 +532,20 @@  discard block
 block discarded – undo
532 532
         // let's sort the groups, make sure it's a valid group, add header (if to show).
533 533
         foreach ($pages_array as $group => $menu_maps) {
534 534
             // valid_group?
535
-            if (! array_key_exists($group, $menu_groups)) {
535
+            if ( ! array_key_exists($group, $menu_groups)) {
536 536
                 continue;
537 537
             }
538 538
             // sort pages.
539 539
             usort($menu_maps, [$this, '_sort_menu_maps']);
540 540
             // prepend header
541
-            array_unshift($menu_maps, $menu_groups[ $group ]);
541
+            array_unshift($menu_maps, $menu_groups[$group]);
542 542
             // reset $pages_array with prepped data
543
-            $pages_array[ $group ] = $menu_maps;
543
+            $pages_array[$group] = $menu_maps;
544 544
         }
545 545
         // now let's setup the _prepped_menu_maps property
546 546
         foreach ($menu_groups as $group => $group_objs) {
547
-            if (isset($pages_array[ $group ])) {
548
-                $this->_prepped_menu_maps = array_merge($this->_prepped_menu_maps, $pages_array[ $group ]);
547
+            if (isset($pages_array[$group])) {
548
+                $this->_prepped_menu_maps = array_merge($this->_prepped_menu_maps, $pages_array[$group]);
549 549
             }
550 550
         }/**/
551 551
     }
@@ -575,32 +575,32 @@  discard block
 block discarded – undo
575 575
     {
576 576
 
577 577
         // first let's check if there IS a caffeinated folder. If there is not then lets get out.
578
-        if (! is_dir(EE_PLUGIN_DIR_PATH . 'caffeinated/admin') || (defined('EE_DECAF') && EE_DECAF)) {
578
+        if ( ! is_dir(EE_PLUGIN_DIR_PATH.'caffeinated/admin') || (defined('EE_DECAF') && EE_DECAF)) {
579 579
             return $installed_refs;
580 580
         }
581 581
         $this->_define_caffeinated_constants();
582 582
         $exclude = ['tickets'];
583 583
         // okay let's setup an "New" pages first (we'll return installed refs later)
584
-        $new_admin_screens = glob(EE_CORE_CAF_ADMIN . 'new/*', GLOB_ONLYDIR);
584
+        $new_admin_screens = glob(EE_CORE_CAF_ADMIN.'new/*', GLOB_ONLYDIR);
585 585
         if ($new_admin_screens) {
586 586
             foreach ($new_admin_screens as $admin_screen) {
587 587
                 // files and anything in the exclude array need not apply
588 588
                 if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) {
589 589
                     // these folders represent the different NEW EE admin pages
590
-                    $installed_refs[ basename($admin_screen) ] = $admin_screen;
590
+                    $installed_refs[basename($admin_screen)] = $admin_screen;
591 591
                     // set autoloaders for our admin page classes based on included path information
592 592
                     EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($admin_screen);
593 593
                 }
594 594
             }
595 595
         }
596 596
         // let's see if there are any EXTENDS to setup in the $_caffeinated_extends array (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page)
597
-        $extends = glob(EE_CORE_CAF_ADMIN . 'extend/*', GLOB_ONLYDIR);
597
+        $extends = glob(EE_CORE_CAF_ADMIN.'extend/*', GLOB_ONLYDIR);
598 598
         if ($extends) {
599 599
             foreach ($extends as $extend) {
600 600
                 if (is_dir($extend)) {
601 601
                     $extend_ref = basename($extend);
602 602
                     // now let's make sure there is a file that matches the expected format
603
-                    $filename                                                = str_replace(
603
+                    $filename = str_replace(
604 604
                         ' ',
605 605
                         '_',
606 606
                         ucwords(
@@ -611,8 +611,8 @@  discard block
 block discarded – undo
611 611
                             )
612 612
                         )
613 613
                     );
614
-                    $filename                                                = 'Extend_' . $filename . '_Admin_Page';
615
-                    $this->_caffeinated_extends[ $extend_ref ]['path']       = str_replace(
614
+                    $filename                                                = 'Extend_'.$filename.'_Admin_Page';
615
+                    $this->_caffeinated_extends[$extend_ref]['path']       = str_replace(
616 616
                         ['\\', '/'],
617 617
                         '/',
618 618
                         EE_CORE_CAF_ADMIN
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
                         . $filename
623 623
                         . '.core.php'
624 624
                     );
625
-                    $this->_caffeinated_extends[ $extend_ref ]['admin_page'] = $filename;
625
+                    $this->_caffeinated_extends[$extend_ref]['admin_page'] = $filename;
626 626
                     // set autoloaders for our admin page classes based on included path information
627 627
                     EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($extend);
628 628
                 }
@@ -630,12 +630,12 @@  discard block
 block discarded – undo
630 630
         }
631 631
         // let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!).
632 632
         $ee_admin_hooks = [];
633
-        $hooks          = glob(EE_CORE_CAF_ADMIN . 'hooks/*.class.php');
633
+        $hooks          = glob(EE_CORE_CAF_ADMIN.'hooks/*.class.php');
634 634
         if ($hooks) {
635 635
             foreach ($hooks as $hook) {
636 636
                 if (is_readable($hook)) {
637 637
                     require_once $hook;
638
-                    $classname = str_replace(EE_CORE_CAF_ADMIN . 'hooks/', '', $hook);
638
+                    $classname = str_replace(EE_CORE_CAF_ADMIN.'hooks/', '', $hook);
639 639
                     $classname = str_replace('.class.php', '', $classname);
640 640
                     if (class_exists($classname)) {
641 641
                         $ee_admin_hooks[] = $this->loader->getShared($classname);
Please login to merge, or discard this patch.
core/admin/EE_Admin_List_Table.core.php 2 patches
Indentation   +860 added lines, -860 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (! class_exists('WP_List_Table')) {
4
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
4
+	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
5 5
 }
6 6
 
7 7
 
@@ -20,873 +20,873 @@  discard block
 block discarded – undo
20 20
 abstract class EE_Admin_List_Table extends WP_List_Table
21 21
 {
22 22
 
23
-    /**
24
-     * holds the data that will be processed for the table
25
-     *
26
-     * @var array $_data
27
-     */
28
-    protected $_data;
29
-
30
-
31
-    /**
32
-     * This holds the value of all the data available for the given view (for all pages).
33
-     *
34
-     * @var int $_all_data_count
35
-     */
36
-    protected $_all_data_count;
37
-
38
-
39
-    /**
40
-     * Will contain the count of trashed items for the view label.
41
-     *
42
-     * @var int $_trashed_count
43
-     */
44
-    protected $_trashed_count;
45
-
46
-
47
-    /**
48
-     * This is what will be referenced as the slug for the current screen
49
-     *
50
-     * @var string $_screen
51
-     */
52
-    protected $_screen;
53
-
54
-
55
-    /**
56
-     * this is the EE_Admin_Page object
57
-     *
58
-     * @var EE_Admin_Page $_admin_page
59
-     */
60
-    protected $_admin_page;
61
-
62
-
63
-    /**
64
-     * The current view
65
-     *
66
-     * @var string $_view
67
-     */
68
-    protected $_view;
69
-
70
-
71
-    /**
72
-     * array of possible views for this table
73
-     *
74
-     * @var array $_views
75
-     */
76
-    protected $_views;
77
-
78
-
79
-    /**
80
-     * An array of key => value pairs containing information about the current table
81
-     * array(
82
-     *        'plural' => 'plural label',
83
-     *        'singular' => 'singular label',
84
-     *        'ajax' => false, //whether to use ajax or not
85
-     *        'screen' => null, //string used to reference what screen this is
86
-     *        (WP_List_table converts to screen object)
87
-     * )
88
-     *
89
-     * @var array $_wp_list_args
90
-     */
91
-    protected $_wp_list_args;
92
-
93
-    /**
94
-     * an array of column names
95
-     * array(
96
-     *    'internal-name' => 'Title'
97
-     * )
98
-     *
99
-     * @var array $_columns
100
-     */
101
-    protected $_columns;
102
-
103
-    /**
104
-     * An array of sortable columns
105
-     * array(
106
-     *    'internal-name' => 'orderby' //or
107
-     *    'internal-name' => array( 'orderby', true )
108
-     * )
109
-     *
110
-     * @var array $_sortable_columns
111
-     */
112
-    protected $_sortable_columns;
113
-
114
-    /**
115
-     * callback method used to perform AJAX row reordering
116
-     *
117
-     * @var string $_ajax_sorting_callback
118
-     */
119
-    protected $_ajax_sorting_callback;
120
-
121
-    /**
122
-     * An array of hidden columns (if needed)
123
-     * array('internal-name', 'internal-name')
124
-     *
125
-     * @var array $_hidden_columns
126
-     */
127
-    protected $_hidden_columns;
128
-
129
-    /**
130
-     * holds the per_page value
131
-     *
132
-     * @var int $_per_page
133
-     */
134
-    protected $_per_page;
135
-
136
-    /**
137
-     * holds what page number is currently being viewed
138
-     *
139
-     * @var int $_current_page
140
-     */
141
-    protected $_current_page;
142
-
143
-    /**
144
-     * the reference string for the nonce_action
145
-     *
146
-     * @var string $_nonce_action_ref
147
-     */
148
-    protected $_nonce_action_ref;
149
-
150
-    /**
151
-     * property to hold incoming request data (as set by the admin_page_core)
152
-     *
153
-     * @var array $_req_data
154
-     */
155
-    protected $_req_data;
156
-
157
-
158
-    /**
159
-     * yes / no array for admin form fields
160
-     *
161
-     * @var array $_yes_no
162
-     */
163
-    protected $_yes_no = [];
164
-
165
-    /**
166
-     * Array describing buttons that should appear at the bottom of the page
167
-     * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
168
-     * and the values are another array with the following keys
169
-     * array(
170
-     *    'route' => 'page_route',
171
-     *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
172
-     * )
173
-     *
174
-     * @var array $_bottom_buttons
175
-     */
176
-    protected $_bottom_buttons = [];
177
-
178
-
179
-    /**
180
-     * Used to indicate what should be the primary column for the list table.
181
-     * If not present then falls back to what WP calculates
182
-     * as the primary column.
183
-     *
184
-     * @type string $_primary_column
185
-     */
186
-    protected $_primary_column = '';
187
-
188
-
189
-    /**
190
-     * Used to indicate whether the table has a checkbox column or not.
191
-     *
192
-     * @type bool $_has_checkbox_column
193
-     */
194
-    protected $_has_checkbox_column = false;
195
-
196
-
197
-    /**
198
-     * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
199
-     */
200
-    public function __construct(EE_Admin_Page $admin_page)
201
-    {
202
-        $this->_admin_page   = $admin_page;
203
-        $this->_req_data     = $this->_admin_page->get_request_data();
204
-        $this->_view         = $this->_admin_page->get_view();
205
-        $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
206
-        $this->_current_page = $this->get_pagenum();
207
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
208
-        $this->_yes_no       = [
209
-            esc_html__('No', 'event_espresso'),
210
-            esc_html__('Yes', 'event_espresso')
211
-        ];
212
-
213
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
214
-
215
-        $this->_setup_data();
216
-        $this->_add_view_counts();
217
-
218
-        $this->_nonce_action_ref = $this->_view;
219
-
220
-        $this->_set_properties();
221
-
222
-        // set primary column
223
-        add_filter('list_table_primary_column', [$this, 'set_primary_column']);
224
-
225
-        // set parent defaults
226
-        parent::__construct($this->_wp_list_args);
227
-
228
-        $this->prepare_items();
229
-    }
230
-
231
-
232
-    /**
233
-     * _setup_data
234
-     * this method is used to setup the $_data, $_all_data_count, and _per_page properties
235
-     *
236
-     * @return void
237
-     * @uses $this->_admin_page
238
-     */
239
-    abstract protected function _setup_data();
240
-
241
-
242
-    /**
243
-     * set the properties that this class needs to be able to execute wp_list_table properly
244
-     * properties set:
245
-     * _wp_list_args = what the arguments required for the parent _wp_list_table.
246
-     * _columns = set the columns in an array.
247
-     * _sortable_columns = columns that are sortable (array).
248
-     * _hidden_columns = columns that are hidden (array)
249
-     * _default_orderby = the default orderby for sorting.
250
-     *
251
-     * @abstract
252
-     * @access protected
253
-     * @return void
254
-     */
255
-    abstract protected function _set_properties();
256
-
257
-
258
-    /**
259
-     * _get_table_filters
260
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
261
-     * gets shown in the table.
262
-     *
263
-     * @abstract
264
-     * @access protected
265
-     * @return string
266
-     */
267
-    abstract protected function _get_table_filters();
268
-
269
-
270
-    /**
271
-     * this is a method that child class will do to add counts to the views array so when views are displayed the
272
-     * counts of the views is accurate.
273
-     *
274
-     * @abstract
275
-     * @access protected
276
-     * @return void
277
-     */
278
-    abstract protected function _add_view_counts();
279
-
280
-
281
-    /**
282
-     * _get_hidden_fields
283
-     * returns a html string of hidden fields so if any table filters are used the current view will be respected.
284
-     *
285
-     * @return string
286
-     */
287
-    protected function _get_hidden_fields()
288
-    {
289
-        $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
290
-        $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
291
-        // if action is STILL empty, then we set it to default
292
-        $action = empty($action) ? 'default' : $action;
293
-        $field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
294
-        $field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
295
-        $field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
296
-
297
-        $bulk_actions = $this->_get_bulk_actions();
298
-        foreach ($bulk_actions as $bulk_action => $label) {
299
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
300
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
301
-        }
302
-
303
-        return $field;
304
-    }
305
-
306
-
307
-    /**
308
-     * _set_column_info
309
-     * we're using this to set the column headers property.
310
-     *
311
-     * @access protected
312
-     * @return void
313
-     */
314
-    protected function _set_column_info()
315
-    {
316
-        $columns   = $this->get_columns();
317
-        $hidden    = $this->get_hidden_columns();
318
-        $_sortable = $this->get_sortable_columns();
319
-
320
-        /**
321
-         * Dynamic hook allowing for adding sortable columns in this list table.
322
-         * Note that $this->screen->id is in the format
323
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
324
-         * table it is: event-espresso_page_espresso_messages.
325
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
326
-         * hook prefix ("event-espresso") will be different.
327
-         *
328
-         * @var array
329
-         */
330
-        $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
331
-
332
-        $sortable = [];
333
-        foreach ($_sortable as $id => $data) {
334
-            if (empty($data)) {
335
-                continue;
336
-            }
337
-            // fix for offset errors with WP_List_Table default get_columninfo()
338
-            if (is_array($data)) {
339
-                $_data[0] = key($data);
340
-                $_data[1] = isset($data[1]) ? $data[1] : false;
341
-            } else {
342
-                $_data[0] = $data;
343
-            }
344
-
345
-            $data = (array) $data;
346
-
347
-            if (! isset($data[1])) {
348
-                $_data[1] = false;
349
-            }
350
-
351
-            $sortable[ $id ] = $_data;
352
-        }
353
-        $primary               = $this->get_primary_column_name();
354
-        $this->_column_headers = [$columns, $hidden, $sortable, $primary];
355
-    }
356
-
357
-
358
-    /**
359
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
360
-     *
361
-     * @return string
362
-     */
363
-    protected function get_primary_column_name()
364
-    {
365
-        foreach (class_parents($this) as $parent) {
366
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
367
-                return parent::get_primary_column_name();
368
-            }
369
-        }
370
-        return $this->_primary_column;
371
-    }
372
-
373
-
374
-    /**
375
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
376
-     *
377
-     * @param EE_Base_Class $item
378
-     * @param string        $column_name
379
-     * @param string        $primary
380
-     * @return string
381
-     */
382
-    protected function handle_row_actions($item, $column_name, $primary)
383
-    {
384
-        foreach (class_parents($this) as $parent) {
385
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
386
-                return parent::handle_row_actions($item, $column_name, $primary);
387
-            }
388
-        }
389
-        return '';
390
-    }
391
-
392
-
393
-    /**
394
-     * _get_bulk_actions
395
-     * This is a wrapper called by WP_List_Table::get_bulk_actions()
396
-     *
397
-     * @access protected
398
-     * @return array bulk_actions
399
-     */
400
-    protected function _get_bulk_actions()
401
-    {
402
-        $actions = [];
403
-        // the _views property should have the bulk_actions, so let's go through and extract them into a properly
404
-        // formatted array for the wp_list_table();
405
-        foreach ($this->_views as $view => $args) {
406
-            if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
407
-                // each bulk action will correspond with a admin page route, so we can check whatever the capability is
408
-                // for that page route and skip adding the bulk action if no access for the current logged in user.
409
-                foreach ($args['bulk_action'] as $route => $label) {
410
-                    if ($this->_admin_page->check_user_access($route, true)) {
411
-                        $actions[ $route ] = $label;
412
-                    }
413
-                }
414
-            }
415
-        }
416
-        return $actions;
417
-    }
418
-
419
-
420
-    /**
421
-     * Generate the table navigation above or below the table.
422
-     * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
423
-     *
424
-     * @throws EE_Error
425
-     * @since 4.9.44.rc.001
426
-     */
427
-    public function display_tablenav($which)
428
-    {
429
-        if ('top' === $which) {
430
-            wp_nonce_field('bulk-' . $this->_args['plural']);
431
-        }
432
-        ?>
23
+	/**
24
+	 * holds the data that will be processed for the table
25
+	 *
26
+	 * @var array $_data
27
+	 */
28
+	protected $_data;
29
+
30
+
31
+	/**
32
+	 * This holds the value of all the data available for the given view (for all pages).
33
+	 *
34
+	 * @var int $_all_data_count
35
+	 */
36
+	protected $_all_data_count;
37
+
38
+
39
+	/**
40
+	 * Will contain the count of trashed items for the view label.
41
+	 *
42
+	 * @var int $_trashed_count
43
+	 */
44
+	protected $_trashed_count;
45
+
46
+
47
+	/**
48
+	 * This is what will be referenced as the slug for the current screen
49
+	 *
50
+	 * @var string $_screen
51
+	 */
52
+	protected $_screen;
53
+
54
+
55
+	/**
56
+	 * this is the EE_Admin_Page object
57
+	 *
58
+	 * @var EE_Admin_Page $_admin_page
59
+	 */
60
+	protected $_admin_page;
61
+
62
+
63
+	/**
64
+	 * The current view
65
+	 *
66
+	 * @var string $_view
67
+	 */
68
+	protected $_view;
69
+
70
+
71
+	/**
72
+	 * array of possible views for this table
73
+	 *
74
+	 * @var array $_views
75
+	 */
76
+	protected $_views;
77
+
78
+
79
+	/**
80
+	 * An array of key => value pairs containing information about the current table
81
+	 * array(
82
+	 *        'plural' => 'plural label',
83
+	 *        'singular' => 'singular label',
84
+	 *        'ajax' => false, //whether to use ajax or not
85
+	 *        'screen' => null, //string used to reference what screen this is
86
+	 *        (WP_List_table converts to screen object)
87
+	 * )
88
+	 *
89
+	 * @var array $_wp_list_args
90
+	 */
91
+	protected $_wp_list_args;
92
+
93
+	/**
94
+	 * an array of column names
95
+	 * array(
96
+	 *    'internal-name' => 'Title'
97
+	 * )
98
+	 *
99
+	 * @var array $_columns
100
+	 */
101
+	protected $_columns;
102
+
103
+	/**
104
+	 * An array of sortable columns
105
+	 * array(
106
+	 *    'internal-name' => 'orderby' //or
107
+	 *    'internal-name' => array( 'orderby', true )
108
+	 * )
109
+	 *
110
+	 * @var array $_sortable_columns
111
+	 */
112
+	protected $_sortable_columns;
113
+
114
+	/**
115
+	 * callback method used to perform AJAX row reordering
116
+	 *
117
+	 * @var string $_ajax_sorting_callback
118
+	 */
119
+	protected $_ajax_sorting_callback;
120
+
121
+	/**
122
+	 * An array of hidden columns (if needed)
123
+	 * array('internal-name', 'internal-name')
124
+	 *
125
+	 * @var array $_hidden_columns
126
+	 */
127
+	protected $_hidden_columns;
128
+
129
+	/**
130
+	 * holds the per_page value
131
+	 *
132
+	 * @var int $_per_page
133
+	 */
134
+	protected $_per_page;
135
+
136
+	/**
137
+	 * holds what page number is currently being viewed
138
+	 *
139
+	 * @var int $_current_page
140
+	 */
141
+	protected $_current_page;
142
+
143
+	/**
144
+	 * the reference string for the nonce_action
145
+	 *
146
+	 * @var string $_nonce_action_ref
147
+	 */
148
+	protected $_nonce_action_ref;
149
+
150
+	/**
151
+	 * property to hold incoming request data (as set by the admin_page_core)
152
+	 *
153
+	 * @var array $_req_data
154
+	 */
155
+	protected $_req_data;
156
+
157
+
158
+	/**
159
+	 * yes / no array for admin form fields
160
+	 *
161
+	 * @var array $_yes_no
162
+	 */
163
+	protected $_yes_no = [];
164
+
165
+	/**
166
+	 * Array describing buttons that should appear at the bottom of the page
167
+	 * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
168
+	 * and the values are another array with the following keys
169
+	 * array(
170
+	 *    'route' => 'page_route',
171
+	 *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
172
+	 * )
173
+	 *
174
+	 * @var array $_bottom_buttons
175
+	 */
176
+	protected $_bottom_buttons = [];
177
+
178
+
179
+	/**
180
+	 * Used to indicate what should be the primary column for the list table.
181
+	 * If not present then falls back to what WP calculates
182
+	 * as the primary column.
183
+	 *
184
+	 * @type string $_primary_column
185
+	 */
186
+	protected $_primary_column = '';
187
+
188
+
189
+	/**
190
+	 * Used to indicate whether the table has a checkbox column or not.
191
+	 *
192
+	 * @type bool $_has_checkbox_column
193
+	 */
194
+	protected $_has_checkbox_column = false;
195
+
196
+
197
+	/**
198
+	 * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
199
+	 */
200
+	public function __construct(EE_Admin_Page $admin_page)
201
+	{
202
+		$this->_admin_page   = $admin_page;
203
+		$this->_req_data     = $this->_admin_page->get_request_data();
204
+		$this->_view         = $this->_admin_page->get_view();
205
+		$this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
206
+		$this->_current_page = $this->get_pagenum();
207
+		$this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
208
+		$this->_yes_no       = [
209
+			esc_html__('No', 'event_espresso'),
210
+			esc_html__('Yes', 'event_espresso')
211
+		];
212
+
213
+		$this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
214
+
215
+		$this->_setup_data();
216
+		$this->_add_view_counts();
217
+
218
+		$this->_nonce_action_ref = $this->_view;
219
+
220
+		$this->_set_properties();
221
+
222
+		// set primary column
223
+		add_filter('list_table_primary_column', [$this, 'set_primary_column']);
224
+
225
+		// set parent defaults
226
+		parent::__construct($this->_wp_list_args);
227
+
228
+		$this->prepare_items();
229
+	}
230
+
231
+
232
+	/**
233
+	 * _setup_data
234
+	 * this method is used to setup the $_data, $_all_data_count, and _per_page properties
235
+	 *
236
+	 * @return void
237
+	 * @uses $this->_admin_page
238
+	 */
239
+	abstract protected function _setup_data();
240
+
241
+
242
+	/**
243
+	 * set the properties that this class needs to be able to execute wp_list_table properly
244
+	 * properties set:
245
+	 * _wp_list_args = what the arguments required for the parent _wp_list_table.
246
+	 * _columns = set the columns in an array.
247
+	 * _sortable_columns = columns that are sortable (array).
248
+	 * _hidden_columns = columns that are hidden (array)
249
+	 * _default_orderby = the default orderby for sorting.
250
+	 *
251
+	 * @abstract
252
+	 * @access protected
253
+	 * @return void
254
+	 */
255
+	abstract protected function _set_properties();
256
+
257
+
258
+	/**
259
+	 * _get_table_filters
260
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
261
+	 * gets shown in the table.
262
+	 *
263
+	 * @abstract
264
+	 * @access protected
265
+	 * @return string
266
+	 */
267
+	abstract protected function _get_table_filters();
268
+
269
+
270
+	/**
271
+	 * this is a method that child class will do to add counts to the views array so when views are displayed the
272
+	 * counts of the views is accurate.
273
+	 *
274
+	 * @abstract
275
+	 * @access protected
276
+	 * @return void
277
+	 */
278
+	abstract protected function _add_view_counts();
279
+
280
+
281
+	/**
282
+	 * _get_hidden_fields
283
+	 * returns a html string of hidden fields so if any table filters are used the current view will be respected.
284
+	 *
285
+	 * @return string
286
+	 */
287
+	protected function _get_hidden_fields()
288
+	{
289
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
290
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
291
+		// if action is STILL empty, then we set it to default
292
+		$action = empty($action) ? 'default' : $action;
293
+		$field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
294
+		$field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
295
+		$field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
296
+
297
+		$bulk_actions = $this->_get_bulk_actions();
298
+		foreach ($bulk_actions as $bulk_action => $label) {
299
+			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
300
+					  . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
301
+		}
302
+
303
+		return $field;
304
+	}
305
+
306
+
307
+	/**
308
+	 * _set_column_info
309
+	 * we're using this to set the column headers property.
310
+	 *
311
+	 * @access protected
312
+	 * @return void
313
+	 */
314
+	protected function _set_column_info()
315
+	{
316
+		$columns   = $this->get_columns();
317
+		$hidden    = $this->get_hidden_columns();
318
+		$_sortable = $this->get_sortable_columns();
319
+
320
+		/**
321
+		 * Dynamic hook allowing for adding sortable columns in this list table.
322
+		 * Note that $this->screen->id is in the format
323
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
324
+		 * table it is: event-espresso_page_espresso_messages.
325
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
326
+		 * hook prefix ("event-espresso") will be different.
327
+		 *
328
+		 * @var array
329
+		 */
330
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
331
+
332
+		$sortable = [];
333
+		foreach ($_sortable as $id => $data) {
334
+			if (empty($data)) {
335
+				continue;
336
+			}
337
+			// fix for offset errors with WP_List_Table default get_columninfo()
338
+			if (is_array($data)) {
339
+				$_data[0] = key($data);
340
+				$_data[1] = isset($data[1]) ? $data[1] : false;
341
+			} else {
342
+				$_data[0] = $data;
343
+			}
344
+
345
+			$data = (array) $data;
346
+
347
+			if (! isset($data[1])) {
348
+				$_data[1] = false;
349
+			}
350
+
351
+			$sortable[ $id ] = $_data;
352
+		}
353
+		$primary               = $this->get_primary_column_name();
354
+		$this->_column_headers = [$columns, $hidden, $sortable, $primary];
355
+	}
356
+
357
+
358
+	/**
359
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
360
+	 *
361
+	 * @return string
362
+	 */
363
+	protected function get_primary_column_name()
364
+	{
365
+		foreach (class_parents($this) as $parent) {
366
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
367
+				return parent::get_primary_column_name();
368
+			}
369
+		}
370
+		return $this->_primary_column;
371
+	}
372
+
373
+
374
+	/**
375
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
376
+	 *
377
+	 * @param EE_Base_Class $item
378
+	 * @param string        $column_name
379
+	 * @param string        $primary
380
+	 * @return string
381
+	 */
382
+	protected function handle_row_actions($item, $column_name, $primary)
383
+	{
384
+		foreach (class_parents($this) as $parent) {
385
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
386
+				return parent::handle_row_actions($item, $column_name, $primary);
387
+			}
388
+		}
389
+		return '';
390
+	}
391
+
392
+
393
+	/**
394
+	 * _get_bulk_actions
395
+	 * This is a wrapper called by WP_List_Table::get_bulk_actions()
396
+	 *
397
+	 * @access protected
398
+	 * @return array bulk_actions
399
+	 */
400
+	protected function _get_bulk_actions()
401
+	{
402
+		$actions = [];
403
+		// the _views property should have the bulk_actions, so let's go through and extract them into a properly
404
+		// formatted array for the wp_list_table();
405
+		foreach ($this->_views as $view => $args) {
406
+			if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
407
+				// each bulk action will correspond with a admin page route, so we can check whatever the capability is
408
+				// for that page route and skip adding the bulk action if no access for the current logged in user.
409
+				foreach ($args['bulk_action'] as $route => $label) {
410
+					if ($this->_admin_page->check_user_access($route, true)) {
411
+						$actions[ $route ] = $label;
412
+					}
413
+				}
414
+			}
415
+		}
416
+		return $actions;
417
+	}
418
+
419
+
420
+	/**
421
+	 * Generate the table navigation above or below the table.
422
+	 * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
423
+	 *
424
+	 * @throws EE_Error
425
+	 * @since 4.9.44.rc.001
426
+	 */
427
+	public function display_tablenav($which)
428
+	{
429
+		if ('top' === $which) {
430
+			wp_nonce_field('bulk-' . $this->_args['plural']);
431
+		}
432
+		?>
433 433
         <div class="tablenav <?php echo esc_attr($which); ?>">
434 434
             <?php if ($this->_get_bulk_actions()) { ?>
435 435
                 <div class="alignleft actions bulkactions">
436 436
                     <?php $this->bulk_actions(); ?>
437 437
                 </div>
438 438
             <?php }
439
-            $this->extra_tablenav($which);
440
-            $this->pagination($which);
441
-            ?>
439
+			$this->extra_tablenav($which);
440
+			$this->pagination($which);
441
+			?>
442 442
 
443 443
             <br class="clear" />
444 444
         </div>
445 445
         <?php
446
-    }
447
-
448
-
449
-    /**
450
-     * _filters
451
-     * This receives the filters array from children _get_table_filters() and assembles the string including the filter
452
-     * button.
453
-     *
454
-     * @access private
455
-     * @return void  echos html showing filters
456
-     */
457
-    private function _filters()
458
-    {
459
-        $classname = get_class($this);
460
-        $filters   = apply_filters(
461
-            "FHEE__{$classname}__filters",
462
-            (array) $this->_get_table_filters(),
463
-            $this,
464
-            $this->_screen
465
-        );
466
-
467
-        if (empty($filters)) {
468
-            return;
469
-        }
470
-        foreach ($filters as $filter) {
471
-            echo $filter; // already escaped
472
-        }
473
-        // add filter button at end
474
-        echo '<input type="submit" class="button-secondary" value="'
475
-             . esc_html__('Filter', 'event_espresso')
476
-             . '" id="post-query-submit" />';
477
-        // add reset filters button at end
478
-        echo '<a class="button button-secondary"  href="'
479
-             . esc_url_raw($this->_admin_page->get_current_page_view_url())
480
-             . '" style="display:inline-block">'
481
-             . esc_html__('Reset Filters', 'event_espresso')
482
-             . '</a>';
483
-    }
484
-
485
-
486
-    /**
487
-     * Callback for 'list_table_primary_column' WordPress filter
488
-     * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
489
-     * column when class is instantiated.
490
-     *
491
-     * @param string $column_name
492
-     * @return string
493
-     * @see WP_List_Table::get_primary_column_name
494
-     */
495
-    public function set_primary_column($column_name)
496
-    {
497
-        return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
498
-    }
499
-
500
-
501
-    /**
502
-     *
503
-     */
504
-    public function prepare_items()
505
-    {
506
-
507
-        $this->_set_column_info();
508
-        // $this->_column_headers = $this->get_column_info();
509
-        $total_items = $this->_all_data_count;
510
-        $this->process_bulk_action();
511
-
512
-        $this->items = $this->_data;
513
-        $this->set_pagination_args(
514
-            [
515
-                'total_items' => $total_items,
516
-                'per_page'    => $this->_per_page,
517
-                'total_pages' => ceil($total_items / $this->_per_page),
518
-            ]
519
-        );
520
-    }
521
-
522
-
523
-    /**
524
-     * @param object|array $item
525
-     * @return string html content for the column
526
-     */
527
-    protected function column_cb($item)
528
-    {
529
-        return '';
530
-    }
531
-
532
-
533
-    /**
534
-     * This column is the default for when there is no defined column method for a registered column.
535
-     * This can be overridden by child classes, but allows for hooking in for custom columns.
536
-     *
537
-     * @param EE_Base_Class $item
538
-     * @param string        $column_name The column being called.
539
-     * @return string html content for the column
540
-     */
541
-    public function column_default($item, $column_name)
542
-    {
543
-        /**
544
-         * Dynamic hook allowing for adding additional column content in this list table.
545
-         * Note that $this->screen->id is in the format
546
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
547
-         * table it is: event-espresso_page_espresso_messages.
548
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
549
-         * hook prefix ("event-espresso") will be different.
550
-         */
551
-        ob_start();
552
-        do_action(
553
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
554
-            $item,
555
-            $this->_screen
556
-        );
557
-        return ob_get_clean();
558
-    }
559
-
560
-
561
-    /**
562
-     * Get a list of columns. The format is:
563
-     * 'internal-name' => 'Title'
564
-     *
565
-     * @return array
566
-     * @since  3.1.0
567
-     * @access public
568
-     * @abstract
569
-     */
570
-    public function get_columns()
571
-    {
572
-        /**
573
-         * Dynamic hook allowing for adding additional columns in this list table.
574
-         * Note that $this->screen->id is in the format
575
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
576
-         * table it is: event-espresso_page_espresso_messages.
577
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
578
-         * hook prefix ("event-espresso") will be different.
579
-         *
580
-         * @var array
581
-         */
582
-        return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
583
-    }
584
-
585
-
586
-    /**
587
-     * Get an associative array ( id => link ) with the list
588
-     * of views available on this table.
589
-     *
590
-     * @return array
591
-     * @since  3.1.0
592
-     * @access protected
593
-     */
594
-    public function get_views()
595
-    {
596
-        return $this->_views;
597
-    }
598
-
599
-
600
-    /**
601
-     * Generate the views html.
602
-     */
603
-    public function display_views()
604
-    {
605
-        $views           = $this->get_views();
606
-        $assembled_views = [];
607
-
608
-        if (empty($views)) {
609
-            return;
610
-        }
611
-        echo "<ul class='subsubsub'>\n";
612
-        foreach ($views as $view) {
613
-            $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
614
-            if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
615
-                $filter = "<li";
616
-                $filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
617
-                $filter .= ">";
618
-                $filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
619
-                $filter .= '<span class="count">(' . $count . ')</span>';
620
-                $filter .= '</li>';
621
-                $assembled_views[ $view['slug'] ] = $filter;
622
-            }
623
-        }
624
-
625
-        echo ! empty($assembled_views)
626
-            ? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
627
-            : '';
628
-        echo "</ul>";
629
-    }
630
-
631
-
632
-    /**
633
-     * Generates content for a single row of the table
634
-     *
635
-     * @param EE_Base_Class $item The current item
636
-     * @since  4.1
637
-     * @access public
638
-     */
639
-    public function single_row($item)
640
-    {
641
-        $row_class = $this->_get_row_class($item);
642
-        echo '<tr class="' . esc_attr($row_class) . '">';
643
-        $this->single_row_columns($item); // already escaped
644
-        echo '</tr>';
645
-    }
646
-
647
-
648
-    /**
649
-     * This simply sets up the row class for the table rows.
650
-     * Allows for easier overriding of child methods for setting up sorting.
651
-     *
652
-     * @param EE_Base_Class $item the current item
653
-     * @return string
654
-     */
655
-    protected function _get_row_class($item)
656
-    {
657
-        static $row_class = '';
658
-        $row_class = ($row_class === '' ? 'alternate' : '');
659
-
660
-        $new_row_class = $row_class;
661
-
662
-        if (! empty($this->_ajax_sorting_callback)) {
663
-            $new_row_class .= ' rowsortable';
664
-        }
665
-
666
-        return $new_row_class;
667
-    }
668
-
669
-
670
-    /**
671
-     * @return array
672
-     */
673
-    public function get_sortable_columns()
674
-    {
675
-        return (array) $this->_sortable_columns;
676
-    }
677
-
678
-
679
-    /**
680
-     * @return string
681
-     */
682
-    public function get_ajax_sorting_callback()
683
-    {
684
-        return $this->_ajax_sorting_callback;
685
-    }
686
-
687
-
688
-    /**
689
-     * @return array
690
-     */
691
-    public function get_hidden_columns()
692
-    {
693
-        $user_id     = get_current_user_id();
694
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
695
-        if (empty($has_default) && ! empty($this->_hidden_columns)) {
696
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
697
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
698
-        }
699
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
700
-        return (array) get_user_option($ref, $user_id);
701
-    }
702
-
703
-
704
-    /**
705
-     * Generates the columns for a single row of the table.
706
-     * Overridden from wp_list_table so as to allow us to filter the column content for a given
707
-     * column.
708
-     *
709
-     * @param EE_Base_Class $item The current item
710
-     * @since 3.1.0
711
-     */
712
-    public function single_row_columns($item)
713
-    {
714
-        list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
715
-
716
-        foreach ($columns as $column_name => $column_display_name) {
717
-
718
-            /**
719
-             * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
720
-             * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
721
-             */
722
-            $hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
723
-
724
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
725
-            if ($primary === $column_name) {
726
-                $classes .= ' has-row-actions column-primary';
727
-            }
728
-
729
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
730
-
731
-            $class = 'class="' . esc_attr($classes) . '"';
732
-
733
-            $attributes = "{$class}{$data}";
734
-
735
-            if ($column_name === 'cb') {
736
-                echo '<th scope="row" class="check-column">';
737
-                echo apply_filters(
738
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
739
-                    $this->column_cb($item), // already escaped
740
-                    $item,
741
-                    $this
742
-                );
743
-                echo '</th>';
744
-            } elseif (method_exists($this, 'column_' . $column_name)) {
745
-                echo "<td $attributes>"; // already escaped
746
-                echo apply_filters(
747
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
748
-                    call_user_func([$this, 'column_' . $column_name], $item),
749
-                    $item,
750
-                    $this
751
-                );
752
-                echo $this->handle_row_actions($item, $column_name, $primary);
753
-                echo "</td>";
754
-            } else {
755
-                echo "<td $attributes>"; // already escaped
756
-                echo apply_filters(
757
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
758
-                    $this->column_default($item, $column_name),
759
-                    $item,
760
-                    $column_name,
761
-                    $this
762
-                );
763
-                echo $this->handle_row_actions($item, $column_name, $primary);
764
-                echo "</td>";
765
-            }
766
-        }
767
-    }
768
-
769
-
770
-    /**
771
-     * Extra controls to be displayed between bulk actions and pagination
772
-     *
773
-     * @access public
774
-     * @param string $which
775
-     * @throws EE_Error
776
-     */
777
-    public function extra_tablenav($which)
778
-    {
779
-        if ($which === 'top') {
780
-            $this->_filters();
781
-            echo $this->_get_hidden_fields(); // already escaped
782
-        } else {
783
-            echo '<div class="list-table-bottom-buttons alignleft actions">';
784
-            foreach ($this->_bottom_buttons as $type => $action) {
785
-                $route         = isset($action['route']) ? $action['route'] : '';
786
-                $extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
787
-                // already escaped
788
-                echo $this->_admin_page->get_action_link_or_button(
789
-                    $route,
790
-                    $type,
791
-                    $extra_request,
792
-                    'button button-secondary'
793
-                );
794
-            }
795
-            do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
796
-            echo '</div>';
797
-        }
798
-    }
799
-
800
-
801
-    /**
802
-     * Get an associative array ( option_name => option_title ) with the list
803
-     * of bulk actions available on this table.
804
-     *
805
-     * @return array
806
-     * @since  3.1.0
807
-     * @access protected
808
-     */
809
-    public function get_bulk_actions()
810
-    {
811
-        return (array) $this->_get_bulk_actions();
812
-    }
813
-
814
-
815
-    /**
816
-     * Processing bulk actions.
817
-     */
818
-    public function process_bulk_action()
819
-    {
820
-        // this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
821
-        // reference in case there is a case where it gets used.
822
-    }
823
-
824
-
825
-    /**
826
-     * returns the EE admin page this list table is associated with
827
-     *
828
-     * @return EE_Admin_Page
829
-     */
830
-    public function get_admin_page()
831
-    {
832
-        return $this->_admin_page;
833
-    }
834
-
835
-
836
-    /**
837
-     * A "helper" function for all children to provide an html string of
838
-     * actions to output in their content.  It is preferable for child classes
839
-     * to use this method for generating their actions content so that it's
840
-     * filterable by plugins
841
-     *
842
-     * @param string        $action_container           what are the html container
843
-     *                                                  elements for this actions string?
844
-     * @param string        $action_class               What class is for the container
845
-     *                                                  element.
846
-     * @param string        $action_items               The contents for the action items
847
-     *                                                  container.  This is filtered before
848
-     *                                                  returned.
849
-     * @param string        $action_id                  What id (optional) is used for the
850
-     *                                                  container element.
851
-     * @param EE_Base_Class $item                       The object for the column displaying
852
-     *                                                  the actions.
853
-     * @return string The assembled action elements container.
854
-     */
855
-    protected function _action_string(
856
-        $action_items,
857
-        $item,
858
-        $action_container = 'ul',
859
-        $action_class = '',
860
-        $action_id = ''
861
-    ) {
862
-        $action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
863
-        $action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
864
-        $open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
865
-        $close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
866
-        try {
867
-            $content = apply_filters(
868
-                'FHEE__EE_Admin_List_Table___action_string__action_items',
869
-                $action_items,
870
-                $item,
871
-                $this
872
-            );
873
-        } catch (Exception $e) {
874
-            if (WP_DEBUG) {
875
-                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
876
-            }
877
-            $content = $action_items;
878
-        }
879
-        return "{$open_tag}{$content}{$close_tag}";
880
-    }
881
-
882
-
883
-    /**
884
-     * @return string
885
-     */
886
-    protected function getReturnUrl()
887
-    {
888
-        $host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
889
-        $uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
890
-        return urlencode("//{$host}{$uri}");
891
-    }
446
+	}
447
+
448
+
449
+	/**
450
+	 * _filters
451
+	 * This receives the filters array from children _get_table_filters() and assembles the string including the filter
452
+	 * button.
453
+	 *
454
+	 * @access private
455
+	 * @return void  echos html showing filters
456
+	 */
457
+	private function _filters()
458
+	{
459
+		$classname = get_class($this);
460
+		$filters   = apply_filters(
461
+			"FHEE__{$classname}__filters",
462
+			(array) $this->_get_table_filters(),
463
+			$this,
464
+			$this->_screen
465
+		);
466
+
467
+		if (empty($filters)) {
468
+			return;
469
+		}
470
+		foreach ($filters as $filter) {
471
+			echo $filter; // already escaped
472
+		}
473
+		// add filter button at end
474
+		echo '<input type="submit" class="button-secondary" value="'
475
+			 . esc_html__('Filter', 'event_espresso')
476
+			 . '" id="post-query-submit" />';
477
+		// add reset filters button at end
478
+		echo '<a class="button button-secondary"  href="'
479
+			 . esc_url_raw($this->_admin_page->get_current_page_view_url())
480
+			 . '" style="display:inline-block">'
481
+			 . esc_html__('Reset Filters', 'event_espresso')
482
+			 . '</a>';
483
+	}
484
+
485
+
486
+	/**
487
+	 * Callback for 'list_table_primary_column' WordPress filter
488
+	 * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
489
+	 * column when class is instantiated.
490
+	 *
491
+	 * @param string $column_name
492
+	 * @return string
493
+	 * @see WP_List_Table::get_primary_column_name
494
+	 */
495
+	public function set_primary_column($column_name)
496
+	{
497
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
498
+	}
499
+
500
+
501
+	/**
502
+	 *
503
+	 */
504
+	public function prepare_items()
505
+	{
506
+
507
+		$this->_set_column_info();
508
+		// $this->_column_headers = $this->get_column_info();
509
+		$total_items = $this->_all_data_count;
510
+		$this->process_bulk_action();
511
+
512
+		$this->items = $this->_data;
513
+		$this->set_pagination_args(
514
+			[
515
+				'total_items' => $total_items,
516
+				'per_page'    => $this->_per_page,
517
+				'total_pages' => ceil($total_items / $this->_per_page),
518
+			]
519
+		);
520
+	}
521
+
522
+
523
+	/**
524
+	 * @param object|array $item
525
+	 * @return string html content for the column
526
+	 */
527
+	protected function column_cb($item)
528
+	{
529
+		return '';
530
+	}
531
+
532
+
533
+	/**
534
+	 * This column is the default for when there is no defined column method for a registered column.
535
+	 * This can be overridden by child classes, but allows for hooking in for custom columns.
536
+	 *
537
+	 * @param EE_Base_Class $item
538
+	 * @param string        $column_name The column being called.
539
+	 * @return string html content for the column
540
+	 */
541
+	public function column_default($item, $column_name)
542
+	{
543
+		/**
544
+		 * Dynamic hook allowing for adding additional column content in this list table.
545
+		 * Note that $this->screen->id is in the format
546
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
547
+		 * table it is: event-espresso_page_espresso_messages.
548
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
549
+		 * hook prefix ("event-espresso") will be different.
550
+		 */
551
+		ob_start();
552
+		do_action(
553
+			'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
554
+			$item,
555
+			$this->_screen
556
+		);
557
+		return ob_get_clean();
558
+	}
559
+
560
+
561
+	/**
562
+	 * Get a list of columns. The format is:
563
+	 * 'internal-name' => 'Title'
564
+	 *
565
+	 * @return array
566
+	 * @since  3.1.0
567
+	 * @access public
568
+	 * @abstract
569
+	 */
570
+	public function get_columns()
571
+	{
572
+		/**
573
+		 * Dynamic hook allowing for adding additional columns in this list table.
574
+		 * Note that $this->screen->id is in the format
575
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
576
+		 * table it is: event-espresso_page_espresso_messages.
577
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
578
+		 * hook prefix ("event-espresso") will be different.
579
+		 *
580
+		 * @var array
581
+		 */
582
+		return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
583
+	}
584
+
585
+
586
+	/**
587
+	 * Get an associative array ( id => link ) with the list
588
+	 * of views available on this table.
589
+	 *
590
+	 * @return array
591
+	 * @since  3.1.0
592
+	 * @access protected
593
+	 */
594
+	public function get_views()
595
+	{
596
+		return $this->_views;
597
+	}
598
+
599
+
600
+	/**
601
+	 * Generate the views html.
602
+	 */
603
+	public function display_views()
604
+	{
605
+		$views           = $this->get_views();
606
+		$assembled_views = [];
607
+
608
+		if (empty($views)) {
609
+			return;
610
+		}
611
+		echo "<ul class='subsubsub'>\n";
612
+		foreach ($views as $view) {
613
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
614
+			if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
615
+				$filter = "<li";
616
+				$filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
617
+				$filter .= ">";
618
+				$filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
619
+				$filter .= '<span class="count">(' . $count . ')</span>';
620
+				$filter .= '</li>';
621
+				$assembled_views[ $view['slug'] ] = $filter;
622
+			}
623
+		}
624
+
625
+		echo ! empty($assembled_views)
626
+			? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
627
+			: '';
628
+		echo "</ul>";
629
+	}
630
+
631
+
632
+	/**
633
+	 * Generates content for a single row of the table
634
+	 *
635
+	 * @param EE_Base_Class $item The current item
636
+	 * @since  4.1
637
+	 * @access public
638
+	 */
639
+	public function single_row($item)
640
+	{
641
+		$row_class = $this->_get_row_class($item);
642
+		echo '<tr class="' . esc_attr($row_class) . '">';
643
+		$this->single_row_columns($item); // already escaped
644
+		echo '</tr>';
645
+	}
646
+
647
+
648
+	/**
649
+	 * This simply sets up the row class for the table rows.
650
+	 * Allows for easier overriding of child methods for setting up sorting.
651
+	 *
652
+	 * @param EE_Base_Class $item the current item
653
+	 * @return string
654
+	 */
655
+	protected function _get_row_class($item)
656
+	{
657
+		static $row_class = '';
658
+		$row_class = ($row_class === '' ? 'alternate' : '');
659
+
660
+		$new_row_class = $row_class;
661
+
662
+		if (! empty($this->_ajax_sorting_callback)) {
663
+			$new_row_class .= ' rowsortable';
664
+		}
665
+
666
+		return $new_row_class;
667
+	}
668
+
669
+
670
+	/**
671
+	 * @return array
672
+	 */
673
+	public function get_sortable_columns()
674
+	{
675
+		return (array) $this->_sortable_columns;
676
+	}
677
+
678
+
679
+	/**
680
+	 * @return string
681
+	 */
682
+	public function get_ajax_sorting_callback()
683
+	{
684
+		return $this->_ajax_sorting_callback;
685
+	}
686
+
687
+
688
+	/**
689
+	 * @return array
690
+	 */
691
+	public function get_hidden_columns()
692
+	{
693
+		$user_id     = get_current_user_id();
694
+		$has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
695
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
696
+			update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
697
+			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
698
+		}
699
+		$ref = 'manage' . $this->screen->id . 'columnshidden';
700
+		return (array) get_user_option($ref, $user_id);
701
+	}
702
+
703
+
704
+	/**
705
+	 * Generates the columns for a single row of the table.
706
+	 * Overridden from wp_list_table so as to allow us to filter the column content for a given
707
+	 * column.
708
+	 *
709
+	 * @param EE_Base_Class $item The current item
710
+	 * @since 3.1.0
711
+	 */
712
+	public function single_row_columns($item)
713
+	{
714
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
715
+
716
+		foreach ($columns as $column_name => $column_display_name) {
717
+
718
+			/**
719
+			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
720
+			 * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
721
+			 */
722
+			$hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
723
+
724
+			$classes = $column_name . ' column-' . $column_name . $hidden_class;
725
+			if ($primary === $column_name) {
726
+				$classes .= ' has-row-actions column-primary';
727
+			}
728
+
729
+			$data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
730
+
731
+			$class = 'class="' . esc_attr($classes) . '"';
732
+
733
+			$attributes = "{$class}{$data}";
734
+
735
+			if ($column_name === 'cb') {
736
+				echo '<th scope="row" class="check-column">';
737
+				echo apply_filters(
738
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
739
+					$this->column_cb($item), // already escaped
740
+					$item,
741
+					$this
742
+				);
743
+				echo '</th>';
744
+			} elseif (method_exists($this, 'column_' . $column_name)) {
745
+				echo "<td $attributes>"; // already escaped
746
+				echo apply_filters(
747
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
748
+					call_user_func([$this, 'column_' . $column_name], $item),
749
+					$item,
750
+					$this
751
+				);
752
+				echo $this->handle_row_actions($item, $column_name, $primary);
753
+				echo "</td>";
754
+			} else {
755
+				echo "<td $attributes>"; // already escaped
756
+				echo apply_filters(
757
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
758
+					$this->column_default($item, $column_name),
759
+					$item,
760
+					$column_name,
761
+					$this
762
+				);
763
+				echo $this->handle_row_actions($item, $column_name, $primary);
764
+				echo "</td>";
765
+			}
766
+		}
767
+	}
768
+
769
+
770
+	/**
771
+	 * Extra controls to be displayed between bulk actions and pagination
772
+	 *
773
+	 * @access public
774
+	 * @param string $which
775
+	 * @throws EE_Error
776
+	 */
777
+	public function extra_tablenav($which)
778
+	{
779
+		if ($which === 'top') {
780
+			$this->_filters();
781
+			echo $this->_get_hidden_fields(); // already escaped
782
+		} else {
783
+			echo '<div class="list-table-bottom-buttons alignleft actions">';
784
+			foreach ($this->_bottom_buttons as $type => $action) {
785
+				$route         = isset($action['route']) ? $action['route'] : '';
786
+				$extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
787
+				// already escaped
788
+				echo $this->_admin_page->get_action_link_or_button(
789
+					$route,
790
+					$type,
791
+					$extra_request,
792
+					'button button-secondary'
793
+				);
794
+			}
795
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
796
+			echo '</div>';
797
+		}
798
+	}
799
+
800
+
801
+	/**
802
+	 * Get an associative array ( option_name => option_title ) with the list
803
+	 * of bulk actions available on this table.
804
+	 *
805
+	 * @return array
806
+	 * @since  3.1.0
807
+	 * @access protected
808
+	 */
809
+	public function get_bulk_actions()
810
+	{
811
+		return (array) $this->_get_bulk_actions();
812
+	}
813
+
814
+
815
+	/**
816
+	 * Processing bulk actions.
817
+	 */
818
+	public function process_bulk_action()
819
+	{
820
+		// this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
821
+		// reference in case there is a case where it gets used.
822
+	}
823
+
824
+
825
+	/**
826
+	 * returns the EE admin page this list table is associated with
827
+	 *
828
+	 * @return EE_Admin_Page
829
+	 */
830
+	public function get_admin_page()
831
+	{
832
+		return $this->_admin_page;
833
+	}
834
+
835
+
836
+	/**
837
+	 * A "helper" function for all children to provide an html string of
838
+	 * actions to output in their content.  It is preferable for child classes
839
+	 * to use this method for generating their actions content so that it's
840
+	 * filterable by plugins
841
+	 *
842
+	 * @param string        $action_container           what are the html container
843
+	 *                                                  elements for this actions string?
844
+	 * @param string        $action_class               What class is for the container
845
+	 *                                                  element.
846
+	 * @param string        $action_items               The contents for the action items
847
+	 *                                                  container.  This is filtered before
848
+	 *                                                  returned.
849
+	 * @param string        $action_id                  What id (optional) is used for the
850
+	 *                                                  container element.
851
+	 * @param EE_Base_Class $item                       The object for the column displaying
852
+	 *                                                  the actions.
853
+	 * @return string The assembled action elements container.
854
+	 */
855
+	protected function _action_string(
856
+		$action_items,
857
+		$item,
858
+		$action_container = 'ul',
859
+		$action_class = '',
860
+		$action_id = ''
861
+	) {
862
+		$action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
863
+		$action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
864
+		$open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
865
+		$close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
866
+		try {
867
+			$content = apply_filters(
868
+				'FHEE__EE_Admin_List_Table___action_string__action_items',
869
+				$action_items,
870
+				$item,
871
+				$this
872
+			);
873
+		} catch (Exception $e) {
874
+			if (WP_DEBUG) {
875
+				EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
876
+			}
877
+			$content = $action_items;
878
+		}
879
+		return "{$open_tag}{$content}{$close_tag}";
880
+	}
881
+
882
+
883
+	/**
884
+	 * @return string
885
+	 */
886
+	protected function getReturnUrl()
887
+	{
888
+		$host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
889
+		$uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
890
+		return urlencode("//{$host}{$uri}");
891
+	}
892 892
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (! class_exists('WP_List_Table')) {
4
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
3
+if ( ! class_exists('WP_List_Table')) {
4
+    require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
5 5
 }
6 6
 
7 7
 
@@ -204,13 +204,13 @@  discard block
 block discarded – undo
204 204
         $this->_view         = $this->_admin_page->get_view();
205 205
         $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
206 206
         $this->_current_page = $this->get_pagenum();
207
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
207
+        $this->_screen       = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view();
208 208
         $this->_yes_no       = [
209 209
             esc_html__('No', 'event_espresso'),
210 210
             esc_html__('Yes', 'event_espresso')
211 211
         ];
212 212
 
213
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
213
+        $this->_per_page = $this->get_items_per_page($this->_screen.'_per_page');
214 214
 
215 215
         $this->_setup_data();
216 216
         $this->_add_view_counts();
@@ -290,14 +290,14 @@  discard block
 block discarded – undo
290 290
         $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
291 291
         // if action is STILL empty, then we set it to default
292 292
         $action = empty($action) ? 'default' : $action;
293
-        $field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
294
-        $field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
295
-        $field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
293
+        $field  = '<input type="hidden" name="page" value="'.esc_attr($this->_req_data['page']).'" />'."\n";
294
+        $field  .= '<input type="hidden" name="route" value="'.esc_attr($action).'" />'."\n";
295
+        $field  .= '<input type="hidden" name="perpage" value="'.esc_attr($this->_per_page).'" />'."\n";
296 296
 
297 297
         $bulk_actions = $this->_get_bulk_actions();
298 298
         foreach ($bulk_actions as $bulk_action => $label) {
299
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
300
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
299
+            $field .= '<input type="hidden" name="'.$bulk_action.'_nonce"'
300
+                      . ' value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n";
301 301
         }
302 302
 
303 303
         return $field;
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
 
345 345
             $data = (array) $data;
346 346
 
347
-            if (! isset($data[1])) {
347
+            if ( ! isset($data[1])) {
348 348
                 $_data[1] = false;
349 349
             }
350 350
 
351
-            $sortable[ $id ] = $_data;
351
+            $sortable[$id] = $_data;
352 352
         }
353 353
         $primary               = $this->get_primary_column_name();
354 354
         $this->_column_headers = [$columns, $hidden, $sortable, $primary];
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
                 // for that page route and skip adding the bulk action if no access for the current logged in user.
409 409
                 foreach ($args['bulk_action'] as $route => $label) {
410 410
                     if ($this->_admin_page->check_user_access($route, true)) {
411
-                        $actions[ $route ] = $label;
411
+                        $actions[$route] = $label;
412 412
                     }
413 413
                 }
414 414
             }
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
     public function display_tablenav($which)
428 428
     {
429 429
         if ('top' === $which) {
430
-            wp_nonce_field('bulk-' . $this->_args['plural']);
430
+            wp_nonce_field('bulk-'.$this->_args['plural']);
431 431
         }
432 432
         ?>
433 433
         <div class="tablenav <?php echo esc_attr($which); ?>">
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
          */
551 551
         ob_start();
552 552
         do_action(
553
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
553
+            'AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id,
554 554
             $item,
555 555
             $this->_screen
556 556
         );
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
          *
580 580
          * @var array
581 581
          */
582
-        return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
582
+        return apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen);
583 583
     }
584 584
 
585 585
 
@@ -613,12 +613,12 @@  discard block
 block discarded – undo
613 613
             $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
614 614
             if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
615 615
                 $filter = "<li";
616
-                $filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
616
+                $filter .= $view['class'] ? " class='".esc_attr($view['class'])."'" : '';
617 617
                 $filter .= ">";
618
-                $filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
619
-                $filter .= '<span class="count">(' . $count . ')</span>';
618
+                $filter .= '<a href="'.esc_url_raw($view['url']).'">'.esc_html($view['label']).'</a>';
619
+                $filter .= '<span class="count">('.$count.')</span>';
620 620
                 $filter .= '</li>';
621
-                $assembled_views[ $view['slug'] ] = $filter;
621
+                $assembled_views[$view['slug']] = $filter;
622 622
             }
623 623
         }
624 624
 
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
     public function single_row($item)
640 640
     {
641 641
         $row_class = $this->_get_row_class($item);
642
-        echo '<tr class="' . esc_attr($row_class) . '">';
642
+        echo '<tr class="'.esc_attr($row_class).'">';
643 643
         $this->single_row_columns($item); // already escaped
644 644
         echo '</tr>';
645 645
     }
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 
660 660
         $new_row_class = $row_class;
661 661
 
662
-        if (! empty($this->_ajax_sorting_callback)) {
662
+        if ( ! empty($this->_ajax_sorting_callback)) {
663 663
             $new_row_class .= ' rowsortable';
664 664
         }
665 665
 
@@ -691,12 +691,12 @@  discard block
 block discarded – undo
691 691
     public function get_hidden_columns()
692 692
     {
693 693
         $user_id     = get_current_user_id();
694
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
694
+        $has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id);
695 695
         if (empty($has_default) && ! empty($this->_hidden_columns)) {
696
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
697
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
696
+            update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', true);
697
+            update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, true);
698 698
         }
699
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
699
+        $ref = 'manage'.$this->screen->id.'columnshidden';
700 700
         return (array) get_user_option($ref, $user_id);
701 701
     }
702 702
 
@@ -721,14 +721,14 @@  discard block
 block discarded – undo
721 721
              */
722 722
             $hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
723 723
 
724
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
724
+            $classes = $column_name.' column-'.$column_name.$hidden_class;
725 725
             if ($primary === $column_name) {
726 726
                 $classes .= ' has-row-actions column-primary';
727 727
             }
728 728
 
729
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
729
+            $data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"';
730 730
 
731
-            $class = 'class="' . esc_attr($classes) . '"';
731
+            $class = 'class="'.esc_attr($classes).'"';
732 732
 
733 733
             $attributes = "{$class}{$data}";
734 734
 
@@ -741,11 +741,11 @@  discard block
 block discarded – undo
741 741
                     $this
742 742
                 );
743 743
                 echo '</th>';
744
-            } elseif (method_exists($this, 'column_' . $column_name)) {
744
+            } elseif (method_exists($this, 'column_'.$column_name)) {
745 745
                 echo "<td $attributes>"; // already escaped
746 746
                 echo apply_filters(
747
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
748
-                    call_user_func([$this, 'column_' . $column_name], $item),
747
+                    'FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content',
748
+                    call_user_func([$this, 'column_'.$column_name], $item),
749 749
                     $item,
750 750
                     $this
751 751
                 );
@@ -859,10 +859,10 @@  discard block
 block discarded – undo
859 859
         $action_class = '',
860 860
         $action_id = ''
861 861
     ) {
862
-        $action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
863
-        $action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
864
-        $open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
865
-        $close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
862
+        $action_class = ! empty($action_class) ? ' class="'.esc_attr($action_class).'"' : '';
863
+        $action_id    = ! empty($action_id) ? ' id="'.esc_attr($action_id).'"' : '';
864
+        $open_tag     = ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : '';
865
+        $close_tag    = ! empty($action_container) ? '</'.$action_container.'>' : '';
866 866
         try {
867 867
             $content = apply_filters(
868 868
                 'FHEE__EE_Admin_List_Table___action_string__action_items',
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_Menu_Map.core.php 2 patches
Indentation   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -11,260 +11,260 @@
 block discarded – undo
11 11
 {
12 12
 
13 13
 
14
-    /**
15
-     * The title for the menu page. (the page the menu links to)
16
-     *
17
-     * @since  4.4.0
18
-     * @var string
19
-     */
20
-    public $title;
21
-
14
+	/**
15
+	 * The title for the menu page. (the page the menu links to)
16
+	 *
17
+	 * @since  4.4.0
18
+	 * @var string
19
+	 */
20
+	public $title;
21
+
22 22
 
23
-    /**
24
-     * The label for the menu item. (What shows up in the actual menu).
25
-     *
26
-     * @since 4.4.0
27
-     * @var string
28
-     */
29
-    public $menu_label;
30
-
31
-
32
-    /**
33
-     * What menu item is the parent of this menu item.
34
-     *
35
-     * @since 4.4.0
36
-     * @var string
37
-     */
38
-    public $parent_slug;
39
-
40
-
41
-    /**
42
-     * What capability is required to access this page.
43
-     *
44
-     * @since 4.4.0
45
-     * @var string
46
-     */
47
-    public $capability = 'administrator';
48
-
49
-
50
-    /**
51
-     * What slug should be used to reference this menu item.
52
-     *
53
-     * @since 4.4.0
54
-     * @var string
55
-     */
56
-    public $menu_slug;
57
-
58
-
59
-    /**
60
-     * The callback for displaying the page that the menu references.
61
-     *
62
-     * @since 4.4.0
63
-     * @var string
64
-     */
65
-    public $menu_callback;
66
-
67
-
68
-    /**
69
-     * The EE_Admin_Page_Init attached to this map.
70
-     *
71
-     * @var EE_Admin_Page_Init
72
-     */
73
-    public $admin_init_page;
74
-
75
-
76
-    /**
77
-     * The EE specific group this menu item belongs in (group slug).
78
-     *
79
-     * @since 4.4.0
80
-     * @var string
81
-     */
82
-    public $menu_group;
83
-
84
-
85
-    /**
86
-     * What order this item should be in the menu.
87
-     *
88
-     * @since 4.4.0
89
-     * @var int
90
-     */
91
-    public $menu_order;
92
-
93
-
94
-    const NONE                   = 0;
95
-
96
-    const BLOG_ADMIN_ONLY        = 1;
97
-
98
-    const BLOG_AND_NETWORK_ADMIN = 2;
99
-
100
-    const NETWORK_ADMIN_ONLY     = 3;
101
-
102
-
103
-    /**
104
-     * Whether this item is displayed in the menu or not.
105
-     * Sometimes an EE Admin Page needs to register itself but is not accessible via the WordPress
106
-     * admin menu.
107
-     *
108
-     * @since 4.4.0
109
-     * @var int
110
-     */
111
-    public $show_on_menu = self::BLOG_ADMIN_ONLY;
112
-
113
-
114
-    /**
115
-     * Menu maps can define a parent slug that gets used instead of the main parent slug for the menu when
116
-     * EE_Maintenance_Mode::level_2_complete_maintenance is active.
117
-     *
118
-     * @var bool
119
-     */
120
-    public $maintenance_mode_parent = '';
121
-
122
-
123
-    /**
124
-     * @param array $menu_args            An array of arguments used to setup the menu
125
-     *                                    properties on construct.
126
-     * @param array $required             An array of keys that should be in the $menu_args, this
127
-     *                                    is used to validate that the items that should be defined
128
-     *                                    are present.
129
-     * @return void
130
-     * @throws EE_Error
131
-     * @since 4.4.0
132
-     *
133
-     */
134
-    public function __construct($menu_args, $required)
135
-    {
136
-        // filter all args before processing so plugins can manipulate various settings for menus.
137
-        $menu_args = apply_filters(
138
-            'FHEE__EE_Admin_Page_Menu_Map__construct__menu_args',
139
-            $menu_args,
140
-            $required,
141
-            get_class($this)
142
-        );
143
-
144
-
145
-        // verify that required keys are present in the incoming array.
146
-        $missing = array_diff((array) $required, array_keys((array) $menu_args));
147
-
148
-        if (! empty($missing)) {
149
-            throw new EE_Error(
150
-                sprintf(
151
-                    esc_html__(
152
-                        '%s is missing some expected keys in the argument array.  The following keys are missing: %s',
153
-                        'event_espresso'
154
-                    ),
155
-                    get_class($this),
156
-                    implode(', ', $missing)
157
-                )
158
-            );
159
-        }
160
-
161
-        // made it here okay, so let's set the properties!
162
-        foreach ($menu_args as $prop => $value) {
163
-            switch ($prop) {
164
-                case 'show_on_menu':
165
-                    $value = (int) $value;
166
-                    break;
167
-                case 'admin_init_page':
168
-                    if (in_array('admin_init_page', $required) && ! $value instanceof EE_Admin_Page_Init) {
169
-                        throw new EE_Error(
170
-                            sprintf(
171
-                                esc_html__(
172
-                                    'The value for the "admin_init_page" argument must be an instance of an EE_Admin_Page_Init object.  Instead %s was given as the value.',
173
-                                    'event_espresso'
174
-                                ),
175
-                                print_r($value, true)
176
-                            )
177
-                        );
178
-                    }
179
-                    break;
180
-                case 'menu_callback':
181
-                    break;
182
-
183
-                default:
184
-                    $value = (string) $value;
185
-                    break;
186
-            }
187
-            if (! EEH_Class_Tools::has_property($this, $prop)) {
188
-                throw new EE_Error(
189
-                    sprintf(
190
-                        esc_html__(
191
-                            'The $menu_args coming into %s has a index key (%s) representing a property that is not defined by the class.  Perhaps there is a typo?',
192
-                            'event_espresso'
193
-                        ),
194
-                        get_class($this),
195
-                        $prop
196
-                    )
197
-                );
198
-            }
199
-            $this->{$prop} = $value;
200
-        }
201
-
202
-        // filter capabilities (both static and dynamic)
203
-        $this->capability = apply_filters('FHEE_management_capability', $this->capability, null);
204
-        $this->capability = apply_filters('FHEE_' . $this->menu_slug . '_capability', $this->capability, null);
205
-
206
-        // Might need to change parent slug depending on maintenance mode.
207
-        if (
208
-            ! empty($this->maintenance_mode_parent)
209
-            && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance
210
-        ) {
211
-            $this->parent_slug = $this->maintenance_mode_parent;
212
-        }
213
-
214
-        // if empty menu_callback let's set default (but only if we have admin page init object)
215
-        if (empty($this->menu_callback) && $this->admin_init_page instanceof EE_Admin_Page_Init) {
216
-            $this->menu_callback = [$this->admin_init_page, 'initialize_admin_page'];
217
-        }
218
-    }
219
-
220
-
221
-    /**
222
-     * This method should define how the menu page gets added for this particular item
223
-     * and go ahead and define it.  Note that child classes MUST also return the result of
224
-     * the function used to register the WordPress admin page (the wp_page_slug string)
225
-     *
226
-     * @return string wp_page_slug.
227
-     * @since  4.4.0
228
-     */
229
-    abstract protected function _add_menu_page();
230
-
231
-
232
-    /**
233
-     * Called by client code to use this menu map for registering a WordPress admin page
234
-     *
235
-     * @param boolean $network_admin whether this is being added to the network admin page or not
236
-     * @throws EE_Error
237
-     * @throws ReflectionException
238
-     * @since  4.4.0
239
-     */
240
-    public function add_menu_page($network_admin = false)
241
-    {
242
-        $show_on_menu_int = (int) $this->show_on_menu;
243
-        if (
244
-            ($network_admin
245
-             && in_array(
246
-                 $show_on_menu_int,
247
-                 [self::BLOG_AND_NETWORK_ADMIN, self::NETWORK_ADMIN_ONLY],
248
-                 true
249
-             ))
250
-            || (! $network_admin
251
-                && in_array(
252
-                    $show_on_menu_int,
253
-                    [self::BLOG_AND_NETWORK_ADMIN, self::BLOG_ADMIN_ONLY],
254
-                    true
255
-                ))
256
-        ) {
257
-            $wp_page_slug = $this->_add_menu_page();
258
-        } else {
259
-            $wp_page_slug = '';
260
-        }
261
-
262
-        if (! empty($wp_page_slug) && $this->admin_init_page instanceof EE_Admin_Page_Init) {
263
-            try {
264
-                $this->admin_init_page->set_page_dependencies($wp_page_slug);
265
-            } catch (EE_Error $e) {
266
-                $e->get_error();
267
-            }
268
-        }
269
-    }
23
+	/**
24
+	 * The label for the menu item. (What shows up in the actual menu).
25
+	 *
26
+	 * @since 4.4.0
27
+	 * @var string
28
+	 */
29
+	public $menu_label;
30
+
31
+
32
+	/**
33
+	 * What menu item is the parent of this menu item.
34
+	 *
35
+	 * @since 4.4.0
36
+	 * @var string
37
+	 */
38
+	public $parent_slug;
39
+
40
+
41
+	/**
42
+	 * What capability is required to access this page.
43
+	 *
44
+	 * @since 4.4.0
45
+	 * @var string
46
+	 */
47
+	public $capability = 'administrator';
48
+
49
+
50
+	/**
51
+	 * What slug should be used to reference this menu item.
52
+	 *
53
+	 * @since 4.4.0
54
+	 * @var string
55
+	 */
56
+	public $menu_slug;
57
+
58
+
59
+	/**
60
+	 * The callback for displaying the page that the menu references.
61
+	 *
62
+	 * @since 4.4.0
63
+	 * @var string
64
+	 */
65
+	public $menu_callback;
66
+
67
+
68
+	/**
69
+	 * The EE_Admin_Page_Init attached to this map.
70
+	 *
71
+	 * @var EE_Admin_Page_Init
72
+	 */
73
+	public $admin_init_page;
74
+
75
+
76
+	/**
77
+	 * The EE specific group this menu item belongs in (group slug).
78
+	 *
79
+	 * @since 4.4.0
80
+	 * @var string
81
+	 */
82
+	public $menu_group;
83
+
84
+
85
+	/**
86
+	 * What order this item should be in the menu.
87
+	 *
88
+	 * @since 4.4.0
89
+	 * @var int
90
+	 */
91
+	public $menu_order;
92
+
93
+
94
+	const NONE                   = 0;
95
+
96
+	const BLOG_ADMIN_ONLY        = 1;
97
+
98
+	const BLOG_AND_NETWORK_ADMIN = 2;
99
+
100
+	const NETWORK_ADMIN_ONLY     = 3;
101
+
102
+
103
+	/**
104
+	 * Whether this item is displayed in the menu or not.
105
+	 * Sometimes an EE Admin Page needs to register itself but is not accessible via the WordPress
106
+	 * admin menu.
107
+	 *
108
+	 * @since 4.4.0
109
+	 * @var int
110
+	 */
111
+	public $show_on_menu = self::BLOG_ADMIN_ONLY;
112
+
113
+
114
+	/**
115
+	 * Menu maps can define a parent slug that gets used instead of the main parent slug for the menu when
116
+	 * EE_Maintenance_Mode::level_2_complete_maintenance is active.
117
+	 *
118
+	 * @var bool
119
+	 */
120
+	public $maintenance_mode_parent = '';
121
+
122
+
123
+	/**
124
+	 * @param array $menu_args            An array of arguments used to setup the menu
125
+	 *                                    properties on construct.
126
+	 * @param array $required             An array of keys that should be in the $menu_args, this
127
+	 *                                    is used to validate that the items that should be defined
128
+	 *                                    are present.
129
+	 * @return void
130
+	 * @throws EE_Error
131
+	 * @since 4.4.0
132
+	 *
133
+	 */
134
+	public function __construct($menu_args, $required)
135
+	{
136
+		// filter all args before processing so plugins can manipulate various settings for menus.
137
+		$menu_args = apply_filters(
138
+			'FHEE__EE_Admin_Page_Menu_Map__construct__menu_args',
139
+			$menu_args,
140
+			$required,
141
+			get_class($this)
142
+		);
143
+
144
+
145
+		// verify that required keys are present in the incoming array.
146
+		$missing = array_diff((array) $required, array_keys((array) $menu_args));
147
+
148
+		if (! empty($missing)) {
149
+			throw new EE_Error(
150
+				sprintf(
151
+					esc_html__(
152
+						'%s is missing some expected keys in the argument array.  The following keys are missing: %s',
153
+						'event_espresso'
154
+					),
155
+					get_class($this),
156
+					implode(', ', $missing)
157
+				)
158
+			);
159
+		}
160
+
161
+		// made it here okay, so let's set the properties!
162
+		foreach ($menu_args as $prop => $value) {
163
+			switch ($prop) {
164
+				case 'show_on_menu':
165
+					$value = (int) $value;
166
+					break;
167
+				case 'admin_init_page':
168
+					if (in_array('admin_init_page', $required) && ! $value instanceof EE_Admin_Page_Init) {
169
+						throw new EE_Error(
170
+							sprintf(
171
+								esc_html__(
172
+									'The value for the "admin_init_page" argument must be an instance of an EE_Admin_Page_Init object.  Instead %s was given as the value.',
173
+									'event_espresso'
174
+								),
175
+								print_r($value, true)
176
+							)
177
+						);
178
+					}
179
+					break;
180
+				case 'menu_callback':
181
+					break;
182
+
183
+				default:
184
+					$value = (string) $value;
185
+					break;
186
+			}
187
+			if (! EEH_Class_Tools::has_property($this, $prop)) {
188
+				throw new EE_Error(
189
+					sprintf(
190
+						esc_html__(
191
+							'The $menu_args coming into %s has a index key (%s) representing a property that is not defined by the class.  Perhaps there is a typo?',
192
+							'event_espresso'
193
+						),
194
+						get_class($this),
195
+						$prop
196
+					)
197
+				);
198
+			}
199
+			$this->{$prop} = $value;
200
+		}
201
+
202
+		// filter capabilities (both static and dynamic)
203
+		$this->capability = apply_filters('FHEE_management_capability', $this->capability, null);
204
+		$this->capability = apply_filters('FHEE_' . $this->menu_slug . '_capability', $this->capability, null);
205
+
206
+		// Might need to change parent slug depending on maintenance mode.
207
+		if (
208
+			! empty($this->maintenance_mode_parent)
209
+			&& EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance
210
+		) {
211
+			$this->parent_slug = $this->maintenance_mode_parent;
212
+		}
213
+
214
+		// if empty menu_callback let's set default (but only if we have admin page init object)
215
+		if (empty($this->menu_callback) && $this->admin_init_page instanceof EE_Admin_Page_Init) {
216
+			$this->menu_callback = [$this->admin_init_page, 'initialize_admin_page'];
217
+		}
218
+	}
219
+
220
+
221
+	/**
222
+	 * This method should define how the menu page gets added for this particular item
223
+	 * and go ahead and define it.  Note that child classes MUST also return the result of
224
+	 * the function used to register the WordPress admin page (the wp_page_slug string)
225
+	 *
226
+	 * @return string wp_page_slug.
227
+	 * @since  4.4.0
228
+	 */
229
+	abstract protected function _add_menu_page();
230
+
231
+
232
+	/**
233
+	 * Called by client code to use this menu map for registering a WordPress admin page
234
+	 *
235
+	 * @param boolean $network_admin whether this is being added to the network admin page or not
236
+	 * @throws EE_Error
237
+	 * @throws ReflectionException
238
+	 * @since  4.4.0
239
+	 */
240
+	public function add_menu_page($network_admin = false)
241
+	{
242
+		$show_on_menu_int = (int) $this->show_on_menu;
243
+		if (
244
+			($network_admin
245
+			 && in_array(
246
+				 $show_on_menu_int,
247
+				 [self::BLOG_AND_NETWORK_ADMIN, self::NETWORK_ADMIN_ONLY],
248
+				 true
249
+			 ))
250
+			|| (! $network_admin
251
+				&& in_array(
252
+					$show_on_menu_int,
253
+					[self::BLOG_AND_NETWORK_ADMIN, self::BLOG_ADMIN_ONLY],
254
+					true
255
+				))
256
+		) {
257
+			$wp_page_slug = $this->_add_menu_page();
258
+		} else {
259
+			$wp_page_slug = '';
260
+		}
261
+
262
+		if (! empty($wp_page_slug) && $this->admin_init_page instanceof EE_Admin_Page_Init) {
263
+			try {
264
+				$this->admin_init_page->set_page_dependencies($wp_page_slug);
265
+			} catch (EE_Error $e) {
266
+				$e->get_error();
267
+			}
268
+		}
269
+	}
270 270
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         // verify that required keys are present in the incoming array.
146 146
         $missing = array_diff((array) $required, array_keys((array) $menu_args));
147 147
 
148
-        if (! empty($missing)) {
148
+        if ( ! empty($missing)) {
149 149
             throw new EE_Error(
150 150
                 sprintf(
151 151
                     esc_html__(
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
                     $value = (string) $value;
185 185
                     break;
186 186
             }
187
-            if (! EEH_Class_Tools::has_property($this, $prop)) {
187
+            if ( ! EEH_Class_Tools::has_property($this, $prop)) {
188 188
                 throw new EE_Error(
189 189
                     sprintf(
190 190
                         esc_html__(
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 
202 202
         // filter capabilities (both static and dynamic)
203 203
         $this->capability = apply_filters('FHEE_management_capability', $this->capability, null);
204
-        $this->capability = apply_filters('FHEE_' . $this->menu_slug . '_capability', $this->capability, null);
204
+        $this->capability = apply_filters('FHEE_'.$this->menu_slug.'_capability', $this->capability, null);
205 205
 
206 206
         // Might need to change parent slug depending on maintenance mode.
207 207
         if (
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                  [self::BLOG_AND_NETWORK_ADMIN, self::NETWORK_ADMIN_ONLY],
248 248
                  true
249 249
              ))
250
-            || (! $network_admin
250
+            || ( ! $network_admin
251 251
                 && in_array(
252 252
                     $show_on_menu_int,
253 253
                     [self::BLOG_AND_NETWORK_ADMIN, self::BLOG_ADMIN_ONLY],
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             $wp_page_slug = '';
260 260
         }
261 261
 
262
-        if (! empty($wp_page_slug) && $this->admin_init_page instanceof EE_Admin_Page_Init) {
262
+        if ( ! empty($wp_page_slug) && $this->admin_init_page instanceof EE_Admin_Page_Init) {
263 263
             try {
264 264
                 $this->admin_init_page->set_page_dependencies($wp_page_slug);
265 265
             } catch (EE_Error $e) {
Please login to merge, or discard this patch.