Completed
Branch FET/replace-legacy-request-for... (66c91a)
by
unknown
10:59 queued 08:42
created
caffeinated/admin/new/pricing/Pricing_Admin_Page.core.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
         wp_enqueue_style('espresso-ui-theme');
342 342
         wp_register_style(
343 343
             'espresso_PRICING',
344
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.css',
344
+            PRICING_ASSETS_URL.'espresso_pricing_admin.css',
345 345
             [],
346 346
             EVENT_ESPRESSO_VERSION
347 347
         );
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
         wp_enqueue_script('jquery-ui-widget');
354 354
         wp_register_script(
355 355
             'espresso_PRICING',
356
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.js',
356
+            PRICING_ASSETS_URL.'espresso_pricing_admin.js',
357 357
             ['jquery'],
358 358
             EVENT_ESPRESSO_VERSION,
359 359
             true
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
      */
451 451
     protected function _price_overview_list_table()
452 452
     {
453
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
453
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
454 454
             'add_new_price',
455 455
             'add',
456 456
             [],
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
         // start with an empty array
478 478
         $event_pricing = [];
479 479
 
480
-        require_once(PRICING_ADMIN . 'Prices_List_Table.class.php');
480
+        require_once(PRICING_ADMIN.'Prices_List_Table.class.php');
481 481
 
482 482
         $orderby = $this->request->getRequestParam('orderby', '');
483 483
         $order   = $this->request->getRequestParam('order', 'ASC');
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
                 $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
556 556
         }
557 557
         // add PRC_ID to title if editing
558
-        $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title;
558
+        $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title.' # '.$PRC_ID : $this->_admin_page_title;
559 559
 
560 560
         if ($PRC_ID) {
561 561
             $price                    = EEM_Price::instance()->get_one_by_ID($PRC_ID);
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
             $this->_set_add_edit_form_tags('insert_price');
569 569
         }
570 570
 
571
-        if (! $price instanceof EE_Price) {
571
+        if ( ! $price instanceof EE_Price) {
572 572
             throw new RuntimeException(
573 573
                 sprintf(
574 574
                     esc_html__(
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
     public function _edit_price_details_meta_box(): string
627 627
     {
628 628
         return EEH_Template::display_template(
629
-            PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php',
629
+            PRICING_TEMPLATE_PATH.'pricing_details_main_meta_box.template.php',
630 630
             $this->_template_args,
631 631
             true
632 632
         );
@@ -789,19 +789,19 @@  discard block
 block discarded – undo
789 789
      */
790 790
     public function adjustTicketRelations(EEM_Base $entity_model, $entity_ID, string $action, int $result)
791 791
     {
792
-        if (! $entity_ID || (float) $result < 1) {
792
+        if ( ! $entity_ID || (float) $result < 1) {
793 793
             return;
794 794
         }
795 795
 
796 796
         $entity = $entity_model->get_one_by_ID($entity_ID);
797
-        if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) {
797
+        if ( ! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) {
798 798
             return;
799 799
         }
800 800
 
801 801
         // get default tickets for updating
802 802
         $default_tickets = EEM_Ticket::instance()->get_all_default_tickets();
803 803
         foreach ($default_tickets as $default_ticket) {
804
-            if (! $default_ticket instanceof EE_Ticket) {
804
+            if ( ! $default_ticket instanceof EE_Ticket) {
805 805
                 continue;
806 806
             }
807 807
             switch ($action) {
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
      */
877 877
     protected function _price_types_overview_list_table()
878 878
     {
879
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
879
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
880 880
             'add_new_price_type',
881 881
             'add_type',
882 882
             [],
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
     public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
902 902
     {
903 903
         // start with an empty array
904
-        require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php');
904
+        require_once(PRICING_ADMIN.'Price_Types_List_Table.class.php');
905 905
 
906 906
         $orderby = $this->request->getRequestParam('orderby', '');
907 907
         $order   = $this->request->getRequestParam('order', 'ASC');
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
                 $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
963 963
         }
964 964
         // add PRT_ID to title if editing
965
-        $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title;
965
+        $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title.' # '.$PRT_ID : $this->_admin_page_title;
966 966
 
967 967
         if ($PRT_ID) {
968 968
             $price_type               = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
             $this->_set_add_edit_form_tags('insert_price_type');
974 974
         }
975 975
 
976
-        if (! $price_type instanceof EE_Price_Type) {
976
+        if ( ! $price_type instanceof EE_Price_Type) {
977 977
             throw new RuntimeException(
978 978
                 sprintf(
979 979
                     esc_html__(
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
     public function _edit_price_type_details_meta_box(): string
1024 1024
     {
1025 1025
         return EEH_Template::display_template(
1026
-            PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php',
1026
+            PRICING_TEMPLATE_PATH.'pricing_type_details_main_meta_box.template.php',
1027 1027
             $this->_template_args,
1028 1028
             true
1029 1029
         );
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
      */
1036 1036
     protected function set_price_type_column_values(): array
1037 1037
     {
1038
-        $base_type  = $this->request->getRequestParam(
1038
+        $base_type = $this->request->getRequestParam(
1039 1039
             'base_type',
1040 1040
             EEM_Price_Type::base_type_base_price,
1041 1041
             DataType::INTEGER
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
     {
1162 1162
         return '
1163 1163
             <a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >
1164
-                ' . esc_html__('learn more about how pricing works', 'event_espresso') . '
1164
+                ' . esc_html__('learn more about how pricing works', 'event_espresso').'
1165 1165
             </a>';
1166 1166
     }
1167 1167
 
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
     public function _update_tax_settings()
1238 1238
     {
1239 1239
         $tax_settings = EE_Config::instance()->tax_settings;
1240
-        if (! $tax_settings instanceof EE_Tax_Config) {
1240
+        if ( ! $tax_settings instanceof EE_Tax_Config) {
1241 1241
             $tax_settings = new EE_Tax_Config();
1242 1242
         }
1243 1243
         try {
Please login to merge, or discard this patch.
Indentation   +1259 added lines, -1259 removed lines patch added patch discarded remove patch
@@ -12,1270 +12,1270 @@
 block discarded – undo
12 12
 class Pricing_Admin_Page extends EE_Admin_Page
13 13
 {
14 14
 
15
-    protected function _init_page_props()
16
-    {
17
-        $this->page_slug        = PRICING_PG_SLUG;
18
-        $this->page_label       = PRICING_LABEL;
19
-        $this->_admin_base_url  = PRICING_ADMIN_URL;
20
-        $this->_admin_base_path = PRICING_ADMIN;
21
-    }
22
-
23
-
24
-    protected function _ajax_hooks()
25
-    {
26
-        add_action('wp_ajax_espresso_update_prices_order', [$this, 'update_price_order']);
27
-    }
28
-
29
-
30
-    protected function _define_page_props()
31
-    {
32
-        $this->_admin_page_title = PRICING_LABEL;
33
-        $this->_labels           = [
34
-            'buttons' => [
35
-                'add'         => esc_html__('Add New Default Price', 'event_espresso'),
36
-                'edit'        => esc_html__('Edit Default Price', 'event_espresso'),
37
-                'delete'      => esc_html__('Delete Default Price', 'event_espresso'),
38
-                'add_type'    => esc_html__('Add New Default Price Type', 'event_espresso'),
39
-                'edit_type'   => esc_html__('Edit Price Type', 'event_espresso'),
40
-                'delete_type' => esc_html__('Delete Price Type', 'event_espresso'),
41
-            ],
42
-        ];
43
-    }
44
-
45
-
46
-    /**
47
-     * an array for storing request actions and their corresponding methods
48
-     *
49
-     * @return void
50
-     */
51
-    protected function _set_page_routes()
52
-    {
53
-        $PRC_ID             = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER);
54
-        $PRT_ID             = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
55
-        $this->_page_routes = [
56
-            'default'                     => [
57
-                'func'       => '_price_overview_list_table',
58
-                'capability' => 'ee_read_default_prices',
59
-            ],
60
-            'add_new_price'               => [
61
-                'func'       => '_edit_price_details',
62
-                'args'       => ['new_price' => true],
63
-                'capability' => 'ee_edit_default_prices',
64
-            ],
65
-            'edit_price'                  => [
66
-                'func'       => '_edit_price_details',
67
-                'args'       => ['new_price' => false],
68
-                'capability' => 'ee_edit_default_price',
69
-                'obj_id'     => $PRC_ID,
70
-            ],
71
-            'insert_price'                => [
72
-                'func'       => '_insert_or_update_price',
73
-                'args'       => ['new_price' => true],
74
-                'noheader'   => true,
75
-                'capability' => 'ee_edit_default_prices',
76
-            ],
77
-            'update_price'                => [
78
-                'func'       => '_insert_or_update_price',
79
-                'args'       => ['new_price' => false],
80
-                'noheader'   => true,
81
-                'capability' => 'ee_edit_default_price',
82
-                'obj_id'     => $PRC_ID,
83
-            ],
84
-            'trash_price'                 => [
85
-                'func'       => '_trash_or_restore_price',
86
-                'args'       => ['trash' => true],
87
-                'noheader'   => true,
88
-                'capability' => 'ee_delete_default_price',
89
-                'obj_id'     => $PRC_ID,
90
-            ],
91
-            'restore_price'               => [
92
-                'func'       => '_trash_or_restore_price',
93
-                'args'       => ['trash' => false],
94
-                'noheader'   => true,
95
-                'capability' => 'ee_delete_default_price',
96
-                'obj_id'     => $PRC_ID,
97
-            ],
98
-            'delete_price'                => [
99
-                'func'       => '_delete_price',
100
-                'noheader'   => true,
101
-                'capability' => 'ee_delete_default_price',
102
-                'obj_id'     => $PRC_ID,
103
-            ],
104
-            'espresso_update_price_order' => [
105
-                'func'       => 'update_price_order',
106
-                'noheader'   => true,
107
-                'capability' => 'ee_edit_default_prices',
108
-            ],
109
-            // price types
110
-            'price_types'                 => [
111
-                'func'       => '_price_types_overview_list_table',
112
-                'capability' => 'ee_read_default_price_types',
113
-            ],
114
-            'add_new_price_type'          => [
115
-                'func'       => '_edit_price_type_details',
116
-                'capability' => 'ee_edit_default_price_types',
117
-            ],
118
-            'edit_price_type'             => [
119
-                'func'       => '_edit_price_type_details',
120
-                'capability' => 'ee_edit_default_price_type',
121
-                'obj_id'     => $PRT_ID,
122
-            ],
123
-            'insert_price_type'           => [
124
-                'func'       => '_insert_or_update_price_type',
125
-                'args'       => ['new_price_type' => true],
126
-                'noheader'   => true,
127
-                'capability' => 'ee_edit_default_price_types',
128
-            ],
129
-            'update_price_type'           => [
130
-                'func'       => '_insert_or_update_price_type',
131
-                'args'       => ['new_price_type' => false],
132
-                'noheader'   => true,
133
-                'capability' => 'ee_edit_default_price_type',
134
-                'obj_id'     => $PRT_ID,
135
-            ],
136
-            'trash_price_type'            => [
137
-                'func'       => '_trash_or_restore_price_type',
138
-                'args'       => ['trash' => true],
139
-                'noheader'   => true,
140
-                'capability' => 'ee_delete_default_price_type',
141
-                'obj_id'     => $PRT_ID,
142
-            ],
143
-            'restore_price_type'          => [
144
-                'func'       => '_trash_or_restore_price_type',
145
-                'args'       => ['trash' => false],
146
-                'noheader'   => true,
147
-                'capability' => 'ee_delete_default_price_type',
148
-                'obj_id'     => $PRT_ID,
149
-            ],
150
-            'delete_price_type'           => [
151
-                'func'       => '_delete_price_type',
152
-                'noheader'   => true,
153
-                'capability' => 'ee_delete_default_price_type',
154
-                'obj_id'     => $PRT_ID,
155
-            ],
156
-            'tax_settings'                => [
157
-                'func'       => '_tax_settings',
158
-                'capability' => 'manage_options',
159
-            ],
160
-            'update_tax_settings'         => [
161
-                'func'       => '_update_tax_settings',
162
-                'capability' => 'manage_options',
163
-                'noheader'   => true,
164
-            ],
165
-        ];
166
-    }
167
-
168
-
169
-    protected function _set_page_config()
170
-    {
171
-        $PRC_ID             = $this->request->getRequestParam('id', 0, DataType::INTEGER);
172
-        $this->_page_config = [
173
-            'default'            => [
174
-                'nav'           => [
175
-                    'label' => esc_html__('Default Pricing', 'event_espresso'),
176
-                    'order' => 10,
177
-                ],
178
-                'list_table'    => 'Prices_List_Table',
179
-                'metaboxes'     => $this->_default_espresso_metaboxes,
180
-                'help_tabs'     => [
181
-                    'pricing_default_pricing_help_tab'                           => [
182
-                        'title'    => esc_html__('Default Pricing', 'event_espresso'),
183
-                        'filename' => 'pricing_default_pricing',
184
-                    ],
185
-                    'pricing_default_pricing_table_column_headings_help_tab'     => [
186
-                        'title'    => esc_html__('Default Pricing Table Column Headings', 'event_espresso'),
187
-                        'filename' => 'pricing_default_pricing_table_column_headings',
188
-                    ],
189
-                    'pricing_default_pricing_views_bulk_actions_search_help_tab' => [
190
-                        'title'    => esc_html__('Default Pricing Views & Bulk Actions & Search', 'event_espresso'),
191
-                        'filename' => 'pricing_default_pricing_views_bulk_actions_search',
192
-                    ],
193
-                ],
194
-                'require_nonce' => false,
195
-            ],
196
-            'add_new_price'      => [
197
-                'nav'           => [
198
-                    'label'      => esc_html__('Add New Default Price', 'event_espresso'),
199
-                    'order'      => 20,
200
-                    'persistent' => false,
201
-                ],
202
-                'help_tabs'     => [
203
-                    'add_new_default_price_help_tab' => [
204
-                        'title'    => esc_html__('Add New Default Price', 'event_espresso'),
205
-                        'filename' => 'pricing_add_new_default_price',
206
-                    ],
207
-                ],
208
-                'metaboxes'     => array_merge(
209
-                    ['_publish_post_box'],
210
-                    $this->_default_espresso_metaboxes
211
-                ),
212
-                'require_nonce' => false,
213
-            ],
214
-            'edit_price'         => [
215
-                'nav'           => [
216
-                    'label'      => esc_html__('Edit Default Price', 'event_espresso'),
217
-                    'order'      => 20,
218
-                    'url'        => $PRC_ID
219
-                        ? add_query_arg(['id' => $PRC_ID], $this->_current_page_view_url)
220
-                        : $this->_admin_base_url,
221
-                    'persistent' => false,
222
-                ],
223
-                'metaboxes'     => array_merge(
224
-                    ['_publish_post_box'],
225
-                    $this->_default_espresso_metaboxes
226
-                ),
227
-                'help_tabs'     => [
228
-                    'edit_default_price_help_tab' => [
229
-                        'title'    => esc_html__('Edit Default Price', 'event_espresso'),
230
-                        'filename' => 'pricing_edit_default_price',
231
-                    ],
232
-                ],
233
-                'require_nonce' => false,
234
-            ],
235
-            'price_types'        => [
236
-                'nav'           => [
237
-                    'label' => esc_html__('Price Types', 'event_espresso'),
238
-                    'order' => 30,
239
-                ],
240
-                'list_table'    => 'Price_Types_List_Table',
241
-                'help_tabs'     => [
242
-                    'pricing_price_types_help_tab'                           => [
243
-                        'title'    => esc_html__('Price Types', 'event_espresso'),
244
-                        'filename' => 'pricing_price_types',
245
-                    ],
246
-                    'pricing_price_types_table_column_headings_help_tab'     => [
247
-                        'title'    => esc_html__('Price Types Table Column Headings', 'event_espresso'),
248
-                        'filename' => 'pricing_price_types_table_column_headings',
249
-                    ],
250
-                    'pricing_price_types_views_bulk_actions_search_help_tab' => [
251
-                        'title'    => esc_html__('Price Types Views & Bulk Actions & Search', 'event_espresso'),
252
-                        'filename' => 'pricing_price_types_views_bulk_actions_search',
253
-                    ],
254
-                ],
255
-                'metaboxes'     => $this->_default_espresso_metaboxes,
256
-                'require_nonce' => false,
257
-            ],
258
-            'add_new_price_type' => [
259
-                'nav'           => [
260
-                    'label'      => esc_html__('Add New Price Type', 'event_espresso'),
261
-                    'order'      => 40,
262
-                    'persistent' => false,
263
-                ],
264
-                'help_tabs'     => [
265
-                    'add_new_price_type_help_tab' => [
266
-                        'title'    => esc_html__('Add New Price Type', 'event_espresso'),
267
-                        'filename' => 'pricing_add_new_price_type',
268
-                    ],
269
-                ],
270
-                'metaboxes'     => array_merge(
271
-                    ['_publish_post_box'],
272
-                    $this->_default_espresso_metaboxes
273
-                ),
274
-                'require_nonce' => false,
275
-            ],
276
-            'edit_price_type'    => [
277
-                'nav'           => [
278
-                    'label'      => esc_html__('Edit Price Type', 'event_espresso'),
279
-                    'order'      => 40,
280
-                    'persistent' => false,
281
-                ],
282
-                'help_tabs'     => [
283
-                    'edit_price_type_help_tab' => [
284
-                        'title'    => esc_html__('Edit Price Type', 'event_espresso'),
285
-                        'filename' => 'pricing_edit_price_type',
286
-                    ],
287
-                ],
288
-                'metaboxes'     => array_merge(
289
-                    ['_publish_post_box'],
290
-                    $this->_default_espresso_metaboxes
291
-                ),
292
-                'require_nonce' => false,
293
-            ],
294
-            'tax_settings'       => [
295
-                'nav'           => [
296
-                    'label' => esc_html__('Tax Settings', 'event_espresso'),
297
-                    'order' => 40,
298
-                ],
299
-                'labels'        => [
300
-                    'publishbox' => esc_html__('Update Tax Settings', 'event_espresso'),
301
-                ],
302
-                'metaboxes'     => array_merge(
303
-                    ['_publish_post_box'],
304
-                    $this->_default_espresso_metaboxes
305
-                ),
306
-                'require_nonce' => true,
307
-            ],
308
-        ];
309
-    }
310
-
311
-
312
-    protected function _add_screen_options()
313
-    {
314
-        // todo
315
-    }
316
-
317
-
318
-    protected function _add_screen_options_default()
319
-    {
320
-        $this->_per_page_screen_option();
321
-    }
322
-
323
-
324
-    protected function _add_screen_options_price_types()
325
-    {
326
-        $page_title              = $this->_admin_page_title;
327
-        $this->_admin_page_title = esc_html__('Price Types', 'event_espresso');
328
-        $this->_per_page_screen_option();
329
-        $this->_admin_page_title = $page_title;
330
-    }
331
-
332
-
333
-    protected function _add_feature_pointers()
334
-    {
335
-    }
336
-
337
-
338
-    public function load_scripts_styles()
339
-    {
340
-        // styles
341
-        wp_enqueue_style('espresso-ui-theme');
342
-        wp_register_style(
343
-            'espresso_PRICING',
344
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.css',
345
-            [],
346
-            EVENT_ESPRESSO_VERSION
347
-        );
348
-        wp_enqueue_style('espresso_PRICING');
349
-
350
-        // scripts
351
-        wp_enqueue_script('ee_admin_js');
352
-        wp_enqueue_script('jquery-ui-position');
353
-        wp_enqueue_script('jquery-ui-widget');
354
-        wp_register_script(
355
-            'espresso_PRICING',
356
-            PRICING_ASSETS_URL . 'espresso_pricing_admin.js',
357
-            ['jquery'],
358
-            EVENT_ESPRESSO_VERSION,
359
-            true
360
-        );
361
-        wp_enqueue_script('espresso_PRICING');
362
-    }
363
-
364
-
365
-    public function load_scripts_styles_default()
366
-    {
367
-        wp_enqueue_script('espresso_ajax_table_sorting');
368
-    }
369
-
370
-
371
-    public function admin_footer_scripts()
372
-    {
373
-    }
374
-
375
-
376
-    public function admin_init()
377
-    {
378
-    }
379
-
380
-
381
-    public function admin_notices()
382
-    {
383
-    }
384
-
385
-
386
-    protected function _set_list_table_views_default()
387
-    {
388
-        $this->_views = [
389
-            'all' => [
390
-                'slug'        => 'all',
391
-                'label'       => esc_html__('View All Default Pricing', 'event_espresso'),
392
-                'count'       => 0,
393
-                'bulk_action' => [
394
-                    'trash_price' => esc_html__('Move to Trash', 'event_espresso'),
395
-                ],
396
-            ],
397
-        ];
398
-
399
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) {
400
-            $this->_views['trashed'] = [
401
-                'slug'        => 'trashed',
402
-                'label'       => esc_html__('Trash', 'event_espresso'),
403
-                'count'       => 0,
404
-                'bulk_action' => [
405
-                    'restore_price' => esc_html__('Restore from Trash', 'event_espresso'),
406
-                    'delete_price'  => esc_html__('Delete Permanently', 'event_espresso'),
407
-                ],
408
-            ];
409
-        }
410
-    }
411
-
412
-
413
-    protected function _set_list_table_views_price_types()
414
-    {
415
-        $this->_views = [
416
-            'all' => [
417
-                'slug'        => 'all',
418
-                'label'       => esc_html__('All', 'event_espresso'),
419
-                'count'       => 0,
420
-                'bulk_action' => [
421
-                    'trash_price_type' => esc_html__('Move to Trash', 'event_espresso'),
422
-                ],
423
-            ],
424
-        ];
425
-
426
-        if (
427
-            EE_Registry::instance()->CAP->current_user_can(
428
-                'ee_delete_default_price_types',
429
-                'pricing_trash_price_type'
430
-            )
431
-        ) {
432
-            $this->_views['trashed'] = [
433
-                'slug'        => 'trashed',
434
-                'label'       => esc_html__('Trash', 'event_espresso'),
435
-                'count'       => 0,
436
-                'bulk_action' => [
437
-                    'restore_price_type' => esc_html__('Restore from Trash', 'event_espresso'),
438
-                    'delete_price_type'  => esc_html__('Delete Permanently', 'event_espresso'),
439
-                ],
440
-            ];
441
-        }
442
-    }
443
-
444
-
445
-    /**
446
-     * generates HTML for main Prices Admin page
447
-     *
448
-     * @return void
449
-     * @throws EE_Error
450
-     */
451
-    protected function _price_overview_list_table()
452
-    {
453
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
454
-            'add_new_price',
455
-            'add',
456
-            [],
457
-            'add-new-h2'
458
-        );
459
-        $this->_admin_page_title .= $this->_learn_more_about_pricing_link();
460
-        $this->_search_btn_label = esc_html__('Default Prices', 'event_espresso');
461
-        $this->display_admin_list_table_page_with_sidebar();
462
-    }
463
-
464
-
465
-    /**
466
-     * retrieve data for Prices List table
467
-     *
468
-     * @param int  $per_page how many prices displayed per page
469
-     * @param bool $count    return the count or objects
470
-     * @param bool $trashed  whether the current view is of the trash can - eww yuck!
471
-     * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects
472
-     * @throws EE_Error
473
-     * @throws ReflectionException
474
-     */
475
-    public function get_prices_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
476
-    {
477
-        // start with an empty array
478
-        $event_pricing = [];
479
-
480
-        require_once(PRICING_ADMIN . 'Prices_List_Table.class.php');
481
-
482
-        $orderby = $this->request->getRequestParam('orderby', '');
483
-        $order   = $this->request->getRequestParam('order', 'ASC');
484
-
485
-        switch ($orderby) {
486
-            case 'name':
487
-                $orderby = ['PRC_name' => $order];
488
-                break;
489
-            case 'type':
490
-                $orderby = ['Price_Type.PRT_name' => $order];
491
-                break;
492
-            case 'amount':
493
-                $orderby = ['PRC_amount' => $order];
494
-                break;
495
-            default:
496
-                $orderby = ['PRC_order' => $order, 'Price_Type.PRT_order' => $order, 'PRC_ID' => $order];
497
-        }
498
-
499
-        $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER);
500
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER);
501
-
502
-        $where = [
503
-            'PRC_is_default' => 1,
504
-            'PRC_deleted'    => $trashed,
505
-        ];
506
-
507
-        $offset = ($current_page - 1) * $per_page;
508
-        $limit  = [$offset, $per_page];
509
-
510
-        $search_term = $this->request->getRequestParam('s');
511
-        if ($search_term) {
512
-            $search_term = "%{$search_term}%";
513
-            $where['OR'] = [
514
-                'PRC_name'            => ['LIKE', $search_term],
515
-                'PRC_desc'            => ['LIKE', $search_term],
516
-                'PRC_amount'          => ['LIKE', $search_term],
517
-                'Price_Type.PRT_name' => ['LIKE', $search_term],
518
-            ];
519
-        }
520
-
521
-        $query_params = [
522
-            $where,
523
-            'order_by' => $orderby,
524
-            'limit'    => $limit,
525
-            'group_by' => 'PRC_ID',
526
-        ];
527
-
528
-        if ($count) {
529
-            return $trashed
530
-                ? EEM_Price::instance()->count([$where])
531
-                : EEM_Price::instance()->count_deleted_and_undeleted([$where]);
532
-        }
533
-        return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params);
534
-    }
535
-
536
-
537
-    /**
538
-     * @return void
539
-     * @throws EE_Error
540
-     * @throws ReflectionException
541
-     */
542
-    protected function _edit_price_details()
543
-    {
544
-        // grab price ID
545
-        $PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER);
546
-        // change page title based on request action
547
-        switch ($this->_req_action) {
548
-            case 'add_new_price':
549
-                $this->_admin_page_title = esc_html__('Add New Price', 'event_espresso');
550
-                break;
551
-            case 'edit_price':
552
-                $this->_admin_page_title = esc_html__('Edit Price', 'event_espresso');
553
-                break;
554
-            default:
555
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
556
-        }
557
-        // add PRC_ID to title if editing
558
-        $this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title;
559
-
560
-        if ($PRC_ID) {
561
-            $price                    = EEM_Price::instance()->get_one_by_ID($PRC_ID);
562
-            $additional_hidden_fields = [
563
-                'PRC_ID' => ['type' => 'hidden', 'value' => $PRC_ID],
564
-            ];
565
-            $this->_set_add_edit_form_tags('update_price', $additional_hidden_fields);
566
-        } else {
567
-            $price = EEM_Price::instance()->get_new_price();
568
-            $this->_set_add_edit_form_tags('insert_price');
569
-        }
570
-
571
-        if (! $price instanceof EE_Price) {
572
-            throw new RuntimeException(
573
-                sprintf(
574
-                    esc_html__(
575
-                        'A valid Price could not be retrieved from the database with ID: %1$s',
576
-                        'event_espresso'
577
-                    ),
578
-                    $PRC_ID
579
-                )
580
-            );
581
-        }
582
-
583
-        $this->_template_args['PRC_ID'] = $PRC_ID;
584
-        $this->_template_args['price']  = $price;
585
-
586
-        $default_base_price = $price->type_obj() && $price->type_obj()->base_type() === 1;
587
-
588
-        $this->_template_args['default_base_price'] = $default_base_price;
589
-
590
-        // get price types
591
-        $price_types = EEM_Price_Type::instance()->get_all([['PBT_ID' => ['!=', 1]]]);
592
-        if (empty($price_types)) {
593
-            $msg = esc_html__(
594
-                'You have no price types defined. Please add a price type before adding a price.',
595
-                'event_espresso'
596
-            );
597
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
598
-            $this->display_admin_page_with_sidebar();
599
-        }
600
-        $attributes       = [];
601
-        $price_type_names = [];
602
-        $attributes[]     = 'id="PRT_ID"';
603
-        if ($default_base_price) {
604
-            $attributes[]       = 'disabled="disabled"';
605
-            $price_type_names[] = ['id' => 1, 'text' => esc_html__('Base Price', 'event_espresso')];
606
-        }
607
-        foreach ($price_types as $type) {
608
-            $price_type_names[] = ['id' => $type->ID(), 'text' => $type->name()];
609
-        }
610
-        $this->_template_args['attributes']  = implode(' ', $attributes);
611
-        $this->_template_args['price_types'] = $price_type_names;
612
-
613
-        $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
614
-        $this->_template_args['admin_page_content']            = $this->_edit_price_details_meta_box();
615
-
616
-        $this->_set_publish_post_box_vars('id', $PRC_ID);
617
-        // the details template wrapper
618
-        $this->display_admin_page_with_sidebar();
619
-    }
620
-
621
-
622
-    /**
623
-     *
624
-     * @return string
625
-     */
626
-    public function _edit_price_details_meta_box(): string
627
-    {
628
-        return EEH_Template::display_template(
629
-            PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php',
630
-            $this->_template_args,
631
-            true
632
-        );
633
-    }
634
-
635
-
636
-    /**
637
-     * @return array
638
-     * @throws EE_Error
639
-     * @throws ReflectionException
640
-     */
641
-    protected function set_price_column_values(): array
642
-    {
643
-        $PRC_order = 0;
644
-        $PRT_ID    = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
645
-        if ($PRT_ID) {
646
-            /** @var EE_Price_Type $price_type */
647
-            $price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
648
-            if ($price_type instanceof EE_Price_Type) {
649
-                $PRC_order = $price_type->order();
650
-            }
651
-        }
652
-        return [
653
-            'PRT_ID'         => $PRT_ID,
654
-            'PRC_amount'     => $this->request->getRequestParam('PRC_amount', 0, DataType::FLOAT),
655
-            'PRC_name'       => $this->request->getRequestParam('PRC_name'),
656
-            'PRC_desc'       => $this->request->getRequestParam('PRC_desc'),
657
-            'PRC_is_default' => 1,
658
-            'PRC_overrides'  => null,
659
-            'PRC_order'      => $PRC_order,
660
-            'PRC_deleted'    => 0,
661
-            'PRC_parent'     => 0,
662
-        ];
663
-    }
664
-
665
-
666
-    /**
667
-     * @param bool $insert - whether to insert or update
668
-     * @return void
669
-     * @throws EE_Error
670
-     * @throws ReflectionException
671
-     */
672
-    protected function _insert_or_update_price(bool $insert = false)
673
-    {
674
-        // why be so pessimistic ???  : (
675
-        $updated = 0;
676
-
677
-        $set_column_values = $this->set_price_column_values();
678
-        // is this a new Price ?
679
-        if ($insert) {
680
-            // run the insert
681
-            $PRC_ID = EEM_Price::instance()->insert($set_column_values);
682
-            if ($PRC_ID) {
683
-                // make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type
684
-                $price = EEM_price::instance()->get_one_by_ID($PRC_ID);
685
-                if (
686
-                    $price instanceof EE_Price
687
-                    && $price->type_obj() instanceof EE_Price_type
688
-                    && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax
689
-                ) {
690
-                    $ticket = EEM_Ticket::instance()->get_one_by_ID(1);
691
-                    $ticket->_add_relation_to($price, 'Price');
692
-                    $ticket->save();
693
-                }
694
-                $updated = 1;
695
-            }
696
-            $action_desc = 'created';
697
-        } else {
698
-            $PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER);
699
-            // run the update
700
-            $where_cols_n_values = ['PRC_ID' => $PRC_ID];
701
-            $updated             = EEM_Price::instance()->update($set_column_values, [$where_cols_n_values]);
702
-
703
-            $price = EEM_Price::instance()->get_one_by_ID($PRC_ID);
704
-            if ($price instanceof EE_Price && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
705
-                // if this is $PRC_ID == 1,
706
-                // then we need to update the default ticket attached to this price so the TKT_price value is updated.
707
-                if ($PRC_ID === 1) {
708
-                    $ticket = $price->get_first_related('Ticket');
709
-                    if ($ticket) {
710
-                        $ticket->set('TKT_price', $price->get('PRC_amount'));
711
-                        $ticket->set('TKT_name', $price->get('PRC_name'));
712
-                        $ticket->set('TKT_description', $price->get('PRC_desc'));
713
-                        $ticket->save();
714
-                    }
715
-                } else {
716
-                    // we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type.
717
-                    $ticket = EEM_Ticket::instance()->get_one_by_ID(1);
718
-                    $ticket->_add_relation_to($PRC_ID, 'Price');
719
-                    $ticket->save();
720
-                }
721
-            }
722
-
723
-            $action_desc = 'updated';
724
-        }
725
-
726
-        $query_args = ['action' => 'edit_price', 'id' => $PRC_ID];
727
-
728
-        $this->_redirect_after_action($updated, 'Prices', $action_desc, $query_args);
729
-    }
730
-
731
-
732
-    /**
733
-     * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE)
734
-     * @return void
735
-     * @throws EE_Error
736
-     * @throws ReflectionException
737
-     */
738
-    protected function _trash_or_restore_price(bool $trash = true)
739
-    {
740
-        $entity_model = EEM_Price::instance();
741
-        $action       = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE;
742
-        $result       = $this->trashRestoreDeleteEntities(
743
-            $entity_model,
744
-            'id',
745
-            $action,
746
-            'PRC_deleted',
747
-            [$this, 'adjustTicketRelations']
748
-        );
749
-
750
-        if ($result) {
751
-            $msg = $trash
752
-                ? esc_html(
753
-                    _n(
754
-                        'The Price has been trashed',
755
-                        'The Prices have been trashed',
756
-                        $result,
757
-                        'event_espresso'
758
-                    )
759
-                )
760
-                : esc_html(
761
-                    _n(
762
-                        'The Price has been restored',
763
-                        'The Prices have been restored',
764
-                        $result,
765
-                        'event_espresso'
766
-                    )
767
-                );
768
-            EE_Error::add_success($msg);
769
-        }
770
-
771
-        $this->_redirect_after_action(
772
-            $result,
773
-            _n('Price', 'Prices', $result, 'event_espresso'),
774
-            $trash ? 'trashed' : 'restored',
775
-            ['action' => 'default'],
776
-            true
777
-        );
778
-    }
779
-
780
-
781
-    /**
782
-     * @param EEM_Base   $entity_model
783
-     * @param int|string $entity_ID
784
-     * @param string     $action
785
-     * @param int        $result
786
-     * @throws EE_Error
787
-     * @throws ReflectionException
788
-     * @since $VID:$
789
-     */
790
-    public function adjustTicketRelations(EEM_Base $entity_model, $entity_ID, string $action, int $result)
791
-    {
792
-        if (! $entity_ID || (float) $result < 1) {
793
-            return;
794
-        }
795
-
796
-        $entity = $entity_model->get_one_by_ID($entity_ID);
797
-        if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) {
798
-            return;
799
-        }
800
-
801
-        // get default tickets for updating
802
-        $default_tickets = EEM_Ticket::instance()->get_all_default_tickets();
803
-        foreach ($default_tickets as $default_ticket) {
804
-            if (! $default_ticket instanceof EE_Ticket) {
805
-                continue;
806
-            }
807
-            switch ($action) {
808
-                case EE_Admin_List_Table::ACTION_DELETE:
809
-                case EE_Admin_List_Table::ACTION_TRASH:
810
-                    // if trashing then remove relations to base default ticket.
811
-                    $default_ticket->_remove_relation_to($entity_ID, 'Price');
812
-                    break;
813
-                case EE_Admin_List_Table::ACTION_RESTORE:
814
-                    // if restoring then add back to base default ticket
815
-                    $default_ticket->_add_relation_to($entity_ID, 'Price');
816
-                    break;
817
-            }
818
-            $default_ticket->save();
819
-        }
820
-    }
821
-
822
-
823
-    /**
824
-     * @return void
825
-     * @throws EE_Error
826
-     * @throws ReflectionException
827
-     */
828
-    protected function _delete_price()
829
-    {
830
-        $entity_model = EEM_Price::instance();
831
-        $deleted      = $this->trashRestoreDeleteEntities($entity_model, 'id');
832
-        $entity       = $entity_model->item_name($deleted);
833
-        $this->_redirect_after_action($deleted, $entity, 'deleted', ['action' => 'default']);
834
-    }
835
-
836
-
837
-    /**
838
-     * @throws EE_Error
839
-     * @throws ReflectionException
840
-     */
841
-    public function update_price_order()
842
-    {
843
-        // grab our row IDs
844
-        $row_ids = $this->request->getRequestParam('row_ids', '');
845
-        $row_ids = explode(',', rtrim($row_ids, ','));
846
-
847
-        $all_updated = true;
848
-        foreach ($row_ids as $i => $row_id) {
849
-            // Update the prices when re-ordering
850
-            $fields_n_values = ['PRC_order' => $i + 1];
851
-            $query_params    = [['PRC_ID' => absint($row_id)]];
852
-            // any failure will toggle $all_updated to false
853
-            $all_updated = $row_id && EEM_Price::instance()->update($fields_n_values, $query_params) !== false
854
-                ? $all_updated
855
-                : false;
856
-        }
857
-        $success = $all_updated ? esc_html__('Price order was updated successfully.', 'event_espresso') : false;
858
-        $errors  = ! $all_updated ? esc_html__('An error occurred. The price order was not updated.', 'event_espresso')
859
-            : false;
860
-
861
-        echo wp_json_encode(['return_data' => false, 'success' => $success, 'errors' => $errors]);
862
-        die();
863
-    }
864
-
865
-
866
-    /******************************************************************************************************************
15
+	protected function _init_page_props()
16
+	{
17
+		$this->page_slug        = PRICING_PG_SLUG;
18
+		$this->page_label       = PRICING_LABEL;
19
+		$this->_admin_base_url  = PRICING_ADMIN_URL;
20
+		$this->_admin_base_path = PRICING_ADMIN;
21
+	}
22
+
23
+
24
+	protected function _ajax_hooks()
25
+	{
26
+		add_action('wp_ajax_espresso_update_prices_order', [$this, 'update_price_order']);
27
+	}
28
+
29
+
30
+	protected function _define_page_props()
31
+	{
32
+		$this->_admin_page_title = PRICING_LABEL;
33
+		$this->_labels           = [
34
+			'buttons' => [
35
+				'add'         => esc_html__('Add New Default Price', 'event_espresso'),
36
+				'edit'        => esc_html__('Edit Default Price', 'event_espresso'),
37
+				'delete'      => esc_html__('Delete Default Price', 'event_espresso'),
38
+				'add_type'    => esc_html__('Add New Default Price Type', 'event_espresso'),
39
+				'edit_type'   => esc_html__('Edit Price Type', 'event_espresso'),
40
+				'delete_type' => esc_html__('Delete Price Type', 'event_espresso'),
41
+			],
42
+		];
43
+	}
44
+
45
+
46
+	/**
47
+	 * an array for storing request actions and their corresponding methods
48
+	 *
49
+	 * @return void
50
+	 */
51
+	protected function _set_page_routes()
52
+	{
53
+		$PRC_ID             = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER);
54
+		$PRT_ID             = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
55
+		$this->_page_routes = [
56
+			'default'                     => [
57
+				'func'       => '_price_overview_list_table',
58
+				'capability' => 'ee_read_default_prices',
59
+			],
60
+			'add_new_price'               => [
61
+				'func'       => '_edit_price_details',
62
+				'args'       => ['new_price' => true],
63
+				'capability' => 'ee_edit_default_prices',
64
+			],
65
+			'edit_price'                  => [
66
+				'func'       => '_edit_price_details',
67
+				'args'       => ['new_price' => false],
68
+				'capability' => 'ee_edit_default_price',
69
+				'obj_id'     => $PRC_ID,
70
+			],
71
+			'insert_price'                => [
72
+				'func'       => '_insert_or_update_price',
73
+				'args'       => ['new_price' => true],
74
+				'noheader'   => true,
75
+				'capability' => 'ee_edit_default_prices',
76
+			],
77
+			'update_price'                => [
78
+				'func'       => '_insert_or_update_price',
79
+				'args'       => ['new_price' => false],
80
+				'noheader'   => true,
81
+				'capability' => 'ee_edit_default_price',
82
+				'obj_id'     => $PRC_ID,
83
+			],
84
+			'trash_price'                 => [
85
+				'func'       => '_trash_or_restore_price',
86
+				'args'       => ['trash' => true],
87
+				'noheader'   => true,
88
+				'capability' => 'ee_delete_default_price',
89
+				'obj_id'     => $PRC_ID,
90
+			],
91
+			'restore_price'               => [
92
+				'func'       => '_trash_or_restore_price',
93
+				'args'       => ['trash' => false],
94
+				'noheader'   => true,
95
+				'capability' => 'ee_delete_default_price',
96
+				'obj_id'     => $PRC_ID,
97
+			],
98
+			'delete_price'                => [
99
+				'func'       => '_delete_price',
100
+				'noheader'   => true,
101
+				'capability' => 'ee_delete_default_price',
102
+				'obj_id'     => $PRC_ID,
103
+			],
104
+			'espresso_update_price_order' => [
105
+				'func'       => 'update_price_order',
106
+				'noheader'   => true,
107
+				'capability' => 'ee_edit_default_prices',
108
+			],
109
+			// price types
110
+			'price_types'                 => [
111
+				'func'       => '_price_types_overview_list_table',
112
+				'capability' => 'ee_read_default_price_types',
113
+			],
114
+			'add_new_price_type'          => [
115
+				'func'       => '_edit_price_type_details',
116
+				'capability' => 'ee_edit_default_price_types',
117
+			],
118
+			'edit_price_type'             => [
119
+				'func'       => '_edit_price_type_details',
120
+				'capability' => 'ee_edit_default_price_type',
121
+				'obj_id'     => $PRT_ID,
122
+			],
123
+			'insert_price_type'           => [
124
+				'func'       => '_insert_or_update_price_type',
125
+				'args'       => ['new_price_type' => true],
126
+				'noheader'   => true,
127
+				'capability' => 'ee_edit_default_price_types',
128
+			],
129
+			'update_price_type'           => [
130
+				'func'       => '_insert_or_update_price_type',
131
+				'args'       => ['new_price_type' => false],
132
+				'noheader'   => true,
133
+				'capability' => 'ee_edit_default_price_type',
134
+				'obj_id'     => $PRT_ID,
135
+			],
136
+			'trash_price_type'            => [
137
+				'func'       => '_trash_or_restore_price_type',
138
+				'args'       => ['trash' => true],
139
+				'noheader'   => true,
140
+				'capability' => 'ee_delete_default_price_type',
141
+				'obj_id'     => $PRT_ID,
142
+			],
143
+			'restore_price_type'          => [
144
+				'func'       => '_trash_or_restore_price_type',
145
+				'args'       => ['trash' => false],
146
+				'noheader'   => true,
147
+				'capability' => 'ee_delete_default_price_type',
148
+				'obj_id'     => $PRT_ID,
149
+			],
150
+			'delete_price_type'           => [
151
+				'func'       => '_delete_price_type',
152
+				'noheader'   => true,
153
+				'capability' => 'ee_delete_default_price_type',
154
+				'obj_id'     => $PRT_ID,
155
+			],
156
+			'tax_settings'                => [
157
+				'func'       => '_tax_settings',
158
+				'capability' => 'manage_options',
159
+			],
160
+			'update_tax_settings'         => [
161
+				'func'       => '_update_tax_settings',
162
+				'capability' => 'manage_options',
163
+				'noheader'   => true,
164
+			],
165
+		];
166
+	}
167
+
168
+
169
+	protected function _set_page_config()
170
+	{
171
+		$PRC_ID             = $this->request->getRequestParam('id', 0, DataType::INTEGER);
172
+		$this->_page_config = [
173
+			'default'            => [
174
+				'nav'           => [
175
+					'label' => esc_html__('Default Pricing', 'event_espresso'),
176
+					'order' => 10,
177
+				],
178
+				'list_table'    => 'Prices_List_Table',
179
+				'metaboxes'     => $this->_default_espresso_metaboxes,
180
+				'help_tabs'     => [
181
+					'pricing_default_pricing_help_tab'                           => [
182
+						'title'    => esc_html__('Default Pricing', 'event_espresso'),
183
+						'filename' => 'pricing_default_pricing',
184
+					],
185
+					'pricing_default_pricing_table_column_headings_help_tab'     => [
186
+						'title'    => esc_html__('Default Pricing Table Column Headings', 'event_espresso'),
187
+						'filename' => 'pricing_default_pricing_table_column_headings',
188
+					],
189
+					'pricing_default_pricing_views_bulk_actions_search_help_tab' => [
190
+						'title'    => esc_html__('Default Pricing Views & Bulk Actions & Search', 'event_espresso'),
191
+						'filename' => 'pricing_default_pricing_views_bulk_actions_search',
192
+					],
193
+				],
194
+				'require_nonce' => false,
195
+			],
196
+			'add_new_price'      => [
197
+				'nav'           => [
198
+					'label'      => esc_html__('Add New Default Price', 'event_espresso'),
199
+					'order'      => 20,
200
+					'persistent' => false,
201
+				],
202
+				'help_tabs'     => [
203
+					'add_new_default_price_help_tab' => [
204
+						'title'    => esc_html__('Add New Default Price', 'event_espresso'),
205
+						'filename' => 'pricing_add_new_default_price',
206
+					],
207
+				],
208
+				'metaboxes'     => array_merge(
209
+					['_publish_post_box'],
210
+					$this->_default_espresso_metaboxes
211
+				),
212
+				'require_nonce' => false,
213
+			],
214
+			'edit_price'         => [
215
+				'nav'           => [
216
+					'label'      => esc_html__('Edit Default Price', 'event_espresso'),
217
+					'order'      => 20,
218
+					'url'        => $PRC_ID
219
+						? add_query_arg(['id' => $PRC_ID], $this->_current_page_view_url)
220
+						: $this->_admin_base_url,
221
+					'persistent' => false,
222
+				],
223
+				'metaboxes'     => array_merge(
224
+					['_publish_post_box'],
225
+					$this->_default_espresso_metaboxes
226
+				),
227
+				'help_tabs'     => [
228
+					'edit_default_price_help_tab' => [
229
+						'title'    => esc_html__('Edit Default Price', 'event_espresso'),
230
+						'filename' => 'pricing_edit_default_price',
231
+					],
232
+				],
233
+				'require_nonce' => false,
234
+			],
235
+			'price_types'        => [
236
+				'nav'           => [
237
+					'label' => esc_html__('Price Types', 'event_espresso'),
238
+					'order' => 30,
239
+				],
240
+				'list_table'    => 'Price_Types_List_Table',
241
+				'help_tabs'     => [
242
+					'pricing_price_types_help_tab'                           => [
243
+						'title'    => esc_html__('Price Types', 'event_espresso'),
244
+						'filename' => 'pricing_price_types',
245
+					],
246
+					'pricing_price_types_table_column_headings_help_tab'     => [
247
+						'title'    => esc_html__('Price Types Table Column Headings', 'event_espresso'),
248
+						'filename' => 'pricing_price_types_table_column_headings',
249
+					],
250
+					'pricing_price_types_views_bulk_actions_search_help_tab' => [
251
+						'title'    => esc_html__('Price Types Views & Bulk Actions & Search', 'event_espresso'),
252
+						'filename' => 'pricing_price_types_views_bulk_actions_search',
253
+					],
254
+				],
255
+				'metaboxes'     => $this->_default_espresso_metaboxes,
256
+				'require_nonce' => false,
257
+			],
258
+			'add_new_price_type' => [
259
+				'nav'           => [
260
+					'label'      => esc_html__('Add New Price Type', 'event_espresso'),
261
+					'order'      => 40,
262
+					'persistent' => false,
263
+				],
264
+				'help_tabs'     => [
265
+					'add_new_price_type_help_tab' => [
266
+						'title'    => esc_html__('Add New Price Type', 'event_espresso'),
267
+						'filename' => 'pricing_add_new_price_type',
268
+					],
269
+				],
270
+				'metaboxes'     => array_merge(
271
+					['_publish_post_box'],
272
+					$this->_default_espresso_metaboxes
273
+				),
274
+				'require_nonce' => false,
275
+			],
276
+			'edit_price_type'    => [
277
+				'nav'           => [
278
+					'label'      => esc_html__('Edit Price Type', 'event_espresso'),
279
+					'order'      => 40,
280
+					'persistent' => false,
281
+				],
282
+				'help_tabs'     => [
283
+					'edit_price_type_help_tab' => [
284
+						'title'    => esc_html__('Edit Price Type', 'event_espresso'),
285
+						'filename' => 'pricing_edit_price_type',
286
+					],
287
+				],
288
+				'metaboxes'     => array_merge(
289
+					['_publish_post_box'],
290
+					$this->_default_espresso_metaboxes
291
+				),
292
+				'require_nonce' => false,
293
+			],
294
+			'tax_settings'       => [
295
+				'nav'           => [
296
+					'label' => esc_html__('Tax Settings', 'event_espresso'),
297
+					'order' => 40,
298
+				],
299
+				'labels'        => [
300
+					'publishbox' => esc_html__('Update Tax Settings', 'event_espresso'),
301
+				],
302
+				'metaboxes'     => array_merge(
303
+					['_publish_post_box'],
304
+					$this->_default_espresso_metaboxes
305
+				),
306
+				'require_nonce' => true,
307
+			],
308
+		];
309
+	}
310
+
311
+
312
+	protected function _add_screen_options()
313
+	{
314
+		// todo
315
+	}
316
+
317
+
318
+	protected function _add_screen_options_default()
319
+	{
320
+		$this->_per_page_screen_option();
321
+	}
322
+
323
+
324
+	protected function _add_screen_options_price_types()
325
+	{
326
+		$page_title              = $this->_admin_page_title;
327
+		$this->_admin_page_title = esc_html__('Price Types', 'event_espresso');
328
+		$this->_per_page_screen_option();
329
+		$this->_admin_page_title = $page_title;
330
+	}
331
+
332
+
333
+	protected function _add_feature_pointers()
334
+	{
335
+	}
336
+
337
+
338
+	public function load_scripts_styles()
339
+	{
340
+		// styles
341
+		wp_enqueue_style('espresso-ui-theme');
342
+		wp_register_style(
343
+			'espresso_PRICING',
344
+			PRICING_ASSETS_URL . 'espresso_pricing_admin.css',
345
+			[],
346
+			EVENT_ESPRESSO_VERSION
347
+		);
348
+		wp_enqueue_style('espresso_PRICING');
349
+
350
+		// scripts
351
+		wp_enqueue_script('ee_admin_js');
352
+		wp_enqueue_script('jquery-ui-position');
353
+		wp_enqueue_script('jquery-ui-widget');
354
+		wp_register_script(
355
+			'espresso_PRICING',
356
+			PRICING_ASSETS_URL . 'espresso_pricing_admin.js',
357
+			['jquery'],
358
+			EVENT_ESPRESSO_VERSION,
359
+			true
360
+		);
361
+		wp_enqueue_script('espresso_PRICING');
362
+	}
363
+
364
+
365
+	public function load_scripts_styles_default()
366
+	{
367
+		wp_enqueue_script('espresso_ajax_table_sorting');
368
+	}
369
+
370
+
371
+	public function admin_footer_scripts()
372
+	{
373
+	}
374
+
375
+
376
+	public function admin_init()
377
+	{
378
+	}
379
+
380
+
381
+	public function admin_notices()
382
+	{
383
+	}
384
+
385
+
386
+	protected function _set_list_table_views_default()
387
+	{
388
+		$this->_views = [
389
+			'all' => [
390
+				'slug'        => 'all',
391
+				'label'       => esc_html__('View All Default Pricing', 'event_espresso'),
392
+				'count'       => 0,
393
+				'bulk_action' => [
394
+					'trash_price' => esc_html__('Move to Trash', 'event_espresso'),
395
+				],
396
+			],
397
+		];
398
+
399
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_default_prices', 'pricing_trash_price')) {
400
+			$this->_views['trashed'] = [
401
+				'slug'        => 'trashed',
402
+				'label'       => esc_html__('Trash', 'event_espresso'),
403
+				'count'       => 0,
404
+				'bulk_action' => [
405
+					'restore_price' => esc_html__('Restore from Trash', 'event_espresso'),
406
+					'delete_price'  => esc_html__('Delete Permanently', 'event_espresso'),
407
+				],
408
+			];
409
+		}
410
+	}
411
+
412
+
413
+	protected function _set_list_table_views_price_types()
414
+	{
415
+		$this->_views = [
416
+			'all' => [
417
+				'slug'        => 'all',
418
+				'label'       => esc_html__('All', 'event_espresso'),
419
+				'count'       => 0,
420
+				'bulk_action' => [
421
+					'trash_price_type' => esc_html__('Move to Trash', 'event_espresso'),
422
+				],
423
+			],
424
+		];
425
+
426
+		if (
427
+			EE_Registry::instance()->CAP->current_user_can(
428
+				'ee_delete_default_price_types',
429
+				'pricing_trash_price_type'
430
+			)
431
+		) {
432
+			$this->_views['trashed'] = [
433
+				'slug'        => 'trashed',
434
+				'label'       => esc_html__('Trash', 'event_espresso'),
435
+				'count'       => 0,
436
+				'bulk_action' => [
437
+					'restore_price_type' => esc_html__('Restore from Trash', 'event_espresso'),
438
+					'delete_price_type'  => esc_html__('Delete Permanently', 'event_espresso'),
439
+				],
440
+			];
441
+		}
442
+	}
443
+
444
+
445
+	/**
446
+	 * generates HTML for main Prices Admin page
447
+	 *
448
+	 * @return void
449
+	 * @throws EE_Error
450
+	 */
451
+	protected function _price_overview_list_table()
452
+	{
453
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
454
+			'add_new_price',
455
+			'add',
456
+			[],
457
+			'add-new-h2'
458
+		);
459
+		$this->_admin_page_title .= $this->_learn_more_about_pricing_link();
460
+		$this->_search_btn_label = esc_html__('Default Prices', 'event_espresso');
461
+		$this->display_admin_list_table_page_with_sidebar();
462
+	}
463
+
464
+
465
+	/**
466
+	 * retrieve data for Prices List table
467
+	 *
468
+	 * @param int  $per_page how many prices displayed per page
469
+	 * @param bool $count    return the count or objects
470
+	 * @param bool $trashed  whether the current view is of the trash can - eww yuck!
471
+	 * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects
472
+	 * @throws EE_Error
473
+	 * @throws ReflectionException
474
+	 */
475
+	public function get_prices_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
476
+	{
477
+		// start with an empty array
478
+		$event_pricing = [];
479
+
480
+		require_once(PRICING_ADMIN . 'Prices_List_Table.class.php');
481
+
482
+		$orderby = $this->request->getRequestParam('orderby', '');
483
+		$order   = $this->request->getRequestParam('order', 'ASC');
484
+
485
+		switch ($orderby) {
486
+			case 'name':
487
+				$orderby = ['PRC_name' => $order];
488
+				break;
489
+			case 'type':
490
+				$orderby = ['Price_Type.PRT_name' => $order];
491
+				break;
492
+			case 'amount':
493
+				$orderby = ['PRC_amount' => $order];
494
+				break;
495
+			default:
496
+				$orderby = ['PRC_order' => $order, 'Price_Type.PRT_order' => $order, 'PRC_ID' => $order];
497
+		}
498
+
499
+		$current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER);
500
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER);
501
+
502
+		$where = [
503
+			'PRC_is_default' => 1,
504
+			'PRC_deleted'    => $trashed,
505
+		];
506
+
507
+		$offset = ($current_page - 1) * $per_page;
508
+		$limit  = [$offset, $per_page];
509
+
510
+		$search_term = $this->request->getRequestParam('s');
511
+		if ($search_term) {
512
+			$search_term = "%{$search_term}%";
513
+			$where['OR'] = [
514
+				'PRC_name'            => ['LIKE', $search_term],
515
+				'PRC_desc'            => ['LIKE', $search_term],
516
+				'PRC_amount'          => ['LIKE', $search_term],
517
+				'Price_Type.PRT_name' => ['LIKE', $search_term],
518
+			];
519
+		}
520
+
521
+		$query_params = [
522
+			$where,
523
+			'order_by' => $orderby,
524
+			'limit'    => $limit,
525
+			'group_by' => 'PRC_ID',
526
+		];
527
+
528
+		if ($count) {
529
+			return $trashed
530
+				? EEM_Price::instance()->count([$where])
531
+				: EEM_Price::instance()->count_deleted_and_undeleted([$where]);
532
+		}
533
+		return EEM_Price::instance()->get_all_deleted_and_undeleted($query_params);
534
+	}
535
+
536
+
537
+	/**
538
+	 * @return void
539
+	 * @throws EE_Error
540
+	 * @throws ReflectionException
541
+	 */
542
+	protected function _edit_price_details()
543
+	{
544
+		// grab price ID
545
+		$PRC_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER);
546
+		// change page title based on request action
547
+		switch ($this->_req_action) {
548
+			case 'add_new_price':
549
+				$this->_admin_page_title = esc_html__('Add New Price', 'event_espresso');
550
+				break;
551
+			case 'edit_price':
552
+				$this->_admin_page_title = esc_html__('Edit Price', 'event_espresso');
553
+				break;
554
+			default:
555
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
556
+		}
557
+		// add PRC_ID to title if editing
558
+		$this->_admin_page_title = $PRC_ID ? $this->_admin_page_title . ' # ' . $PRC_ID : $this->_admin_page_title;
559
+
560
+		if ($PRC_ID) {
561
+			$price                    = EEM_Price::instance()->get_one_by_ID($PRC_ID);
562
+			$additional_hidden_fields = [
563
+				'PRC_ID' => ['type' => 'hidden', 'value' => $PRC_ID],
564
+			];
565
+			$this->_set_add_edit_form_tags('update_price', $additional_hidden_fields);
566
+		} else {
567
+			$price = EEM_Price::instance()->get_new_price();
568
+			$this->_set_add_edit_form_tags('insert_price');
569
+		}
570
+
571
+		if (! $price instanceof EE_Price) {
572
+			throw new RuntimeException(
573
+				sprintf(
574
+					esc_html__(
575
+						'A valid Price could not be retrieved from the database with ID: %1$s',
576
+						'event_espresso'
577
+					),
578
+					$PRC_ID
579
+				)
580
+			);
581
+		}
582
+
583
+		$this->_template_args['PRC_ID'] = $PRC_ID;
584
+		$this->_template_args['price']  = $price;
585
+
586
+		$default_base_price = $price->type_obj() && $price->type_obj()->base_type() === 1;
587
+
588
+		$this->_template_args['default_base_price'] = $default_base_price;
589
+
590
+		// get price types
591
+		$price_types = EEM_Price_Type::instance()->get_all([['PBT_ID' => ['!=', 1]]]);
592
+		if (empty($price_types)) {
593
+			$msg = esc_html__(
594
+				'You have no price types defined. Please add a price type before adding a price.',
595
+				'event_espresso'
596
+			);
597
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
598
+			$this->display_admin_page_with_sidebar();
599
+		}
600
+		$attributes       = [];
601
+		$price_type_names = [];
602
+		$attributes[]     = 'id="PRT_ID"';
603
+		if ($default_base_price) {
604
+			$attributes[]       = 'disabled="disabled"';
605
+			$price_type_names[] = ['id' => 1, 'text' => esc_html__('Base Price', 'event_espresso')];
606
+		}
607
+		foreach ($price_types as $type) {
608
+			$price_type_names[] = ['id' => $type->ID(), 'text' => $type->name()];
609
+		}
610
+		$this->_template_args['attributes']  = implode(' ', $attributes);
611
+		$this->_template_args['price_types'] = $price_type_names;
612
+
613
+		$this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
614
+		$this->_template_args['admin_page_content']            = $this->_edit_price_details_meta_box();
615
+
616
+		$this->_set_publish_post_box_vars('id', $PRC_ID);
617
+		// the details template wrapper
618
+		$this->display_admin_page_with_sidebar();
619
+	}
620
+
621
+
622
+	/**
623
+	 *
624
+	 * @return string
625
+	 */
626
+	public function _edit_price_details_meta_box(): string
627
+	{
628
+		return EEH_Template::display_template(
629
+			PRICING_TEMPLATE_PATH . 'pricing_details_main_meta_box.template.php',
630
+			$this->_template_args,
631
+			true
632
+		);
633
+	}
634
+
635
+
636
+	/**
637
+	 * @return array
638
+	 * @throws EE_Error
639
+	 * @throws ReflectionException
640
+	 */
641
+	protected function set_price_column_values(): array
642
+	{
643
+		$PRC_order = 0;
644
+		$PRT_ID    = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
645
+		if ($PRT_ID) {
646
+			/** @var EE_Price_Type $price_type */
647
+			$price_type = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
648
+			if ($price_type instanceof EE_Price_Type) {
649
+				$PRC_order = $price_type->order();
650
+			}
651
+		}
652
+		return [
653
+			'PRT_ID'         => $PRT_ID,
654
+			'PRC_amount'     => $this->request->getRequestParam('PRC_amount', 0, DataType::FLOAT),
655
+			'PRC_name'       => $this->request->getRequestParam('PRC_name'),
656
+			'PRC_desc'       => $this->request->getRequestParam('PRC_desc'),
657
+			'PRC_is_default' => 1,
658
+			'PRC_overrides'  => null,
659
+			'PRC_order'      => $PRC_order,
660
+			'PRC_deleted'    => 0,
661
+			'PRC_parent'     => 0,
662
+		];
663
+	}
664
+
665
+
666
+	/**
667
+	 * @param bool $insert - whether to insert or update
668
+	 * @return void
669
+	 * @throws EE_Error
670
+	 * @throws ReflectionException
671
+	 */
672
+	protected function _insert_or_update_price(bool $insert = false)
673
+	{
674
+		// why be so pessimistic ???  : (
675
+		$updated = 0;
676
+
677
+		$set_column_values = $this->set_price_column_values();
678
+		// is this a new Price ?
679
+		if ($insert) {
680
+			// run the insert
681
+			$PRC_ID = EEM_Price::instance()->insert($set_column_values);
682
+			if ($PRC_ID) {
683
+				// make sure this new price modifier is attached to the ticket but ONLY if it is not a tax type
684
+				$price = EEM_price::instance()->get_one_by_ID($PRC_ID);
685
+				if (
686
+					$price instanceof EE_Price
687
+					&& $price->type_obj() instanceof EE_Price_type
688
+					&& $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax
689
+				) {
690
+					$ticket = EEM_Ticket::instance()->get_one_by_ID(1);
691
+					$ticket->_add_relation_to($price, 'Price');
692
+					$ticket->save();
693
+				}
694
+				$updated = 1;
695
+			}
696
+			$action_desc = 'created';
697
+		} else {
698
+			$PRC_ID = $this->request->getRequestParam('PRC_ID', 0, DataType::INTEGER);
699
+			// run the update
700
+			$where_cols_n_values = ['PRC_ID' => $PRC_ID];
701
+			$updated             = EEM_Price::instance()->update($set_column_values, [$where_cols_n_values]);
702
+
703
+			$price = EEM_Price::instance()->get_one_by_ID($PRC_ID);
704
+			if ($price instanceof EE_Price && $price->type_obj()->base_type() !== EEM_Price_Type::base_type_tax) {
705
+				// if this is $PRC_ID == 1,
706
+				// then we need to update the default ticket attached to this price so the TKT_price value is updated.
707
+				if ($PRC_ID === 1) {
708
+					$ticket = $price->get_first_related('Ticket');
709
+					if ($ticket) {
710
+						$ticket->set('TKT_price', $price->get('PRC_amount'));
711
+						$ticket->set('TKT_name', $price->get('PRC_name'));
712
+						$ticket->set('TKT_description', $price->get('PRC_desc'));
713
+						$ticket->save();
714
+					}
715
+				} else {
716
+					// we make sure this price is attached to base ticket. but ONLY if its not a tax ticket type.
717
+					$ticket = EEM_Ticket::instance()->get_one_by_ID(1);
718
+					$ticket->_add_relation_to($PRC_ID, 'Price');
719
+					$ticket->save();
720
+				}
721
+			}
722
+
723
+			$action_desc = 'updated';
724
+		}
725
+
726
+		$query_args = ['action' => 'edit_price', 'id' => $PRC_ID];
727
+
728
+		$this->_redirect_after_action($updated, 'Prices', $action_desc, $query_args);
729
+	}
730
+
731
+
732
+	/**
733
+	 * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE)
734
+	 * @return void
735
+	 * @throws EE_Error
736
+	 * @throws ReflectionException
737
+	 */
738
+	protected function _trash_or_restore_price(bool $trash = true)
739
+	{
740
+		$entity_model = EEM_Price::instance();
741
+		$action       = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE;
742
+		$result       = $this->trashRestoreDeleteEntities(
743
+			$entity_model,
744
+			'id',
745
+			$action,
746
+			'PRC_deleted',
747
+			[$this, 'adjustTicketRelations']
748
+		);
749
+
750
+		if ($result) {
751
+			$msg = $trash
752
+				? esc_html(
753
+					_n(
754
+						'The Price has been trashed',
755
+						'The Prices have been trashed',
756
+						$result,
757
+						'event_espresso'
758
+					)
759
+				)
760
+				: esc_html(
761
+					_n(
762
+						'The Price has been restored',
763
+						'The Prices have been restored',
764
+						$result,
765
+						'event_espresso'
766
+					)
767
+				);
768
+			EE_Error::add_success($msg);
769
+		}
770
+
771
+		$this->_redirect_after_action(
772
+			$result,
773
+			_n('Price', 'Prices', $result, 'event_espresso'),
774
+			$trash ? 'trashed' : 'restored',
775
+			['action' => 'default'],
776
+			true
777
+		);
778
+	}
779
+
780
+
781
+	/**
782
+	 * @param EEM_Base   $entity_model
783
+	 * @param int|string $entity_ID
784
+	 * @param string     $action
785
+	 * @param int        $result
786
+	 * @throws EE_Error
787
+	 * @throws ReflectionException
788
+	 * @since $VID:$
789
+	 */
790
+	public function adjustTicketRelations(EEM_Base $entity_model, $entity_ID, string $action, int $result)
791
+	{
792
+		if (! $entity_ID || (float) $result < 1) {
793
+			return;
794
+		}
795
+
796
+		$entity = $entity_model->get_one_by_ID($entity_ID);
797
+		if (! $entity instanceof EE_Price || $entity->type_obj()->base_type() === EEM_Price_Type::base_type_tax) {
798
+			return;
799
+		}
800
+
801
+		// get default tickets for updating
802
+		$default_tickets = EEM_Ticket::instance()->get_all_default_tickets();
803
+		foreach ($default_tickets as $default_ticket) {
804
+			if (! $default_ticket instanceof EE_Ticket) {
805
+				continue;
806
+			}
807
+			switch ($action) {
808
+				case EE_Admin_List_Table::ACTION_DELETE:
809
+				case EE_Admin_List_Table::ACTION_TRASH:
810
+					// if trashing then remove relations to base default ticket.
811
+					$default_ticket->_remove_relation_to($entity_ID, 'Price');
812
+					break;
813
+				case EE_Admin_List_Table::ACTION_RESTORE:
814
+					// if restoring then add back to base default ticket
815
+					$default_ticket->_add_relation_to($entity_ID, 'Price');
816
+					break;
817
+			}
818
+			$default_ticket->save();
819
+		}
820
+	}
821
+
822
+
823
+	/**
824
+	 * @return void
825
+	 * @throws EE_Error
826
+	 * @throws ReflectionException
827
+	 */
828
+	protected function _delete_price()
829
+	{
830
+		$entity_model = EEM_Price::instance();
831
+		$deleted      = $this->trashRestoreDeleteEntities($entity_model, 'id');
832
+		$entity       = $entity_model->item_name($deleted);
833
+		$this->_redirect_after_action($deleted, $entity, 'deleted', ['action' => 'default']);
834
+	}
835
+
836
+
837
+	/**
838
+	 * @throws EE_Error
839
+	 * @throws ReflectionException
840
+	 */
841
+	public function update_price_order()
842
+	{
843
+		// grab our row IDs
844
+		$row_ids = $this->request->getRequestParam('row_ids', '');
845
+		$row_ids = explode(',', rtrim($row_ids, ','));
846
+
847
+		$all_updated = true;
848
+		foreach ($row_ids as $i => $row_id) {
849
+			// Update the prices when re-ordering
850
+			$fields_n_values = ['PRC_order' => $i + 1];
851
+			$query_params    = [['PRC_ID' => absint($row_id)]];
852
+			// any failure will toggle $all_updated to false
853
+			$all_updated = $row_id && EEM_Price::instance()->update($fields_n_values, $query_params) !== false
854
+				? $all_updated
855
+				: false;
856
+		}
857
+		$success = $all_updated ? esc_html__('Price order was updated successfully.', 'event_espresso') : false;
858
+		$errors  = ! $all_updated ? esc_html__('An error occurred. The price order was not updated.', 'event_espresso')
859
+			: false;
860
+
861
+		echo wp_json_encode(['return_data' => false, 'success' => $success, 'errors' => $errors]);
862
+		die();
863
+	}
864
+
865
+
866
+	/******************************************************************************************************************
867 867
      ***********************************************  TICKET PRICE TYPES  *********************************************
868 868
      ******************************************************************************************************************/
869 869
 
870 870
 
871
-    /**
872
-     * generates HTML for main Prices Admin page
873
-     *
874
-     * @return void
875
-     * @throws EE_Error
876
-     */
877
-    protected function _price_types_overview_list_table()
878
-    {
879
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
880
-            'add_new_price_type',
881
-            'add_type',
882
-            [],
883
-            'add-new-h2'
884
-        );
885
-        $this->_admin_page_title .= $this->_learn_more_about_pricing_link();
886
-        $this->_search_btn_label = esc_html__('Price Types', 'event_espresso');
887
-        $this->display_admin_list_table_page_with_sidebar();
888
-    }
889
-
890
-
891
-    /**
892
-     * retrieve data for Price Types List table
893
-     *
894
-     * @param int  $per_page how many prices displayed per page
895
-     * @param bool $count    return the count or objects
896
-     * @param bool $trashed  whether the current view is of the trash can - eww yuck!
897
-     * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects
898
-     * @throws EE_Error
899
-     * @throws ReflectionException
900
-     */
901
-    public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
902
-    {
903
-        // start with an empty array
904
-        require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php');
905
-
906
-        $orderby = $this->request->getRequestParam('orderby', '');
907
-        $order   = $this->request->getRequestParam('order', 'ASC');
908
-
909
-        switch ($orderby) {
910
-            case 'name':
911
-                $orderby = ['PRT_name' => $order];
912
-                break;
913
-            default:
914
-                $orderby = ['PRT_order' => $order];
915
-        }
916
-
917
-        $current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER);
918
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER);
919
-
920
-        $offset = ($current_page - 1) * $per_page;
921
-        $limit  = [$offset, $per_page];
922
-
923
-        $where = ['PRT_deleted' => $trashed, 'PBT_ID' => ['!=', 1]];
924
-
925
-        $search_term = $this->request->getRequestParam('s');
926
-        if ($search_term) {
927
-            $where['OR'] = [
928
-                'PRT_name' => ['LIKE', "%{$search_term}%"],
929
-            ];
930
-        }
931
-        $query_params = [
932
-            $where,
933
-            'order_by' => $orderby,
934
-            'limit'    => $limit,
935
-        ];
936
-        return $count
937
-            ? EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params)
938
-            : EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params);
939
-    }
940
-
941
-
942
-    /**
943
-     * _edit_price_type_details
944
-     *
945
-     * @return void
946
-     * @throws EE_Error
947
-     * @throws ReflectionException
948
-     */
949
-    protected function _edit_price_type_details()
950
-    {
951
-        // grab price type ID
952
-        $PRT_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER);
953
-        // change page title based on request action
954
-        switch ($this->_req_action) {
955
-            case 'add_new_price_type':
956
-                $this->_admin_page_title = esc_html__('Add New Price Type', 'event_espresso');
957
-                break;
958
-            case 'edit_price_type':
959
-                $this->_admin_page_title = esc_html__('Edit Price Type', 'event_espresso');
960
-                break;
961
-            default:
962
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
963
-        }
964
-        // add PRT_ID to title if editing
965
-        $this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title;
966
-
967
-        if ($PRT_ID) {
968
-            $price_type               = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
969
-            $additional_hidden_fields = ['PRT_ID' => ['type' => 'hidden', 'value' => $PRT_ID]];
970
-            $this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields);
971
-        } else {
972
-            $price_type = EEM_Price_Type::instance()->get_new_price_type();
973
-            $this->_set_add_edit_form_tags('insert_price_type');
974
-        }
975
-
976
-        if (! $price_type instanceof EE_Price_Type) {
977
-            throw new RuntimeException(
978
-                sprintf(
979
-                    esc_html__(
980
-                        'A valid Price Type could not be retrieved from the database with ID: %1$s',
981
-                        'event_espresso'
982
-                    ),
983
-                    $PRT_ID
984
-                )
985
-            );
986
-        }
987
-
988
-        $this->_template_args['PRT_ID']     = $PRT_ID;
989
-        $this->_template_args['price_type'] = $price_type;
990
-
991
-        $base_types    = EEM_Price_Type::instance()->get_base_types();
992
-        $select_values = [];
993
-        foreach ($base_types as $ref => $text) {
994
-            if ($ref == EEM_Price_Type::base_type_base_price) {
995
-                // do not allow creation of base_type_base_prices because that's a system only base type.
996
-                continue;
997
-            }
998
-            $select_values[] = ['id' => $ref, 'text' => $text];
999
-        }
1000
-
1001
-        $this->_template_args['base_type_select'] = EEH_Form_Fields::select_input(
1002
-            'base_type',
1003
-            $select_values,
1004
-            $price_type->base_type(),
1005
-            'id="price-type-base-type-slct"'
1006
-        );
1007
-
1008
-        $this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
1009
-        $this->_template_args['admin_page_content']            = $this->_edit_price_type_details_meta_box();
1010
-
1011
-        $redirect_URL = add_query_arg(['action' => 'price_types'], $this->_admin_base_url);
1012
-        $this->_set_publish_post_box_vars('id', $PRT_ID, false, $redirect_URL);
1013
-        // the details template wrapper
1014
-        $this->display_admin_page_with_sidebar();
1015
-    }
1016
-
1017
-
1018
-    /**
1019
-     * _edit_price_type_details_meta_box
1020
-     *
1021
-     * @return string
1022
-     */
1023
-    public function _edit_price_type_details_meta_box(): string
1024
-    {
1025
-        return EEH_Template::display_template(
1026
-            PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php',
1027
-            $this->_template_args,
1028
-            true
1029
-        );
1030
-    }
1031
-
1032
-
1033
-    /**
1034
-     * @return array
1035
-     */
1036
-    protected function set_price_type_column_values(): array
1037
-    {
1038
-        $base_type  = $this->request->getRequestParam(
1039
-            'base_type',
1040
-            EEM_Price_Type::base_type_base_price,
1041
-            DataType::INTEGER
1042
-        );
1043
-        $is_percent = $this->request->getRequestParam('PRT_is_percent', 0, DataType::INTEGER);
1044
-        $order      = $this->request->getRequestParam('PRT_order', 0, DataType::INTEGER);
1045
-        switch ($base_type) {
1046
-            case EEM_Price_Type::base_type_base_price:
1047
-                $is_percent = 0;
1048
-                $order      = 0;
1049
-                break;
1050
-
1051
-            case EEM_Price_Type::base_type_discount:
1052
-            case EEM_Price_Type::base_type_surcharge:
1053
-                break;
1054
-
1055
-            case EEM_Price_Type::base_type_tax:
1056
-                $is_percent = 1;
1057
-                break;
1058
-        }
1059
-
1060
-        return [
1061
-            'PBT_ID'         => $base_type,
1062
-            'PRT_name'       => $this->request->getRequestParam('PRT_name', ''),
1063
-            'PRT_is_percent' => $is_percent,
1064
-            'PRT_order'      => $order,
1065
-            'PRT_deleted'    => 0,
1066
-        ];
1067
-    }
1068
-
1069
-
1070
-    /**
1071
-     * @param bool $new_price_type - whether to insert or update
1072
-     * @return void
1073
-     * @throws EE_Error
1074
-     * @throws ReflectionException
1075
-     */
1076
-    protected function _insert_or_update_price_type(bool $new_price_type = false)
1077
-    {
1078
-        // why be so pessimistic ???  : (
1079
-        $success = 0;
1080
-
1081
-        $set_column_values = $this->set_price_type_column_values();
1082
-        // is this a new Price ?
1083
-        if ($new_price_type) {
1084
-            // run the insert
1085
-            if ($PRT_ID = EEM_Price_Type::instance()->insert($set_column_values)) {
1086
-                $success = 1;
1087
-            }
1088
-            $action_desc = 'created';
1089
-        } else {
1090
-            $PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
1091
-            // run the update
1092
-            $where_cols_n_values = ['PRT_ID' => $PRT_ID];
1093
-            if (EEM_Price_Type::instance()->update($set_column_values, [$where_cols_n_values])) {
1094
-                $success = 1;
1095
-            }
1096
-            $action_desc = 'updated';
1097
-        }
1098
-
1099
-        $query_args = ['action' => 'edit_price_type', 'id' => $PRT_ID];
1100
-        $this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args);
1101
-    }
1102
-
1103
-
1104
-    /**
1105
-     * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE)
1106
-     * @return void
1107
-     * @throws EE_Error
1108
-     * @throws ReflectionException
1109
-     */
1110
-    protected function _trash_or_restore_price_type(bool $trash = true)
1111
-    {
1112
-        $entity_model = EEM_Price_Type::instance();
1113
-        $action       = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE;
1114
-        $success      = $this->trashRestoreDeleteEntities($entity_model, 'id', $action, 'PRT_deleted');
1115
-        if ($success) {
1116
-            $msg = $trash
1117
-                ? esc_html(
1118
-                    _n(
1119
-                        'The Price Type has been trashed',
1120
-                        'The Price Types have been trashed',
1121
-                        $success,
1122
-                        'event_espresso'
1123
-                    )
1124
-                )
1125
-                : esc_html(
1126
-                    _n(
1127
-                        'The Price Type has been restored',
1128
-                        'The Price Types have been restored',
1129
-                        $success,
1130
-                        'event_espresso'
1131
-                    )
1132
-                );
1133
-            EE_Error::add_success($msg);
1134
-        }
1135
-        $this->_redirect_after_action('', '', '', ['action' => 'price_types'], true);
1136
-    }
1137
-
1138
-
1139
-    /**
1140
-     * @return void
1141
-     * @throws EE_Error
1142
-     * @throws ReflectionException
1143
-     */
1144
-    protected function _delete_price_type()
1145
-    {
1146
-        $entity_model = EEM_Price_Type::instance();
1147
-        $deleted      = $this->trashRestoreDeleteEntities($entity_model, 'id');
1148
-        $this->_redirect_after_action(
1149
-            $deleted,
1150
-            $entity_model->item_name($deleted),
1151
-            'deleted',
1152
-            ['action' => 'price_types']
1153
-        );
1154
-    }
1155
-
1156
-
1157
-    /**
1158
-     * @return string
1159
-     */
1160
-    protected function _learn_more_about_pricing_link(): string
1161
-    {
1162
-        return '
871
+	/**
872
+	 * generates HTML for main Prices Admin page
873
+	 *
874
+	 * @return void
875
+	 * @throws EE_Error
876
+	 */
877
+	protected function _price_types_overview_list_table()
878
+	{
879
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
880
+			'add_new_price_type',
881
+			'add_type',
882
+			[],
883
+			'add-new-h2'
884
+		);
885
+		$this->_admin_page_title .= $this->_learn_more_about_pricing_link();
886
+		$this->_search_btn_label = esc_html__('Price Types', 'event_espresso');
887
+		$this->display_admin_list_table_page_with_sidebar();
888
+	}
889
+
890
+
891
+	/**
892
+	 * retrieve data for Price Types List table
893
+	 *
894
+	 * @param int  $per_page how many prices displayed per page
895
+	 * @param bool $count    return the count or objects
896
+	 * @param bool $trashed  whether the current view is of the trash can - eww yuck!
897
+	 * @return EE_Soft_Delete_Base_Class[]|int int = count || array of price objects
898
+	 * @throws EE_Error
899
+	 * @throws ReflectionException
900
+	 */
901
+	public function get_price_types_overview_data(int $per_page = 10, bool $count = false, bool $trashed = false)
902
+	{
903
+		// start with an empty array
904
+		require_once(PRICING_ADMIN . 'Price_Types_List_Table.class.php');
905
+
906
+		$orderby = $this->request->getRequestParam('orderby', '');
907
+		$order   = $this->request->getRequestParam('order', 'ASC');
908
+
909
+		switch ($orderby) {
910
+			case 'name':
911
+				$orderby = ['PRT_name' => $order];
912
+				break;
913
+			default:
914
+				$orderby = ['PRT_order' => $order];
915
+		}
916
+
917
+		$current_page = $this->request->getRequestParam('paged', 1, DataType::INTEGER);
918
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, DataType::INTEGER);
919
+
920
+		$offset = ($current_page - 1) * $per_page;
921
+		$limit  = [$offset, $per_page];
922
+
923
+		$where = ['PRT_deleted' => $trashed, 'PBT_ID' => ['!=', 1]];
924
+
925
+		$search_term = $this->request->getRequestParam('s');
926
+		if ($search_term) {
927
+			$where['OR'] = [
928
+				'PRT_name' => ['LIKE', "%{$search_term}%"],
929
+			];
930
+		}
931
+		$query_params = [
932
+			$where,
933
+			'order_by' => $orderby,
934
+			'limit'    => $limit,
935
+		];
936
+		return $count
937
+			? EEM_Price_Type::instance()->count_deleted_and_undeleted($query_params)
938
+			: EEM_Price_Type::instance()->get_all_deleted_and_undeleted($query_params);
939
+	}
940
+
941
+
942
+	/**
943
+	 * _edit_price_type_details
944
+	 *
945
+	 * @return void
946
+	 * @throws EE_Error
947
+	 * @throws ReflectionException
948
+	 */
949
+	protected function _edit_price_type_details()
950
+	{
951
+		// grab price type ID
952
+		$PRT_ID = $this->request->getRequestParam('id', 0, DataType::INTEGER);
953
+		// change page title based on request action
954
+		switch ($this->_req_action) {
955
+			case 'add_new_price_type':
956
+				$this->_admin_page_title = esc_html__('Add New Price Type', 'event_espresso');
957
+				break;
958
+			case 'edit_price_type':
959
+				$this->_admin_page_title = esc_html__('Edit Price Type', 'event_espresso');
960
+				break;
961
+			default:
962
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
963
+		}
964
+		// add PRT_ID to title if editing
965
+		$this->_admin_page_title = $PRT_ID ? $this->_admin_page_title . ' # ' . $PRT_ID : $this->_admin_page_title;
966
+
967
+		if ($PRT_ID) {
968
+			$price_type               = EEM_Price_Type::instance()->get_one_by_ID($PRT_ID);
969
+			$additional_hidden_fields = ['PRT_ID' => ['type' => 'hidden', 'value' => $PRT_ID]];
970
+			$this->_set_add_edit_form_tags('update_price_type', $additional_hidden_fields);
971
+		} else {
972
+			$price_type = EEM_Price_Type::instance()->get_new_price_type();
973
+			$this->_set_add_edit_form_tags('insert_price_type');
974
+		}
975
+
976
+		if (! $price_type instanceof EE_Price_Type) {
977
+			throw new RuntimeException(
978
+				sprintf(
979
+					esc_html__(
980
+						'A valid Price Type could not be retrieved from the database with ID: %1$s',
981
+						'event_espresso'
982
+					),
983
+					$PRT_ID
984
+				)
985
+			);
986
+		}
987
+
988
+		$this->_template_args['PRT_ID']     = $PRT_ID;
989
+		$this->_template_args['price_type'] = $price_type;
990
+
991
+		$base_types    = EEM_Price_Type::instance()->get_base_types();
992
+		$select_values = [];
993
+		foreach ($base_types as $ref => $text) {
994
+			if ($ref == EEM_Price_Type::base_type_base_price) {
995
+				// do not allow creation of base_type_base_prices because that's a system only base type.
996
+				continue;
997
+			}
998
+			$select_values[] = ['id' => $ref, 'text' => $text];
999
+		}
1000
+
1001
+		$this->_template_args['base_type_select'] = EEH_Form_Fields::select_input(
1002
+			'base_type',
1003
+			$select_values,
1004
+			$price_type->base_type(),
1005
+			'id="price-type-base-type-slct"'
1006
+		);
1007
+
1008
+		$this->_template_args['learn_more_about_pricing_link'] = $this->_learn_more_about_pricing_link();
1009
+		$this->_template_args['admin_page_content']            = $this->_edit_price_type_details_meta_box();
1010
+
1011
+		$redirect_URL = add_query_arg(['action' => 'price_types'], $this->_admin_base_url);
1012
+		$this->_set_publish_post_box_vars('id', $PRT_ID, false, $redirect_URL);
1013
+		// the details template wrapper
1014
+		$this->display_admin_page_with_sidebar();
1015
+	}
1016
+
1017
+
1018
+	/**
1019
+	 * _edit_price_type_details_meta_box
1020
+	 *
1021
+	 * @return string
1022
+	 */
1023
+	public function _edit_price_type_details_meta_box(): string
1024
+	{
1025
+		return EEH_Template::display_template(
1026
+			PRICING_TEMPLATE_PATH . 'pricing_type_details_main_meta_box.template.php',
1027
+			$this->_template_args,
1028
+			true
1029
+		);
1030
+	}
1031
+
1032
+
1033
+	/**
1034
+	 * @return array
1035
+	 */
1036
+	protected function set_price_type_column_values(): array
1037
+	{
1038
+		$base_type  = $this->request->getRequestParam(
1039
+			'base_type',
1040
+			EEM_Price_Type::base_type_base_price,
1041
+			DataType::INTEGER
1042
+		);
1043
+		$is_percent = $this->request->getRequestParam('PRT_is_percent', 0, DataType::INTEGER);
1044
+		$order      = $this->request->getRequestParam('PRT_order', 0, DataType::INTEGER);
1045
+		switch ($base_type) {
1046
+			case EEM_Price_Type::base_type_base_price:
1047
+				$is_percent = 0;
1048
+				$order      = 0;
1049
+				break;
1050
+
1051
+			case EEM_Price_Type::base_type_discount:
1052
+			case EEM_Price_Type::base_type_surcharge:
1053
+				break;
1054
+
1055
+			case EEM_Price_Type::base_type_tax:
1056
+				$is_percent = 1;
1057
+				break;
1058
+		}
1059
+
1060
+		return [
1061
+			'PBT_ID'         => $base_type,
1062
+			'PRT_name'       => $this->request->getRequestParam('PRT_name', ''),
1063
+			'PRT_is_percent' => $is_percent,
1064
+			'PRT_order'      => $order,
1065
+			'PRT_deleted'    => 0,
1066
+		];
1067
+	}
1068
+
1069
+
1070
+	/**
1071
+	 * @param bool $new_price_type - whether to insert or update
1072
+	 * @return void
1073
+	 * @throws EE_Error
1074
+	 * @throws ReflectionException
1075
+	 */
1076
+	protected function _insert_or_update_price_type(bool $new_price_type = false)
1077
+	{
1078
+		// why be so pessimistic ???  : (
1079
+		$success = 0;
1080
+
1081
+		$set_column_values = $this->set_price_type_column_values();
1082
+		// is this a new Price ?
1083
+		if ($new_price_type) {
1084
+			// run the insert
1085
+			if ($PRT_ID = EEM_Price_Type::instance()->insert($set_column_values)) {
1086
+				$success = 1;
1087
+			}
1088
+			$action_desc = 'created';
1089
+		} else {
1090
+			$PRT_ID = $this->request->getRequestParam('PRT_ID', 0, DataType::INTEGER);
1091
+			// run the update
1092
+			$where_cols_n_values = ['PRT_ID' => $PRT_ID];
1093
+			if (EEM_Price_Type::instance()->update($set_column_values, [$where_cols_n_values])) {
1094
+				$success = 1;
1095
+			}
1096
+			$action_desc = 'updated';
1097
+		}
1098
+
1099
+		$query_args = ['action' => 'edit_price_type', 'id' => $PRT_ID];
1100
+		$this->_redirect_after_action($success, 'Price Type', $action_desc, $query_args);
1101
+	}
1102
+
1103
+
1104
+	/**
1105
+	 * @param bool $trash - whether to move item to trash (TRUE) or restore it (FALSE)
1106
+	 * @return void
1107
+	 * @throws EE_Error
1108
+	 * @throws ReflectionException
1109
+	 */
1110
+	protected function _trash_or_restore_price_type(bool $trash = true)
1111
+	{
1112
+		$entity_model = EEM_Price_Type::instance();
1113
+		$action       = $trash ? EE_Admin_List_Table::ACTION_TRASH : EE_Admin_List_Table::ACTION_RESTORE;
1114
+		$success      = $this->trashRestoreDeleteEntities($entity_model, 'id', $action, 'PRT_deleted');
1115
+		if ($success) {
1116
+			$msg = $trash
1117
+				? esc_html(
1118
+					_n(
1119
+						'The Price Type has been trashed',
1120
+						'The Price Types have been trashed',
1121
+						$success,
1122
+						'event_espresso'
1123
+					)
1124
+				)
1125
+				: esc_html(
1126
+					_n(
1127
+						'The Price Type has been restored',
1128
+						'The Price Types have been restored',
1129
+						$success,
1130
+						'event_espresso'
1131
+					)
1132
+				);
1133
+			EE_Error::add_success($msg);
1134
+		}
1135
+		$this->_redirect_after_action('', '', '', ['action' => 'price_types'], true);
1136
+	}
1137
+
1138
+
1139
+	/**
1140
+	 * @return void
1141
+	 * @throws EE_Error
1142
+	 * @throws ReflectionException
1143
+	 */
1144
+	protected function _delete_price_type()
1145
+	{
1146
+		$entity_model = EEM_Price_Type::instance();
1147
+		$deleted      = $this->trashRestoreDeleteEntities($entity_model, 'id');
1148
+		$this->_redirect_after_action(
1149
+			$deleted,
1150
+			$entity_model->item_name($deleted),
1151
+			'deleted',
1152
+			['action' => 'price_types']
1153
+		);
1154
+	}
1155
+
1156
+
1157
+	/**
1158
+	 * @return string
1159
+	 */
1160
+	protected function _learn_more_about_pricing_link(): string
1161
+	{
1162
+		return '
1163 1163
             <a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >
1164 1164
                 ' . esc_html__('learn more about how pricing works', 'event_espresso') . '
1165 1165
             </a>';
1166
-    }
1167
-
1168
-
1169
-    /**
1170
-     * @throws EE_Error
1171
-     */
1172
-    protected function _tax_settings()
1173
-    {
1174
-        $this->_set_add_edit_form_tags('update_tax_settings');
1175
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
1176
-        $this->_template_args['admin_page_content'] = $this->tax_settings_form()->get_html();
1177
-        $this->display_admin_page_with_sidebar();
1178
-    }
1179
-
1180
-
1181
-    /**
1182
-     * @return EE_Form_Section_Proper
1183
-     * @throws EE_Error
1184
-     */
1185
-    protected function tax_settings_form(): EE_Form_Section_Proper
1186
-    {
1187
-        $tax_settings = EE_Config::instance()->tax_settings;
1188
-        return new EE_Form_Section_Proper(
1189
-            [
1190
-                'name'            => 'tax_settings_form',
1191
-                'html_id'         => 'tax_settings_form',
1192
-                'html_class'      => 'padding',
1193
-                'layout_strategy' => new EE_Div_Per_Section_Layout(),
1194
-                'subsections'     => apply_filters(
1195
-                    'FHEE__Pricing_Admin_Page__tax_settings_form__form_subsections',
1196
-                    [
1197
-                        'tax_settings' => new EE_Form_Section_Proper(
1198
-                            [
1199
-                                'name'            => 'tax_settings_tbl',
1200
-                                'html_id'         => 'tax_settings_tbl',
1201
-                                'html_class'      => 'form-table',
1202
-                                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1203
-                                'subsections'     => [
1204
-                                    'prices_displayed_including_taxes' => new EE_Yes_No_Input(
1205
-                                        [
1206
-                                            'html_label_text'         => esc_html__(
1207
-                                                'Show Prices With Taxes Included?',
1208
-                                                'event_espresso'
1209
-                                            ),
1210
-                                            'html_help_text'          => esc_html__(
1211
-                                                'Indicates whether or not to display prices with the taxes included',
1212
-                                                'event_espresso'
1213
-                                            ),
1214
-                                            'default'                 => $tax_settings->prices_displayed_including_taxes
1215
-                                                                         ?? true,
1216
-                                            'display_html_label_text' => false,
1217
-                                        ]
1218
-                                    ),
1219
-                                ],
1220
-                            ]
1221
-                        ),
1222
-                    ]
1223
-                ),
1224
-            ]
1225
-        );
1226
-    }
1227
-
1228
-
1229
-    /**
1230
-     * _update_tax_settings
1231
-     *
1232
-     * @return void
1233
-     * @throws EE_Error
1234
-     * @throws ReflectionException
1235
-     * @since 4.9.13
1236
-     */
1237
-    public function _update_tax_settings()
1238
-    {
1239
-        $tax_settings = EE_Config::instance()->tax_settings;
1240
-        if (! $tax_settings instanceof EE_Tax_Config) {
1241
-            $tax_settings = new EE_Tax_Config();
1242
-        }
1243
-        try {
1244
-            $tax_form = $this->tax_settings_form();
1245
-            // check for form submission
1246
-            if ($tax_form->was_submitted()) {
1247
-                // capture form data
1248
-                $tax_form->receive_form_submission();
1249
-                // validate form data
1250
-                if ($tax_form->is_valid()) {
1251
-                    // grab validated data from form
1252
-                    $valid_data = $tax_form->valid_data();
1253
-                    // set data on config
1254
-                    $tax_settings->prices_displayed_including_taxes =
1255
-                        $valid_data['tax_settings']['prices_displayed_including_taxes'];
1256
-                } else {
1257
-                    if ($tax_form->submission_error_message() !== '') {
1258
-                        EE_Error::add_error(
1259
-                            $tax_form->submission_error_message(),
1260
-                            __FILE__,
1261
-                            __FUNCTION__,
1262
-                            __LINE__
1263
-                        );
1264
-                    }
1265
-                }
1266
-            }
1267
-        } catch (EE_Error $e) {
1268
-            EE_Error::add_error($e->get_error(), __FILE__, __FUNCTION__, __LINE__);
1269
-        }
1270
-
1271
-        $what    = 'Tax Settings';
1272
-        $success = $this->_update_espresso_configuration(
1273
-            $what,
1274
-            $tax_settings,
1275
-            __FILE__,
1276
-            __FUNCTION__,
1277
-            __LINE__
1278
-        );
1279
-        $this->_redirect_after_action($success, $what, 'updated', ['action' => 'tax_settings']);
1280
-    }
1166
+	}
1167
+
1168
+
1169
+	/**
1170
+	 * @throws EE_Error
1171
+	 */
1172
+	protected function _tax_settings()
1173
+	{
1174
+		$this->_set_add_edit_form_tags('update_tax_settings');
1175
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
1176
+		$this->_template_args['admin_page_content'] = $this->tax_settings_form()->get_html();
1177
+		$this->display_admin_page_with_sidebar();
1178
+	}
1179
+
1180
+
1181
+	/**
1182
+	 * @return EE_Form_Section_Proper
1183
+	 * @throws EE_Error
1184
+	 */
1185
+	protected function tax_settings_form(): EE_Form_Section_Proper
1186
+	{
1187
+		$tax_settings = EE_Config::instance()->tax_settings;
1188
+		return new EE_Form_Section_Proper(
1189
+			[
1190
+				'name'            => 'tax_settings_form',
1191
+				'html_id'         => 'tax_settings_form',
1192
+				'html_class'      => 'padding',
1193
+				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1194
+				'subsections'     => apply_filters(
1195
+					'FHEE__Pricing_Admin_Page__tax_settings_form__form_subsections',
1196
+					[
1197
+						'tax_settings' => new EE_Form_Section_Proper(
1198
+							[
1199
+								'name'            => 'tax_settings_tbl',
1200
+								'html_id'         => 'tax_settings_tbl',
1201
+								'html_class'      => 'form-table',
1202
+								'layout_strategy' => new EE_Admin_Two_Column_Layout(),
1203
+								'subsections'     => [
1204
+									'prices_displayed_including_taxes' => new EE_Yes_No_Input(
1205
+										[
1206
+											'html_label_text'         => esc_html__(
1207
+												'Show Prices With Taxes Included?',
1208
+												'event_espresso'
1209
+											),
1210
+											'html_help_text'          => esc_html__(
1211
+												'Indicates whether or not to display prices with the taxes included',
1212
+												'event_espresso'
1213
+											),
1214
+											'default'                 => $tax_settings->prices_displayed_including_taxes
1215
+																		 ?? true,
1216
+											'display_html_label_text' => false,
1217
+										]
1218
+									),
1219
+								],
1220
+							]
1221
+						),
1222
+					]
1223
+				),
1224
+			]
1225
+		);
1226
+	}
1227
+
1228
+
1229
+	/**
1230
+	 * _update_tax_settings
1231
+	 *
1232
+	 * @return void
1233
+	 * @throws EE_Error
1234
+	 * @throws ReflectionException
1235
+	 * @since 4.9.13
1236
+	 */
1237
+	public function _update_tax_settings()
1238
+	{
1239
+		$tax_settings = EE_Config::instance()->tax_settings;
1240
+		if (! $tax_settings instanceof EE_Tax_Config) {
1241
+			$tax_settings = new EE_Tax_Config();
1242
+		}
1243
+		try {
1244
+			$tax_form = $this->tax_settings_form();
1245
+			// check for form submission
1246
+			if ($tax_form->was_submitted()) {
1247
+				// capture form data
1248
+				$tax_form->receive_form_submission();
1249
+				// validate form data
1250
+				if ($tax_form->is_valid()) {
1251
+					// grab validated data from form
1252
+					$valid_data = $tax_form->valid_data();
1253
+					// set data on config
1254
+					$tax_settings->prices_displayed_including_taxes =
1255
+						$valid_data['tax_settings']['prices_displayed_including_taxes'];
1256
+				} else {
1257
+					if ($tax_form->submission_error_message() !== '') {
1258
+						EE_Error::add_error(
1259
+							$tax_form->submission_error_message(),
1260
+							__FILE__,
1261
+							__FUNCTION__,
1262
+							__LINE__
1263
+						);
1264
+					}
1265
+				}
1266
+			}
1267
+		} catch (EE_Error $e) {
1268
+			EE_Error::add_error($e->get_error(), __FILE__, __FUNCTION__, __LINE__);
1269
+		}
1270
+
1271
+		$what    = 'Tax Settings';
1272
+		$success = $this->_update_espresso_configuration(
1273
+			$what,
1274
+			$tax_settings,
1275
+			__FILE__,
1276
+			__FUNCTION__,
1277
+			__LINE__
1278
+		);
1279
+		$this->_redirect_after_action($success, $what, 'updated', ['action' => 'tax_settings']);
1280
+	}
1281 1281
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_List_Table.core.php 1 patch
Indentation   +878 added lines, -878 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
 
@@ -19,891 +19,891 @@  discard block
 block discarded – undo
19 19
  */
20 20
 abstract class EE_Admin_List_Table extends WP_List_Table
21 21
 {
22
-    const ACTION_COPY    = 'duplicate';
23
-
24
-    const ACTION_DELETE  = 'delete';
25
-
26
-    const ACTION_EDIT    = 'edit';
27
-
28
-    const ACTION_RESTORE = 'restore';
29
-
30
-    const ACTION_TRASH   = 'trash';
31
-
32
-    protected static $actions = [
33
-        self::ACTION_COPY,
34
-        self::ACTION_DELETE,
35
-        self::ACTION_EDIT,
36
-        self::ACTION_RESTORE,
37
-        self::ACTION_TRASH,
38
-    ];
39
-
40
-    /**
41
-     * holds the data that will be processed for the table
42
-     *
43
-     * @var array $_data
44
-     */
45
-    protected $_data;
46
-
47
-
48
-    /**
49
-     * This holds the value of all the data available for the given view (for all pages).
50
-     *
51
-     * @var int $_all_data_count
52
-     */
53
-    protected $_all_data_count;
54
-
55
-
56
-    /**
57
-     * Will contain the count of trashed items for the view label.
58
-     *
59
-     * @var int $_trashed_count
60
-     */
61
-    protected $_trashed_count;
62
-
63
-
64
-    /**
65
-     * This is what will be referenced as the slug for the current screen
66
-     *
67
-     * @var string $_screen
68
-     */
69
-    protected $_screen;
70
-
71
-
72
-    /**
73
-     * this is the EE_Admin_Page object
74
-     *
75
-     * @var EE_Admin_Page $_admin_page
76
-     */
77
-    protected $_admin_page;
78
-
79
-
80
-    /**
81
-     * The current view
82
-     *
83
-     * @var string $_view
84
-     */
85
-    protected $_view;
86
-
87
-
88
-    /**
89
-     * array of possible views for this table
90
-     *
91
-     * @var array $_views
92
-     */
93
-    protected $_views;
94
-
95
-
96
-    /**
97
-     * An array of key => value pairs containing information about the current table
98
-     * array(
99
-     *        'plural' => 'plural label',
100
-     *        'singular' => 'singular label',
101
-     *        'ajax' => false, //whether to use ajax or not
102
-     *        'screen' => null, //string used to reference what screen this is
103
-     *        (WP_List_table converts to screen object)
104
-     * )
105
-     *
106
-     * @var array $_wp_list_args
107
-     */
108
-    protected $_wp_list_args;
109
-
110
-    /**
111
-     * an array of column names
112
-     * array(
113
-     *    'internal-name' => 'Title'
114
-     * )
115
-     *
116
-     * @var array $_columns
117
-     */
118
-    protected $_columns;
119
-
120
-    /**
121
-     * An array of sortable columns
122
-     * array(
123
-     *    'internal-name' => 'orderby' //or
124
-     *    'internal-name' => array( 'orderby', true )
125
-     * )
126
-     *
127
-     * @var array $_sortable_columns
128
-     */
129
-    protected $_sortable_columns;
130
-
131
-    /**
132
-     * callback method used to perform AJAX row reordering
133
-     *
134
-     * @var string $_ajax_sorting_callback
135
-     */
136
-    protected $_ajax_sorting_callback;
137
-
138
-    /**
139
-     * An array of hidden columns (if needed)
140
-     * array('internal-name', 'internal-name')
141
-     *
142
-     * @var array $_hidden_columns
143
-     */
144
-    protected $_hidden_columns;
145
-
146
-    /**
147
-     * holds the per_page value
148
-     *
149
-     * @var int $_per_page
150
-     */
151
-    protected $_per_page;
152
-
153
-    /**
154
-     * holds what page number is currently being viewed
155
-     *
156
-     * @var int $_current_page
157
-     */
158
-    protected $_current_page;
159
-
160
-    /**
161
-     * the reference string for the nonce_action
162
-     *
163
-     * @var string $_nonce_action_ref
164
-     */
165
-    protected $_nonce_action_ref;
166
-
167
-    /**
168
-     * property to hold incoming request data (as set by the admin_page_core)
169
-     *
170
-     * @var array $_req_data
171
-     */
172
-    protected $_req_data;
173
-
174
-
175
-    /**
176
-     * yes / no array for admin form fields
177
-     *
178
-     * @var array $_yes_no
179
-     */
180
-    protected $_yes_no = [];
181
-
182
-    /**
183
-     * Array describing buttons that should appear at the bottom of the page
184
-     * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
185
-     * and the values are another array with the following keys
186
-     * array(
187
-     *    'route' => 'page_route',
188
-     *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
189
-     * )
190
-     *
191
-     * @var array $_bottom_buttons
192
-     */
193
-    protected $_bottom_buttons = [];
194
-
195
-
196
-    /**
197
-     * Used to indicate what should be the primary column for the list table.
198
-     * If not present then falls back to what WP calculates
199
-     * as the primary column.
200
-     *
201
-     * @type string $_primary_column
202
-     */
203
-    protected $_primary_column = '';
204
-
205
-
206
-    /**
207
-     * Used to indicate whether the table has a checkbox column or not.
208
-     *
209
-     * @type bool $_has_checkbox_column
210
-     */
211
-    protected $_has_checkbox_column = false;
212
-
213
-
214
-    /**
215
-     * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
216
-     */
217
-    public function __construct(EE_Admin_Page $admin_page)
218
-    {
219
-        $this->_admin_page   = $admin_page;
220
-        $this->_req_data     = $this->_admin_page->get_request_data();
221
-        $this->_view         = $this->_admin_page->get_view();
222
-        $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
223
-        $this->_current_page = $this->get_pagenum();
224
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
225
-        $this->_yes_no       = [
226
-            esc_html__('No', 'event_espresso'),
227
-            esc_html__('Yes', 'event_espresso')
228
-        ];
229
-
230
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
231
-
232
-        $this->_setup_data();
233
-        $this->_add_view_counts();
234
-
235
-        $this->_nonce_action_ref = $this->_view;
236
-
237
-        $this->_set_properties();
238
-
239
-        // set primary column
240
-        add_filter('list_table_primary_column', [$this, 'set_primary_column']);
241
-
242
-        // set parent defaults
243
-        parent::__construct($this->_wp_list_args);
244
-
245
-        $this->prepare_items();
246
-    }
247
-
248
-
249
-    /**
250
-     * _setup_data
251
-     * this method is used to setup the $_data, $_all_data_count, and _per_page properties
252
-     *
253
-     * @return void
254
-     * @uses $this->_admin_page
255
-     */
256
-    abstract protected function _setup_data();
257
-
258
-
259
-    /**
260
-     * set the properties that this class needs to be able to execute wp_list_table properly
261
-     * properties set:
262
-     * _wp_list_args = what the arguments required for the parent _wp_list_table.
263
-     * _columns = set the columns in an array.
264
-     * _sortable_columns = columns that are sortable (array).
265
-     * _hidden_columns = columns that are hidden (array)
266
-     * _default_orderby = the default orderby for sorting.
267
-     *
268
-     * @abstract
269
-     * @access protected
270
-     * @return void
271
-     */
272
-    abstract protected function _set_properties();
273
-
274
-
275
-    /**
276
-     * _get_table_filters
277
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
278
-     * gets shown in the table.
279
-     *
280
-     * @abstract
281
-     * @access protected
282
-     * @return string
283
-     */
284
-    abstract protected function _get_table_filters();
285
-
286
-
287
-    /**
288
-     * this is a method that child class will do to add counts to the views array so when views are displayed the
289
-     * counts of the views is accurate.
290
-     *
291
-     * @abstract
292
-     * @access protected
293
-     * @return void
294
-     */
295
-    abstract protected function _add_view_counts();
296
-
297
-
298
-    /**
299
-     * _get_hidden_fields
300
-     * returns a html string of hidden fields so if any table filters are used the current view will be respected.
301
-     *
302
-     * @return string
303
-     */
304
-    protected function _get_hidden_fields()
305
-    {
306
-        $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
307
-        $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
308
-        // if action is STILL empty, then we set it to default
309
-        $action = empty($action) ? 'default' : $action;
310
-        $field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
311
-        $field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
312
-        $field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
313
-
314
-        $bulk_actions = $this->_get_bulk_actions();
315
-        foreach ($bulk_actions as $bulk_action => $label) {
316
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
317
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
318
-        }
319
-
320
-        return $field;
321
-    }
322
-
323
-
324
-    /**
325
-     * _set_column_info
326
-     * we're using this to set the column headers property.
327
-     *
328
-     * @access protected
329
-     * @return void
330
-     */
331
-    protected function _set_column_info()
332
-    {
333
-        $columns   = $this->get_columns();
334
-        $hidden    = $this->get_hidden_columns();
335
-        $_sortable = $this->get_sortable_columns();
336
-
337
-        /**
338
-         * Dynamic hook allowing for adding sortable columns in this list table.
339
-         * Note that $this->screen->id is in the format
340
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
341
-         * table it is: event-espresso_page_espresso_messages.
342
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
343
-         * hook prefix ("event-espresso") will be different.
344
-         *
345
-         * @var array
346
-         */
347
-        $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
348
-
349
-        $sortable = [];
350
-        foreach ($_sortable as $id => $data) {
351
-            if (empty($data)) {
352
-                continue;
353
-            }
354
-            // fix for offset errors with WP_List_Table default get_columninfo()
355
-            if (is_array($data)) {
356
-                $_data[0] = key($data);
357
-                $_data[1] = isset($data[1]) ? $data[1] : false;
358
-            } else {
359
-                $_data[0] = $data;
360
-            }
361
-
362
-            $data = (array) $data;
363
-
364
-            if (! isset($data[1])) {
365
-                $_data[1] = false;
366
-            }
367
-
368
-            $sortable[ $id ] = $_data;
369
-        }
370
-        $primary               = $this->get_primary_column_name();
371
-        $this->_column_headers = [$columns, $hidden, $sortable, $primary];
372
-    }
373
-
374
-
375
-    /**
376
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
377
-     *
378
-     * @return string
379
-     */
380
-    protected function get_primary_column_name()
381
-    {
382
-        foreach (class_parents($this) as $parent) {
383
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
384
-                return parent::get_primary_column_name();
385
-            }
386
-        }
387
-        return $this->_primary_column;
388
-    }
389
-
390
-
391
-    /**
392
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
393
-     *
394
-     * @param EE_Base_Class $item
395
-     * @param string        $column_name
396
-     * @param string        $primary
397
-     * @return string
398
-     */
399
-    protected function handle_row_actions($item, $column_name, $primary)
400
-    {
401
-        foreach (class_parents($this) as $parent) {
402
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
403
-                return parent::handle_row_actions($item, $column_name, $primary);
404
-            }
405
-        }
406
-        return '';
407
-    }
408
-
409
-
410
-    /**
411
-     * _get_bulk_actions
412
-     * This is a wrapper called by WP_List_Table::get_bulk_actions()
413
-     *
414
-     * @access protected
415
-     * @return array bulk_actions
416
-     */
417
-    protected function _get_bulk_actions()
418
-    {
419
-        $actions = [];
420
-        // the _views property should have the bulk_actions, so let's go through and extract them into a properly
421
-        // formatted array for the wp_list_table();
422
-        foreach ($this->_views as $view => $args) {
423
-            if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
424
-                // each bulk action will correspond with a admin page route, so we can check whatever the capability is
425
-                // for that page route and skip adding the bulk action if no access for the current logged in user.
426
-                foreach ($args['bulk_action'] as $route => $label) {
427
-                    if ($this->_admin_page->check_user_access($route, true)) {
428
-                        $actions[ $route ] = $label;
429
-                    }
430
-                }
431
-            }
432
-        }
433
-        return $actions;
434
-    }
435
-
436
-
437
-    /**
438
-     * Generate the table navigation above or below the table.
439
-     * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
440
-     *
441
-     * @throws EE_Error
442
-     * @since 4.9.44.rc.001
443
-     */
444
-    public function display_tablenav($which)
445
-    {
446
-        if ('top' === $which) {
447
-            wp_nonce_field('bulk-' . $this->_args['plural']);
448
-        }
449
-        ?>
22
+	const ACTION_COPY    = 'duplicate';
23
+
24
+	const ACTION_DELETE  = 'delete';
25
+
26
+	const ACTION_EDIT    = 'edit';
27
+
28
+	const ACTION_RESTORE = 'restore';
29
+
30
+	const ACTION_TRASH   = 'trash';
31
+
32
+	protected static $actions = [
33
+		self::ACTION_COPY,
34
+		self::ACTION_DELETE,
35
+		self::ACTION_EDIT,
36
+		self::ACTION_RESTORE,
37
+		self::ACTION_TRASH,
38
+	];
39
+
40
+	/**
41
+	 * holds the data that will be processed for the table
42
+	 *
43
+	 * @var array $_data
44
+	 */
45
+	protected $_data;
46
+
47
+
48
+	/**
49
+	 * This holds the value of all the data available for the given view (for all pages).
50
+	 *
51
+	 * @var int $_all_data_count
52
+	 */
53
+	protected $_all_data_count;
54
+
55
+
56
+	/**
57
+	 * Will contain the count of trashed items for the view label.
58
+	 *
59
+	 * @var int $_trashed_count
60
+	 */
61
+	protected $_trashed_count;
62
+
63
+
64
+	/**
65
+	 * This is what will be referenced as the slug for the current screen
66
+	 *
67
+	 * @var string $_screen
68
+	 */
69
+	protected $_screen;
70
+
71
+
72
+	/**
73
+	 * this is the EE_Admin_Page object
74
+	 *
75
+	 * @var EE_Admin_Page $_admin_page
76
+	 */
77
+	protected $_admin_page;
78
+
79
+
80
+	/**
81
+	 * The current view
82
+	 *
83
+	 * @var string $_view
84
+	 */
85
+	protected $_view;
86
+
87
+
88
+	/**
89
+	 * array of possible views for this table
90
+	 *
91
+	 * @var array $_views
92
+	 */
93
+	protected $_views;
94
+
95
+
96
+	/**
97
+	 * An array of key => value pairs containing information about the current table
98
+	 * array(
99
+	 *        'plural' => 'plural label',
100
+	 *        'singular' => 'singular label',
101
+	 *        'ajax' => false, //whether to use ajax or not
102
+	 *        'screen' => null, //string used to reference what screen this is
103
+	 *        (WP_List_table converts to screen object)
104
+	 * )
105
+	 *
106
+	 * @var array $_wp_list_args
107
+	 */
108
+	protected $_wp_list_args;
109
+
110
+	/**
111
+	 * an array of column names
112
+	 * array(
113
+	 *    'internal-name' => 'Title'
114
+	 * )
115
+	 *
116
+	 * @var array $_columns
117
+	 */
118
+	protected $_columns;
119
+
120
+	/**
121
+	 * An array of sortable columns
122
+	 * array(
123
+	 *    'internal-name' => 'orderby' //or
124
+	 *    'internal-name' => array( 'orderby', true )
125
+	 * )
126
+	 *
127
+	 * @var array $_sortable_columns
128
+	 */
129
+	protected $_sortable_columns;
130
+
131
+	/**
132
+	 * callback method used to perform AJAX row reordering
133
+	 *
134
+	 * @var string $_ajax_sorting_callback
135
+	 */
136
+	protected $_ajax_sorting_callback;
137
+
138
+	/**
139
+	 * An array of hidden columns (if needed)
140
+	 * array('internal-name', 'internal-name')
141
+	 *
142
+	 * @var array $_hidden_columns
143
+	 */
144
+	protected $_hidden_columns;
145
+
146
+	/**
147
+	 * holds the per_page value
148
+	 *
149
+	 * @var int $_per_page
150
+	 */
151
+	protected $_per_page;
152
+
153
+	/**
154
+	 * holds what page number is currently being viewed
155
+	 *
156
+	 * @var int $_current_page
157
+	 */
158
+	protected $_current_page;
159
+
160
+	/**
161
+	 * the reference string for the nonce_action
162
+	 *
163
+	 * @var string $_nonce_action_ref
164
+	 */
165
+	protected $_nonce_action_ref;
166
+
167
+	/**
168
+	 * property to hold incoming request data (as set by the admin_page_core)
169
+	 *
170
+	 * @var array $_req_data
171
+	 */
172
+	protected $_req_data;
173
+
174
+
175
+	/**
176
+	 * yes / no array for admin form fields
177
+	 *
178
+	 * @var array $_yes_no
179
+	 */
180
+	protected $_yes_no = [];
181
+
182
+	/**
183
+	 * Array describing buttons that should appear at the bottom of the page
184
+	 * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
185
+	 * and the values are another array with the following keys
186
+	 * array(
187
+	 *    'route' => 'page_route',
188
+	 *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
189
+	 * )
190
+	 *
191
+	 * @var array $_bottom_buttons
192
+	 */
193
+	protected $_bottom_buttons = [];
194
+
195
+
196
+	/**
197
+	 * Used to indicate what should be the primary column for the list table.
198
+	 * If not present then falls back to what WP calculates
199
+	 * as the primary column.
200
+	 *
201
+	 * @type string $_primary_column
202
+	 */
203
+	protected $_primary_column = '';
204
+
205
+
206
+	/**
207
+	 * Used to indicate whether the table has a checkbox column or not.
208
+	 *
209
+	 * @type bool $_has_checkbox_column
210
+	 */
211
+	protected $_has_checkbox_column = false;
212
+
213
+
214
+	/**
215
+	 * @param EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
216
+	 */
217
+	public function __construct(EE_Admin_Page $admin_page)
218
+	{
219
+		$this->_admin_page   = $admin_page;
220
+		$this->_req_data     = $this->_admin_page->get_request_data();
221
+		$this->_view         = $this->_admin_page->get_view();
222
+		$this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
223
+		$this->_current_page = $this->get_pagenum();
224
+		$this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
225
+		$this->_yes_no       = [
226
+			esc_html__('No', 'event_espresso'),
227
+			esc_html__('Yes', 'event_espresso')
228
+		];
229
+
230
+		$this->_per_page = $this->get_items_per_page($this->_screen . '_per_page');
231
+
232
+		$this->_setup_data();
233
+		$this->_add_view_counts();
234
+
235
+		$this->_nonce_action_ref = $this->_view;
236
+
237
+		$this->_set_properties();
238
+
239
+		// set primary column
240
+		add_filter('list_table_primary_column', [$this, 'set_primary_column']);
241
+
242
+		// set parent defaults
243
+		parent::__construct($this->_wp_list_args);
244
+
245
+		$this->prepare_items();
246
+	}
247
+
248
+
249
+	/**
250
+	 * _setup_data
251
+	 * this method is used to setup the $_data, $_all_data_count, and _per_page properties
252
+	 *
253
+	 * @return void
254
+	 * @uses $this->_admin_page
255
+	 */
256
+	abstract protected function _setup_data();
257
+
258
+
259
+	/**
260
+	 * set the properties that this class needs to be able to execute wp_list_table properly
261
+	 * properties set:
262
+	 * _wp_list_args = what the arguments required for the parent _wp_list_table.
263
+	 * _columns = set the columns in an array.
264
+	 * _sortable_columns = columns that are sortable (array).
265
+	 * _hidden_columns = columns that are hidden (array)
266
+	 * _default_orderby = the default orderby for sorting.
267
+	 *
268
+	 * @abstract
269
+	 * @access protected
270
+	 * @return void
271
+	 */
272
+	abstract protected function _set_properties();
273
+
274
+
275
+	/**
276
+	 * _get_table_filters
277
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
278
+	 * gets shown in the table.
279
+	 *
280
+	 * @abstract
281
+	 * @access protected
282
+	 * @return string
283
+	 */
284
+	abstract protected function _get_table_filters();
285
+
286
+
287
+	/**
288
+	 * this is a method that child class will do to add counts to the views array so when views are displayed the
289
+	 * counts of the views is accurate.
290
+	 *
291
+	 * @abstract
292
+	 * @access protected
293
+	 * @return void
294
+	 */
295
+	abstract protected function _add_view_counts();
296
+
297
+
298
+	/**
299
+	 * _get_hidden_fields
300
+	 * returns a html string of hidden fields so if any table filters are used the current view will be respected.
301
+	 *
302
+	 * @return string
303
+	 */
304
+	protected function _get_hidden_fields()
305
+	{
306
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
307
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
308
+		// if action is STILL empty, then we set it to default
309
+		$action = empty($action) ? 'default' : $action;
310
+		$field  = '<input type="hidden" name="page" value="' . esc_attr($this->_req_data['page']) . '" />' . "\n";
311
+		$field  .= '<input type="hidden" name="route" value="' . esc_attr($action) . '" />' . "\n";
312
+		$field  .= '<input type="hidden" name="perpage" value="' . esc_attr($this->_per_page) . '" />' . "\n";
313
+
314
+		$bulk_actions = $this->_get_bulk_actions();
315
+		foreach ($bulk_actions as $bulk_action => $label) {
316
+			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
317
+					  . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
318
+		}
319
+
320
+		return $field;
321
+	}
322
+
323
+
324
+	/**
325
+	 * _set_column_info
326
+	 * we're using this to set the column headers property.
327
+	 *
328
+	 * @access protected
329
+	 * @return void
330
+	 */
331
+	protected function _set_column_info()
332
+	{
333
+		$columns   = $this->get_columns();
334
+		$hidden    = $this->get_hidden_columns();
335
+		$_sortable = $this->get_sortable_columns();
336
+
337
+		/**
338
+		 * Dynamic hook allowing for adding sortable columns in this list table.
339
+		 * Note that $this->screen->id is in the format
340
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
341
+		 * table it is: event-espresso_page_espresso_messages.
342
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
343
+		 * hook prefix ("event-espresso") will be different.
344
+		 *
345
+		 * @var array
346
+		 */
347
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
348
+
349
+		$sortable = [];
350
+		foreach ($_sortable as $id => $data) {
351
+			if (empty($data)) {
352
+				continue;
353
+			}
354
+			// fix for offset errors with WP_List_Table default get_columninfo()
355
+			if (is_array($data)) {
356
+				$_data[0] = key($data);
357
+				$_data[1] = isset($data[1]) ? $data[1] : false;
358
+			} else {
359
+				$_data[0] = $data;
360
+			}
361
+
362
+			$data = (array) $data;
363
+
364
+			if (! isset($data[1])) {
365
+				$_data[1] = false;
366
+			}
367
+
368
+			$sortable[ $id ] = $_data;
369
+		}
370
+		$primary               = $this->get_primary_column_name();
371
+		$this->_column_headers = [$columns, $hidden, $sortable, $primary];
372
+	}
373
+
374
+
375
+	/**
376
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
377
+	 *
378
+	 * @return string
379
+	 */
380
+	protected function get_primary_column_name()
381
+	{
382
+		foreach (class_parents($this) as $parent) {
383
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
384
+				return parent::get_primary_column_name();
385
+			}
386
+		}
387
+		return $this->_primary_column;
388
+	}
389
+
390
+
391
+	/**
392
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
393
+	 *
394
+	 * @param EE_Base_Class $item
395
+	 * @param string        $column_name
396
+	 * @param string        $primary
397
+	 * @return string
398
+	 */
399
+	protected function handle_row_actions($item, $column_name, $primary)
400
+	{
401
+		foreach (class_parents($this) as $parent) {
402
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
403
+				return parent::handle_row_actions($item, $column_name, $primary);
404
+			}
405
+		}
406
+		return '';
407
+	}
408
+
409
+
410
+	/**
411
+	 * _get_bulk_actions
412
+	 * This is a wrapper called by WP_List_Table::get_bulk_actions()
413
+	 *
414
+	 * @access protected
415
+	 * @return array bulk_actions
416
+	 */
417
+	protected function _get_bulk_actions()
418
+	{
419
+		$actions = [];
420
+		// the _views property should have the bulk_actions, so let's go through and extract them into a properly
421
+		// formatted array for the wp_list_table();
422
+		foreach ($this->_views as $view => $args) {
423
+			if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
424
+				// each bulk action will correspond with a admin page route, so we can check whatever the capability is
425
+				// for that page route and skip adding the bulk action if no access for the current logged in user.
426
+				foreach ($args['bulk_action'] as $route => $label) {
427
+					if ($this->_admin_page->check_user_access($route, true)) {
428
+						$actions[ $route ] = $label;
429
+					}
430
+				}
431
+			}
432
+		}
433
+		return $actions;
434
+	}
435
+
436
+
437
+	/**
438
+	 * Generate the table navigation above or below the table.
439
+	 * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
440
+	 *
441
+	 * @throws EE_Error
442
+	 * @since 4.9.44.rc.001
443
+	 */
444
+	public function display_tablenav($which)
445
+	{
446
+		if ('top' === $which) {
447
+			wp_nonce_field('bulk-' . $this->_args['plural']);
448
+		}
449
+		?>
450 450
         <div class="tablenav <?php echo esc_attr($which); ?>">
451 451
             <?php if ($this->_get_bulk_actions()) { ?>
452 452
                 <div class="alignleft actions bulkactions">
453 453
                     <?php $this->bulk_actions(); ?>
454 454
                 </div>
455 455
             <?php }
456
-            $this->extra_tablenav($which);
457
-            $this->pagination($which);
458
-            ?>
456
+			$this->extra_tablenav($which);
457
+			$this->pagination($which);
458
+			?>
459 459
 
460 460
             <br class="clear" />
461 461
         </div>
462 462
         <?php
463
-    }
464
-
465
-
466
-    /**
467
-     * _filters
468
-     * This receives the filters array from children _get_table_filters() and assembles the string including the filter
469
-     * button.
470
-     *
471
-     * @access private
472
-     * @return void  echos html showing filters
473
-     */
474
-    private function _filters()
475
-    {
476
-        $classname = get_class($this);
477
-        $filters   = apply_filters(
478
-            "FHEE__{$classname}__filters",
479
-            (array) $this->_get_table_filters(),
480
-            $this,
481
-            $this->_screen
482
-        );
483
-
484
-        if (empty($filters)) {
485
-            return;
486
-        }
487
-        foreach ($filters as $filter) {
488
-            echo $filter; // already escaped
489
-        }
490
-        // add filter button at end
491
-        echo '<input type="submit" class="button-secondary" value="'
492
-             . esc_html__('Filter', 'event_espresso')
493
-             . '" id="post-query-submit" />';
494
-        // add reset filters button at end
495
-        echo '<a class="button button-secondary"  href="'
496
-             . esc_url_raw($this->_admin_page->get_current_page_view_url())
497
-             . '" style="display:inline-block">'
498
-             . esc_html__('Reset Filters', 'event_espresso')
499
-             . '</a>';
500
-    }
501
-
502
-
503
-    /**
504
-     * Callback for 'list_table_primary_column' WordPress filter
505
-     * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
506
-     * column when class is instantiated.
507
-     *
508
-     * @param string $column_name
509
-     * @return string
510
-     * @see WP_List_Table::get_primary_column_name
511
-     */
512
-    public function set_primary_column($column_name)
513
-    {
514
-        return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
515
-    }
516
-
517
-
518
-    /**
519
-     *
520
-     */
521
-    public function prepare_items()
522
-    {
523
-
524
-        $this->_set_column_info();
525
-        // $this->_column_headers = $this->get_column_info();
526
-        $total_items = $this->_all_data_count;
527
-        $this->process_bulk_action();
528
-
529
-        $this->items = $this->_data;
530
-        $this->set_pagination_args(
531
-            [
532
-                'total_items' => $total_items,
533
-                'per_page'    => $this->_per_page,
534
-                'total_pages' => ceil($total_items / $this->_per_page),
535
-            ]
536
-        );
537
-    }
538
-
539
-
540
-    /**
541
-     * @param object|array $item
542
-     * @return string html content for the column
543
-     */
544
-    protected function column_cb($item)
545
-    {
546
-        return '';
547
-    }
548
-
549
-
550
-    /**
551
-     * This column is the default for when there is no defined column method for a registered column.
552
-     * This can be overridden by child classes, but allows for hooking in for custom columns.
553
-     *
554
-     * @param EE_Base_Class $item
555
-     * @param string        $column_name The column being called.
556
-     * @return string html content for the column
557
-     */
558
-    public function column_default($item, $column_name)
559
-    {
560
-        /**
561
-         * Dynamic hook allowing for adding additional column content in this list table.
562
-         * Note that $this->screen->id is in the format
563
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
564
-         * table it is: event-espresso_page_espresso_messages.
565
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
566
-         * hook prefix ("event-espresso") will be different.
567
-         */
568
-        ob_start();
569
-        do_action(
570
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
571
-            $item,
572
-            $this->_screen
573
-        );
574
-        return ob_get_clean();
575
-    }
576
-
577
-
578
-    /**
579
-     * Get a list of columns. The format is:
580
-     * 'internal-name' => 'Title'
581
-     *
582
-     * @return array
583
-     * @since  3.1.0
584
-     * @access public
585
-     * @abstract
586
-     */
587
-    public function get_columns()
588
-    {
589
-        /**
590
-         * Dynamic hook allowing for adding additional columns in this list table.
591
-         * Note that $this->screen->id is in the format
592
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
593
-         * table it is: event-espresso_page_espresso_messages.
594
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
595
-         * hook prefix ("event-espresso") will be different.
596
-         *
597
-         * @var array
598
-         */
599
-        return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
600
-    }
601
-
602
-
603
-    /**
604
-     * Get an associative array ( id => link ) with the list
605
-     * of views available on this table.
606
-     *
607
-     * @return array
608
-     * @since  3.1.0
609
-     * @access protected
610
-     */
611
-    public function get_views()
612
-    {
613
-        return $this->_views;
614
-    }
615
-
616
-
617
-    /**
618
-     * Generate the views html.
619
-     */
620
-    public function display_views()
621
-    {
622
-        $views           = $this->get_views();
623
-        $assembled_views = [];
624
-
625
-        if (empty($views)) {
626
-            return;
627
-        }
628
-        echo "<ul class='subsubsub'>\n";
629
-        foreach ($views as $view) {
630
-            $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
631
-            if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
632
-                $filter = "<li";
633
-                $filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
634
-                $filter .= ">";
635
-                $filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
636
-                $filter .= '<span class="count">(' . $count . ')</span>';
637
-                $filter .= '</li>';
638
-                $assembled_views[ $view['slug'] ] = $filter;
639
-            }
640
-        }
641
-
642
-        echo ! empty($assembled_views)
643
-            ? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
644
-            : '';
645
-        echo "</ul>";
646
-    }
647
-
648
-
649
-    /**
650
-     * Generates content for a single row of the table
651
-     *
652
-     * @param EE_Base_Class $item The current item
653
-     * @since  4.1
654
-     * @access public
655
-     */
656
-    public function single_row($item)
657
-    {
658
-        $row_class = $this->_get_row_class($item);
659
-        echo '<tr class="' . esc_attr($row_class) . '">';
660
-        $this->single_row_columns($item); // already escaped
661
-        echo '</tr>';
662
-    }
663
-
664
-
665
-    /**
666
-     * This simply sets up the row class for the table rows.
667
-     * Allows for easier overriding of child methods for setting up sorting.
668
-     *
669
-     * @param EE_Base_Class $item the current item
670
-     * @return string
671
-     */
672
-    protected function _get_row_class($item)
673
-    {
674
-        static $row_class = '';
675
-        $row_class = ($row_class === '' ? 'alternate' : '');
676
-
677
-        $new_row_class = $row_class;
678
-
679
-        if (! empty($this->_ajax_sorting_callback)) {
680
-            $new_row_class .= ' rowsortable';
681
-        }
682
-
683
-        return $new_row_class;
684
-    }
685
-
686
-
687
-    /**
688
-     * @return array
689
-     */
690
-    public function get_sortable_columns()
691
-    {
692
-        return (array) $this->_sortable_columns;
693
-    }
694
-
695
-
696
-    /**
697
-     * @return string
698
-     */
699
-    public function get_ajax_sorting_callback()
700
-    {
701
-        return $this->_ajax_sorting_callback;
702
-    }
703
-
704
-
705
-    /**
706
-     * @return array
707
-     */
708
-    public function get_hidden_columns()
709
-    {
710
-        $user_id     = get_current_user_id();
711
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
712
-        if (empty($has_default) && ! empty($this->_hidden_columns)) {
713
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
714
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
715
-        }
716
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
717
-        return (array) get_user_option($ref, $user_id);
718
-    }
719
-
720
-
721
-    /**
722
-     * Generates the columns for a single row of the table.
723
-     * Overridden from wp_list_table so as to allow us to filter the column content for a given
724
-     * column.
725
-     *
726
-     * @param EE_Base_Class $item The current item
727
-     * @since 3.1.0
728
-     */
729
-    public function single_row_columns($item)
730
-    {
731
-        [$columns, $hidden, $sortable, $primary] = $this->get_column_info();
732
-
733
-        foreach ($columns as $column_name => $column_display_name) {
734
-
735
-            /**
736
-             * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
737
-             * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
738
-             */
739
-            $hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
740
-
741
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
742
-            if ($primary === $column_name) {
743
-                $classes .= ' has-row-actions column-primary';
744
-            }
745
-
746
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
747
-
748
-            $class = 'class="' . esc_attr($classes) . '"';
749
-
750
-            $attributes = "{$class}{$data}";
751
-
752
-            if ($column_name === 'cb') {
753
-                echo '<th scope="row" class="check-column">';
754
-                echo apply_filters(
755
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
756
-                    $this->column_cb($item), // already escaped
757
-                    $item,
758
-                    $this
759
-                );
760
-                echo '</th>';
761
-            } elseif (method_exists($this, 'column_' . $column_name)) {
762
-                echo "<td $attributes>"; // already escaped
763
-                echo apply_filters(
764
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
765
-                    call_user_func([$this, 'column_' . $column_name], $item),
766
-                    $item,
767
-                    $this
768
-                );
769
-                echo $this->handle_row_actions($item, $column_name, $primary);
770
-                echo "</td>";
771
-            } else {
772
-                echo "<td $attributes>"; // already escaped
773
-                echo apply_filters(
774
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
775
-                    $this->column_default($item, $column_name),
776
-                    $item,
777
-                    $column_name,
778
-                    $this
779
-                );
780
-                echo $this->handle_row_actions($item, $column_name, $primary);
781
-                echo "</td>";
782
-            }
783
-        }
784
-    }
785
-
786
-
787
-    /**
788
-     * Extra controls to be displayed between bulk actions and pagination
789
-     *
790
-     * @access public
791
-     * @param string $which
792
-     * @throws EE_Error
793
-     */
794
-    public function extra_tablenav($which)
795
-    {
796
-        if ($which === 'top') {
797
-            $this->_filters();
798
-            echo $this->_get_hidden_fields(); // already escaped
799
-        } else {
800
-            echo '<div class="list-table-bottom-buttons alignleft actions">';
801
-            foreach ($this->_bottom_buttons as $type => $action) {
802
-                $route         = isset($action['route']) ? $action['route'] : '';
803
-                $extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
804
-                // already escaped
805
-                echo $this->_admin_page->get_action_link_or_button(
806
-                    $route,
807
-                    $type,
808
-                    $extra_request,
809
-                    'button button-secondary'
810
-                );
811
-            }
812
-            do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
813
-            echo '</div>';
814
-        }
815
-    }
816
-
817
-
818
-    /**
819
-     * Get an associative array ( option_name => option_title ) with the list
820
-     * of bulk actions available on this table.
821
-     *
822
-     * @return array
823
-     * @since  3.1.0
824
-     * @access protected
825
-     */
826
-    public function get_bulk_actions()
827
-    {
828
-        return (array) $this->_get_bulk_actions();
829
-    }
830
-
831
-
832
-    /**
833
-     * Processing bulk actions.
834
-     */
835
-    public function process_bulk_action()
836
-    {
837
-        // this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
838
-        // reference in case there is a case where it gets used.
839
-    }
840
-
841
-
842
-    /**
843
-     * returns the EE admin page this list table is associated with
844
-     *
845
-     * @return EE_Admin_Page
846
-     */
847
-    public function get_admin_page()
848
-    {
849
-        return $this->_admin_page;
850
-    }
851
-
852
-
853
-    /**
854
-     * A "helper" function for all children to provide an html string of
855
-     * actions to output in their content.  It is preferable for child classes
856
-     * to use this method for generating their actions content so that it's
857
-     * filterable by plugins
858
-     *
859
-     * @param string        $action_container           what are the html container
860
-     *                                                  elements for this actions string?
861
-     * @param string        $action_class               What class is for the container
862
-     *                                                  element.
863
-     * @param string        $action_items               The contents for the action items
864
-     *                                                  container.  This is filtered before
865
-     *                                                  returned.
866
-     * @param string        $action_id                  What id (optional) is used for the
867
-     *                                                  container element.
868
-     * @param EE_Base_Class $item                       The object for the column displaying
869
-     *                                                  the actions.
870
-     * @return string The assembled action elements container.
871
-     */
872
-    protected function _action_string(
873
-        $action_items,
874
-        $item,
875
-        $action_container = 'ul',
876
-        $action_class = '',
877
-        $action_id = ''
878
-    ) {
879
-        $action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
880
-        $action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
881
-        $open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
882
-        $close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
883
-        try {
884
-            $content = apply_filters(
885
-                'FHEE__EE_Admin_List_Table___action_string__action_items',
886
-                $action_items,
887
-                $item,
888
-                $this
889
-            );
890
-        } catch (Exception $e) {
891
-            if (WP_DEBUG) {
892
-                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
893
-            }
894
-            $content = $action_items;
895
-        }
896
-        return "{$open_tag}{$content}{$close_tag}";
897
-    }
898
-
899
-
900
-    /**
901
-     * @return string
902
-     */
903
-    protected function getReturnUrl()
904
-    {
905
-        $host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
906
-        $uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
907
-        return urlencode(esc_url_raw("//{$host}{$uri}"));
908
-    }
463
+	}
464
+
465
+
466
+	/**
467
+	 * _filters
468
+	 * This receives the filters array from children _get_table_filters() and assembles the string including the filter
469
+	 * button.
470
+	 *
471
+	 * @access private
472
+	 * @return void  echos html showing filters
473
+	 */
474
+	private function _filters()
475
+	{
476
+		$classname = get_class($this);
477
+		$filters   = apply_filters(
478
+			"FHEE__{$classname}__filters",
479
+			(array) $this->_get_table_filters(),
480
+			$this,
481
+			$this->_screen
482
+		);
483
+
484
+		if (empty($filters)) {
485
+			return;
486
+		}
487
+		foreach ($filters as $filter) {
488
+			echo $filter; // already escaped
489
+		}
490
+		// add filter button at end
491
+		echo '<input type="submit" class="button-secondary" value="'
492
+			 . esc_html__('Filter', 'event_espresso')
493
+			 . '" id="post-query-submit" />';
494
+		// add reset filters button at end
495
+		echo '<a class="button button-secondary"  href="'
496
+			 . esc_url_raw($this->_admin_page->get_current_page_view_url())
497
+			 . '" style="display:inline-block">'
498
+			 . esc_html__('Reset Filters', 'event_espresso')
499
+			 . '</a>';
500
+	}
501
+
502
+
503
+	/**
504
+	 * Callback for 'list_table_primary_column' WordPress filter
505
+	 * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
506
+	 * column when class is instantiated.
507
+	 *
508
+	 * @param string $column_name
509
+	 * @return string
510
+	 * @see WP_List_Table::get_primary_column_name
511
+	 */
512
+	public function set_primary_column($column_name)
513
+	{
514
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
515
+	}
516
+
517
+
518
+	/**
519
+	 *
520
+	 */
521
+	public function prepare_items()
522
+	{
523
+
524
+		$this->_set_column_info();
525
+		// $this->_column_headers = $this->get_column_info();
526
+		$total_items = $this->_all_data_count;
527
+		$this->process_bulk_action();
528
+
529
+		$this->items = $this->_data;
530
+		$this->set_pagination_args(
531
+			[
532
+				'total_items' => $total_items,
533
+				'per_page'    => $this->_per_page,
534
+				'total_pages' => ceil($total_items / $this->_per_page),
535
+			]
536
+		);
537
+	}
538
+
539
+
540
+	/**
541
+	 * @param object|array $item
542
+	 * @return string html content for the column
543
+	 */
544
+	protected function column_cb($item)
545
+	{
546
+		return '';
547
+	}
548
+
549
+
550
+	/**
551
+	 * This column is the default for when there is no defined column method for a registered column.
552
+	 * This can be overridden by child classes, but allows for hooking in for custom columns.
553
+	 *
554
+	 * @param EE_Base_Class $item
555
+	 * @param string        $column_name The column being called.
556
+	 * @return string html content for the column
557
+	 */
558
+	public function column_default($item, $column_name)
559
+	{
560
+		/**
561
+		 * Dynamic hook allowing for adding additional column content in this list table.
562
+		 * Note that $this->screen->id is in the format
563
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
564
+		 * table it is: event-espresso_page_espresso_messages.
565
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
566
+		 * hook prefix ("event-espresso") will be different.
567
+		 */
568
+		ob_start();
569
+		do_action(
570
+			'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
571
+			$item,
572
+			$this->_screen
573
+		);
574
+		return ob_get_clean();
575
+	}
576
+
577
+
578
+	/**
579
+	 * Get a list of columns. The format is:
580
+	 * 'internal-name' => 'Title'
581
+	 *
582
+	 * @return array
583
+	 * @since  3.1.0
584
+	 * @access public
585
+	 * @abstract
586
+	 */
587
+	public function get_columns()
588
+	{
589
+		/**
590
+		 * Dynamic hook allowing for adding additional columns in this list table.
591
+		 * Note that $this->screen->id is in the format
592
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
593
+		 * table it is: event-espresso_page_espresso_messages.
594
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
595
+		 * hook prefix ("event-espresso") will be different.
596
+		 *
597
+		 * @var array
598
+		 */
599
+		return apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
600
+	}
601
+
602
+
603
+	/**
604
+	 * Get an associative array ( id => link ) with the list
605
+	 * of views available on this table.
606
+	 *
607
+	 * @return array
608
+	 * @since  3.1.0
609
+	 * @access protected
610
+	 */
611
+	public function get_views()
612
+	{
613
+		return $this->_views;
614
+	}
615
+
616
+
617
+	/**
618
+	 * Generate the views html.
619
+	 */
620
+	public function display_views()
621
+	{
622
+		$views           = $this->get_views();
623
+		$assembled_views = [];
624
+
625
+		if (empty($views)) {
626
+			return;
627
+		}
628
+		echo "<ul class='subsubsub'>\n";
629
+		foreach ($views as $view) {
630
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
631
+			if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
632
+				$filter = "<li";
633
+				$filter .= $view['class'] ? " class='" . esc_attr($view['class']) . "'" : '';
634
+				$filter .= ">";
635
+				$filter .= '<a href="' . esc_url_raw($view['url']) . '">' . esc_html($view['label']) . '</a>';
636
+				$filter .= '<span class="count">(' . $count . ')</span>';
637
+				$filter .= '</li>';
638
+				$assembled_views[ $view['slug'] ] = $filter;
639
+			}
640
+		}
641
+
642
+		echo ! empty($assembled_views)
643
+			? implode("<li style='margin:0 .5rem;'>|</li>", $assembled_views)
644
+			: '';
645
+		echo "</ul>";
646
+	}
647
+
648
+
649
+	/**
650
+	 * Generates content for a single row of the table
651
+	 *
652
+	 * @param EE_Base_Class $item The current item
653
+	 * @since  4.1
654
+	 * @access public
655
+	 */
656
+	public function single_row($item)
657
+	{
658
+		$row_class = $this->_get_row_class($item);
659
+		echo '<tr class="' . esc_attr($row_class) . '">';
660
+		$this->single_row_columns($item); // already escaped
661
+		echo '</tr>';
662
+	}
663
+
664
+
665
+	/**
666
+	 * This simply sets up the row class for the table rows.
667
+	 * Allows for easier overriding of child methods for setting up sorting.
668
+	 *
669
+	 * @param EE_Base_Class $item the current item
670
+	 * @return string
671
+	 */
672
+	protected function _get_row_class($item)
673
+	{
674
+		static $row_class = '';
675
+		$row_class = ($row_class === '' ? 'alternate' : '');
676
+
677
+		$new_row_class = $row_class;
678
+
679
+		if (! empty($this->_ajax_sorting_callback)) {
680
+			$new_row_class .= ' rowsortable';
681
+		}
682
+
683
+		return $new_row_class;
684
+	}
685
+
686
+
687
+	/**
688
+	 * @return array
689
+	 */
690
+	public function get_sortable_columns()
691
+	{
692
+		return (array) $this->_sortable_columns;
693
+	}
694
+
695
+
696
+	/**
697
+	 * @return string
698
+	 */
699
+	public function get_ajax_sorting_callback()
700
+	{
701
+		return $this->_ajax_sorting_callback;
702
+	}
703
+
704
+
705
+	/**
706
+	 * @return array
707
+	 */
708
+	public function get_hidden_columns()
709
+	{
710
+		$user_id     = get_current_user_id();
711
+		$has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
712
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
713
+			update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
714
+			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
715
+		}
716
+		$ref = 'manage' . $this->screen->id . 'columnshidden';
717
+		return (array) get_user_option($ref, $user_id);
718
+	}
719
+
720
+
721
+	/**
722
+	 * Generates the columns for a single row of the table.
723
+	 * Overridden from wp_list_table so as to allow us to filter the column content for a given
724
+	 * column.
725
+	 *
726
+	 * @param EE_Base_Class $item The current item
727
+	 * @since 3.1.0
728
+	 */
729
+	public function single_row_columns($item)
730
+	{
731
+		[$columns, $hidden, $sortable, $primary] = $this->get_column_info();
732
+
733
+		foreach ($columns as $column_name => $column_display_name) {
734
+
735
+			/**
736
+			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
737
+			 * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
738
+			 */
739
+			$hidden_class = in_array($column_name, $hidden) ? ' hidden' : '';
740
+
741
+			$classes = $column_name . ' column-' . $column_name . $hidden_class;
742
+			if ($primary === $column_name) {
743
+				$classes .= ' has-row-actions column-primary';
744
+			}
745
+
746
+			$data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
747
+
748
+			$class = 'class="' . esc_attr($classes) . '"';
749
+
750
+			$attributes = "{$class}{$data}";
751
+
752
+			if ($column_name === 'cb') {
753
+				echo '<th scope="row" class="check-column">';
754
+				echo apply_filters(
755
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
756
+					$this->column_cb($item), // already escaped
757
+					$item,
758
+					$this
759
+				);
760
+				echo '</th>';
761
+			} elseif (method_exists($this, 'column_' . $column_name)) {
762
+				echo "<td $attributes>"; // already escaped
763
+				echo apply_filters(
764
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
765
+					call_user_func([$this, 'column_' . $column_name], $item),
766
+					$item,
767
+					$this
768
+				);
769
+				echo $this->handle_row_actions($item, $column_name, $primary);
770
+				echo "</td>";
771
+			} else {
772
+				echo "<td $attributes>"; // already escaped
773
+				echo apply_filters(
774
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
775
+					$this->column_default($item, $column_name),
776
+					$item,
777
+					$column_name,
778
+					$this
779
+				);
780
+				echo $this->handle_row_actions($item, $column_name, $primary);
781
+				echo "</td>";
782
+			}
783
+		}
784
+	}
785
+
786
+
787
+	/**
788
+	 * Extra controls to be displayed between bulk actions and pagination
789
+	 *
790
+	 * @access public
791
+	 * @param string $which
792
+	 * @throws EE_Error
793
+	 */
794
+	public function extra_tablenav($which)
795
+	{
796
+		if ($which === 'top') {
797
+			$this->_filters();
798
+			echo $this->_get_hidden_fields(); // already escaped
799
+		} else {
800
+			echo '<div class="list-table-bottom-buttons alignleft actions">';
801
+			foreach ($this->_bottom_buttons as $type => $action) {
802
+				$route         = isset($action['route']) ? $action['route'] : '';
803
+				$extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
804
+				// already escaped
805
+				echo $this->_admin_page->get_action_link_or_button(
806
+					$route,
807
+					$type,
808
+					$extra_request,
809
+					'button button-secondary'
810
+				);
811
+			}
812
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
813
+			echo '</div>';
814
+		}
815
+	}
816
+
817
+
818
+	/**
819
+	 * Get an associative array ( option_name => option_title ) with the list
820
+	 * of bulk actions available on this table.
821
+	 *
822
+	 * @return array
823
+	 * @since  3.1.0
824
+	 * @access protected
825
+	 */
826
+	public function get_bulk_actions()
827
+	{
828
+		return (array) $this->_get_bulk_actions();
829
+	}
830
+
831
+
832
+	/**
833
+	 * Processing bulk actions.
834
+	 */
835
+	public function process_bulk_action()
836
+	{
837
+		// this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
838
+		// reference in case there is a case where it gets used.
839
+	}
840
+
841
+
842
+	/**
843
+	 * returns the EE admin page this list table is associated with
844
+	 *
845
+	 * @return EE_Admin_Page
846
+	 */
847
+	public function get_admin_page()
848
+	{
849
+		return $this->_admin_page;
850
+	}
851
+
852
+
853
+	/**
854
+	 * A "helper" function for all children to provide an html string of
855
+	 * actions to output in their content.  It is preferable for child classes
856
+	 * to use this method for generating their actions content so that it's
857
+	 * filterable by plugins
858
+	 *
859
+	 * @param string        $action_container           what are the html container
860
+	 *                                                  elements for this actions string?
861
+	 * @param string        $action_class               What class is for the container
862
+	 *                                                  element.
863
+	 * @param string        $action_items               The contents for the action items
864
+	 *                                                  container.  This is filtered before
865
+	 *                                                  returned.
866
+	 * @param string        $action_id                  What id (optional) is used for the
867
+	 *                                                  container element.
868
+	 * @param EE_Base_Class $item                       The object for the column displaying
869
+	 *                                                  the actions.
870
+	 * @return string The assembled action elements container.
871
+	 */
872
+	protected function _action_string(
873
+		$action_items,
874
+		$item,
875
+		$action_container = 'ul',
876
+		$action_class = '',
877
+		$action_id = ''
878
+	) {
879
+		$action_class = ! empty($action_class) ? ' class="' . esc_attr($action_class) . '"' : '';
880
+		$action_id    = ! empty($action_id) ? ' id="' . esc_attr($action_id) . '"' : '';
881
+		$open_tag     = ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
882
+		$close_tag    = ! empty($action_container) ? '</' . $action_container . '>' : '';
883
+		try {
884
+			$content = apply_filters(
885
+				'FHEE__EE_Admin_List_Table___action_string__action_items',
886
+				$action_items,
887
+				$item,
888
+				$this
889
+			);
890
+		} catch (Exception $e) {
891
+			if (WP_DEBUG) {
892
+				EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
893
+			}
894
+			$content = $action_items;
895
+		}
896
+		return "{$open_tag}{$content}{$close_tag}";
897
+	}
898
+
899
+
900
+	/**
901
+	 * @return string
902
+	 */
903
+	protected function getReturnUrl()
904
+	{
905
+		$host = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
906
+		$uri  = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
907
+		return urlencode(esc_url_raw("//{$host}{$uri}"));
908
+	}
909 909
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +4093 added lines, -4093 removed lines patch added patch discarded remove patch
@@ -18,4167 +18,4167 @@
 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 56
 
57
-    // template variables (used by templates)
58
-    protected $_template_path;
57
+	// template variables (used by templates)
58
+	protected $_template_path;
59 59
 
60
-    protected $_column_template_path;
60
+	protected $_column_template_path;
61 61
 
62
-    /**
63
-     * @var array $_template_args
64
-     */
65
-    protected $_template_args = [];
62
+	/**
63
+	 * @var array $_template_args
64
+	 */
65
+	protected $_template_args = [];
66 66
 
67
-    /**
68
-     * this will hold the list table object for a given view.
69
-     *
70
-     * @var EE_Admin_List_Table $_list_table_object
71
-     */
72
-    protected $_list_table_object;
67
+	/**
68
+	 * this will hold the list table object for a given view.
69
+	 *
70
+	 * @var EE_Admin_List_Table $_list_table_object
71
+	 */
72
+	protected $_list_table_object;
73 73
 
74
-    // bools
75
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
74
+	// bools
75
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
76 76
 
77
-    protected $_routing;
77
+	protected $_routing;
78 78
 
79
-    // list table args
80
-    protected $_view;
79
+	// list table args
80
+	protected $_view;
81 81
 
82
-    protected $_views;
82
+	protected $_views;
83 83
 
84 84
 
85
-    // action => method pairs used for routing incoming requests
86
-    protected $_page_routes;
85
+	// action => method pairs used for routing incoming requests
86
+	protected $_page_routes;
87 87
 
88
-    /**
89
-     * @var array $_page_config
90
-     */
91
-    protected $_page_config;
88
+	/**
89
+	 * @var array $_page_config
90
+	 */
91
+	protected $_page_config;
92 92
 
93
-    /**
94
-     * the current page route and route config
95
-     *
96
-     * @var string $_route
97
-     */
98
-    protected $_route;
93
+	/**
94
+	 * the current page route and route config
95
+	 *
96
+	 * @var string $_route
97
+	 */
98
+	protected $_route;
99 99
 
100
-    /**
101
-     * @var string $_cpt_route
102
-     */
103
-    protected $_cpt_route;
100
+	/**
101
+	 * @var string $_cpt_route
102
+	 */
103
+	protected $_cpt_route;
104 104
 
105
-    /**
106
-     * @var array $_route_config
107
-     */
108
-    protected $_route_config;
105
+	/**
106
+	 * @var array $_route_config
107
+	 */
108
+	protected $_route_config;
109 109
 
110
-    /**
111
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
112
-     * actions.
113
-     *
114
-     * @since 4.6.x
115
-     * @var array.
116
-     */
117
-    protected $_default_route_query_args;
118
-
119
-    // set via request page and action args.
120
-    protected $_current_page;
121
-
122
-    protected $_current_view;
123
-
124
-    protected $_current_page_view_url;
125
-
126
-    /**
127
-     * unprocessed value for the 'action' request param (default '')
128
-     *
129
-     * @var string
130
-     */
131
-    protected $raw_req_action = '';
132
-
133
-    /**
134
-     * unprocessed value for the 'page' request param (default '')
135
-     *
136
-     * @var string
137
-     */
138
-    protected $raw_req_page = '';
139
-
140
-    /**
141
-     * sanitized request action (and nonce)
142
-     *
143
-     * @var string
144
-     */
145
-    protected $_req_action = '';
146
-
147
-    /**
148
-     * sanitized request action nonce
149
-     *
150
-     * @var string
151
-     */
152
-    protected $_req_nonce = '';
153
-
154
-    /**
155
-     * @var string
156
-     */
157
-    protected $_search_btn_label = '';
158
-
159
-    /**
160
-     * @var string
161
-     */
162
-    protected $_search_box_callback = '';
163
-
164
-    /**
165
-     * @var WP_Screen
166
-     */
167
-    protected $_current_screen;
168
-
169
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
170
-    protected $_hook_obj;
171
-
172
-    // for holding incoming request data
173
-    protected $_req_data = [];
174
-
175
-    // yes / no array for admin form fields
176
-    protected $_yes_no_values = [];
177
-
178
-    // some default things shared by all child classes
179
-    protected $_default_espresso_metaboxes;
180
-
181
-    /**
182
-     * @var EE_Registry
183
-     */
184
-    protected $EE = null;
185
-
186
-
187
-    /**
188
-     * This is just a property that flags whether the given route is a caffeinated route or not.
189
-     *
190
-     * @var boolean
191
-     */
192
-    protected $_is_caf = false;
193
-
194
-
195
-    /**
196
-     * @Constructor
197
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
198
-     * @throws EE_Error
199
-     * @throws InvalidArgumentException
200
-     * @throws ReflectionException
201
-     * @throws InvalidDataTypeException
202
-     * @throws InvalidInterfaceException
203
-     */
204
-    public function __construct($routing = true)
205
-    {
206
-        $this->loader  = LoaderFactory::getLoader();
207
-        $this->request = $this->loader->getShared(RequestInterface::class);
208
-        $this->_routing = $routing;
209
-
210
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
211
-            $this->_is_caf = true;
212
-        }
213
-        $this->_yes_no_values = [
214
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
215
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
216
-        ];
217
-        // set the _req_data property.
218
-        $this->_req_data = $this->request->requestParams();
219
-        // set initial page props (child method)
220
-        $this->_init_page_props();
221
-        // set global defaults
222
-        $this->_set_defaults();
223
-        // set early because incoming requests could be ajax related and we need to register those hooks.
224
-        $this->_global_ajax_hooks();
225
-        $this->_ajax_hooks();
226
-        // other_page_hooks have to be early too.
227
-        $this->_do_other_page_hooks();
228
-        // set up page dependencies
229
-        $this->_before_page_setup();
230
-        $this->_page_setup();
231
-        // die();
232
-    }
233
-
234
-
235
-    /**
236
-     * _init_page_props
237
-     * Child classes use to set at least the following properties:
238
-     * $page_slug.
239
-     * $page_label.
240
-     *
241
-     * @abstract
242
-     * @return void
243
-     */
244
-    abstract protected function _init_page_props();
245
-
246
-
247
-    /**
248
-     * _ajax_hooks
249
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
250
-     * Note: within the ajax callback methods.
251
-     *
252
-     * @abstract
253
-     * @return void
254
-     */
255
-    abstract protected function _ajax_hooks();
256
-
257
-
258
-    /**
259
-     * _define_page_props
260
-     * child classes define page properties in here.  Must include at least:
261
-     * $_admin_base_url = base_url for all admin pages
262
-     * $_admin_page_title = default admin_page_title for admin pages
263
-     * $_labels = array of default labels for various automatically generated elements:
264
-     *    array(
265
-     *        'buttons' => array(
266
-     *            'add' => esc_html__('label for add new button'),
267
-     *            'edit' => esc_html__('label for edit button'),
268
-     *            'delete' => esc_html__('label for delete button')
269
-     *            )
270
-     *        )
271
-     *
272
-     * @abstract
273
-     * @return void
274
-     */
275
-    abstract protected function _define_page_props();
276
-
277
-
278
-    /**
279
-     * _set_page_routes
280
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
281
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
282
-     * have a 'default' route. Here's the format
283
-     * $this->_page_routes = array(
284
-     *        'default' => array(
285
-     *            'func' => '_default_method_handling_route',
286
-     *            'args' => array('array','of','args'),
287
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
288
-     *            ajax request, backend processing)
289
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
290
-     *            headers route after.  The string you enter here should match the defined route reference for a
291
-     *            headers sent route.
292
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
293
-     *            this route.
294
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
295
-     *            checks).
296
-     *        ),
297
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
298
-     *        handling method.
299
-     *        )
300
-     * )
301
-     *
302
-     * @abstract
303
-     * @return void
304
-     */
305
-    abstract protected function _set_page_routes();
306
-
307
-
308
-    /**
309
-     * _set_page_config
310
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
311
-     * array corresponds to the page_route for the loaded page. Format:
312
-     * $this->_page_config = array(
313
-     *        'default' => array(
314
-     *            'labels' => array(
315
-     *                'buttons' => array(
316
-     *                    'add' => esc_html__('label for adding item'),
317
-     *                    'edit' => esc_html__('label for editing item'),
318
-     *                    'delete' => esc_html__('label for deleting item')
319
-     *                ),
320
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
321
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
322
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
323
-     *            _define_page_props() method
324
-     *            'nav' => array(
325
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
326
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
327
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
328
-     *                'order' => 10, //required to indicate tab position.
329
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
330
-     *                displayed then add this parameter.
331
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
332
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
333
-     *            metaboxes set for eventespresso admin pages.
334
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
335
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
336
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
337
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
338
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
339
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
340
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
341
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
342
-     *            want to display.
343
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
344
-     *                'tab_id' => array(
345
-     *                    'title' => 'tab_title',
346
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
347
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
348
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
349
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
350
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
351
-     *                    attempt to use the callback which should match the name of a method in the class
352
-     *                    ),
353
-     *                'tab2_id' => array(
354
-     *                    'title' => 'tab2 title',
355
-     *                    'filename' => 'file_name_2'
356
-     *                    'callback' => 'callback_method_for_content',
357
-     *                 ),
358
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
359
-     *            help tab area on an admin page. @return void
360
-     *
361
-     * @abstract
362
-     */
363
-    abstract protected function _set_page_config();
364
-
365
-
366
-    /**
367
-     * _add_screen_options
368
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
369
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
370
-     * to a particular view.
371
-     *
372
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
373
-     *         see also WP_Screen object documents...
374
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
375
-     * @abstract
376
-     * @return void
377
-     */
378
-    abstract protected function _add_screen_options();
379
-
380
-
381
-    /**
382
-     * _add_feature_pointers
383
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
384
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
385
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
386
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
387
-     * extended) also see:
388
-     *
389
-     * @link   http://eamann.com/tech/wordpress-portland/
390
-     * @abstract
391
-     * @return void
392
-     */
393
-    abstract protected function _add_feature_pointers();
394
-
395
-
396
-    /**
397
-     * load_scripts_styles
398
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
399
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
400
-     * scripts/styles per view by putting them in a dynamic function in this format
401
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
402
-     *
403
-     * @abstract
404
-     * @return void
405
-     */
406
-    abstract public function load_scripts_styles();
407
-
408
-
409
-    /**
410
-     * admin_init
411
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
412
-     * all pages/views loaded by child class.
413
-     *
414
-     * @abstract
415
-     * @return void
416
-     */
417
-    abstract public function admin_init();
418
-
419
-
420
-    /**
421
-     * admin_notices
422
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
423
-     * all pages/views loaded by child class.
424
-     *
425
-     * @abstract
426
-     * @return void
427
-     */
428
-    abstract public function admin_notices();
429
-
430
-
431
-    /**
432
-     * admin_footer_scripts
433
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
434
-     * will apply to all pages/views loaded by child class.
435
-     *
436
-     * @return void
437
-     */
438
-    abstract public function admin_footer_scripts();
439
-
440
-
441
-    /**
442
-     * admin_footer
443
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
444
-     * apply to all pages/views loaded by child class.
445
-     *
446
-     * @return void
447
-     */
448
-    public function admin_footer()
449
-    {
450
-    }
451
-
452
-
453
-    /**
454
-     * _global_ajax_hooks
455
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
456
-     * Note: within the ajax callback methods.
457
-     *
458
-     * @abstract
459
-     * @return void
460
-     */
461
-    protected function _global_ajax_hooks()
462
-    {
463
-        // for lazy loading of metabox content
464
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
465
-    }
466
-
467
-
468
-    public function ajax_metabox_content()
469
-    {
470
-        $content_id  = $this->request->getRequestParam('contentid', '');
471
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
472
-        self::cached_rss_display($content_id, $content_url);
473
-        wp_die();
474
-    }
475
-
476
-
477
-    /**
478
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
479
-     *
480
-     * @return void
481
-     */
482
-    protected function _before_page_setup()
483
-    {
484
-        // default is to do nothing
485
-    }
486
-
487
-
488
-    /**
489
-     * Makes sure any things that need to be loaded early get handled.
490
-     * We also escape early here if the page requested doesn't match the object.
491
-     *
492
-     * @final
493
-     * @return void
494
-     * @throws EE_Error
495
-     * @throws InvalidArgumentException
496
-     * @throws ReflectionException
497
-     * @throws InvalidDataTypeException
498
-     * @throws InvalidInterfaceException
499
-     */
500
-    final protected function _page_setup()
501
-    {
502
-        // requires?
503
-        // admin_init stuff - global - we're setting this REALLY early
504
-        // so if EE_Admin pages have to hook into other WP pages they can.
505
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
506
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
507
-        // next verify if we need to load anything...
508
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
509
-        $this->page_folder   = strtolower(
510
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
511
-        );
512
-        global $ee_menu_slugs;
513
-        $ee_menu_slugs = (array) $ee_menu_slugs;
514
-        if (
515
-            ! $this->request->isAjax()
516
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
517
-        ) {
518
-            return;
519
-        }
520
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
521
-        // we need to copy the action from the second to the first
522
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
523
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
524
-        $action     = $action !== '-1' ? $action : $action2;
525
-        $req_action = $action !== '-1' ? $action : 'default';
526
-
527
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
528
-        // then let's use the route as the action.
529
-        // This covers cases where we're coming in from a list table that isn't on the default route.
530
-        $route = $this->request->getRequestParam('route');
531
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
532
-            ? $route
533
-            : $req_action;
534
-
535
-        $this->_current_view = $this->_req_action;
536
-        $this->_req_nonce    = $this->_req_action . '_nonce';
537
-        $this->_define_page_props();
538
-        $this->_current_page_view_url = add_query_arg(
539
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
540
-            $this->_admin_base_url
541
-        );
542
-        // default things
543
-        $this->_default_espresso_metaboxes = [
544
-            '_espresso_news_post_box',
545
-            '_espresso_links_post_box',
546
-            '_espresso_ratings_request',
547
-            '_espresso_sponsors_post_box',
548
-        ];
549
-        // set page configs
550
-        $this->_set_page_routes();
551
-        $this->_set_page_config();
552
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
553
-        if ($this->request->requestParamIsSet('wp_referer')) {
554
-            $wp_referer = $this->request->getRequestParam('wp_referer');
555
-            if ($wp_referer) {
556
-                $this->_default_route_query_args['wp_referer'] = $wp_referer;
557
-            }
558
-        }
559
-        // for caffeinated and other extended functionality.
560
-        //  If there is a _extend_page_config method
561
-        // then let's run that to modify the all the various page configuration arrays
562
-        if (method_exists($this, '_extend_page_config')) {
563
-            $this->_extend_page_config();
564
-        }
565
-        // for CPT and other extended functionality.
566
-        // If there is an _extend_page_config_for_cpt
567
-        // then let's run that to modify all the various page configuration arrays.
568
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
569
-            $this->_extend_page_config_for_cpt();
570
-        }
571
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
572
-        $this->_page_routes = apply_filters(
573
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
574
-            $this->_page_routes,
575
-            $this
576
-        );
577
-        $this->_page_config = apply_filters(
578
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
579
-            $this->_page_config,
580
-            $this
581
-        );
582
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
583
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
584
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
585
-            add_action(
586
-                'AHEE__EE_Admin_Page__route_admin_request',
587
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
588
-                10,
589
-                2
590
-            );
591
-        }
592
-        // next route only if routing enabled
593
-        if ($this->_routing && ! $this->request->isAjax()) {
594
-            $this->_verify_routes();
595
-            // next let's just check user_access and kill if no access
596
-            $this->check_user_access();
597
-            if ($this->_is_UI_request) {
598
-                // admin_init stuff - global, all views for this page class, specific view
599
-                add_action('admin_init', [$this, 'admin_init'], 10);
600
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
601
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
602
-                }
603
-            } else {
604
-                // hijack regular WP loading and route admin request immediately
605
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
606
-                $this->route_admin_request();
607
-            }
608
-        }
609
-    }
610
-
611
-
612
-    /**
613
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
614
-     *
615
-     * @return void
616
-     * @throws EE_Error
617
-     */
618
-    private function _do_other_page_hooks()
619
-    {
620
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
621
-        foreach ($registered_pages as $page) {
622
-            // now let's setup the file name and class that should be present
623
-            $classname = str_replace('.class.php', '', $page);
624
-            // autoloaders should take care of loading file
625
-            if (! class_exists($classname)) {
626
-                $error_msg[] = sprintf(
627
-                    esc_html__(
628
-                        'Something went wrong with loading the %s admin hooks page.',
629
-                        'event_espresso'
630
-                    ),
631
-                    $page
632
-                );
633
-                $error_msg[] = $error_msg[0]
634
-                               . "\r\n"
635
-                               . sprintf(
636
-                                   esc_html__(
637
-                                       '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',
638
-                                       'event_espresso'
639
-                                   ),
640
-                                   $page,
641
-                                   '<br />',
642
-                                   '<strong>' . $classname . '</strong>'
643
-                               );
644
-                throw new EE_Error(implode('||', $error_msg));
645
-            }
646
-            // notice we are passing the instance of this class to the hook object.
647
-            $this->loader->getShared($classname, [$this]);
648
-        }
649
-    }
650
-
651
-
652
-    /**
653
-     * @throws ReflectionException
654
-     * @throws EE_Error
655
-     */
656
-    public function load_page_dependencies()
657
-    {
658
-        try {
659
-            $this->_load_page_dependencies();
660
-        } catch (EE_Error $e) {
661
-            $e->get_error();
662
-        }
663
-    }
664
-
665
-
666
-    /**
667
-     * load_page_dependencies
668
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
669
-     *
670
-     * @return void
671
-     * @throws DomainException
672
-     * @throws EE_Error
673
-     * @throws InvalidArgumentException
674
-     * @throws InvalidDataTypeException
675
-     * @throws InvalidInterfaceException
676
-     */
677
-    protected function _load_page_dependencies()
678
-    {
679
-        // let's set the current_screen and screen options to override what WP set
680
-        $this->_current_screen = get_current_screen();
681
-        // load admin_notices - global, page class, and view specific
682
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
683
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
684
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
685
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
686
-        }
687
-        // load network admin_notices - global, page class, and view specific
688
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
689
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
690
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
691
-        }
692
-        // this will save any per_page screen options if they are present
693
-        $this->_set_per_page_screen_options();
694
-        // setup list table properties
695
-        $this->_set_list_table();
696
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
697
-        // However in some cases the metaboxes will need to be added within a route handling callback.
698
-        $this->_add_registered_meta_boxes();
699
-        $this->_add_screen_columns();
700
-        // add screen options - global, page child class, and view specific
701
-        $this->_add_global_screen_options();
702
-        $this->_add_screen_options();
703
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
704
-        if (method_exists($this, $add_screen_options)) {
705
-            $this->{$add_screen_options}();
706
-        }
707
-        // add help tab(s) - set via page_config and qtips.
708
-        $this->_add_help_tabs();
709
-        $this->_add_qtips();
710
-        // add feature_pointers - global, page child class, and view specific
711
-        $this->_add_feature_pointers();
712
-        $this->_add_global_feature_pointers();
713
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
714
-        if (method_exists($this, $add_feature_pointer)) {
715
-            $this->{$add_feature_pointer}();
716
-        }
717
-        // enqueue scripts/styles - global, page class, and view specific
718
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
719
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
720
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
721
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
722
-        }
723
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
724
-        // admin_print_footer_scripts - global, page child class, and view specific.
725
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
726
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
727
-        // is a good use case. Notice the late priority we're giving these
728
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
729
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
730
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
731
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
732
-        }
733
-        // admin footer scripts
734
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
735
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
736
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
737
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
738
-        }
739
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
740
-        // targeted hook
741
-        do_action(
742
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
743
-        );
744
-    }
745
-
746
-
747
-    /**
748
-     * _set_defaults
749
-     * This sets some global defaults for class properties.
750
-     */
751
-    private function _set_defaults()
752
-    {
753
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
754
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
755
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
756
-        $this->_page_config          = $this->_default_route_query_args = [];
757
-        $this->_default_nav_tab_name = 'overview';
758
-        // init template args
759
-        $this->_template_args = [
760
-            'admin_page_header'  => '',
761
-            'admin_page_content' => '',
762
-            'post_body_content'  => '',
763
-            'before_list_table'  => '',
764
-            'after_list_table'   => '',
765
-        ];
766
-    }
767
-
768
-
769
-    /**
770
-     * route_admin_request
771
-     *
772
-     * @return void
773
-     * @throws InvalidArgumentException
774
-     * @throws InvalidInterfaceException
775
-     * @throws InvalidDataTypeException
776
-     * @throws EE_Error
777
-     * @throws ReflectionException
778
-     * @see    _route_admin_request()
779
-     */
780
-    public function route_admin_request()
781
-    {
782
-        try {
783
-            $this->_route_admin_request();
784
-        } catch (EE_Error $e) {
785
-            $e->get_error();
786
-        }
787
-    }
788
-
789
-
790
-    public function set_wp_page_slug($wp_page_slug)
791
-    {
792
-        $this->_wp_page_slug = $wp_page_slug;
793
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
794
-        if (is_network_admin()) {
795
-            $this->_wp_page_slug .= '-network';
796
-        }
797
-    }
798
-
799
-
800
-    /**
801
-     * _verify_routes
802
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
803
-     * we know if we need to drop out.
804
-     *
805
-     * @return bool
806
-     * @throws EE_Error
807
-     */
808
-    protected function _verify_routes()
809
-    {
810
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
811
-        if (! $this->_current_page && ! $this->request->isAjax()) {
812
-            return false;
813
-        }
814
-        $this->_route = false;
815
-        // check that the page_routes array is not empty
816
-        if (empty($this->_page_routes)) {
817
-            // user error msg
818
-            $error_msg = sprintf(
819
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
820
-                $this->_admin_page_title
821
-            );
822
-            // developer error msg
823
-            $error_msg .= '||' . $error_msg
824
-                          . esc_html__(
825
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
826
-                              'event_espresso'
827
-                          );
828
-            throw new EE_Error($error_msg);
829
-        }
830
-        // and that the requested page route exists
831
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
832
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
833
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
834
-                ? $this->_page_config[ $this->_req_action ]
835
-                : [];
836
-        } else {
837
-            // user error msg
838
-            $error_msg = sprintf(
839
-                esc_html__(
840
-                    'The requested page route does not exist for the %s admin page.',
841
-                    'event_espresso'
842
-                ),
843
-                $this->_admin_page_title
844
-            );
845
-            // developer error msg
846
-            $error_msg .= '||' . $error_msg
847
-                          . sprintf(
848
-                              esc_html__(
849
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
850
-                                  'event_espresso'
851
-                              ),
852
-                              $this->_req_action
853
-                          );
854
-            throw new EE_Error($error_msg);
855
-        }
856
-        // and that a default route exists
857
-        if (! array_key_exists('default', $this->_page_routes)) {
858
-            // user error msg
859
-            $error_msg = sprintf(
860
-                esc_html__(
861
-                    'A default page route has not been set for the % admin page.',
862
-                    'event_espresso'
863
-                ),
864
-                $this->_admin_page_title
865
-            );
866
-            // developer error msg
867
-            $error_msg .= '||' . $error_msg
868
-                          . esc_html__(
869
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
870
-                              'event_espresso'
871
-                          );
872
-            throw new EE_Error($error_msg);
873
-        }
874
-        // first lets' catch if the UI request has EVER been set.
875
-        if ($this->_is_UI_request === null) {
876
-            // lets set if this is a UI request or not.
877
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
878
-            // wait a minute... we might have a noheader in the route array
879
-            $this->_is_UI_request = ! (
880
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
881
-            )
882
-                ? $this->_is_UI_request
883
-                : false;
884
-        }
885
-        $this->_set_current_labels();
886
-        return true;
887
-    }
888
-
889
-
890
-    /**
891
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
892
-     *
893
-     * @param string $route the route name we're verifying
894
-     * @return bool we'll throw an exception if this isn't a valid route.
895
-     * @throws EE_Error
896
-     */
897
-    protected function _verify_route($route)
898
-    {
899
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
900
-            return true;
901
-        }
902
-        // user error msg
903
-        $error_msg = sprintf(
904
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
905
-            $this->_admin_page_title
906
-        );
907
-        // developer error msg
908
-        $error_msg .= '||' . $error_msg
909
-                      . sprintf(
910
-                          esc_html__(
911
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
912
-                              'event_espresso'
913
-                          ),
914
-                          $route
915
-                      );
916
-        throw new EE_Error($error_msg);
917
-    }
918
-
919
-
920
-    /**
921
-     * perform nonce verification
922
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
923
-     * using this method (and save retyping!)
924
-     *
925
-     * @param string $nonce     The nonce sent
926
-     * @param string $nonce_ref The nonce reference string (name0)
927
-     * @return void
928
-     * @throws EE_Error
929
-     */
930
-    protected function _verify_nonce($nonce, $nonce_ref)
931
-    {
932
-        // verify nonce against expected value
933
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
934
-            // these are not the droids you are looking for !!!
935
-            $msg = sprintf(
936
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
937
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
938
-                '</a>'
939
-            );
940
-            if (WP_DEBUG) {
941
-                $msg .= "\n  ";
942
-                $msg .= sprintf(
943
-                    esc_html__(
944
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
945
-                        'event_espresso'
946
-                    ),
947
-                    __CLASS__
948
-                );
949
-            }
950
-            if (! $this->request->isAjax()) {
951
-                wp_die($msg);
952
-            }
953
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
954
-            $this->_return_json();
955
-        }
956
-    }
957
-
958
-
959
-    /**
960
-     * _route_admin_request()
961
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
962
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
963
-     * in the page routes and then will try to load the corresponding method.
964
-     *
965
-     * @return void
966
-     * @throws EE_Error
967
-     * @throws InvalidArgumentException
968
-     * @throws InvalidDataTypeException
969
-     * @throws InvalidInterfaceException
970
-     * @throws ReflectionException
971
-     */
972
-    protected function _route_admin_request()
973
-    {
974
-        if (! $this->_is_UI_request) {
975
-            $this->_verify_routes();
976
-        }
977
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
978
-        if ($this->_req_action !== 'default' && $nonce_check) {
979
-            // set nonce from post data
980
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
981
-            $this->_verify_nonce($nonce, $this->_req_nonce);
982
-        }
983
-        // set the nav_tabs array but ONLY if this is  UI_request
984
-        if ($this->_is_UI_request) {
985
-            $this->_set_nav_tabs();
986
-        }
987
-        // grab callback function
988
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
989
-        // check if callback has args
990
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
991
-        $error_msg = '';
992
-        // action right before calling route
993
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
994
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
995
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
996
-        }
997
-        // right before calling the route, let's clean the _wp_http_referer
998
-        $this->request->setServerParam(
999
-            'REQUEST_URI',
1000
-            remove_query_arg(
1001
-                '_wp_http_referer',
1002
-                wp_unslash($this->request->getServerParam('REQUEST_URI'))
1003
-            )
1004
-        );
1005
-        if (! empty($func)) {
1006
-            if (is_array($func)) {
1007
-                list($class, $method) = $func;
1008
-            } elseif (strpos($func, '::') !== false) {
1009
-                list($class, $method) = explode('::', $func);
1010
-            } else {
1011
-                $class  = $this;
1012
-                $method = $func;
1013
-            }
1014
-            if (! (is_object($class) && $class === $this)) {
1015
-                // send along this admin page object for access by addons.
1016
-                $args['admin_page_object'] = $this;
1017
-            }
1018
-            if (
1019
-                // is it a method on a class that doesn't work?
1020
-                (
1021
-                    (
1022
-                        method_exists($class, $method)
1023
-                        && call_user_func_array([$class, $method], $args) === false
1024
-                    )
1025
-                    && (
1026
-                        // is it a standalone function that doesn't work?
1027
-                        function_exists($method)
1028
-                        && call_user_func_array(
1029
-                            $func,
1030
-                            array_merge(['admin_page_object' => $this], $args)
1031
-                        ) === false
1032
-                    )
1033
-                )
1034
-                || (
1035
-                    // is it neither a class method NOR a standalone function?
1036
-                    ! method_exists($class, $method)
1037
-                    && ! function_exists($method)
1038
-                )
1039
-            ) {
1040
-                // user error msg
1041
-                $error_msg = esc_html__(
1042
-                    'An error occurred. The  requested page route could not be found.',
1043
-                    'event_espresso'
1044
-                );
1045
-                // developer error msg
1046
-                $error_msg .= '||';
1047
-                $error_msg .= sprintf(
1048
-                    esc_html__(
1049
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1050
-                        'event_espresso'
1051
-                    ),
1052
-                    $method
1053
-                );
1054
-            }
1055
-            if (! empty($error_msg)) {
1056
-                throw new EE_Error($error_msg);
1057
-            }
1058
-        }
1059
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1060
-        // then we need to reset the routing properties to the new route.
1061
-        // 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.
1062
-        if (
1063
-            $this->_is_UI_request === false
1064
-            && is_array($this->_route)
1065
-            && ! empty($this->_route['headers_sent_route'])
1066
-        ) {
1067
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1068
-        }
1069
-    }
1070
-
1071
-
1072
-    /**
1073
-     * This method just allows the resetting of page properties in the case where a no headers
1074
-     * route redirects to a headers route in its route config.
1075
-     *
1076
-     * @param string $new_route New (non header) route to redirect to.
1077
-     * @return   void
1078
-     * @throws ReflectionException
1079
-     * @throws InvalidArgumentException
1080
-     * @throws InvalidInterfaceException
1081
-     * @throws InvalidDataTypeException
1082
-     * @throws EE_Error
1083
-     * @since   4.3.0
1084
-     */
1085
-    protected function _reset_routing_properties($new_route)
1086
-    {
1087
-        $this->_is_UI_request = true;
1088
-        // now we set the current route to whatever the headers_sent_route is set at
1089
-        $this->request->setRequestParam('action', $new_route);
1090
-        // rerun page setup
1091
-        $this->_page_setup();
1092
-    }
1093
-
1094
-
1095
-    /**
1096
-     * _add_query_arg
1097
-     * adds nonce to array of arguments then calls WP add_query_arg function
1098
-     *(internally just uses EEH_URL's function with the same name)
1099
-     *
1100
-     * @param array  $args
1101
-     * @param string $url
1102
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1103
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1104
-     *                                        Example usage: If the current page is:
1105
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1106
-     *                                        &action=default&event_id=20&month_range=March%202015
1107
-     *                                        &_wpnonce=5467821
1108
-     *                                        and you call:
1109
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1110
-     *                                        array(
1111
-     *                                        'action' => 'resend_something',
1112
-     *                                        'page=>espresso_registrations'
1113
-     *                                        ),
1114
-     *                                        $some_url,
1115
-     *                                        true
1116
-     *                                        );
1117
-     *                                        It will produce a url in this structure:
1118
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1119
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1120
-     *                                        month_range]=March%202015
1121
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1122
-     * @return string
1123
-     */
1124
-    public static function add_query_args_and_nonce(
1125
-        $args = [],
1126
-        $url = false,
1127
-        $sticky = false,
1128
-        $exclude_nonce = false
1129
-    ) {
1130
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1131
-        if ($sticky) {
1132
-            /** @var RequestInterface $request */
1133
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1134
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1135
-            foreach ($request->requestParams() as $key => $value) {
1136
-                // do not add nonces
1137
-                if (strpos($key, 'nonce') !== false) {
1138
-                    continue;
1139
-                }
1140
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1141
-            }
1142
-        }
1143
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1144
-    }
1145
-
1146
-
1147
-    /**
1148
-     * This returns a generated link that will load the related help tab.
1149
-     *
1150
-     * @param string $help_tab_id the id for the connected help tab
1151
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1152
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1153
-     * @return string              generated link
1154
-     * @uses EEH_Template::get_help_tab_link()
1155
-     */
1156
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1157
-    {
1158
-        return EEH_Template::get_help_tab_link(
1159
-            $help_tab_id,
1160
-            $this->page_slug,
1161
-            $this->_req_action,
1162
-            $icon_style,
1163
-            $help_text
1164
-        );
1165
-    }
1166
-
1167
-
1168
-    /**
1169
-     * _add_help_tabs
1170
-     * Note child classes define their help tabs within the page_config array.
1171
-     *
1172
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1173
-     * @return void
1174
-     * @throws DomainException
1175
-     * @throws EE_Error
1176
-     */
1177
-    protected function _add_help_tabs()
1178
-    {
1179
-        if (isset($this->_page_config[ $this->_req_action ])) {
1180
-            $config = $this->_page_config[ $this->_req_action ];
1181
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1182
-            if (is_array($config) && isset($config['help_sidebar'])) {
1183
-                // check that the callback given is valid
1184
-                if (! method_exists($this, $config['help_sidebar'])) {
1185
-                    throw new EE_Error(
1186
-                        sprintf(
1187
-                            esc_html__(
1188
-                                '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',
1189
-                                'event_espresso'
1190
-                            ),
1191
-                            $config['help_sidebar'],
1192
-                            get_class($this)
1193
-                        )
1194
-                    );
1195
-                }
1196
-                $content = apply_filters(
1197
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1198
-                    $this->{$config['help_sidebar']}()
1199
-                );
1200
-                $this->_current_screen->set_help_sidebar($content);
1201
-            }
1202
-            if (! isset($config['help_tabs'])) {
1203
-                return;
1204
-            } //no help tabs for this route
1205
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1206
-                // we're here so there ARE help tabs!
1207
-                // make sure we've got what we need
1208
-                if (! isset($cfg['title'])) {
1209
-                    throw new EE_Error(
1210
-                        esc_html__(
1211
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1212
-                            'event_espresso'
1213
-                        )
1214
-                    );
1215
-                }
1216
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1217
-                    throw new EE_Error(
1218
-                        esc_html__(
1219
-                            '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',
1220
-                            'event_espresso'
1221
-                        )
1222
-                    );
1223
-                }
1224
-                // first priority goes to content.
1225
-                if (! empty($cfg['content'])) {
1226
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1227
-                    // second priority goes to filename
1228
-                } elseif (! empty($cfg['filename'])) {
1229
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1230
-                    // 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)
1231
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1232
-                                                             . basename($this->_get_dir())
1233
-                                                             . '/help_tabs/'
1234
-                                                             . $cfg['filename']
1235
-                                                             . '.help_tab.php' : $file_path;
1236
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1237
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1238
-                        EE_Error::add_error(
1239
-                            sprintf(
1240
-                                esc_html__(
1241
-                                    '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',
1242
-                                    'event_espresso'
1243
-                                ),
1244
-                                $tab_id,
1245
-                                key($config),
1246
-                                $file_path
1247
-                            ),
1248
-                            __FILE__,
1249
-                            __FUNCTION__,
1250
-                            __LINE__
1251
-                        );
1252
-                        return;
1253
-                    }
1254
-                    $template_args['admin_page_obj'] = $this;
1255
-                    $content                         = EEH_Template::display_template(
1256
-                        $file_path,
1257
-                        $template_args,
1258
-                        true
1259
-                    );
1260
-                } else {
1261
-                    $content = '';
1262
-                }
1263
-                // check if callback is valid
1264
-                if (
1265
-                    empty($content)
1266
-                    && (
1267
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1268
-                    )
1269
-                ) {
1270
-                    EE_Error::add_error(
1271
-                        sprintf(
1272
-                            esc_html__(
1273
-                                '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.',
1274
-                                'event_espresso'
1275
-                            ),
1276
-                            $cfg['title']
1277
-                        ),
1278
-                        __FILE__,
1279
-                        __FUNCTION__,
1280
-                        __LINE__
1281
-                    );
1282
-                    return;
1283
-                }
1284
-                // setup config array for help tab method
1285
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1286
-                $_ht = [
1287
-                    'id'       => $id,
1288
-                    'title'    => $cfg['title'],
1289
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1290
-                    'content'  => $content,
1291
-                ];
1292
-                $this->_current_screen->add_help_tab($_ht);
1293
-            }
1294
-        }
1295
-    }
1296
-
1297
-
1298
-    /**
1299
-     * This simply sets up any qtips that have been defined in the page config
1300
-     *
1301
-     * @return void
1302
-     */
1303
-    protected function _add_qtips()
1304
-    {
1305
-        if (isset($this->_route_config['qtips'])) {
1306
-            $qtips = (array) $this->_route_config['qtips'];
1307
-            // load qtip loader
1308
-            $path = [
1309
-                $this->_get_dir() . '/qtips/',
1310
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1311
-            ];
1312
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1313
-        }
1314
-    }
1315
-
1316
-
1317
-    /**
1318
-     * _set_nav_tabs
1319
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1320
-     * wish to add additional tabs or modify accordingly.
1321
-     *
1322
-     * @return void
1323
-     * @throws InvalidArgumentException
1324
-     * @throws InvalidInterfaceException
1325
-     * @throws InvalidDataTypeException
1326
-     */
1327
-    protected function _set_nav_tabs()
1328
-    {
1329
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1330
-        $i = 0;
1331
-        foreach ($this->_page_config as $slug => $config) {
1332
-            if (! is_array($config) || empty($config['nav'])) {
1333
-                continue;
1334
-            }
1335
-            // no nav tab for this config
1336
-            // check for persistent flag
1337
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1338
-                // nav tab is only to appear when route requested.
1339
-                continue;
1340
-            }
1341
-            if (! $this->check_user_access($slug, true)) {
1342
-                // no nav tab because current user does not have access.
1343
-                continue;
1344
-            }
1345
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1346
-            $this->_nav_tabs[ $slug ] = [
1347
-                'url'       => isset($config['nav']['url'])
1348
-                    ? $config['nav']['url']
1349
-                    : self::add_query_args_and_nonce(
1350
-                        ['action' => $slug],
1351
-                        $this->_admin_base_url
1352
-                    ),
1353
-                'link_text' => isset($config['nav']['label'])
1354
-                    ? $config['nav']['label']
1355
-                    : ucwords(
1356
-                        str_replace('_', ' ', $slug)
1357
-                    ),
1358
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1359
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1360
-            ];
1361
-            $i++;
1362
-        }
1363
-        // if $this->_nav_tabs is empty then lets set the default
1364
-        if (empty($this->_nav_tabs)) {
1365
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1366
-                'url'       => $this->_admin_base_url,
1367
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1368
-                'css_class' => 'nav-tab-active',
1369
-                'order'     => 10,
1370
-            ];
1371
-        }
1372
-        // now let's sort the tabs according to order
1373
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1374
-    }
1375
-
1376
-
1377
-    /**
1378
-     * _set_current_labels
1379
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1380
-     * property array
1381
-     *
1382
-     * @return void
1383
-     */
1384
-    private function _set_current_labels()
1385
-    {
1386
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1387
-            foreach ($this->_route_config['labels'] as $label => $text) {
1388
-                if (is_array($text)) {
1389
-                    foreach ($text as $sublabel => $subtext) {
1390
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1391
-                    }
1392
-                } else {
1393
-                    $this->_labels[ $label ] = $text;
1394
-                }
1395
-            }
1396
-        }
1397
-    }
1398
-
1399
-
1400
-    /**
1401
-     *        verifies user access for this admin page
1402
-     *
1403
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1404
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1405
-     *                               return false if verify fail.
1406
-     * @return bool
1407
-     * @throws InvalidArgumentException
1408
-     * @throws InvalidDataTypeException
1409
-     * @throws InvalidInterfaceException
1410
-     */
1411
-    public function check_user_access($route_to_check = '', $verify_only = false)
1412
-    {
1413
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1414
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1415
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1416
-                          && is_array(
1417
-                              $this->_page_routes[ $route_to_check ]
1418
-                          )
1419
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1420
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1421
-        if (empty($capability) && empty($route_to_check)) {
1422
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1423
-                : $this->_route['capability'];
1424
-        } else {
1425
-            $capability = empty($capability) ? 'manage_options' : $capability;
1426
-        }
1427
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1428
-        if (
1429
-            ! $this->request->isAjax()
1430
-            && (
1431
-                ! function_exists('is_admin')
1432
-                || ! EE_Registry::instance()->CAP->current_user_can(
1433
-                    $capability,
1434
-                    $this->page_slug
1435
-                    . '_'
1436
-                    . $route_to_check,
1437
-                    $id
1438
-                )
1439
-            )
1440
-        ) {
1441
-            if ($verify_only) {
1442
-                return false;
1443
-            }
1444
-            if (is_user_logged_in()) {
1445
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1446
-            } else {
1447
-                return false;
1448
-            }
1449
-        }
1450
-        return true;
1451
-    }
1452
-
1453
-
1454
-    /**
1455
-     * admin_init_global
1456
-     * This runs all the code that we want executed within the WP admin_init hook.
1457
-     * This method executes for ALL EE Admin pages.
1458
-     *
1459
-     * @return void
1460
-     */
1461
-    public function admin_init_global()
1462
-    {
1463
-    }
1464
-
1465
-
1466
-    /**
1467
-     * wp_loaded_global
1468
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1469
-     * EE_Admin page and will execute on every EE Admin Page load
1470
-     *
1471
-     * @return void
1472
-     */
1473
-    public function wp_loaded()
1474
-    {
1475
-    }
1476
-
1477
-
1478
-    /**
1479
-     * admin_notices
1480
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1481
-     * ALL EE_Admin pages.
1482
-     *
1483
-     * @return void
1484
-     */
1485
-    public function admin_notices_global()
1486
-    {
1487
-        $this->_display_no_javascript_warning();
1488
-        $this->_display_espresso_notices();
1489
-    }
1490
-
1491
-
1492
-    public function network_admin_notices_global()
1493
-    {
1494
-        $this->_display_no_javascript_warning();
1495
-        $this->_display_espresso_notices();
1496
-    }
1497
-
1498
-
1499
-    /**
1500
-     * admin_footer_scripts_global
1501
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1502
-     * will apply on ALL EE_Admin pages.
1503
-     *
1504
-     * @return void
1505
-     */
1506
-    public function admin_footer_scripts_global()
1507
-    {
1508
-        $this->_add_admin_page_ajax_loading_img();
1509
-        $this->_add_admin_page_overlay();
1510
-        // if metaboxes are present we need to add the nonce field
1511
-        if (
1512
-            isset($this->_route_config['metaboxes'])
1513
-            || isset($this->_route_config['list_table'])
1514
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1515
-        ) {
1516
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1517
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1518
-        }
1519
-    }
1520
-
1521
-
1522
-    /**
1523
-     * admin_footer_global
1524
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1525
-     * ALL EE_Admin Pages.
1526
-     *
1527
-     * @return void
1528
-     */
1529
-    public function admin_footer_global()
1530
-    {
1531
-        // dialog container for dialog helper
1532
-        echo '
110
+	/**
111
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
112
+	 * actions.
113
+	 *
114
+	 * @since 4.6.x
115
+	 * @var array.
116
+	 */
117
+	protected $_default_route_query_args;
118
+
119
+	// set via request page and action args.
120
+	protected $_current_page;
121
+
122
+	protected $_current_view;
123
+
124
+	protected $_current_page_view_url;
125
+
126
+	/**
127
+	 * unprocessed value for the 'action' request param (default '')
128
+	 *
129
+	 * @var string
130
+	 */
131
+	protected $raw_req_action = '';
132
+
133
+	/**
134
+	 * unprocessed value for the 'page' request param (default '')
135
+	 *
136
+	 * @var string
137
+	 */
138
+	protected $raw_req_page = '';
139
+
140
+	/**
141
+	 * sanitized request action (and nonce)
142
+	 *
143
+	 * @var string
144
+	 */
145
+	protected $_req_action = '';
146
+
147
+	/**
148
+	 * sanitized request action nonce
149
+	 *
150
+	 * @var string
151
+	 */
152
+	protected $_req_nonce = '';
153
+
154
+	/**
155
+	 * @var string
156
+	 */
157
+	protected $_search_btn_label = '';
158
+
159
+	/**
160
+	 * @var string
161
+	 */
162
+	protected $_search_box_callback = '';
163
+
164
+	/**
165
+	 * @var WP_Screen
166
+	 */
167
+	protected $_current_screen;
168
+
169
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
170
+	protected $_hook_obj;
171
+
172
+	// for holding incoming request data
173
+	protected $_req_data = [];
174
+
175
+	// yes / no array for admin form fields
176
+	protected $_yes_no_values = [];
177
+
178
+	// some default things shared by all child classes
179
+	protected $_default_espresso_metaboxes;
180
+
181
+	/**
182
+	 * @var EE_Registry
183
+	 */
184
+	protected $EE = null;
185
+
186
+
187
+	/**
188
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
189
+	 *
190
+	 * @var boolean
191
+	 */
192
+	protected $_is_caf = false;
193
+
194
+
195
+	/**
196
+	 * @Constructor
197
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
198
+	 * @throws EE_Error
199
+	 * @throws InvalidArgumentException
200
+	 * @throws ReflectionException
201
+	 * @throws InvalidDataTypeException
202
+	 * @throws InvalidInterfaceException
203
+	 */
204
+	public function __construct($routing = true)
205
+	{
206
+		$this->loader  = LoaderFactory::getLoader();
207
+		$this->request = $this->loader->getShared(RequestInterface::class);
208
+		$this->_routing = $routing;
209
+
210
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
211
+			$this->_is_caf = true;
212
+		}
213
+		$this->_yes_no_values = [
214
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
215
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
216
+		];
217
+		// set the _req_data property.
218
+		$this->_req_data = $this->request->requestParams();
219
+		// set initial page props (child method)
220
+		$this->_init_page_props();
221
+		// set global defaults
222
+		$this->_set_defaults();
223
+		// set early because incoming requests could be ajax related and we need to register those hooks.
224
+		$this->_global_ajax_hooks();
225
+		$this->_ajax_hooks();
226
+		// other_page_hooks have to be early too.
227
+		$this->_do_other_page_hooks();
228
+		// set up page dependencies
229
+		$this->_before_page_setup();
230
+		$this->_page_setup();
231
+		// die();
232
+	}
233
+
234
+
235
+	/**
236
+	 * _init_page_props
237
+	 * Child classes use to set at least the following properties:
238
+	 * $page_slug.
239
+	 * $page_label.
240
+	 *
241
+	 * @abstract
242
+	 * @return void
243
+	 */
244
+	abstract protected function _init_page_props();
245
+
246
+
247
+	/**
248
+	 * _ajax_hooks
249
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
250
+	 * Note: within the ajax callback methods.
251
+	 *
252
+	 * @abstract
253
+	 * @return void
254
+	 */
255
+	abstract protected function _ajax_hooks();
256
+
257
+
258
+	/**
259
+	 * _define_page_props
260
+	 * child classes define page properties in here.  Must include at least:
261
+	 * $_admin_base_url = base_url for all admin pages
262
+	 * $_admin_page_title = default admin_page_title for admin pages
263
+	 * $_labels = array of default labels for various automatically generated elements:
264
+	 *    array(
265
+	 *        'buttons' => array(
266
+	 *            'add' => esc_html__('label for add new button'),
267
+	 *            'edit' => esc_html__('label for edit button'),
268
+	 *            'delete' => esc_html__('label for delete button')
269
+	 *            )
270
+	 *        )
271
+	 *
272
+	 * @abstract
273
+	 * @return void
274
+	 */
275
+	abstract protected function _define_page_props();
276
+
277
+
278
+	/**
279
+	 * _set_page_routes
280
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
281
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
282
+	 * have a 'default' route. Here's the format
283
+	 * $this->_page_routes = array(
284
+	 *        'default' => array(
285
+	 *            'func' => '_default_method_handling_route',
286
+	 *            'args' => array('array','of','args'),
287
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
288
+	 *            ajax request, backend processing)
289
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
290
+	 *            headers route after.  The string you enter here should match the defined route reference for a
291
+	 *            headers sent route.
292
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
293
+	 *            this route.
294
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
295
+	 *            checks).
296
+	 *        ),
297
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
298
+	 *        handling method.
299
+	 *        )
300
+	 * )
301
+	 *
302
+	 * @abstract
303
+	 * @return void
304
+	 */
305
+	abstract protected function _set_page_routes();
306
+
307
+
308
+	/**
309
+	 * _set_page_config
310
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
311
+	 * array corresponds to the page_route for the loaded page. Format:
312
+	 * $this->_page_config = array(
313
+	 *        'default' => array(
314
+	 *            'labels' => array(
315
+	 *                'buttons' => array(
316
+	 *                    'add' => esc_html__('label for adding item'),
317
+	 *                    'edit' => esc_html__('label for editing item'),
318
+	 *                    'delete' => esc_html__('label for deleting item')
319
+	 *                ),
320
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
321
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
322
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
323
+	 *            _define_page_props() method
324
+	 *            'nav' => array(
325
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
326
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
327
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
328
+	 *                'order' => 10, //required to indicate tab position.
329
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
330
+	 *                displayed then add this parameter.
331
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
332
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
333
+	 *            metaboxes set for eventespresso admin pages.
334
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
335
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
336
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
337
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
338
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
339
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
340
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
341
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
342
+	 *            want to display.
343
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
344
+	 *                'tab_id' => array(
345
+	 *                    'title' => 'tab_title',
346
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
347
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
348
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
349
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
350
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
351
+	 *                    attempt to use the callback which should match the name of a method in the class
352
+	 *                    ),
353
+	 *                'tab2_id' => array(
354
+	 *                    'title' => 'tab2 title',
355
+	 *                    'filename' => 'file_name_2'
356
+	 *                    'callback' => 'callback_method_for_content',
357
+	 *                 ),
358
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
359
+	 *            help tab area on an admin page. @return void
360
+	 *
361
+	 * @abstract
362
+	 */
363
+	abstract protected function _set_page_config();
364
+
365
+
366
+	/**
367
+	 * _add_screen_options
368
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
369
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
370
+	 * to a particular view.
371
+	 *
372
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
373
+	 *         see also WP_Screen object documents...
374
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
375
+	 * @abstract
376
+	 * @return void
377
+	 */
378
+	abstract protected function _add_screen_options();
379
+
380
+
381
+	/**
382
+	 * _add_feature_pointers
383
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
384
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
385
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
386
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
387
+	 * extended) also see:
388
+	 *
389
+	 * @link   http://eamann.com/tech/wordpress-portland/
390
+	 * @abstract
391
+	 * @return void
392
+	 */
393
+	abstract protected function _add_feature_pointers();
394
+
395
+
396
+	/**
397
+	 * load_scripts_styles
398
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
399
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
400
+	 * scripts/styles per view by putting them in a dynamic function in this format
401
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
402
+	 *
403
+	 * @abstract
404
+	 * @return void
405
+	 */
406
+	abstract public function load_scripts_styles();
407
+
408
+
409
+	/**
410
+	 * admin_init
411
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
412
+	 * all pages/views loaded by child class.
413
+	 *
414
+	 * @abstract
415
+	 * @return void
416
+	 */
417
+	abstract public function admin_init();
418
+
419
+
420
+	/**
421
+	 * admin_notices
422
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
423
+	 * all pages/views loaded by child class.
424
+	 *
425
+	 * @abstract
426
+	 * @return void
427
+	 */
428
+	abstract public function admin_notices();
429
+
430
+
431
+	/**
432
+	 * admin_footer_scripts
433
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
434
+	 * will apply to all pages/views loaded by child class.
435
+	 *
436
+	 * @return void
437
+	 */
438
+	abstract public function admin_footer_scripts();
439
+
440
+
441
+	/**
442
+	 * admin_footer
443
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
444
+	 * apply to all pages/views loaded by child class.
445
+	 *
446
+	 * @return void
447
+	 */
448
+	public function admin_footer()
449
+	{
450
+	}
451
+
452
+
453
+	/**
454
+	 * _global_ajax_hooks
455
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
456
+	 * Note: within the ajax callback methods.
457
+	 *
458
+	 * @abstract
459
+	 * @return void
460
+	 */
461
+	protected function _global_ajax_hooks()
462
+	{
463
+		// for lazy loading of metabox content
464
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
465
+	}
466
+
467
+
468
+	public function ajax_metabox_content()
469
+	{
470
+		$content_id  = $this->request->getRequestParam('contentid', '');
471
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
472
+		self::cached_rss_display($content_id, $content_url);
473
+		wp_die();
474
+	}
475
+
476
+
477
+	/**
478
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
479
+	 *
480
+	 * @return void
481
+	 */
482
+	protected function _before_page_setup()
483
+	{
484
+		// default is to do nothing
485
+	}
486
+
487
+
488
+	/**
489
+	 * Makes sure any things that need to be loaded early get handled.
490
+	 * We also escape early here if the page requested doesn't match the object.
491
+	 *
492
+	 * @final
493
+	 * @return void
494
+	 * @throws EE_Error
495
+	 * @throws InvalidArgumentException
496
+	 * @throws ReflectionException
497
+	 * @throws InvalidDataTypeException
498
+	 * @throws InvalidInterfaceException
499
+	 */
500
+	final protected function _page_setup()
501
+	{
502
+		// requires?
503
+		// admin_init stuff - global - we're setting this REALLY early
504
+		// so if EE_Admin pages have to hook into other WP pages they can.
505
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
506
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
507
+		// next verify if we need to load anything...
508
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
509
+		$this->page_folder   = strtolower(
510
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
511
+		);
512
+		global $ee_menu_slugs;
513
+		$ee_menu_slugs = (array) $ee_menu_slugs;
514
+		if (
515
+			! $this->request->isAjax()
516
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
517
+		) {
518
+			return;
519
+		}
520
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
521
+		// we need to copy the action from the second to the first
522
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
523
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
524
+		$action     = $action !== '-1' ? $action : $action2;
525
+		$req_action = $action !== '-1' ? $action : 'default';
526
+
527
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
528
+		// then let's use the route as the action.
529
+		// This covers cases where we're coming in from a list table that isn't on the default route.
530
+		$route = $this->request->getRequestParam('route');
531
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
532
+			? $route
533
+			: $req_action;
534
+
535
+		$this->_current_view = $this->_req_action;
536
+		$this->_req_nonce    = $this->_req_action . '_nonce';
537
+		$this->_define_page_props();
538
+		$this->_current_page_view_url = add_query_arg(
539
+			['page' => $this->_current_page, 'action' => $this->_current_view],
540
+			$this->_admin_base_url
541
+		);
542
+		// default things
543
+		$this->_default_espresso_metaboxes = [
544
+			'_espresso_news_post_box',
545
+			'_espresso_links_post_box',
546
+			'_espresso_ratings_request',
547
+			'_espresso_sponsors_post_box',
548
+		];
549
+		// set page configs
550
+		$this->_set_page_routes();
551
+		$this->_set_page_config();
552
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
553
+		if ($this->request->requestParamIsSet('wp_referer')) {
554
+			$wp_referer = $this->request->getRequestParam('wp_referer');
555
+			if ($wp_referer) {
556
+				$this->_default_route_query_args['wp_referer'] = $wp_referer;
557
+			}
558
+		}
559
+		// for caffeinated and other extended functionality.
560
+		//  If there is a _extend_page_config method
561
+		// then let's run that to modify the all the various page configuration arrays
562
+		if (method_exists($this, '_extend_page_config')) {
563
+			$this->_extend_page_config();
564
+		}
565
+		// for CPT and other extended functionality.
566
+		// If there is an _extend_page_config_for_cpt
567
+		// then let's run that to modify all the various page configuration arrays.
568
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
569
+			$this->_extend_page_config_for_cpt();
570
+		}
571
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
572
+		$this->_page_routes = apply_filters(
573
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
574
+			$this->_page_routes,
575
+			$this
576
+		);
577
+		$this->_page_config = apply_filters(
578
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
579
+			$this->_page_config,
580
+			$this
581
+		);
582
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
583
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
584
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
585
+			add_action(
586
+				'AHEE__EE_Admin_Page__route_admin_request',
587
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
588
+				10,
589
+				2
590
+			);
591
+		}
592
+		// next route only if routing enabled
593
+		if ($this->_routing && ! $this->request->isAjax()) {
594
+			$this->_verify_routes();
595
+			// next let's just check user_access and kill if no access
596
+			$this->check_user_access();
597
+			if ($this->_is_UI_request) {
598
+				// admin_init stuff - global, all views for this page class, specific view
599
+				add_action('admin_init', [$this, 'admin_init'], 10);
600
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
601
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
602
+				}
603
+			} else {
604
+				// hijack regular WP loading and route admin request immediately
605
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
606
+				$this->route_admin_request();
607
+			}
608
+		}
609
+	}
610
+
611
+
612
+	/**
613
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
614
+	 *
615
+	 * @return void
616
+	 * @throws EE_Error
617
+	 */
618
+	private function _do_other_page_hooks()
619
+	{
620
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
621
+		foreach ($registered_pages as $page) {
622
+			// now let's setup the file name and class that should be present
623
+			$classname = str_replace('.class.php', '', $page);
624
+			// autoloaders should take care of loading file
625
+			if (! class_exists($classname)) {
626
+				$error_msg[] = sprintf(
627
+					esc_html__(
628
+						'Something went wrong with loading the %s admin hooks page.',
629
+						'event_espresso'
630
+					),
631
+					$page
632
+				);
633
+				$error_msg[] = $error_msg[0]
634
+							   . "\r\n"
635
+							   . sprintf(
636
+								   esc_html__(
637
+									   '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',
638
+									   'event_espresso'
639
+								   ),
640
+								   $page,
641
+								   '<br />',
642
+								   '<strong>' . $classname . '</strong>'
643
+							   );
644
+				throw new EE_Error(implode('||', $error_msg));
645
+			}
646
+			// notice we are passing the instance of this class to the hook object.
647
+			$this->loader->getShared($classname, [$this]);
648
+		}
649
+	}
650
+
651
+
652
+	/**
653
+	 * @throws ReflectionException
654
+	 * @throws EE_Error
655
+	 */
656
+	public function load_page_dependencies()
657
+	{
658
+		try {
659
+			$this->_load_page_dependencies();
660
+		} catch (EE_Error $e) {
661
+			$e->get_error();
662
+		}
663
+	}
664
+
665
+
666
+	/**
667
+	 * load_page_dependencies
668
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
669
+	 *
670
+	 * @return void
671
+	 * @throws DomainException
672
+	 * @throws EE_Error
673
+	 * @throws InvalidArgumentException
674
+	 * @throws InvalidDataTypeException
675
+	 * @throws InvalidInterfaceException
676
+	 */
677
+	protected function _load_page_dependencies()
678
+	{
679
+		// let's set the current_screen and screen options to override what WP set
680
+		$this->_current_screen = get_current_screen();
681
+		// load admin_notices - global, page class, and view specific
682
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
683
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
684
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
685
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
686
+		}
687
+		// load network admin_notices - global, page class, and view specific
688
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
689
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
690
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
691
+		}
692
+		// this will save any per_page screen options if they are present
693
+		$this->_set_per_page_screen_options();
694
+		// setup list table properties
695
+		$this->_set_list_table();
696
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
697
+		// However in some cases the metaboxes will need to be added within a route handling callback.
698
+		$this->_add_registered_meta_boxes();
699
+		$this->_add_screen_columns();
700
+		// add screen options - global, page child class, and view specific
701
+		$this->_add_global_screen_options();
702
+		$this->_add_screen_options();
703
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
704
+		if (method_exists($this, $add_screen_options)) {
705
+			$this->{$add_screen_options}();
706
+		}
707
+		// add help tab(s) - set via page_config and qtips.
708
+		$this->_add_help_tabs();
709
+		$this->_add_qtips();
710
+		// add feature_pointers - global, page child class, and view specific
711
+		$this->_add_feature_pointers();
712
+		$this->_add_global_feature_pointers();
713
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
714
+		if (method_exists($this, $add_feature_pointer)) {
715
+			$this->{$add_feature_pointer}();
716
+		}
717
+		// enqueue scripts/styles - global, page class, and view specific
718
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
719
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
720
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
721
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
722
+		}
723
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
724
+		// admin_print_footer_scripts - global, page child class, and view specific.
725
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
726
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
727
+		// is a good use case. Notice the late priority we're giving these
728
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
729
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
730
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
731
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
732
+		}
733
+		// admin footer scripts
734
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
735
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
736
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
737
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
738
+		}
739
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
740
+		// targeted hook
741
+		do_action(
742
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
743
+		);
744
+	}
745
+
746
+
747
+	/**
748
+	 * _set_defaults
749
+	 * This sets some global defaults for class properties.
750
+	 */
751
+	private function _set_defaults()
752
+	{
753
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
754
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
755
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
756
+		$this->_page_config          = $this->_default_route_query_args = [];
757
+		$this->_default_nav_tab_name = 'overview';
758
+		// init template args
759
+		$this->_template_args = [
760
+			'admin_page_header'  => '',
761
+			'admin_page_content' => '',
762
+			'post_body_content'  => '',
763
+			'before_list_table'  => '',
764
+			'after_list_table'   => '',
765
+		];
766
+	}
767
+
768
+
769
+	/**
770
+	 * route_admin_request
771
+	 *
772
+	 * @return void
773
+	 * @throws InvalidArgumentException
774
+	 * @throws InvalidInterfaceException
775
+	 * @throws InvalidDataTypeException
776
+	 * @throws EE_Error
777
+	 * @throws ReflectionException
778
+	 * @see    _route_admin_request()
779
+	 */
780
+	public function route_admin_request()
781
+	{
782
+		try {
783
+			$this->_route_admin_request();
784
+		} catch (EE_Error $e) {
785
+			$e->get_error();
786
+		}
787
+	}
788
+
789
+
790
+	public function set_wp_page_slug($wp_page_slug)
791
+	{
792
+		$this->_wp_page_slug = $wp_page_slug;
793
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
794
+		if (is_network_admin()) {
795
+			$this->_wp_page_slug .= '-network';
796
+		}
797
+	}
798
+
799
+
800
+	/**
801
+	 * _verify_routes
802
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
803
+	 * we know if we need to drop out.
804
+	 *
805
+	 * @return bool
806
+	 * @throws EE_Error
807
+	 */
808
+	protected function _verify_routes()
809
+	{
810
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
811
+		if (! $this->_current_page && ! $this->request->isAjax()) {
812
+			return false;
813
+		}
814
+		$this->_route = false;
815
+		// check that the page_routes array is not empty
816
+		if (empty($this->_page_routes)) {
817
+			// user error msg
818
+			$error_msg = sprintf(
819
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
820
+				$this->_admin_page_title
821
+			);
822
+			// developer error msg
823
+			$error_msg .= '||' . $error_msg
824
+						  . esc_html__(
825
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
826
+							  'event_espresso'
827
+						  );
828
+			throw new EE_Error($error_msg);
829
+		}
830
+		// and that the requested page route exists
831
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
832
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
833
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
834
+				? $this->_page_config[ $this->_req_action ]
835
+				: [];
836
+		} else {
837
+			// user error msg
838
+			$error_msg = sprintf(
839
+				esc_html__(
840
+					'The requested page route does not exist for the %s admin page.',
841
+					'event_espresso'
842
+				),
843
+				$this->_admin_page_title
844
+			);
845
+			// developer error msg
846
+			$error_msg .= '||' . $error_msg
847
+						  . sprintf(
848
+							  esc_html__(
849
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
850
+								  'event_espresso'
851
+							  ),
852
+							  $this->_req_action
853
+						  );
854
+			throw new EE_Error($error_msg);
855
+		}
856
+		// and that a default route exists
857
+		if (! array_key_exists('default', $this->_page_routes)) {
858
+			// user error msg
859
+			$error_msg = sprintf(
860
+				esc_html__(
861
+					'A default page route has not been set for the % admin page.',
862
+					'event_espresso'
863
+				),
864
+				$this->_admin_page_title
865
+			);
866
+			// developer error msg
867
+			$error_msg .= '||' . $error_msg
868
+						  . esc_html__(
869
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
870
+							  'event_espresso'
871
+						  );
872
+			throw new EE_Error($error_msg);
873
+		}
874
+		// first lets' catch if the UI request has EVER been set.
875
+		if ($this->_is_UI_request === null) {
876
+			// lets set if this is a UI request or not.
877
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
878
+			// wait a minute... we might have a noheader in the route array
879
+			$this->_is_UI_request = ! (
880
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
881
+			)
882
+				? $this->_is_UI_request
883
+				: false;
884
+		}
885
+		$this->_set_current_labels();
886
+		return true;
887
+	}
888
+
889
+
890
+	/**
891
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
892
+	 *
893
+	 * @param string $route the route name we're verifying
894
+	 * @return bool we'll throw an exception if this isn't a valid route.
895
+	 * @throws EE_Error
896
+	 */
897
+	protected function _verify_route($route)
898
+	{
899
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
900
+			return true;
901
+		}
902
+		// user error msg
903
+		$error_msg = sprintf(
904
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
905
+			$this->_admin_page_title
906
+		);
907
+		// developer error msg
908
+		$error_msg .= '||' . $error_msg
909
+					  . sprintf(
910
+						  esc_html__(
911
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
912
+							  'event_espresso'
913
+						  ),
914
+						  $route
915
+					  );
916
+		throw new EE_Error($error_msg);
917
+	}
918
+
919
+
920
+	/**
921
+	 * perform nonce verification
922
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
923
+	 * using this method (and save retyping!)
924
+	 *
925
+	 * @param string $nonce     The nonce sent
926
+	 * @param string $nonce_ref The nonce reference string (name0)
927
+	 * @return void
928
+	 * @throws EE_Error
929
+	 */
930
+	protected function _verify_nonce($nonce, $nonce_ref)
931
+	{
932
+		// verify nonce against expected value
933
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
934
+			// these are not the droids you are looking for !!!
935
+			$msg = sprintf(
936
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
937
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
938
+				'</a>'
939
+			);
940
+			if (WP_DEBUG) {
941
+				$msg .= "\n  ";
942
+				$msg .= sprintf(
943
+					esc_html__(
944
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
945
+						'event_espresso'
946
+					),
947
+					__CLASS__
948
+				);
949
+			}
950
+			if (! $this->request->isAjax()) {
951
+				wp_die($msg);
952
+			}
953
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
954
+			$this->_return_json();
955
+		}
956
+	}
957
+
958
+
959
+	/**
960
+	 * _route_admin_request()
961
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
962
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
963
+	 * in the page routes and then will try to load the corresponding method.
964
+	 *
965
+	 * @return void
966
+	 * @throws EE_Error
967
+	 * @throws InvalidArgumentException
968
+	 * @throws InvalidDataTypeException
969
+	 * @throws InvalidInterfaceException
970
+	 * @throws ReflectionException
971
+	 */
972
+	protected function _route_admin_request()
973
+	{
974
+		if (! $this->_is_UI_request) {
975
+			$this->_verify_routes();
976
+		}
977
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
978
+		if ($this->_req_action !== 'default' && $nonce_check) {
979
+			// set nonce from post data
980
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
981
+			$this->_verify_nonce($nonce, $this->_req_nonce);
982
+		}
983
+		// set the nav_tabs array but ONLY if this is  UI_request
984
+		if ($this->_is_UI_request) {
985
+			$this->_set_nav_tabs();
986
+		}
987
+		// grab callback function
988
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
989
+		// check if callback has args
990
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
991
+		$error_msg = '';
992
+		// action right before calling route
993
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
994
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
995
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
996
+		}
997
+		// right before calling the route, let's clean the _wp_http_referer
998
+		$this->request->setServerParam(
999
+			'REQUEST_URI',
1000
+			remove_query_arg(
1001
+				'_wp_http_referer',
1002
+				wp_unslash($this->request->getServerParam('REQUEST_URI'))
1003
+			)
1004
+		);
1005
+		if (! empty($func)) {
1006
+			if (is_array($func)) {
1007
+				list($class, $method) = $func;
1008
+			} elseif (strpos($func, '::') !== false) {
1009
+				list($class, $method) = explode('::', $func);
1010
+			} else {
1011
+				$class  = $this;
1012
+				$method = $func;
1013
+			}
1014
+			if (! (is_object($class) && $class === $this)) {
1015
+				// send along this admin page object for access by addons.
1016
+				$args['admin_page_object'] = $this;
1017
+			}
1018
+			if (
1019
+				// is it a method on a class that doesn't work?
1020
+				(
1021
+					(
1022
+						method_exists($class, $method)
1023
+						&& call_user_func_array([$class, $method], $args) === false
1024
+					)
1025
+					&& (
1026
+						// is it a standalone function that doesn't work?
1027
+						function_exists($method)
1028
+						&& call_user_func_array(
1029
+							$func,
1030
+							array_merge(['admin_page_object' => $this], $args)
1031
+						) === false
1032
+					)
1033
+				)
1034
+				|| (
1035
+					// is it neither a class method NOR a standalone function?
1036
+					! method_exists($class, $method)
1037
+					&& ! function_exists($method)
1038
+				)
1039
+			) {
1040
+				// user error msg
1041
+				$error_msg = esc_html__(
1042
+					'An error occurred. The  requested page route could not be found.',
1043
+					'event_espresso'
1044
+				);
1045
+				// developer error msg
1046
+				$error_msg .= '||';
1047
+				$error_msg .= sprintf(
1048
+					esc_html__(
1049
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1050
+						'event_espresso'
1051
+					),
1052
+					$method
1053
+				);
1054
+			}
1055
+			if (! empty($error_msg)) {
1056
+				throw new EE_Error($error_msg);
1057
+			}
1058
+		}
1059
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1060
+		// then we need to reset the routing properties to the new route.
1061
+		// 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.
1062
+		if (
1063
+			$this->_is_UI_request === false
1064
+			&& is_array($this->_route)
1065
+			&& ! empty($this->_route['headers_sent_route'])
1066
+		) {
1067
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1068
+		}
1069
+	}
1070
+
1071
+
1072
+	/**
1073
+	 * This method just allows the resetting of page properties in the case where a no headers
1074
+	 * route redirects to a headers route in its route config.
1075
+	 *
1076
+	 * @param string $new_route New (non header) route to redirect to.
1077
+	 * @return   void
1078
+	 * @throws ReflectionException
1079
+	 * @throws InvalidArgumentException
1080
+	 * @throws InvalidInterfaceException
1081
+	 * @throws InvalidDataTypeException
1082
+	 * @throws EE_Error
1083
+	 * @since   4.3.0
1084
+	 */
1085
+	protected function _reset_routing_properties($new_route)
1086
+	{
1087
+		$this->_is_UI_request = true;
1088
+		// now we set the current route to whatever the headers_sent_route is set at
1089
+		$this->request->setRequestParam('action', $new_route);
1090
+		// rerun page setup
1091
+		$this->_page_setup();
1092
+	}
1093
+
1094
+
1095
+	/**
1096
+	 * _add_query_arg
1097
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1098
+	 *(internally just uses EEH_URL's function with the same name)
1099
+	 *
1100
+	 * @param array  $args
1101
+	 * @param string $url
1102
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1103
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1104
+	 *                                        Example usage: If the current page is:
1105
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1106
+	 *                                        &action=default&event_id=20&month_range=March%202015
1107
+	 *                                        &_wpnonce=5467821
1108
+	 *                                        and you call:
1109
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1110
+	 *                                        array(
1111
+	 *                                        'action' => 'resend_something',
1112
+	 *                                        'page=>espresso_registrations'
1113
+	 *                                        ),
1114
+	 *                                        $some_url,
1115
+	 *                                        true
1116
+	 *                                        );
1117
+	 *                                        It will produce a url in this structure:
1118
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1119
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1120
+	 *                                        month_range]=March%202015
1121
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1122
+	 * @return string
1123
+	 */
1124
+	public static function add_query_args_and_nonce(
1125
+		$args = [],
1126
+		$url = false,
1127
+		$sticky = false,
1128
+		$exclude_nonce = false
1129
+	) {
1130
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1131
+		if ($sticky) {
1132
+			/** @var RequestInterface $request */
1133
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1134
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1135
+			foreach ($request->requestParams() as $key => $value) {
1136
+				// do not add nonces
1137
+				if (strpos($key, 'nonce') !== false) {
1138
+					continue;
1139
+				}
1140
+				$args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1141
+			}
1142
+		}
1143
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1144
+	}
1145
+
1146
+
1147
+	/**
1148
+	 * This returns a generated link that will load the related help tab.
1149
+	 *
1150
+	 * @param string $help_tab_id the id for the connected help tab
1151
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1152
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1153
+	 * @return string              generated link
1154
+	 * @uses EEH_Template::get_help_tab_link()
1155
+	 */
1156
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1157
+	{
1158
+		return EEH_Template::get_help_tab_link(
1159
+			$help_tab_id,
1160
+			$this->page_slug,
1161
+			$this->_req_action,
1162
+			$icon_style,
1163
+			$help_text
1164
+		);
1165
+	}
1166
+
1167
+
1168
+	/**
1169
+	 * _add_help_tabs
1170
+	 * Note child classes define their help tabs within the page_config array.
1171
+	 *
1172
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1173
+	 * @return void
1174
+	 * @throws DomainException
1175
+	 * @throws EE_Error
1176
+	 */
1177
+	protected function _add_help_tabs()
1178
+	{
1179
+		if (isset($this->_page_config[ $this->_req_action ])) {
1180
+			$config = $this->_page_config[ $this->_req_action ];
1181
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1182
+			if (is_array($config) && isset($config['help_sidebar'])) {
1183
+				// check that the callback given is valid
1184
+				if (! method_exists($this, $config['help_sidebar'])) {
1185
+					throw new EE_Error(
1186
+						sprintf(
1187
+							esc_html__(
1188
+								'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',
1189
+								'event_espresso'
1190
+							),
1191
+							$config['help_sidebar'],
1192
+							get_class($this)
1193
+						)
1194
+					);
1195
+				}
1196
+				$content = apply_filters(
1197
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1198
+					$this->{$config['help_sidebar']}()
1199
+				);
1200
+				$this->_current_screen->set_help_sidebar($content);
1201
+			}
1202
+			if (! isset($config['help_tabs'])) {
1203
+				return;
1204
+			} //no help tabs for this route
1205
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1206
+				// we're here so there ARE help tabs!
1207
+				// make sure we've got what we need
1208
+				if (! isset($cfg['title'])) {
1209
+					throw new EE_Error(
1210
+						esc_html__(
1211
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1212
+							'event_espresso'
1213
+						)
1214
+					);
1215
+				}
1216
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1217
+					throw new EE_Error(
1218
+						esc_html__(
1219
+							'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',
1220
+							'event_espresso'
1221
+						)
1222
+					);
1223
+				}
1224
+				// first priority goes to content.
1225
+				if (! empty($cfg['content'])) {
1226
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1227
+					// second priority goes to filename
1228
+				} elseif (! empty($cfg['filename'])) {
1229
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1230
+					// 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)
1231
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1232
+															 . basename($this->_get_dir())
1233
+															 . '/help_tabs/'
1234
+															 . $cfg['filename']
1235
+															 . '.help_tab.php' : $file_path;
1236
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1237
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1238
+						EE_Error::add_error(
1239
+							sprintf(
1240
+								esc_html__(
1241
+									'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',
1242
+									'event_espresso'
1243
+								),
1244
+								$tab_id,
1245
+								key($config),
1246
+								$file_path
1247
+							),
1248
+							__FILE__,
1249
+							__FUNCTION__,
1250
+							__LINE__
1251
+						);
1252
+						return;
1253
+					}
1254
+					$template_args['admin_page_obj'] = $this;
1255
+					$content                         = EEH_Template::display_template(
1256
+						$file_path,
1257
+						$template_args,
1258
+						true
1259
+					);
1260
+				} else {
1261
+					$content = '';
1262
+				}
1263
+				// check if callback is valid
1264
+				if (
1265
+					empty($content)
1266
+					&& (
1267
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1268
+					)
1269
+				) {
1270
+					EE_Error::add_error(
1271
+						sprintf(
1272
+							esc_html__(
1273
+								'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.',
1274
+								'event_espresso'
1275
+							),
1276
+							$cfg['title']
1277
+						),
1278
+						__FILE__,
1279
+						__FUNCTION__,
1280
+						__LINE__
1281
+					);
1282
+					return;
1283
+				}
1284
+				// setup config array for help tab method
1285
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1286
+				$_ht = [
1287
+					'id'       => $id,
1288
+					'title'    => $cfg['title'],
1289
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1290
+					'content'  => $content,
1291
+				];
1292
+				$this->_current_screen->add_help_tab($_ht);
1293
+			}
1294
+		}
1295
+	}
1296
+
1297
+
1298
+	/**
1299
+	 * This simply sets up any qtips that have been defined in the page config
1300
+	 *
1301
+	 * @return void
1302
+	 */
1303
+	protected function _add_qtips()
1304
+	{
1305
+		if (isset($this->_route_config['qtips'])) {
1306
+			$qtips = (array) $this->_route_config['qtips'];
1307
+			// load qtip loader
1308
+			$path = [
1309
+				$this->_get_dir() . '/qtips/',
1310
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1311
+			];
1312
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1313
+		}
1314
+	}
1315
+
1316
+
1317
+	/**
1318
+	 * _set_nav_tabs
1319
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1320
+	 * wish to add additional tabs or modify accordingly.
1321
+	 *
1322
+	 * @return void
1323
+	 * @throws InvalidArgumentException
1324
+	 * @throws InvalidInterfaceException
1325
+	 * @throws InvalidDataTypeException
1326
+	 */
1327
+	protected function _set_nav_tabs()
1328
+	{
1329
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1330
+		$i = 0;
1331
+		foreach ($this->_page_config as $slug => $config) {
1332
+			if (! is_array($config) || empty($config['nav'])) {
1333
+				continue;
1334
+			}
1335
+			// no nav tab for this config
1336
+			// check for persistent flag
1337
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1338
+				// nav tab is only to appear when route requested.
1339
+				continue;
1340
+			}
1341
+			if (! $this->check_user_access($slug, true)) {
1342
+				// no nav tab because current user does not have access.
1343
+				continue;
1344
+			}
1345
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1346
+			$this->_nav_tabs[ $slug ] = [
1347
+				'url'       => isset($config['nav']['url'])
1348
+					? $config['nav']['url']
1349
+					: self::add_query_args_and_nonce(
1350
+						['action' => $slug],
1351
+						$this->_admin_base_url
1352
+					),
1353
+				'link_text' => isset($config['nav']['label'])
1354
+					? $config['nav']['label']
1355
+					: ucwords(
1356
+						str_replace('_', ' ', $slug)
1357
+					),
1358
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1359
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1360
+			];
1361
+			$i++;
1362
+		}
1363
+		// if $this->_nav_tabs is empty then lets set the default
1364
+		if (empty($this->_nav_tabs)) {
1365
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1366
+				'url'       => $this->_admin_base_url,
1367
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1368
+				'css_class' => 'nav-tab-active',
1369
+				'order'     => 10,
1370
+			];
1371
+		}
1372
+		// now let's sort the tabs according to order
1373
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1374
+	}
1375
+
1376
+
1377
+	/**
1378
+	 * _set_current_labels
1379
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1380
+	 * property array
1381
+	 *
1382
+	 * @return void
1383
+	 */
1384
+	private function _set_current_labels()
1385
+	{
1386
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1387
+			foreach ($this->_route_config['labels'] as $label => $text) {
1388
+				if (is_array($text)) {
1389
+					foreach ($text as $sublabel => $subtext) {
1390
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1391
+					}
1392
+				} else {
1393
+					$this->_labels[ $label ] = $text;
1394
+				}
1395
+			}
1396
+		}
1397
+	}
1398
+
1399
+
1400
+	/**
1401
+	 *        verifies user access for this admin page
1402
+	 *
1403
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1404
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1405
+	 *                               return false if verify fail.
1406
+	 * @return bool
1407
+	 * @throws InvalidArgumentException
1408
+	 * @throws InvalidDataTypeException
1409
+	 * @throws InvalidInterfaceException
1410
+	 */
1411
+	public function check_user_access($route_to_check = '', $verify_only = false)
1412
+	{
1413
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1414
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1415
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1416
+						  && is_array(
1417
+							  $this->_page_routes[ $route_to_check ]
1418
+						  )
1419
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1420
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1421
+		if (empty($capability) && empty($route_to_check)) {
1422
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1423
+				: $this->_route['capability'];
1424
+		} else {
1425
+			$capability = empty($capability) ? 'manage_options' : $capability;
1426
+		}
1427
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1428
+		if (
1429
+			! $this->request->isAjax()
1430
+			&& (
1431
+				! function_exists('is_admin')
1432
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1433
+					$capability,
1434
+					$this->page_slug
1435
+					. '_'
1436
+					. $route_to_check,
1437
+					$id
1438
+				)
1439
+			)
1440
+		) {
1441
+			if ($verify_only) {
1442
+				return false;
1443
+			}
1444
+			if (is_user_logged_in()) {
1445
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1446
+			} else {
1447
+				return false;
1448
+			}
1449
+		}
1450
+		return true;
1451
+	}
1452
+
1453
+
1454
+	/**
1455
+	 * admin_init_global
1456
+	 * This runs all the code that we want executed within the WP admin_init hook.
1457
+	 * This method executes for ALL EE Admin pages.
1458
+	 *
1459
+	 * @return void
1460
+	 */
1461
+	public function admin_init_global()
1462
+	{
1463
+	}
1464
+
1465
+
1466
+	/**
1467
+	 * wp_loaded_global
1468
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1469
+	 * EE_Admin page and will execute on every EE Admin Page load
1470
+	 *
1471
+	 * @return void
1472
+	 */
1473
+	public function wp_loaded()
1474
+	{
1475
+	}
1476
+
1477
+
1478
+	/**
1479
+	 * admin_notices
1480
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1481
+	 * ALL EE_Admin pages.
1482
+	 *
1483
+	 * @return void
1484
+	 */
1485
+	public function admin_notices_global()
1486
+	{
1487
+		$this->_display_no_javascript_warning();
1488
+		$this->_display_espresso_notices();
1489
+	}
1490
+
1491
+
1492
+	public function network_admin_notices_global()
1493
+	{
1494
+		$this->_display_no_javascript_warning();
1495
+		$this->_display_espresso_notices();
1496
+	}
1497
+
1498
+
1499
+	/**
1500
+	 * admin_footer_scripts_global
1501
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1502
+	 * will apply on ALL EE_Admin pages.
1503
+	 *
1504
+	 * @return void
1505
+	 */
1506
+	public function admin_footer_scripts_global()
1507
+	{
1508
+		$this->_add_admin_page_ajax_loading_img();
1509
+		$this->_add_admin_page_overlay();
1510
+		// if metaboxes are present we need to add the nonce field
1511
+		if (
1512
+			isset($this->_route_config['metaboxes'])
1513
+			|| isset($this->_route_config['list_table'])
1514
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1515
+		) {
1516
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1517
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1518
+		}
1519
+	}
1520
+
1521
+
1522
+	/**
1523
+	 * admin_footer_global
1524
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1525
+	 * ALL EE_Admin Pages.
1526
+	 *
1527
+	 * @return void
1528
+	 */
1529
+	public function admin_footer_global()
1530
+	{
1531
+		// dialog container for dialog helper
1532
+		echo '
1533 1533
         <div class="ee-admin-dialog-container auto-hide hidden">
1534 1534
             <div class="ee-notices"></div>
1535 1535
             <div class="ee-admin-dialog-container-inner-content"></div>
1536 1536
         </div>
1537 1537
         ';
1538 1538
 
1539
-        // current set timezone for timezone js
1540
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1541
-    }
1542
-
1543
-
1544
-    /**
1545
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1546
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1547
-     * help popups then in your templates or your content you set "triggers" for the content using the
1548
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1549
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1550
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1551
-     * for the
1552
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1553
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1554
-     *    'help_trigger_id' => array(
1555
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1556
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1557
-     *    )
1558
-     * );
1559
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1560
-     *
1561
-     * @param array $help_array
1562
-     * @param bool  $display
1563
-     * @return string content
1564
-     * @throws DomainException
1565
-     * @throws EE_Error
1566
-     */
1567
-    protected function _set_help_popup_content($help_array = [], $display = false)
1568
-    {
1569
-        $content    = '';
1570
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1571
-        // loop through the array and setup content
1572
-        foreach ($help_array as $trigger => $help) {
1573
-            // make sure the array is setup properly
1574
-            if (! isset($help['title']) || ! isset($help['content'])) {
1575
-                throw new EE_Error(
1576
-                    esc_html__(
1577
-                        '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',
1578
-                        'event_espresso'
1579
-                    )
1580
-                );
1581
-            }
1582
-            // we're good so let's setup the template vars and then assign parsed template content to our content.
1583
-            $template_args = [
1584
-                'help_popup_id'      => $trigger,
1585
-                'help_popup_title'   => $help['title'],
1586
-                'help_popup_content' => $help['content'],
1587
-            ];
1588
-            $content       .= EEH_Template::display_template(
1589
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1590
-                $template_args,
1591
-                true
1592
-            );
1593
-        }
1594
-        if ($display) {
1595
-            echo $content; // already escaped
1596
-            return '';
1597
-        }
1598
-        return $content;
1599
-    }
1600
-
1601
-
1602
-    /**
1603
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1604
-     *
1605
-     * @return array properly formatted array for help popup content
1606
-     * @throws EE_Error
1607
-     */
1608
-    private function _get_help_content()
1609
-    {
1610
-        // what is the method we're looking for?
1611
-        $method_name = '_help_popup_content_' . $this->_req_action;
1612
-        // if method doesn't exist let's get out.
1613
-        if (! method_exists($this, $method_name)) {
1614
-            return [];
1615
-        }
1616
-        // k we're good to go let's retrieve the help array
1617
-        $help_array = call_user_func([$this, $method_name]);
1618
-        // make sure we've got an array!
1619
-        if (! is_array($help_array)) {
1620
-            throw new EE_Error(
1621
-                esc_html__(
1622
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1623
-                    'event_espresso'
1624
-                )
1625
-            );
1626
-        }
1627
-        return $help_array;
1628
-    }
1629
-
1630
-
1631
-    /**
1632
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1633
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1634
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1635
-     *
1636
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1637
-     * @param boolean $display    if false then we return the trigger string
1638
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1639
-     * @return string
1640
-     * @throws DomainException
1641
-     * @throws EE_Error
1642
-     */
1643
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1644
-    {
1645
-        if ($this->request->isAjax()) {
1646
-            return '';
1647
-        }
1648
-        // 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
1649
-        $help_array   = $this->_get_help_content();
1650
-        $help_content = '';
1651
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1652
-            $help_array[ $trigger_id ] = [
1653
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1654
-                'content' => esc_html__(
1655
-                    '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.)',
1656
-                    'event_espresso'
1657
-                ),
1658
-            ];
1659
-            $help_content              = $this->_set_help_popup_content($help_array);
1660
-        }
1661
-        // let's setup the trigger
1662
-        $content = '<a class="ee-dialog" href="?height='
1663
-                   . esc_attr($dimensions[0])
1664
-                   . '&width='
1665
-                   . esc_attr($dimensions[1])
1666
-                   . '&inlineId='
1667
-                   . esc_attr($trigger_id)
1668
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1669
-        $content .= $help_content;
1670
-        if ($display) {
1671
-            echo $content; // already escaped
1672
-            return '';
1673
-        }
1674
-        return $content;
1675
-    }
1676
-
1677
-
1678
-    /**
1679
-     * _add_global_screen_options
1680
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1681
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1682
-     *
1683
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1684
-     *         see also WP_Screen object documents...
1685
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1686
-     * @abstract
1687
-     * @return void
1688
-     */
1689
-    private function _add_global_screen_options()
1690
-    {
1691
-    }
1692
-
1693
-
1694
-    /**
1695
-     * _add_global_feature_pointers
1696
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1697
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1698
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1699
-     *
1700
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1701
-     *         extended) also see:
1702
-     * @link   http://eamann.com/tech/wordpress-portland/
1703
-     * @abstract
1704
-     * @return void
1705
-     */
1706
-    private function _add_global_feature_pointers()
1707
-    {
1708
-    }
1709
-
1710
-
1711
-    /**
1712
-     * load_global_scripts_styles
1713
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1714
-     *
1715
-     * @return void
1716
-     */
1717
-    public function load_global_scripts_styles()
1718
-    {
1719
-        /** STYLES **/
1720
-        // add debugging styles
1721
-        if (WP_DEBUG) {
1722
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1723
-        }
1724
-        // register all styles
1725
-        wp_register_style(
1726
-            'espresso-ui-theme',
1727
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1728
-            [],
1729
-            EVENT_ESPRESSO_VERSION
1730
-        );
1731
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1732
-        // helpers styles
1733
-        wp_register_style(
1734
-            'ee-text-links',
1735
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1736
-            [],
1737
-            EVENT_ESPRESSO_VERSION
1738
-        );
1739
-        /** SCRIPTS **/
1740
-        // register all scripts
1741
-        wp_register_script(
1742
-            'ee-dialog',
1743
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1744
-            ['jquery', 'jquery-ui-draggable'],
1745
-            EVENT_ESPRESSO_VERSION,
1746
-            true
1747
-        );
1748
-        wp_register_script(
1749
-            'ee_admin_js',
1750
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1751
-            ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1752
-            EVENT_ESPRESSO_VERSION,
1753
-            true
1754
-        );
1755
-        wp_register_script(
1756
-            'jquery-ui-timepicker-addon',
1757
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1758
-            ['jquery-ui-datepicker', 'jquery-ui-slider'],
1759
-            EVENT_ESPRESSO_VERSION,
1760
-            true
1761
-        );
1762
-        // script for sorting tables
1763
-        wp_register_script(
1764
-            'espresso_ajax_table_sorting',
1765
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1766
-            ['ee_admin_js', 'jquery-ui-sortable'],
1767
-            EVENT_ESPRESSO_VERSION,
1768
-            true
1769
-        );
1770
-        // script for parsing uri's
1771
-        wp_register_script(
1772
-            'ee-parse-uri',
1773
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1774
-            [],
1775
-            EVENT_ESPRESSO_VERSION,
1776
-            true
1777
-        );
1778
-        // and parsing associative serialized form elements
1779
-        wp_register_script(
1780
-            'ee-serialize-full-array',
1781
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1782
-            ['jquery'],
1783
-            EVENT_ESPRESSO_VERSION,
1784
-            true
1785
-        );
1786
-        // helpers scripts
1787
-        wp_register_script(
1788
-            'ee-text-links',
1789
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1790
-            ['jquery'],
1791
-            EVENT_ESPRESSO_VERSION,
1792
-            true
1793
-        );
1794
-        wp_register_script(
1795
-            'ee-moment-core',
1796
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1797
-            [],
1798
-            EVENT_ESPRESSO_VERSION,
1799
-            true
1800
-        );
1801
-        wp_register_script(
1802
-            'ee-moment',
1803
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1804
-            ['ee-moment-core'],
1805
-            EVENT_ESPRESSO_VERSION,
1806
-            true
1807
-        );
1808
-        wp_register_script(
1809
-            'ee-datepicker',
1810
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1811
-            ['jquery-ui-timepicker-addon', 'ee-moment'],
1812
-            EVENT_ESPRESSO_VERSION,
1813
-            true
1814
-        );
1815
-        // google charts
1816
-        wp_register_script(
1817
-            'google-charts',
1818
-            'https://www.gstatic.com/charts/loader.js',
1819
-            [],
1820
-            EVENT_ESPRESSO_VERSION
1821
-        );
1822
-        // ENQUEUE ALL BASICS BY DEFAULT
1823
-        wp_enqueue_style('ee-admin-css');
1824
-        wp_enqueue_script('ee_admin_js');
1825
-        wp_enqueue_script('ee-accounting');
1826
-        wp_enqueue_script('jquery-validate');
1827
-        // taking care of metaboxes
1828
-        if (
1829
-            empty($this->_cpt_route)
1830
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1831
-        ) {
1832
-            wp_enqueue_script('dashboard');
1833
-        }
1834
-        // LOCALIZED DATA
1835
-        // localize script for ajax lazy loading
1836
-        $lazy_loader_container_ids = apply_filters(
1837
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1838
-            ['espresso_news_post_box_content']
1839
-        );
1840
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1841
-        add_filter(
1842
-            'admin_body_class',
1843
-            function ($classes) {
1844
-                if (strpos($classes, 'espresso-admin') === false) {
1845
-                    $classes .= ' espresso-admin';
1846
-                }
1847
-                return $classes;
1848
-            }
1849
-        );
1850
-    }
1851
-
1852
-
1853
-    /**
1854
-     *        admin_footer_scripts_eei18n_js_strings
1855
-     *
1856
-     * @return        void
1857
-     */
1858
-    public function admin_footer_scripts_eei18n_js_strings()
1859
-    {
1860
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1861
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1862
-            __(
1863
-                '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!!!',
1864
-                'event_espresso'
1865
-            )
1866
-        );
1867
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1868
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1869
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1870
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1871
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1872
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1873
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1874
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1875
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1876
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1877
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1878
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1879
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1880
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1881
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1882
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1883
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1884
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1885
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1886
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1887
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1888
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1889
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1890
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1891
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1892
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1893
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1894
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1895
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1896
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1897
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1898
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1899
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1900
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1901
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1902
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1903
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1904
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1905
-    }
1906
-
1907
-
1908
-    /**
1909
-     *        load enhanced xdebug styles for ppl with failing eyesight
1910
-     *
1911
-     * @return        void
1912
-     */
1913
-    public function add_xdebug_style()
1914
-    {
1915
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1916
-    }
1917
-
1918
-
1919
-    /************************/
1920
-    /** LIST TABLE METHODS **/
1921
-    /************************/
1922
-    /**
1923
-     * this sets up the list table if the current view requires it.
1924
-     *
1925
-     * @return void
1926
-     * @throws EE_Error
1927
-     */
1928
-    protected function _set_list_table()
1929
-    {
1930
-        // first is this a list_table view?
1931
-        if (! isset($this->_route_config['list_table'])) {
1932
-            return;
1933
-        } //not a list_table view so get out.
1934
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
1935
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
1936
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1937
-            // user error msg
1938
-            $error_msg = esc_html__(
1939
-                'An error occurred. The requested list table views could not be found.',
1940
-                'event_espresso'
1941
-            );
1942
-            // developer error msg
1943
-            $error_msg .= '||'
1944
-                          . sprintf(
1945
-                              esc_html__(
1946
-                                  '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.',
1947
-                                  'event_espresso'
1948
-                              ),
1949
-                              $this->_req_action,
1950
-                              $list_table_view
1951
-                          );
1952
-            throw new EE_Error($error_msg);
1953
-        }
1954
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1955
-        $this->_views = apply_filters(
1956
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1957
-            $this->_views
1958
-        );
1959
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1960
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1961
-        $this->_set_list_table_view();
1962
-        $this->_set_list_table_object();
1963
-    }
1964
-
1965
-
1966
-    /**
1967
-     * set current view for List Table
1968
-     *
1969
-     * @return void
1970
-     */
1971
-    protected function _set_list_table_view()
1972
-    {
1973
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1974
-        $status = $this->request->getRequestParam('status', null, 'key');
1975
-        $this->_view = $status && array_key_exists($status, $this->_views)
1976
-            ? $status
1977
-            : $this->_view;
1978
-    }
1979
-
1980
-
1981
-    /**
1982
-     * _set_list_table_object
1983
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1984
-     *
1985
-     * @throws InvalidInterfaceException
1986
-     * @throws InvalidArgumentException
1987
-     * @throws InvalidDataTypeException
1988
-     * @throws EE_Error
1989
-     * @throws InvalidInterfaceException
1990
-     */
1991
-    protected function _set_list_table_object()
1992
-    {
1993
-        if (isset($this->_route_config['list_table'])) {
1994
-            if (! class_exists($this->_route_config['list_table'])) {
1995
-                throw new EE_Error(
1996
-                    sprintf(
1997
-                        esc_html__(
1998
-                            '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.',
1999
-                            'event_espresso'
2000
-                        ),
2001
-                        $this->_route_config['list_table'],
2002
-                        get_class($this)
2003
-                    )
2004
-                );
2005
-            }
2006
-            $this->_list_table_object = $this->loader->getShared(
2007
-                $this->_route_config['list_table'],
2008
-                [$this]
2009
-            );
2010
-        }
2011
-    }
2012
-
2013
-
2014
-    /**
2015
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2016
-     *
2017
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2018
-     *                                                    urls.  The array should be indexed by the view it is being
2019
-     *                                                    added to.
2020
-     * @return array
2021
-     */
2022
-    public function get_list_table_view_RLs($extra_query_args = [])
2023
-    {
2024
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2025
-        if (empty($this->_views)) {
2026
-            $this->_views = [];
2027
-        }
2028
-        // cycle thru views
2029
-        foreach ($this->_views as $key => $view) {
2030
-            $query_args = [];
2031
-            // check for current view
2032
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2033
-            $query_args['action']                        = $this->_req_action;
2034
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2035
-            $query_args['status']                        = $view['slug'];
2036
-            // merge any other arguments sent in.
2037
-            if (isset($extra_query_args[ $view['slug'] ])) {
2038
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2039
-            }
2040
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2041
-        }
2042
-        return $this->_views;
2043
-    }
2044
-
2045
-
2046
-    /**
2047
-     * _entries_per_page_dropdown
2048
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2049
-     *
2050
-     * @param int $max_entries total number of rows in the table
2051
-     * @return string
2052
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2053
-     *         WP does it.
2054
-     */
2055
-    protected function _entries_per_page_dropdown($max_entries = 0)
2056
-    {
2057
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2058
-        $values   = [10, 25, 50, 100];
2059
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2060
-        if ($max_entries) {
2061
-            $values[] = $max_entries;
2062
-            sort($values);
2063
-        }
2064
-        $entries_per_page_dropdown = '
1539
+		// current set timezone for timezone js
1540
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1541
+	}
1542
+
1543
+
1544
+	/**
1545
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1546
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1547
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1548
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1549
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1550
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1551
+	 * for the
1552
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1553
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1554
+	 *    'help_trigger_id' => array(
1555
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1556
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1557
+	 *    )
1558
+	 * );
1559
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1560
+	 *
1561
+	 * @param array $help_array
1562
+	 * @param bool  $display
1563
+	 * @return string content
1564
+	 * @throws DomainException
1565
+	 * @throws EE_Error
1566
+	 */
1567
+	protected function _set_help_popup_content($help_array = [], $display = false)
1568
+	{
1569
+		$content    = '';
1570
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1571
+		// loop through the array and setup content
1572
+		foreach ($help_array as $trigger => $help) {
1573
+			// make sure the array is setup properly
1574
+			if (! isset($help['title']) || ! isset($help['content'])) {
1575
+				throw new EE_Error(
1576
+					esc_html__(
1577
+						'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',
1578
+						'event_espresso'
1579
+					)
1580
+				);
1581
+			}
1582
+			// we're good so let's setup the template vars and then assign parsed template content to our content.
1583
+			$template_args = [
1584
+				'help_popup_id'      => $trigger,
1585
+				'help_popup_title'   => $help['title'],
1586
+				'help_popup_content' => $help['content'],
1587
+			];
1588
+			$content       .= EEH_Template::display_template(
1589
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1590
+				$template_args,
1591
+				true
1592
+			);
1593
+		}
1594
+		if ($display) {
1595
+			echo $content; // already escaped
1596
+			return '';
1597
+		}
1598
+		return $content;
1599
+	}
1600
+
1601
+
1602
+	/**
1603
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1604
+	 *
1605
+	 * @return array properly formatted array for help popup content
1606
+	 * @throws EE_Error
1607
+	 */
1608
+	private function _get_help_content()
1609
+	{
1610
+		// what is the method we're looking for?
1611
+		$method_name = '_help_popup_content_' . $this->_req_action;
1612
+		// if method doesn't exist let's get out.
1613
+		if (! method_exists($this, $method_name)) {
1614
+			return [];
1615
+		}
1616
+		// k we're good to go let's retrieve the help array
1617
+		$help_array = call_user_func([$this, $method_name]);
1618
+		// make sure we've got an array!
1619
+		if (! is_array($help_array)) {
1620
+			throw new EE_Error(
1621
+				esc_html__(
1622
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1623
+					'event_espresso'
1624
+				)
1625
+			);
1626
+		}
1627
+		return $help_array;
1628
+	}
1629
+
1630
+
1631
+	/**
1632
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1633
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1634
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1635
+	 *
1636
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1637
+	 * @param boolean $display    if false then we return the trigger string
1638
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1639
+	 * @return string
1640
+	 * @throws DomainException
1641
+	 * @throws EE_Error
1642
+	 */
1643
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1644
+	{
1645
+		if ($this->request->isAjax()) {
1646
+			return '';
1647
+		}
1648
+		// 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
1649
+		$help_array   = $this->_get_help_content();
1650
+		$help_content = '';
1651
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1652
+			$help_array[ $trigger_id ] = [
1653
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1654
+				'content' => esc_html__(
1655
+					'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.)',
1656
+					'event_espresso'
1657
+				),
1658
+			];
1659
+			$help_content              = $this->_set_help_popup_content($help_array);
1660
+		}
1661
+		// let's setup the trigger
1662
+		$content = '<a class="ee-dialog" href="?height='
1663
+				   . esc_attr($dimensions[0])
1664
+				   . '&width='
1665
+				   . esc_attr($dimensions[1])
1666
+				   . '&inlineId='
1667
+				   . esc_attr($trigger_id)
1668
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1669
+		$content .= $help_content;
1670
+		if ($display) {
1671
+			echo $content; // already escaped
1672
+			return '';
1673
+		}
1674
+		return $content;
1675
+	}
1676
+
1677
+
1678
+	/**
1679
+	 * _add_global_screen_options
1680
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1681
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1682
+	 *
1683
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1684
+	 *         see also WP_Screen object documents...
1685
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1686
+	 * @abstract
1687
+	 * @return void
1688
+	 */
1689
+	private function _add_global_screen_options()
1690
+	{
1691
+	}
1692
+
1693
+
1694
+	/**
1695
+	 * _add_global_feature_pointers
1696
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1697
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1698
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1699
+	 *
1700
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1701
+	 *         extended) also see:
1702
+	 * @link   http://eamann.com/tech/wordpress-portland/
1703
+	 * @abstract
1704
+	 * @return void
1705
+	 */
1706
+	private function _add_global_feature_pointers()
1707
+	{
1708
+	}
1709
+
1710
+
1711
+	/**
1712
+	 * load_global_scripts_styles
1713
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1714
+	 *
1715
+	 * @return void
1716
+	 */
1717
+	public function load_global_scripts_styles()
1718
+	{
1719
+		/** STYLES **/
1720
+		// add debugging styles
1721
+		if (WP_DEBUG) {
1722
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1723
+		}
1724
+		// register all styles
1725
+		wp_register_style(
1726
+			'espresso-ui-theme',
1727
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1728
+			[],
1729
+			EVENT_ESPRESSO_VERSION
1730
+		);
1731
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1732
+		// helpers styles
1733
+		wp_register_style(
1734
+			'ee-text-links',
1735
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1736
+			[],
1737
+			EVENT_ESPRESSO_VERSION
1738
+		);
1739
+		/** SCRIPTS **/
1740
+		// register all scripts
1741
+		wp_register_script(
1742
+			'ee-dialog',
1743
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1744
+			['jquery', 'jquery-ui-draggable'],
1745
+			EVENT_ESPRESSO_VERSION,
1746
+			true
1747
+		);
1748
+		wp_register_script(
1749
+			'ee_admin_js',
1750
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1751
+			['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1752
+			EVENT_ESPRESSO_VERSION,
1753
+			true
1754
+		);
1755
+		wp_register_script(
1756
+			'jquery-ui-timepicker-addon',
1757
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1758
+			['jquery-ui-datepicker', 'jquery-ui-slider'],
1759
+			EVENT_ESPRESSO_VERSION,
1760
+			true
1761
+		);
1762
+		// script for sorting tables
1763
+		wp_register_script(
1764
+			'espresso_ajax_table_sorting',
1765
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1766
+			['ee_admin_js', 'jquery-ui-sortable'],
1767
+			EVENT_ESPRESSO_VERSION,
1768
+			true
1769
+		);
1770
+		// script for parsing uri's
1771
+		wp_register_script(
1772
+			'ee-parse-uri',
1773
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1774
+			[],
1775
+			EVENT_ESPRESSO_VERSION,
1776
+			true
1777
+		);
1778
+		// and parsing associative serialized form elements
1779
+		wp_register_script(
1780
+			'ee-serialize-full-array',
1781
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1782
+			['jquery'],
1783
+			EVENT_ESPRESSO_VERSION,
1784
+			true
1785
+		);
1786
+		// helpers scripts
1787
+		wp_register_script(
1788
+			'ee-text-links',
1789
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1790
+			['jquery'],
1791
+			EVENT_ESPRESSO_VERSION,
1792
+			true
1793
+		);
1794
+		wp_register_script(
1795
+			'ee-moment-core',
1796
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1797
+			[],
1798
+			EVENT_ESPRESSO_VERSION,
1799
+			true
1800
+		);
1801
+		wp_register_script(
1802
+			'ee-moment',
1803
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1804
+			['ee-moment-core'],
1805
+			EVENT_ESPRESSO_VERSION,
1806
+			true
1807
+		);
1808
+		wp_register_script(
1809
+			'ee-datepicker',
1810
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1811
+			['jquery-ui-timepicker-addon', 'ee-moment'],
1812
+			EVENT_ESPRESSO_VERSION,
1813
+			true
1814
+		);
1815
+		// google charts
1816
+		wp_register_script(
1817
+			'google-charts',
1818
+			'https://www.gstatic.com/charts/loader.js',
1819
+			[],
1820
+			EVENT_ESPRESSO_VERSION
1821
+		);
1822
+		// ENQUEUE ALL BASICS BY DEFAULT
1823
+		wp_enqueue_style('ee-admin-css');
1824
+		wp_enqueue_script('ee_admin_js');
1825
+		wp_enqueue_script('ee-accounting');
1826
+		wp_enqueue_script('jquery-validate');
1827
+		// taking care of metaboxes
1828
+		if (
1829
+			empty($this->_cpt_route)
1830
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1831
+		) {
1832
+			wp_enqueue_script('dashboard');
1833
+		}
1834
+		// LOCALIZED DATA
1835
+		// localize script for ajax lazy loading
1836
+		$lazy_loader_container_ids = apply_filters(
1837
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1838
+			['espresso_news_post_box_content']
1839
+		);
1840
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1841
+		add_filter(
1842
+			'admin_body_class',
1843
+			function ($classes) {
1844
+				if (strpos($classes, 'espresso-admin') === false) {
1845
+					$classes .= ' espresso-admin';
1846
+				}
1847
+				return $classes;
1848
+			}
1849
+		);
1850
+	}
1851
+
1852
+
1853
+	/**
1854
+	 *        admin_footer_scripts_eei18n_js_strings
1855
+	 *
1856
+	 * @return        void
1857
+	 */
1858
+	public function admin_footer_scripts_eei18n_js_strings()
1859
+	{
1860
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1861
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
1862
+			__(
1863
+				'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!!!',
1864
+				'event_espresso'
1865
+			)
1866
+		);
1867
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
1868
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
1869
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
1870
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
1871
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1872
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
1873
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
1874
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
1875
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
1876
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
1877
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
1878
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
1879
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
1880
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
1881
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
1882
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
1883
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
1884
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
1885
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
1886
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
1887
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
1888
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
1889
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
1890
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
1891
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
1892
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
1893
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
1894
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
1895
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
1896
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
1897
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
1898
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
1899
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
1900
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
1901
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
1902
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
1903
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
1904
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
1905
+	}
1906
+
1907
+
1908
+	/**
1909
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1910
+	 *
1911
+	 * @return        void
1912
+	 */
1913
+	public function add_xdebug_style()
1914
+	{
1915
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1916
+	}
1917
+
1918
+
1919
+	/************************/
1920
+	/** LIST TABLE METHODS **/
1921
+	/************************/
1922
+	/**
1923
+	 * this sets up the list table if the current view requires it.
1924
+	 *
1925
+	 * @return void
1926
+	 * @throws EE_Error
1927
+	 */
1928
+	protected function _set_list_table()
1929
+	{
1930
+		// first is this a list_table view?
1931
+		if (! isset($this->_route_config['list_table'])) {
1932
+			return;
1933
+		} //not a list_table view so get out.
1934
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
1935
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
1936
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1937
+			// user error msg
1938
+			$error_msg = esc_html__(
1939
+				'An error occurred. The requested list table views could not be found.',
1940
+				'event_espresso'
1941
+			);
1942
+			// developer error msg
1943
+			$error_msg .= '||'
1944
+						  . sprintf(
1945
+							  esc_html__(
1946
+								  '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.',
1947
+								  'event_espresso'
1948
+							  ),
1949
+							  $this->_req_action,
1950
+							  $list_table_view
1951
+						  );
1952
+			throw new EE_Error($error_msg);
1953
+		}
1954
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1955
+		$this->_views = apply_filters(
1956
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1957
+			$this->_views
1958
+		);
1959
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1960
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1961
+		$this->_set_list_table_view();
1962
+		$this->_set_list_table_object();
1963
+	}
1964
+
1965
+
1966
+	/**
1967
+	 * set current view for List Table
1968
+	 *
1969
+	 * @return void
1970
+	 */
1971
+	protected function _set_list_table_view()
1972
+	{
1973
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1974
+		$status = $this->request->getRequestParam('status', null, 'key');
1975
+		$this->_view = $status && array_key_exists($status, $this->_views)
1976
+			? $status
1977
+			: $this->_view;
1978
+	}
1979
+
1980
+
1981
+	/**
1982
+	 * _set_list_table_object
1983
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1984
+	 *
1985
+	 * @throws InvalidInterfaceException
1986
+	 * @throws InvalidArgumentException
1987
+	 * @throws InvalidDataTypeException
1988
+	 * @throws EE_Error
1989
+	 * @throws InvalidInterfaceException
1990
+	 */
1991
+	protected function _set_list_table_object()
1992
+	{
1993
+		if (isset($this->_route_config['list_table'])) {
1994
+			if (! class_exists($this->_route_config['list_table'])) {
1995
+				throw new EE_Error(
1996
+					sprintf(
1997
+						esc_html__(
1998
+							'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.',
1999
+							'event_espresso'
2000
+						),
2001
+						$this->_route_config['list_table'],
2002
+						get_class($this)
2003
+					)
2004
+				);
2005
+			}
2006
+			$this->_list_table_object = $this->loader->getShared(
2007
+				$this->_route_config['list_table'],
2008
+				[$this]
2009
+			);
2010
+		}
2011
+	}
2012
+
2013
+
2014
+	/**
2015
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2016
+	 *
2017
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2018
+	 *                                                    urls.  The array should be indexed by the view it is being
2019
+	 *                                                    added to.
2020
+	 * @return array
2021
+	 */
2022
+	public function get_list_table_view_RLs($extra_query_args = [])
2023
+	{
2024
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2025
+		if (empty($this->_views)) {
2026
+			$this->_views = [];
2027
+		}
2028
+		// cycle thru views
2029
+		foreach ($this->_views as $key => $view) {
2030
+			$query_args = [];
2031
+			// check for current view
2032
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2033
+			$query_args['action']                        = $this->_req_action;
2034
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2035
+			$query_args['status']                        = $view['slug'];
2036
+			// merge any other arguments sent in.
2037
+			if (isset($extra_query_args[ $view['slug'] ])) {
2038
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2039
+			}
2040
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2041
+		}
2042
+		return $this->_views;
2043
+	}
2044
+
2045
+
2046
+	/**
2047
+	 * _entries_per_page_dropdown
2048
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2049
+	 *
2050
+	 * @param int $max_entries total number of rows in the table
2051
+	 * @return string
2052
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2053
+	 *         WP does it.
2054
+	 */
2055
+	protected function _entries_per_page_dropdown($max_entries = 0)
2056
+	{
2057
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2058
+		$values   = [10, 25, 50, 100];
2059
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2060
+		if ($max_entries) {
2061
+			$values[] = $max_entries;
2062
+			sort($values);
2063
+		}
2064
+		$entries_per_page_dropdown = '
2065 2065
 			<div id="entries-per-page-dv" class="alignleft actions">
2066 2066
 				<label class="hide-if-no-js">
2067 2067
 					Show
2068 2068
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2069
-        foreach ($values as $value) {
2070
-            if ($value < $max_entries) {
2071
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2072
-                $entries_per_page_dropdown .= '
2069
+		foreach ($values as $value) {
2070
+			if ($value < $max_entries) {
2071
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2072
+				$entries_per_page_dropdown .= '
2073 2073
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2074
-            }
2075
-        }
2076
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2077
-        $entries_per_page_dropdown .= '
2074
+			}
2075
+		}
2076
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2077
+		$entries_per_page_dropdown .= '
2078 2078
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2079
-        $entries_per_page_dropdown .= '
2079
+		$entries_per_page_dropdown .= '
2080 2080
 					</select>
2081 2081
 					entries
2082 2082
 				</label>
2083 2083
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2084 2084
 			</div>
2085 2085
 		';
2086
-        return $entries_per_page_dropdown;
2087
-    }
2088
-
2089
-
2090
-    /**
2091
-     *        _set_search_attributes
2092
-     *
2093
-     * @return        void
2094
-     */
2095
-    public function _set_search_attributes()
2096
-    {
2097
-        $this->_template_args['search']['btn_label'] = sprintf(
2098
-            esc_html__('Search %s', 'event_espresso'),
2099
-            empty($this->_search_btn_label) ? $this->page_label
2100
-                : $this->_search_btn_label
2101
-        );
2102
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2103
-    }
2104
-
2105
-
2106
-
2107
-    /*** END LIST TABLE METHODS **/
2108
-
2109
-
2110
-    /**
2111
-     * _add_registered_metaboxes
2112
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2113
-     *
2114
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2115
-     * @return void
2116
-     * @throws EE_Error
2117
-     */
2118
-    private function _add_registered_meta_boxes()
2119
-    {
2120
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2121
-        // we only add meta boxes if the page_route calls for it
2122
-        if (
2123
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2124
-            && is_array(
2125
-                $this->_route_config['metaboxes']
2126
-            )
2127
-        ) {
2128
-            // this simply loops through the callbacks provided
2129
-            // and checks if there is a corresponding callback registered by the child
2130
-            // if there is then we go ahead and process the metabox loader.
2131
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2132
-                // first check for Closures
2133
-                if ($metabox_callback instanceof Closure) {
2134
-                    $result = $metabox_callback();
2135
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2136
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2137
-                } else {
2138
-                    $result = call_user_func([$this, &$metabox_callback]);
2139
-                }
2140
-                if ($result === false) {
2141
-                    // user error msg
2142
-                    $error_msg = esc_html__(
2143
-                        'An error occurred. The  requested metabox could not be found.',
2144
-                        'event_espresso'
2145
-                    );
2146
-                    // developer error msg
2147
-                    $error_msg .= '||'
2148
-                                  . sprintf(
2149
-                                      esc_html__(
2150
-                                          '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.',
2151
-                                          'event_espresso'
2152
-                                      ),
2153
-                                      $metabox_callback
2154
-                                  );
2155
-                    throw new EE_Error($error_msg);
2156
-                }
2157
-            }
2158
-        }
2159
-    }
2160
-
2161
-
2162
-    /**
2163
-     * _add_screen_columns
2164
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2165
-     * the dynamic column template and we'll setup the column options for the page.
2166
-     *
2167
-     * @return void
2168
-     */
2169
-    private function _add_screen_columns()
2170
-    {
2171
-        if (
2172
-            is_array($this->_route_config)
2173
-            && isset($this->_route_config['columns'])
2174
-            && is_array($this->_route_config['columns'])
2175
-            && count($this->_route_config['columns']) === 2
2176
-        ) {
2177
-            add_screen_option(
2178
-                'layout_columns',
2179
-                [
2180
-                    'max'     => (int) $this->_route_config['columns'][0],
2181
-                    'default' => (int) $this->_route_config['columns'][1],
2182
-                ]
2183
-            );
2184
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2185
-            $screen_id                                           = $this->_current_screen->id;
2186
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2187
-            $total_columns                                       = ! empty($screen_columns)
2188
-                ? $screen_columns
2189
-                : $this->_route_config['columns'][1];
2190
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2191
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2192
-            $this->_template_args['screen']                      = $this->_current_screen;
2193
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2194
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2195
-            // finally if we don't have has_metaboxes set in the route config
2196
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2197
-            $this->_route_config['has_metaboxes'] = true;
2198
-        }
2199
-    }
2200
-
2201
-
2202
-
2203
-    /** GLOBALLY AVAILABLE METABOXES **/
2204
-
2205
-
2206
-    /**
2207
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2208
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2209
-     * these get loaded on.
2210
-     */
2211
-    private function _espresso_news_post_box()
2212
-    {
2213
-        $news_box_title = apply_filters(
2214
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2215
-            esc_html__('New @ Event Espresso', 'event_espresso')
2216
-        );
2217
-        add_meta_box(
2218
-            'espresso_news_post_box',
2219
-            $news_box_title,
2220
-            [
2221
-                $this,
2222
-                'espresso_news_post_box',
2223
-            ],
2224
-            $this->_wp_page_slug,
2225
-            'side'
2226
-        );
2227
-    }
2228
-
2229
-
2230
-    /**
2231
-     * Code for setting up espresso ratings request metabox.
2232
-     */
2233
-    protected function _espresso_ratings_request()
2234
-    {
2235
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2236
-            return;
2237
-        }
2238
-        $ratings_box_title = apply_filters(
2239
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2240
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2241
-        );
2242
-        add_meta_box(
2243
-            'espresso_ratings_request',
2244
-            $ratings_box_title,
2245
-            [
2246
-                $this,
2247
-                'espresso_ratings_request',
2248
-            ],
2249
-            $this->_wp_page_slug,
2250
-            'side'
2251
-        );
2252
-    }
2253
-
2254
-
2255
-    /**
2256
-     * Code for setting up espresso ratings request metabox content.
2257
-     *
2258
-     * @throws DomainException
2259
-     */
2260
-    public function espresso_ratings_request()
2261
-    {
2262
-        EEH_Template::display_template(
2263
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2264
-            []
2265
-        );
2266
-    }
2267
-
2268
-
2269
-    public static function cached_rss_display($rss_id, $url)
2270
-    {
2271
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2272
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2273
-                     . '</p><p class="hide-if-js">'
2274
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2275
-                     . '</p>';
2276
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2277
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2278
-        $post      = '</div>' . "\n";
2279
-        $cache_key = 'ee_rss_' . md5($rss_id);
2280
-        $output    = get_transient($cache_key);
2281
-        if ($output !== false) {
2282
-            echo $pre . $output . $post; // already escaped
2283
-            return true;
2284
-        }
2285
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2286
-            echo $pre . $loading . $post; // already escaped
2287
-            return false;
2288
-        }
2289
-        ob_start();
2290
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2291
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2292
-        return true;
2293
-    }
2294
-
2295
-
2296
-    public function espresso_news_post_box()
2297
-    {
2298
-        ?>
2086
+		return $entries_per_page_dropdown;
2087
+	}
2088
+
2089
+
2090
+	/**
2091
+	 *        _set_search_attributes
2092
+	 *
2093
+	 * @return        void
2094
+	 */
2095
+	public function _set_search_attributes()
2096
+	{
2097
+		$this->_template_args['search']['btn_label'] = sprintf(
2098
+			esc_html__('Search %s', 'event_espresso'),
2099
+			empty($this->_search_btn_label) ? $this->page_label
2100
+				: $this->_search_btn_label
2101
+		);
2102
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2103
+	}
2104
+
2105
+
2106
+
2107
+	/*** END LIST TABLE METHODS **/
2108
+
2109
+
2110
+	/**
2111
+	 * _add_registered_metaboxes
2112
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2113
+	 *
2114
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2115
+	 * @return void
2116
+	 * @throws EE_Error
2117
+	 */
2118
+	private function _add_registered_meta_boxes()
2119
+	{
2120
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2121
+		// we only add meta boxes if the page_route calls for it
2122
+		if (
2123
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2124
+			&& is_array(
2125
+				$this->_route_config['metaboxes']
2126
+			)
2127
+		) {
2128
+			// this simply loops through the callbacks provided
2129
+			// and checks if there is a corresponding callback registered by the child
2130
+			// if there is then we go ahead and process the metabox loader.
2131
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2132
+				// first check for Closures
2133
+				if ($metabox_callback instanceof Closure) {
2134
+					$result = $metabox_callback();
2135
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2136
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2137
+				} else {
2138
+					$result = call_user_func([$this, &$metabox_callback]);
2139
+				}
2140
+				if ($result === false) {
2141
+					// user error msg
2142
+					$error_msg = esc_html__(
2143
+						'An error occurred. The  requested metabox could not be found.',
2144
+						'event_espresso'
2145
+					);
2146
+					// developer error msg
2147
+					$error_msg .= '||'
2148
+								  . sprintf(
2149
+									  esc_html__(
2150
+										  '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.',
2151
+										  'event_espresso'
2152
+									  ),
2153
+									  $metabox_callback
2154
+								  );
2155
+					throw new EE_Error($error_msg);
2156
+				}
2157
+			}
2158
+		}
2159
+	}
2160
+
2161
+
2162
+	/**
2163
+	 * _add_screen_columns
2164
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2165
+	 * the dynamic column template and we'll setup the column options for the page.
2166
+	 *
2167
+	 * @return void
2168
+	 */
2169
+	private function _add_screen_columns()
2170
+	{
2171
+		if (
2172
+			is_array($this->_route_config)
2173
+			&& isset($this->_route_config['columns'])
2174
+			&& is_array($this->_route_config['columns'])
2175
+			&& count($this->_route_config['columns']) === 2
2176
+		) {
2177
+			add_screen_option(
2178
+				'layout_columns',
2179
+				[
2180
+					'max'     => (int) $this->_route_config['columns'][0],
2181
+					'default' => (int) $this->_route_config['columns'][1],
2182
+				]
2183
+			);
2184
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2185
+			$screen_id                                           = $this->_current_screen->id;
2186
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2187
+			$total_columns                                       = ! empty($screen_columns)
2188
+				? $screen_columns
2189
+				: $this->_route_config['columns'][1];
2190
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2191
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2192
+			$this->_template_args['screen']                      = $this->_current_screen;
2193
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2194
+																   . 'admin_details_metabox_column_wrapper.template.php';
2195
+			// finally if we don't have has_metaboxes set in the route config
2196
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2197
+			$this->_route_config['has_metaboxes'] = true;
2198
+		}
2199
+	}
2200
+
2201
+
2202
+
2203
+	/** GLOBALLY AVAILABLE METABOXES **/
2204
+
2205
+
2206
+	/**
2207
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2208
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2209
+	 * these get loaded on.
2210
+	 */
2211
+	private function _espresso_news_post_box()
2212
+	{
2213
+		$news_box_title = apply_filters(
2214
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2215
+			esc_html__('New @ Event Espresso', 'event_espresso')
2216
+		);
2217
+		add_meta_box(
2218
+			'espresso_news_post_box',
2219
+			$news_box_title,
2220
+			[
2221
+				$this,
2222
+				'espresso_news_post_box',
2223
+			],
2224
+			$this->_wp_page_slug,
2225
+			'side'
2226
+		);
2227
+	}
2228
+
2229
+
2230
+	/**
2231
+	 * Code for setting up espresso ratings request metabox.
2232
+	 */
2233
+	protected function _espresso_ratings_request()
2234
+	{
2235
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2236
+			return;
2237
+		}
2238
+		$ratings_box_title = apply_filters(
2239
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2240
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2241
+		);
2242
+		add_meta_box(
2243
+			'espresso_ratings_request',
2244
+			$ratings_box_title,
2245
+			[
2246
+				$this,
2247
+				'espresso_ratings_request',
2248
+			],
2249
+			$this->_wp_page_slug,
2250
+			'side'
2251
+		);
2252
+	}
2253
+
2254
+
2255
+	/**
2256
+	 * Code for setting up espresso ratings request metabox content.
2257
+	 *
2258
+	 * @throws DomainException
2259
+	 */
2260
+	public function espresso_ratings_request()
2261
+	{
2262
+		EEH_Template::display_template(
2263
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2264
+			[]
2265
+		);
2266
+	}
2267
+
2268
+
2269
+	public static function cached_rss_display($rss_id, $url)
2270
+	{
2271
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2272
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2273
+					 . '</p><p class="hide-if-js">'
2274
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2275
+					 . '</p>';
2276
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2277
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2278
+		$post      = '</div>' . "\n";
2279
+		$cache_key = 'ee_rss_' . md5($rss_id);
2280
+		$output    = get_transient($cache_key);
2281
+		if ($output !== false) {
2282
+			echo $pre . $output . $post; // already escaped
2283
+			return true;
2284
+		}
2285
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2286
+			echo $pre . $loading . $post; // already escaped
2287
+			return false;
2288
+		}
2289
+		ob_start();
2290
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2291
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2292
+		return true;
2293
+	}
2294
+
2295
+
2296
+	public function espresso_news_post_box()
2297
+	{
2298
+		?>
2299 2299
         <div class="padding">
2300 2300
             <div id="espresso_news_post_box_content" class="infolinks">
2301 2301
                 <?php
2302
-                // Get RSS Feed(s)
2303
-                self::cached_rss_display(
2304
-                    'espresso_news_post_box_content',
2305
-                    esc_url_raw(
2306
-                        apply_filters(
2307
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2308
-                            'https://eventespresso.com/feed/'
2309
-                        )
2310
-                    )
2311
-                );
2312
-                ?>
2302
+				// Get RSS Feed(s)
2303
+				self::cached_rss_display(
2304
+					'espresso_news_post_box_content',
2305
+					esc_url_raw(
2306
+						apply_filters(
2307
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2308
+							'https://eventespresso.com/feed/'
2309
+						)
2310
+					)
2311
+				);
2312
+				?>
2313 2313
             </div>
2314 2314
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2315 2315
         </div>
2316 2316
         <?php
2317
-    }
2318
-
2319
-
2320
-    private function _espresso_links_post_box()
2321
-    {
2322
-        // Hiding until we actually have content to put in here...
2323
-        // 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');
2324
-    }
2325
-
2326
-
2327
-    public function espresso_links_post_box()
2328
-    {
2329
-        // Hiding until we actually have content to put in here...
2330
-        // EEH_Template::display_template(
2331
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2332
-        // );
2333
-    }
2334
-
2335
-
2336
-    protected function _espresso_sponsors_post_box()
2337
-    {
2338
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2339
-            add_meta_box(
2340
-                'espresso_sponsors_post_box',
2341
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2342
-                [$this, 'espresso_sponsors_post_box'],
2343
-                $this->_wp_page_slug,
2344
-                'side'
2345
-            );
2346
-        }
2347
-    }
2348
-
2349
-
2350
-    public function espresso_sponsors_post_box()
2351
-    {
2352
-        EEH_Template::display_template(
2353
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2354
-        );
2355
-    }
2356
-
2357
-
2358
-    private function _publish_post_box()
2359
-    {
2360
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2361
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2362
-        // then we'll use that for the metabox label.
2363
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2364
-        if (! empty($this->_labels['publishbox'])) {
2365
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2366
-                : $this->_labels['publishbox'];
2367
-        } else {
2368
-            $box_label = esc_html__('Publish', 'event_espresso');
2369
-        }
2370
-        $box_label = apply_filters(
2371
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2372
-            $box_label,
2373
-            $this->_req_action,
2374
-            $this
2375
-        );
2376
-        add_meta_box(
2377
-            $meta_box_ref,
2378
-            $box_label,
2379
-            [$this, 'editor_overview'],
2380
-            $this->_current_screen->id,
2381
-            'side',
2382
-            'high'
2383
-        );
2384
-    }
2385
-
2386
-
2387
-    public function editor_overview()
2388
-    {
2389
-        // if we have extra content set let's add it in if not make sure its empty
2390
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2391
-            ? $this->_template_args['publish_box_extra_content']
2392
-            : '';
2393
-        echo EEH_Template::display_template(
2394
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2395
-            $this->_template_args,
2396
-            true
2397
-        );
2398
-    }
2399
-
2400
-
2401
-    /** end of globally available metaboxes section **/
2402
-
2403
-
2404
-    /**
2405
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2406
-     * protected method.
2407
-     *
2408
-     * @param string $name
2409
-     * @param int    $id
2410
-     * @param bool   $delete
2411
-     * @param string $save_close_redirect_URL
2412
-     * @param bool   $both_btns
2413
-     * @throws EE_Error
2414
-     * @throws InvalidArgumentException
2415
-     * @throws InvalidDataTypeException
2416
-     * @throws InvalidInterfaceException
2417
-     * @see   $this->_set_publish_post_box_vars for param details
2418
-     * @since 4.6.0
2419
-     */
2420
-    public function set_publish_post_box_vars(
2421
-        $name = '',
2422
-        $id = 0,
2423
-        $delete = false,
2424
-        $save_close_redirect_URL = '',
2425
-        $both_btns = true
2426
-    ) {
2427
-        $this->_set_publish_post_box_vars(
2428
-            $name,
2429
-            $id,
2430
-            $delete,
2431
-            $save_close_redirect_URL,
2432
-            $both_btns
2433
-        );
2434
-    }
2435
-
2436
-
2437
-    /**
2438
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2439
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2440
-     * save, and save and close buttons to work properly, then you will want to include a
2441
-     * values for the name and id arguments.
2442
-     *
2443
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2444
-     * @param int     $id                         id attached to the item published
2445
-     * @param string  $delete                     page route callback for the delete action
2446
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2447
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2448
-     *                                            the Save button
2449
-     * @throws EE_Error
2450
-     * @throws InvalidArgumentException
2451
-     * @throws InvalidDataTypeException
2452
-     * @throws InvalidInterfaceException
2453
-     * @todo  Add in validation for name/id arguments.
2454
-     */
2455
-    protected function _set_publish_post_box_vars(
2456
-        $name = '',
2457
-        $id = 0,
2458
-        $delete = '',
2459
-        $save_close_redirect_URL = '',
2460
-        $both_btns = true
2461
-    ) {
2462
-        // if Save & Close, use a custom redirect URL or default to the main page?
2463
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2464
-            ? $save_close_redirect_URL
2465
-            : $this->_admin_base_url;
2466
-        // create the Save & Close and Save buttons
2467
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2468
-        // if we have extra content set let's add it in if not make sure its empty
2469
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2470
-            ? $this->_template_args['publish_box_extra_content']
2471
-            : '';
2472
-        if ($delete && ! empty($id)) {
2473
-            // make sure we have a default if just true is sent.
2474
-            $delete           = ! empty($delete) ? $delete : 'delete';
2475
-            $delete_link_args = [$name => $id];
2476
-            $delete           = $this->get_action_link_or_button(
2477
-                $delete,
2478
-                $delete,
2479
-                $delete_link_args,
2480
-                'submitdelete deletion',
2481
-                '',
2482
-                false
2483
-            );
2484
-        }
2485
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2486
-        if (! empty($name) && ! empty($id)) {
2487
-            $hidden_field_arr[ $name ] = [
2488
-                'type'  => 'hidden',
2489
-                'value' => $id,
2490
-            ];
2491
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2492
-        } else {
2493
-            $hf = '';
2494
-        }
2495
-        // add hidden field
2496
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2497
-            ? $hf[ $name ]['field']
2498
-            : $hf;
2499
-    }
2500
-
2501
-
2502
-    /**
2503
-     * displays an error message to ppl who have javascript disabled
2504
-     *
2505
-     * @return void
2506
-     */
2507
-    private function _display_no_javascript_warning()
2508
-    {
2509
-        ?>
2317
+	}
2318
+
2319
+
2320
+	private function _espresso_links_post_box()
2321
+	{
2322
+		// Hiding until we actually have content to put in here...
2323
+		// 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');
2324
+	}
2325
+
2326
+
2327
+	public function espresso_links_post_box()
2328
+	{
2329
+		// Hiding until we actually have content to put in here...
2330
+		// EEH_Template::display_template(
2331
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2332
+		// );
2333
+	}
2334
+
2335
+
2336
+	protected function _espresso_sponsors_post_box()
2337
+	{
2338
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2339
+			add_meta_box(
2340
+				'espresso_sponsors_post_box',
2341
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2342
+				[$this, 'espresso_sponsors_post_box'],
2343
+				$this->_wp_page_slug,
2344
+				'side'
2345
+			);
2346
+		}
2347
+	}
2348
+
2349
+
2350
+	public function espresso_sponsors_post_box()
2351
+	{
2352
+		EEH_Template::display_template(
2353
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2354
+		);
2355
+	}
2356
+
2357
+
2358
+	private function _publish_post_box()
2359
+	{
2360
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2361
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2362
+		// then we'll use that for the metabox label.
2363
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2364
+		if (! empty($this->_labels['publishbox'])) {
2365
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2366
+				: $this->_labels['publishbox'];
2367
+		} else {
2368
+			$box_label = esc_html__('Publish', 'event_espresso');
2369
+		}
2370
+		$box_label = apply_filters(
2371
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2372
+			$box_label,
2373
+			$this->_req_action,
2374
+			$this
2375
+		);
2376
+		add_meta_box(
2377
+			$meta_box_ref,
2378
+			$box_label,
2379
+			[$this, 'editor_overview'],
2380
+			$this->_current_screen->id,
2381
+			'side',
2382
+			'high'
2383
+		);
2384
+	}
2385
+
2386
+
2387
+	public function editor_overview()
2388
+	{
2389
+		// if we have extra content set let's add it in if not make sure its empty
2390
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2391
+			? $this->_template_args['publish_box_extra_content']
2392
+			: '';
2393
+		echo EEH_Template::display_template(
2394
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2395
+			$this->_template_args,
2396
+			true
2397
+		);
2398
+	}
2399
+
2400
+
2401
+	/** end of globally available metaboxes section **/
2402
+
2403
+
2404
+	/**
2405
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2406
+	 * protected method.
2407
+	 *
2408
+	 * @param string $name
2409
+	 * @param int    $id
2410
+	 * @param bool   $delete
2411
+	 * @param string $save_close_redirect_URL
2412
+	 * @param bool   $both_btns
2413
+	 * @throws EE_Error
2414
+	 * @throws InvalidArgumentException
2415
+	 * @throws InvalidDataTypeException
2416
+	 * @throws InvalidInterfaceException
2417
+	 * @see   $this->_set_publish_post_box_vars for param details
2418
+	 * @since 4.6.0
2419
+	 */
2420
+	public function set_publish_post_box_vars(
2421
+		$name = '',
2422
+		$id = 0,
2423
+		$delete = false,
2424
+		$save_close_redirect_URL = '',
2425
+		$both_btns = true
2426
+	) {
2427
+		$this->_set_publish_post_box_vars(
2428
+			$name,
2429
+			$id,
2430
+			$delete,
2431
+			$save_close_redirect_URL,
2432
+			$both_btns
2433
+		);
2434
+	}
2435
+
2436
+
2437
+	/**
2438
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2439
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2440
+	 * save, and save and close buttons to work properly, then you will want to include a
2441
+	 * values for the name and id arguments.
2442
+	 *
2443
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2444
+	 * @param int     $id                         id attached to the item published
2445
+	 * @param string  $delete                     page route callback for the delete action
2446
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2447
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2448
+	 *                                            the Save button
2449
+	 * @throws EE_Error
2450
+	 * @throws InvalidArgumentException
2451
+	 * @throws InvalidDataTypeException
2452
+	 * @throws InvalidInterfaceException
2453
+	 * @todo  Add in validation for name/id arguments.
2454
+	 */
2455
+	protected function _set_publish_post_box_vars(
2456
+		$name = '',
2457
+		$id = 0,
2458
+		$delete = '',
2459
+		$save_close_redirect_URL = '',
2460
+		$both_btns = true
2461
+	) {
2462
+		// if Save & Close, use a custom redirect URL or default to the main page?
2463
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2464
+			? $save_close_redirect_URL
2465
+			: $this->_admin_base_url;
2466
+		// create the Save & Close and Save buttons
2467
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2468
+		// if we have extra content set let's add it in if not make sure its empty
2469
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2470
+			? $this->_template_args['publish_box_extra_content']
2471
+			: '';
2472
+		if ($delete && ! empty($id)) {
2473
+			// make sure we have a default if just true is sent.
2474
+			$delete           = ! empty($delete) ? $delete : 'delete';
2475
+			$delete_link_args = [$name => $id];
2476
+			$delete           = $this->get_action_link_or_button(
2477
+				$delete,
2478
+				$delete,
2479
+				$delete_link_args,
2480
+				'submitdelete deletion',
2481
+				'',
2482
+				false
2483
+			);
2484
+		}
2485
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2486
+		if (! empty($name) && ! empty($id)) {
2487
+			$hidden_field_arr[ $name ] = [
2488
+				'type'  => 'hidden',
2489
+				'value' => $id,
2490
+			];
2491
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2492
+		} else {
2493
+			$hf = '';
2494
+		}
2495
+		// add hidden field
2496
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2497
+			? $hf[ $name ]['field']
2498
+			: $hf;
2499
+	}
2500
+
2501
+
2502
+	/**
2503
+	 * displays an error message to ppl who have javascript disabled
2504
+	 *
2505
+	 * @return void
2506
+	 */
2507
+	private function _display_no_javascript_warning()
2508
+	{
2509
+		?>
2510 2510
         <noscript>
2511 2511
             <div id="no-js-message" class="error">
2512 2512
                 <p style="font-size:1.3em;">
2513 2513
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2514 2514
                     <?php esc_html_e(
2515
-                        '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.',
2516
-                        'event_espresso'
2517
-                    ); ?>
2515
+						'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.',
2516
+						'event_espresso'
2517
+					); ?>
2518 2518
                 </p>
2519 2519
             </div>
2520 2520
         </noscript>
2521 2521
         <?php
2522
-    }
2523
-
2524
-
2525
-    /**
2526
-     * displays espresso success and/or error notices
2527
-     *
2528
-     * @return void
2529
-     */
2530
-    protected function _display_espresso_notices()
2531
-    {
2532
-        $notices = $this->_get_transient(true);
2533
-        echo stripslashes($notices);
2534
-    }
2535
-
2536
-
2537
-    /**
2538
-     * spinny things pacify the masses
2539
-     *
2540
-     * @return void
2541
-     */
2542
-    protected function _add_admin_page_ajax_loading_img()
2543
-    {
2544
-        ?>
2522
+	}
2523
+
2524
+
2525
+	/**
2526
+	 * displays espresso success and/or error notices
2527
+	 *
2528
+	 * @return void
2529
+	 */
2530
+	protected function _display_espresso_notices()
2531
+	{
2532
+		$notices = $this->_get_transient(true);
2533
+		echo stripslashes($notices);
2534
+	}
2535
+
2536
+
2537
+	/**
2538
+	 * spinny things pacify the masses
2539
+	 *
2540
+	 * @return void
2541
+	 */
2542
+	protected function _add_admin_page_ajax_loading_img()
2543
+	{
2544
+		?>
2545 2545
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2546 2546
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2547
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2547
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2548 2548
         </div>
2549 2549
         <?php
2550
-    }
2550
+	}
2551 2551
 
2552 2552
 
2553
-    /**
2554
-     * add admin page overlay for modal boxes
2555
-     *
2556
-     * @return void
2557
-     */
2558
-    protected function _add_admin_page_overlay()
2559
-    {
2560
-        ?>
2553
+	/**
2554
+	 * add admin page overlay for modal boxes
2555
+	 *
2556
+	 * @return void
2557
+	 */
2558
+	protected function _add_admin_page_overlay()
2559
+	{
2560
+		?>
2561 2561
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2562 2562
         <?php
2563
-    }
2564
-
2565
-
2566
-    /**
2567
-     * facade for add_meta_box
2568
-     *
2569
-     * @param string  $action        where the metabox gets displayed
2570
-     * @param string  $title         Title of Metabox (output in metabox header)
2571
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2572
-     *                               instead of the one created in here.
2573
-     * @param array   $callback_args an array of args supplied for the metabox
2574
-     * @param string  $column        what metabox column
2575
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2576
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2577
-     *                               created but just set our own callback for wp's add_meta_box.
2578
-     * @throws DomainException
2579
-     */
2580
-    public function _add_admin_page_meta_box(
2581
-        $action,
2582
-        $title,
2583
-        $callback,
2584
-        $callback_args,
2585
-        $column = 'normal',
2586
-        $priority = 'high',
2587
-        $create_func = true
2588
-    ) {
2589
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2590
-        // 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.
2591
-        if (empty($callback_args) && $create_func) {
2592
-            $callback_args = [
2593
-                'template_path' => $this->_template_path,
2594
-                'template_args' => $this->_template_args,
2595
-            ];
2596
-        }
2597
-        // 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)
2598
-        $call_back_func = $create_func
2599
-            ? function ($post, $metabox) {
2600
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2601
-                echo EEH_Template::display_template(
2602
-                    $metabox['args']['template_path'],
2603
-                    $metabox['args']['template_args'],
2604
-                    true
2605
-                );
2606
-            }
2607
-            : $callback;
2608
-        add_meta_box(
2609
-            str_replace('_', '-', $action) . '-mbox',
2610
-            $title,
2611
-            $call_back_func,
2612
-            $this->_wp_page_slug,
2613
-            $column,
2614
-            $priority,
2615
-            $callback_args
2616
-        );
2617
-    }
2618
-
2619
-
2620
-    /**
2621
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2622
-     *
2623
-     * @throws DomainException
2624
-     * @throws EE_Error
2625
-     */
2626
-    public function display_admin_page_with_metabox_columns()
2627
-    {
2628
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2629
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2630
-            $this->_column_template_path,
2631
-            $this->_template_args,
2632
-            true
2633
-        );
2634
-        // the final wrapper
2635
-        $this->admin_page_wrapper();
2636
-    }
2637
-
2638
-
2639
-    /**
2640
-     * generates  HTML wrapper for an admin details page
2641
-     *
2642
-     * @return void
2643
-     * @throws EE_Error
2644
-     * @throws DomainException
2645
-     */
2646
-    public function display_admin_page_with_sidebar()
2647
-    {
2648
-        $this->_display_admin_page(true);
2649
-    }
2650
-
2651
-
2652
-    /**
2653
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2654
-     *
2655
-     * @return void
2656
-     * @throws EE_Error
2657
-     * @throws DomainException
2658
-     */
2659
-    public function display_admin_page_with_no_sidebar()
2660
-    {
2661
-        $this->_display_admin_page();
2662
-    }
2663
-
2664
-
2665
-    /**
2666
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2667
-     *
2668
-     * @return void
2669
-     * @throws EE_Error
2670
-     * @throws DomainException
2671
-     */
2672
-    public function display_about_admin_page()
2673
-    {
2674
-        $this->_display_admin_page(false, true);
2675
-    }
2676
-
2677
-
2678
-    /**
2679
-     * display_admin_page
2680
-     * contains the code for actually displaying an admin page
2681
-     *
2682
-     * @param boolean $sidebar true with sidebar, false without
2683
-     * @param boolean $about   use the about_admin_wrapper instead of the default.
2684
-     * @return void
2685
-     * @throws DomainException
2686
-     * @throws EE_Error
2687
-     */
2688
-    private function _display_admin_page($sidebar = false, $about = false)
2689
-    {
2690
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2691
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2692
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2693
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2694
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2695
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2696
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2697
-            ? 'poststuff'
2698
-            : 'espresso-default-admin';
2699
-        $template_path                                     = $sidebar
2700
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2701
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2702
-        if ($this->request->isAjax()) {
2703
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2704
-        }
2705
-        $template_path                                     = ! empty($this->_column_template_path)
2706
-            ? $this->_column_template_path : $template_path;
2707
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2708
-            ? $this->_template_args['admin_page_content']
2709
-            : '';
2710
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2711
-            ? $this->_template_args['before_admin_page_content']
2712
-            : '';
2713
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2714
-            ? $this->_template_args['after_admin_page_content']
2715
-            : '';
2716
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2717
-            $template_path,
2718
-            $this->_template_args,
2719
-            true
2720
-        );
2721
-        // the final template wrapper
2722
-        $this->admin_page_wrapper($about);
2723
-    }
2724
-
2725
-
2726
-    /**
2727
-     * This is used to display caf preview pages.
2728
-     *
2729
-     * @param string $utm_campaign_source what is the key used for google analytics link
2730
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2731
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2732
-     * @return void
2733
-     * @throws DomainException
2734
-     * @throws EE_Error
2735
-     * @throws InvalidArgumentException
2736
-     * @throws InvalidDataTypeException
2737
-     * @throws InvalidInterfaceException
2738
-     * @since 4.3.2
2739
-     */
2740
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2741
-    {
2742
-        // let's generate a default preview action button if there isn't one already present.
2743
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2744
-            'Upgrade to Event Espresso 4 Right Now',
2745
-            'event_espresso'
2746
-        );
2747
-        $buy_now_url                                   = add_query_arg(
2748
-            [
2749
-                'ee_ver'       => 'ee4',
2750
-                'utm_source'   => 'ee4_plugin_admin',
2751
-                'utm_medium'   => 'link',
2752
-                'utm_campaign' => $utm_campaign_source,
2753
-                'utm_content'  => 'buy_now_button',
2754
-            ],
2755
-            'https://eventespresso.com/pricing/'
2756
-        );
2757
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2758
-            ? $this->get_action_link_or_button(
2759
-                '',
2760
-                'buy_now',
2761
-                [],
2762
-                'button-primary button-large',
2763
-                esc_url_raw($buy_now_url),
2764
-                true
2765
-            )
2766
-            : $this->_template_args['preview_action_button'];
2767
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2768
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2769
-            $this->_template_args,
2770
-            true
2771
-        );
2772
-        $this->_display_admin_page($display_sidebar);
2773
-    }
2774
-
2775
-
2776
-    /**
2777
-     * display_admin_list_table_page_with_sidebar
2778
-     * generates HTML wrapper for an admin_page with list_table
2779
-     *
2780
-     * @return void
2781
-     * @throws EE_Error
2782
-     * @throws DomainException
2783
-     */
2784
-    public function display_admin_list_table_page_with_sidebar()
2785
-    {
2786
-        $this->_display_admin_list_table_page(true);
2787
-    }
2788
-
2789
-
2790
-    /**
2791
-     * display_admin_list_table_page_with_no_sidebar
2792
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2793
-     *
2794
-     * @return void
2795
-     * @throws EE_Error
2796
-     * @throws DomainException
2797
-     */
2798
-    public function display_admin_list_table_page_with_no_sidebar()
2799
-    {
2800
-        $this->_display_admin_list_table_page();
2801
-    }
2802
-
2803
-
2804
-    /**
2805
-     * generates html wrapper for an admin_list_table page
2806
-     *
2807
-     * @param boolean $sidebar whether to display with sidebar or not.
2808
-     * @return void
2809
-     * @throws DomainException
2810
-     * @throws EE_Error
2811
-     */
2812
-    private function _display_admin_list_table_page($sidebar = false)
2813
-    {
2814
-        // setup search attributes
2815
-        $this->_set_search_attributes();
2816
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
2817
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2818
-        $this->_template_args['table_url']        = $this->request->isAjax()
2819
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2820
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2821
-        $this->_template_args['list_table']       = $this->_list_table_object;
2822
-        $this->_template_args['current_route']    = $this->_req_action;
2823
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2824
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2825
-        if (! empty($ajax_sorting_callback)) {
2826
-            $sortable_list_table_form_fields = wp_nonce_field(
2827
-                $ajax_sorting_callback . '_nonce',
2828
-                $ajax_sorting_callback . '_nonce',
2829
-                false,
2830
-                false
2831
-            );
2832
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2833
-                                                . $this->page_slug
2834
-                                                . '" />';
2835
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2836
-                                                . $ajax_sorting_callback
2837
-                                                . '" />';
2838
-        } else {
2839
-            $sortable_list_table_form_fields = '';
2840
-        }
2841
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2842
-        $hidden_form_fields                                      =
2843
-            isset($this->_template_args['list_table_hidden_fields'])
2844
-                ? $this->_template_args['list_table_hidden_fields']
2845
-                : '';
2846
-        $nonce_ref                                               = $this->_req_action . '_nonce';
2847
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
2848
-                                                                    . $nonce_ref
2849
-                                                                    . '" value="'
2850
-                                                                    . wp_create_nonce($nonce_ref)
2851
-                                                                    . '">';
2852
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2853
-        // display message about search results?
2854
-        $search = $this->request->getRequestParam('s');
2855
-        $this->_template_args['before_list_table'] .= ! empty($search)
2856
-            ? '<p class="ee-search-results">' . sprintf(
2857
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2858
-                trim($search, '%')
2859
-            ) . '</p>'
2860
-            : '';
2861
-        // filter before_list_table template arg
2862
-        $this->_template_args['before_list_table'] = apply_filters(
2863
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2864
-            $this->_template_args['before_list_table'],
2865
-            $this->page_slug,
2866
-            $this->request->requestParams(),
2867
-            $this->_req_action
2868
-        );
2869
-        // convert to array and filter again
2870
-        // arrays are easier to inject new items in a specific location,
2871
-        // but would not be backwards compatible, so we have to add a new filter
2872
-        $this->_template_args['before_list_table'] = implode(
2873
-            " \n",
2874
-            (array) apply_filters(
2875
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2876
-                (array) $this->_template_args['before_list_table'],
2877
-                $this->page_slug,
2878
-                $this->request->requestParams(),
2879
-                $this->_req_action
2880
-            )
2881
-        );
2882
-        // filter after_list_table template arg
2883
-        $this->_template_args['after_list_table'] = apply_filters(
2884
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2885
-            $this->_template_args['after_list_table'],
2886
-            $this->page_slug,
2887
-            $this->request->requestParams(),
2888
-            $this->_req_action
2889
-        );
2890
-        // convert to array and filter again
2891
-        // arrays are easier to inject new items in a specific location,
2892
-        // but would not be backwards compatible, so we have to add a new filter
2893
-        $this->_template_args['after_list_table']   = implode(
2894
-            " \n",
2895
-            (array) apply_filters(
2896
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2897
-                (array) $this->_template_args['after_list_table'],
2898
-                $this->page_slug,
2899
-                $this->request->requestParams(),
2900
-                $this->_req_action
2901
-            )
2902
-        );
2903
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2904
-            $template_path,
2905
-            $this->_template_args,
2906
-            true
2907
-        );
2908
-        // the final template wrapper
2909
-        if ($sidebar) {
2910
-            $this->display_admin_page_with_sidebar();
2911
-        } else {
2912
-            $this->display_admin_page_with_no_sidebar();
2913
-        }
2914
-    }
2915
-
2916
-
2917
-    /**
2918
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2919
-     * html string for the legend.
2920
-     * $items are expected in an array in the following format:
2921
-     * $legend_items = array(
2922
-     *        'item_id' => array(
2923
-     *            'icon' => 'http://url_to_icon_being_described.png',
2924
-     *            'desc' => esc_html__('localized description of item');
2925
-     *        )
2926
-     * );
2927
-     *
2928
-     * @param array $items see above for format of array
2929
-     * @return string html string of legend
2930
-     * @throws DomainException
2931
-     */
2932
-    protected function _display_legend($items)
2933
-    {
2934
-        $this->_template_args['items'] = apply_filters(
2935
-            'FHEE__EE_Admin_Page___display_legend__items',
2936
-            (array) $items,
2937
-            $this
2938
-        );
2939
-        return EEH_Template::display_template(
2940
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2941
-            $this->_template_args,
2942
-            true
2943
-        );
2944
-    }
2945
-
2946
-
2947
-    /**
2948
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2949
-     * The returned json object is created from an array in the following format:
2950
-     * array(
2951
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2952
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
2953
-     *  'notices' => '', // - contains any EE_Error formatted notices
2954
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2955
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
2956
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
2957
-     *  that might be included in here)
2958
-     * )
2959
-     * The json object is populated by whatever is set in the $_template_args property.
2960
-     *
2961
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
2962
-     *                                 instead of displayed.
2963
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
2964
-     * @return void
2965
-     * @throws EE_Error
2966
-     */
2967
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
2968
-    {
2969
-        // make sure any EE_Error notices have been handled.
2970
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
2971
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
2972
-        unset($this->_template_args['data']);
2973
-        $json = [
2974
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2975
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2976
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2977
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2978
-            'notices'   => EE_Error::get_notices(),
2979
-            'content'   => isset($this->_template_args['admin_page_content'])
2980
-                ? $this->_template_args['admin_page_content'] : '',
2981
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
2982
-            'isEEajax'  => true
2983
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2984
-        ];
2985
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
2986
-        if (null === error_get_last() || ! headers_sent()) {
2987
-            header('Content-Type: application/json; charset=UTF-8');
2988
-        }
2989
-        echo wp_json_encode($json);
2990
-        exit();
2991
-    }
2992
-
2993
-
2994
-    /**
2995
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2996
-     *
2997
-     * @return void
2998
-     * @throws EE_Error
2999
-     */
3000
-    public function return_json()
3001
-    {
3002
-        if ($this->request->isAjax()) {
3003
-            $this->_return_json();
3004
-        } else {
3005
-            throw new EE_Error(
3006
-                sprintf(
3007
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3008
-                    __FUNCTION__
3009
-                )
3010
-            );
3011
-        }
3012
-    }
3013
-
3014
-
3015
-    /**
3016
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3017
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3018
-     *
3019
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3020
-     */
3021
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3022
-    {
3023
-        $this->_hook_obj = $hook_obj;
3024
-    }
3025
-
3026
-
3027
-    /**
3028
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3029
-     *
3030
-     * @param boolean $about whether to use the special about page wrapper or default.
3031
-     * @return void
3032
-     * @throws DomainException
3033
-     * @throws EE_Error
3034
-     */
3035
-    public function admin_page_wrapper($about = false)
3036
-    {
3037
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3038
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3039
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3040
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3041
-
3042
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3043
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3044
-            isset($this->_template_args['before_admin_page_content'])
3045
-                ? $this->_template_args['before_admin_page_content']
3046
-                : ''
3047
-        );
3048
-
3049
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3050
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3051
-            isset($this->_template_args['after_admin_page_content'])
3052
-                ? $this->_template_args['after_admin_page_content']
3053
-                : ''
3054
-        );
3055
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3056
-
3057
-        if ($this->request->isAjax()) {
3058
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3059
-                // $template_path,
3060
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3061
-                $this->_template_args,
3062
-                true
3063
-            );
3064
-            $this->_return_json();
3065
-        }
3066
-        // load settings page wrapper template
3067
-        $template_path = $about
3068
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3069
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3070
-
3071
-        EEH_Template::display_template($template_path, $this->_template_args);
3072
-    }
3073
-
3074
-
3075
-    /**
3076
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3077
-     *
3078
-     * @return string html
3079
-     * @throws EE_Error
3080
-     */
3081
-    protected function _get_main_nav_tabs()
3082
-    {
3083
-        // let's generate the html using the EEH_Tabbed_Content helper.
3084
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3085
-        // (rather than setting in the page_routes array)
3086
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3087
-    }
3088
-
3089
-
3090
-    /**
3091
-     *        sort nav tabs
3092
-     *
3093
-     * @param $a
3094
-     * @param $b
3095
-     * @return int
3096
-     */
3097
-    private function _sort_nav_tabs($a, $b)
3098
-    {
3099
-        if ($a['order'] === $b['order']) {
3100
-            return 0;
3101
-        }
3102
-        return ($a['order'] < $b['order']) ? -1 : 1;
3103
-    }
3104
-
3105
-
3106
-    /**
3107
-     *    generates HTML for the forms used on admin pages
3108
-     *
3109
-     * @param array  $input_vars   - array of input field details
3110
-     * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3111
-     *                             use)
3112
-     * @param bool   $id
3113
-     * @return array|string
3114
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3115
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3116
-     */
3117
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3118
-    {
3119
-        return $generator === 'string'
3120
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3121
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3122
-    }
3123
-
3124
-
3125
-    /**
3126
-     * generates the "Save" and "Save & Close" buttons for edit forms
3127
-     *
3128
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3129
-     *                                   Close" button.
3130
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3131
-     *                                   'Save', [1] => 'save & close')
3132
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3133
-     *                                   via the "name" value in the button).  We can also use this to just dump
3134
-     *                                   default actions by submitting some other value.
3135
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3136
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3137
-     *                                   close (normal form handling).
3138
-     */
3139
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3140
-    {
3141
-        // make sure $text and $actions are in an array
3142
-        $text          = (array) $text;
3143
-        $actions       = (array) $actions;
3144
-        $referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3145
-        $button_text   = ! empty($text)
3146
-            ? $text
3147
-            : [
3148
-                esc_html__('Save', 'event_espresso'),
3149
-                esc_html__('Save and Close', 'event_espresso'),
3150
-            ];
3151
-        $default_names = ['save', 'save_and_close'];
3152
-        $buttons = '';
3153
-        foreach ($button_text as $key => $button) {
3154
-            $ref     = $default_names[ $key ];
3155
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3156
-            $buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3157
-                        . 'value="' . $button . '" name="' . $name . '" '
3158
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3159
-            if (! $both) {
3160
-                break;
3161
-            }
3162
-        }
3163
-        // add in a hidden index for the current page (so save and close redirects properly)
3164
-        $buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3165
-                   . $referrer_url
3166
-                   . '" />';
3167
-        $this->_template_args['save_buttons'] = $buttons;
3168
-    }
3169
-
3170
-
3171
-    /**
3172
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3173
-     *
3174
-     * @param string $route
3175
-     * @param array  $additional_hidden_fields
3176
-     * @see   $this->_set_add_edit_form_tags() for details on params
3177
-     * @since 4.6.0
3178
-     */
3179
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3180
-    {
3181
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3182
-    }
3183
-
3184
-
3185
-    /**
3186
-     * set form open and close tags on add/edit pages.
3187
-     *
3188
-     * @param string $route                    the route you want the form to direct to
3189
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3190
-     * @return void
3191
-     */
3192
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3193
-    {
3194
-        if (empty($route)) {
3195
-            $user_msg = esc_html__(
3196
-                'An error occurred. No action was set for this page\'s form.',
3197
-                'event_espresso'
3198
-            );
3199
-            $dev_msg  = $user_msg . "\n"
3200
-                        . sprintf(
3201
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3202
-                            __FUNCTION__,
3203
-                            __CLASS__
3204
-                        );
3205
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3206
-        }
3207
-        // open form
3208
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3209
-                                                             . $this->_admin_base_url
3210
-                                                             . '" id="'
3211
-                                                             . $route
3212
-                                                             . '_event_form" >';
3213
-        // add nonce
3214
-        $nonce                                             =
3215
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3216
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3217
-        // add REQUIRED form action
3218
-        $hidden_fields = [
3219
-            'action' => ['type' => 'hidden', 'value' => $route],
3220
-        ];
3221
-        // merge arrays
3222
-        $hidden_fields = is_array($additional_hidden_fields)
3223
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3224
-            : $hidden_fields;
3225
-        // generate form fields
3226
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3227
-        // add fields to form
3228
-        foreach ((array) $form_fields as $form_field) {
3229
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3230
-        }
3231
-        // close form
3232
-        $this->_template_args['after_admin_page_content'] = '</form>';
3233
-    }
3234
-
3235
-
3236
-    /**
3237
-     * Public Wrapper for _redirect_after_action() method since its
3238
-     * discovered it would be useful for external code to have access.
3239
-     *
3240
-     * @param bool   $success
3241
-     * @param string $what
3242
-     * @param string $action_desc
3243
-     * @param array  $query_args
3244
-     * @param bool   $override_overwrite
3245
-     * @throws EE_Error
3246
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3247
-     * @since 4.5.0
3248
-     */
3249
-    public function redirect_after_action(
3250
-        $success = false,
3251
-        $what = 'item',
3252
-        $action_desc = 'processed',
3253
-        $query_args = [],
3254
-        $override_overwrite = false
3255
-    ) {
3256
-        $this->_redirect_after_action(
3257
-            $success,
3258
-            $what,
3259
-            $action_desc,
3260
-            $query_args,
3261
-            $override_overwrite
3262
-        );
3263
-    }
3264
-
3265
-
3266
-    /**
3267
-     * Helper method for merging existing request data with the returned redirect url.
3268
-     *
3269
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3270
-     * filters are still applied.
3271
-     *
3272
-     * @param array $new_route_data
3273
-     * @return array
3274
-     */
3275
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3276
-    {
3277
-        foreach ($this->request->requestParams() as $ref => $value) {
3278
-            // unset nonces
3279
-            if (strpos($ref, 'nonce') !== false) {
3280
-                $this->request->unSetRequestParam($ref);
3281
-                continue;
3282
-            }
3283
-            // urlencode values.
3284
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3285
-            $this->request->setRequestParam($ref, $value);
3286
-        }
3287
-        return array_merge($this->request->requestParams(), $new_route_data);
3288
-    }
3289
-
3290
-
3291
-    /**
3292
-     *    _redirect_after_action
3293
-     *
3294
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3295
-     * @param string $what               - what the action was performed on
3296
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3297
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3298
-     *                                   action is completed
3299
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3300
-     *                                   override this so that they show.
3301
-     * @return void
3302
-     * @throws EE_Error
3303
-     */
3304
-    protected function _redirect_after_action(
3305
-        $success = 0,
3306
-        $what = 'item',
3307
-        $action_desc = 'processed',
3308
-        $query_args = [],
3309
-        $override_overwrite = false
3310
-    ) {
3311
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3312
-        // class name for actions/filters.
3313
-        $classname = get_class($this);
3314
-        // set redirect url.
3315
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3316
-        // otherwise we go with whatever is set as the _admin_base_url
3317
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3318
-        $notices      = EE_Error::get_notices(false);
3319
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3320
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3321
-            EE_Error::overwrite_success();
3322
-        }
3323
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3324
-            // how many records affected ? more than one record ? or just one ?
3325
-            if ($success > 1) {
3326
-                // set plural msg
3327
-                EE_Error::add_success(
3328
-                    sprintf(
3329
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3330
-                        $what,
3331
-                        $action_desc
3332
-                    ),
3333
-                    __FILE__,
3334
-                    __FUNCTION__,
3335
-                    __LINE__
3336
-                );
3337
-            } elseif ($success === 1) {
3338
-                // set singular msg
3339
-                EE_Error::add_success(
3340
-                    sprintf(
3341
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3342
-                        $what,
3343
-                        $action_desc
3344
-                    ),
3345
-                    __FILE__,
3346
-                    __FUNCTION__,
3347
-                    __LINE__
3348
-                );
3349
-            }
3350
-        }
3351
-        // check that $query_args isn't something crazy
3352
-        if (! is_array($query_args)) {
3353
-            $query_args = [];
3354
-        }
3355
-        /**
3356
-         * Allow injecting actions before the query_args are modified for possible different
3357
-         * redirections on save and close actions
3358
-         *
3359
-         * @param array $query_args       The original query_args array coming into the
3360
-         *                                method.
3361
-         * @since 4.2.0
3362
-         */
3363
-        do_action(
3364
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3365
-            $query_args
3366
-        );
3367
-        // calculate where we're going (if we have a "save and close" button pushed)
3368
-
3369
-        if (
3370
-            $this->request->requestParamIsSet('save_and_close')
3371
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3372
-        ) {
3373
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3374
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3375
-            // regenerate query args array from referrer URL
3376
-            parse_str($parsed_url['query'], $query_args);
3377
-            // correct page and action will be in the query args now
3378
-            $redirect_url = admin_url('admin.php');
3379
-        }
3380
-        // merge any default query_args set in _default_route_query_args property
3381
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3382
-            $args_to_merge = [];
3383
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3384
-                // is there a wp_referer array in our _default_route_query_args property?
3385
-                if ($query_param === 'wp_referer') {
3386
-                    $query_value = (array) $query_value;
3387
-                    foreach ($query_value as $reference => $value) {
3388
-                        if (strpos($reference, 'nonce') !== false) {
3389
-                            continue;
3390
-                        }
3391
-                        // finally we will override any arguments in the referer with
3392
-                        // what might be set on the _default_route_query_args array.
3393
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3394
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3395
-                        } else {
3396
-                            $args_to_merge[ $reference ] = urlencode($value);
3397
-                        }
3398
-                    }
3399
-                    continue;
3400
-                }
3401
-                $args_to_merge[ $query_param ] = $query_value;
3402
-            }
3403
-            // now let's merge these arguments but override with what was specifically sent in to the
3404
-            // redirect.
3405
-            $query_args = array_merge($args_to_merge, $query_args);
3406
-        }
3407
-        $this->_process_notices($query_args);
3408
-        // generate redirect url
3409
-        // if redirecting to anything other than the main page, add a nonce
3410
-        if (isset($query_args['action'])) {
3411
-            // manually generate wp_nonce and merge that with the query vars
3412
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3413
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3414
-        }
3415
-        // we're adding some hooks and filters in here for processing any things just before redirects
3416
-        // (example: an admin page has done an insert or update and we want to run something after that).
3417
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3418
-        $redirect_url = apply_filters(
3419
-            'FHEE_redirect_' . $classname . $this->_req_action,
3420
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3421
-            $query_args
3422
-        );
3423
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3424
-        if ($this->request->isAjax()) {
3425
-            $default_data                    = [
3426
-                'close'        => true,
3427
-                'redirect_url' => $redirect_url,
3428
-                'where'        => 'main',
3429
-                'what'         => 'append',
3430
-            ];
3431
-            $this->_template_args['success'] = $success;
3432
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3433
-                $default_data,
3434
-                $this->_template_args['data']
3435
-            ) : $default_data;
3436
-            $this->_return_json();
3437
-        }
3438
-        wp_safe_redirect($redirect_url);
3439
-        exit();
3440
-    }
3441
-
3442
-
3443
-    /**
3444
-     * process any notices before redirecting (or returning ajax request)
3445
-     * This method sets the $this->_template_args['notices'] attribute;
3446
-     *
3447
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3448
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3449
-     *                                  page_routes haven't been defined yet.
3450
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3451
-     *                                  still save a transient for the notice.
3452
-     * @return void
3453
-     * @throws EE_Error
3454
-     */
3455
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3456
-    {
3457
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3458
-        if ($this->request->isAjax()) {
3459
-            $notices = EE_Error::get_notices(false);
3460
-            if (empty($this->_template_args['success'])) {
3461
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3462
-            }
3463
-            if (empty($this->_template_args['errors'])) {
3464
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3465
-            }
3466
-            if (empty($this->_template_args['attention'])) {
3467
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3468
-            }
3469
-        }
3470
-        $this->_template_args['notices'] = EE_Error::get_notices();
3471
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3472
-        if (! $this->request->isAjax() || $sticky_notices) {
3473
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3474
-            $this->_add_transient(
3475
-                $route,
3476
-                $this->_template_args['notices'],
3477
-                true,
3478
-                $skip_route_verify
3479
-            );
3480
-        }
3481
-    }
3482
-
3483
-
3484
-    /**
3485
-     * get_action_link_or_button
3486
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3487
-     *
3488
-     * @param string $action        use this to indicate which action the url is generated with.
3489
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3490
-     *                              property.
3491
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3492
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3493
-     * @param string $base_url      If this is not provided
3494
-     *                              the _admin_base_url will be used as the default for the button base_url.
3495
-     *                              Otherwise this value will be used.
3496
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3497
-     * @return string
3498
-     * @throws InvalidArgumentException
3499
-     * @throws InvalidInterfaceException
3500
-     * @throws InvalidDataTypeException
3501
-     * @throws EE_Error
3502
-     */
3503
-    public function get_action_link_or_button(
3504
-        $action,
3505
-        $type = 'add',
3506
-        $extra_request = [],
3507
-        $class = 'button-primary',
3508
-        $base_url = '',
3509
-        $exclude_nonce = false
3510
-    ) {
3511
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3512
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3513
-            throw new EE_Error(
3514
-                sprintf(
3515
-                    esc_html__(
3516
-                        'There is no page route for given action for the button.  This action was given: %s',
3517
-                        'event_espresso'
3518
-                    ),
3519
-                    $action
3520
-                )
3521
-            );
3522
-        }
3523
-        if (! isset($this->_labels['buttons'][ $type ])) {
3524
-            throw new EE_Error(
3525
-                sprintf(
3526
-                    esc_html__(
3527
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3528
-                        'event_espresso'
3529
-                    ),
3530
-                    $type
3531
-                )
3532
-            );
3533
-        }
3534
-        // finally check user access for this button.
3535
-        $has_access = $this->check_user_access($action, true);
3536
-        if (! $has_access) {
3537
-            return '';
3538
-        }
3539
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3540
-        $query_args = [
3541
-            'action' => $action,
3542
-        ];
3543
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3544
-        if (! empty($extra_request)) {
3545
-            $query_args = array_merge($extra_request, $query_args);
3546
-        }
3547
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3548
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3549
-    }
3550
-
3551
-
3552
-    /**
3553
-     * _per_page_screen_option
3554
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3555
-     *
3556
-     * @return void
3557
-     * @throws InvalidArgumentException
3558
-     * @throws InvalidInterfaceException
3559
-     * @throws InvalidDataTypeException
3560
-     */
3561
-    protected function _per_page_screen_option()
3562
-    {
3563
-        $option = 'per_page';
3564
-        $args   = [
3565
-            'label'   => apply_filters(
3566
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3567
-                $this->_admin_page_title,
3568
-                $this
3569
-            ),
3570
-            'default' => (int) apply_filters(
3571
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3572
-                20
3573
-            ),
3574
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3575
-        ];
3576
-        // ONLY add the screen option if the user has access to it.
3577
-        if ($this->check_user_access($this->_current_view, true)) {
3578
-            add_screen_option($option, $args);
3579
-        }
3580
-    }
3581
-
3582
-
3583
-    /**
3584
-     * set_per_page_screen_option
3585
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3586
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3587
-     * admin_menu.
3588
-     *
3589
-     * @return void
3590
-     */
3591
-    private function _set_per_page_screen_options()
3592
-    {
3593
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3594
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3595
-            if (! $user = wp_get_current_user()) {
3596
-                return;
3597
-            }
3598
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3599
-            if (! $option) {
3600
-                return;
3601
-            }
3602
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3603
-            $map_option = $option;
3604
-            $option     = str_replace('-', '_', $option);
3605
-            switch ($map_option) {
3606
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3607
-                    $max_value = apply_filters(
3608
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3609
-                        999,
3610
-                        $this->_current_page,
3611
-                        $this->_current_view
3612
-                    );
3613
-                    if ($value < 1) {
3614
-                        return;
3615
-                    }
3616
-                    $value = min($value, $max_value);
3617
-                    break;
3618
-                default:
3619
-                    $value = apply_filters(
3620
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3621
-                        false,
3622
-                        $option,
3623
-                        $value
3624
-                    );
3625
-                    if (false === $value) {
3626
-                        return;
3627
-                    }
3628
-                    break;
3629
-            }
3630
-            update_user_meta($user->ID, $option, $value);
3631
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3632
-            exit;
3633
-        }
3634
-    }
3635
-
3636
-
3637
-    /**
3638
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3639
-     *
3640
-     * @param array $data array that will be assigned to template args.
3641
-     */
3642
-    public function set_template_args($data)
3643
-    {
3644
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3645
-    }
3646
-
3647
-
3648
-    /**
3649
-     * This makes available the WP transient system for temporarily moving data between routes
3650
-     *
3651
-     * @param string $route             the route that should receive the transient
3652
-     * @param array  $data              the data that gets sent
3653
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3654
-     *                                  normal route transient.
3655
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3656
-     *                                  when we are adding a transient before page_routes have been defined.
3657
-     * @return void
3658
-     * @throws EE_Error
3659
-     */
3660
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3661
-    {
3662
-        $user_id = get_current_user_id();
3663
-        if (! $skip_route_verify) {
3664
-            $this->_verify_route($route);
3665
-        }
3666
-        // now let's set the string for what kind of transient we're setting
3667
-        $transient = $notices
3668
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3669
-            : 'rte_tx_' . $route . '_' . $user_id;
3670
-        $data      = $notices ? ['notices' => $data] : $data;
3671
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3672
-        $existing = is_multisite() && is_network_admin()
3673
-            ? get_site_transient($transient)
3674
-            : get_transient($transient);
3675
-        if ($existing) {
3676
-            $data = array_merge((array) $data, (array) $existing);
3677
-        }
3678
-        if (is_multisite() && is_network_admin()) {
3679
-            set_site_transient($transient, $data, 8);
3680
-        } else {
3681
-            set_transient($transient, $data, 8);
3682
-        }
3683
-    }
3684
-
3685
-
3686
-    /**
3687
-     * this retrieves the temporary transient that has been set for moving data between routes.
3688
-     *
3689
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3690
-     * @param string $route
3691
-     * @return mixed data
3692
-     */
3693
-    protected function _get_transient($notices = false, $route = '')
3694
-    {
3695
-        $user_id   = get_current_user_id();
3696
-        $route     = ! $route ? $this->_req_action : $route;
3697
-        $transient = $notices
3698
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3699
-            : 'rte_tx_' . $route . '_' . $user_id;
3700
-        $data      = is_multisite() && is_network_admin()
3701
-            ? get_site_transient($transient)
3702
-            : get_transient($transient);
3703
-        // delete transient after retrieval (just in case it hasn't expired);
3704
-        if (is_multisite() && is_network_admin()) {
3705
-            delete_site_transient($transient);
3706
-        } else {
3707
-            delete_transient($transient);
3708
-        }
3709
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3710
-    }
3711
-
3712
-
3713
-    /**
3714
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3715
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3716
-     * default route callback on the EE_Admin page you want it run.)
3717
-     *
3718
-     * @return void
3719
-     */
3720
-    protected function _transient_garbage_collection()
3721
-    {
3722
-        global $wpdb;
3723
-        // retrieve all existing transients
3724
-        $query =
3725
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3726
-        if ($results = $wpdb->get_results($query)) {
3727
-            foreach ($results as $result) {
3728
-                $transient = str_replace('_transient_', '', $result->option_name);
3729
-                get_transient($transient);
3730
-                if (is_multisite() && is_network_admin()) {
3731
-                    get_site_transient($transient);
3732
-                }
3733
-            }
3734
-        }
3735
-    }
3736
-
3737
-
3738
-    /**
3739
-     * get_view
3740
-     *
3741
-     * @return string content of _view property
3742
-     */
3743
-    public function get_view()
3744
-    {
3745
-        return $this->_view;
3746
-    }
3747
-
3748
-
3749
-    /**
3750
-     * getter for the protected $_views property
3751
-     *
3752
-     * @return array
3753
-     */
3754
-    public function get_views()
3755
-    {
3756
-        return $this->_views;
3757
-    }
3758
-
3759
-
3760
-    /**
3761
-     * get_current_page
3762
-     *
3763
-     * @return string _current_page property value
3764
-     */
3765
-    public function get_current_page()
3766
-    {
3767
-        return $this->_current_page;
3768
-    }
3769
-
3770
-
3771
-    /**
3772
-     * get_current_view
3773
-     *
3774
-     * @return string _current_view property value
3775
-     */
3776
-    public function get_current_view()
3777
-    {
3778
-        return $this->_current_view;
3779
-    }
3780
-
3781
-
3782
-    /**
3783
-     * get_current_screen
3784
-     *
3785
-     * @return object The current WP_Screen object
3786
-     */
3787
-    public function get_current_screen()
3788
-    {
3789
-        return $this->_current_screen;
3790
-    }
3791
-
3792
-
3793
-    /**
3794
-     * get_current_page_view_url
3795
-     *
3796
-     * @return string This returns the url for the current_page_view.
3797
-     */
3798
-    public function get_current_page_view_url()
3799
-    {
3800
-        return $this->_current_page_view_url;
3801
-    }
3802
-
3803
-
3804
-    /**
3805
-     * just returns the Request
3806
-     *
3807
-     * @return RequestInterface
3808
-     */
3809
-    public function get_request()
3810
-    {
3811
-        return $this->request;
3812
-    }
3813
-
3814
-
3815
-    /**
3816
-     * just returns the _req_data property
3817
-     *
3818
-     * @return array
3819
-     */
3820
-    public function get_request_data()
3821
-    {
3822
-        return $this->request->requestParams();
3823
-    }
3824
-
3825
-
3826
-    /**
3827
-     * returns the _req_data protected property
3828
-     *
3829
-     * @return string
3830
-     */
3831
-    public function get_req_action()
3832
-    {
3833
-        return $this->_req_action;
3834
-    }
3835
-
3836
-
3837
-    /**
3838
-     * @return bool  value of $_is_caf property
3839
-     */
3840
-    public function is_caf()
3841
-    {
3842
-        return $this->_is_caf;
3843
-    }
3844
-
3845
-
3846
-    /**
3847
-     * @return mixed
3848
-     */
3849
-    public function default_espresso_metaboxes()
3850
-    {
3851
-        return $this->_default_espresso_metaboxes;
3852
-    }
3853
-
3854
-
3855
-    /**
3856
-     * @return mixed
3857
-     */
3858
-    public function admin_base_url()
3859
-    {
3860
-        return $this->_admin_base_url;
3861
-    }
3862
-
3863
-
3864
-    /**
3865
-     * @return mixed
3866
-     */
3867
-    public function wp_page_slug()
3868
-    {
3869
-        return $this->_wp_page_slug;
3870
-    }
3871
-
3872
-
3873
-    /**
3874
-     * updates  espresso configuration settings
3875
-     *
3876
-     * @param string                   $tab
3877
-     * @param EE_Config_Base|EE_Config $config
3878
-     * @param string                   $file file where error occurred
3879
-     * @param string                   $func function  where error occurred
3880
-     * @param string                   $line line no where error occurred
3881
-     * @return boolean
3882
-     */
3883
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3884
-    {
3885
-        // remove any options that are NOT going to be saved with the config settings.
3886
-        if (isset($config->core->ee_ueip_optin)) {
3887
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3888
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3889
-            update_option('ee_ueip_has_notified', true);
3890
-        }
3891
-        // and save it (note we're also doing the network save here)
3892
-        $net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3893
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3894
-        if ($config_saved && $net_saved) {
3895
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3896
-            return true;
3897
-        }
3898
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3899
-        return false;
3900
-    }
3901
-
3902
-
3903
-    /**
3904
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3905
-     *
3906
-     * @return array
3907
-     */
3908
-    public function get_yes_no_values()
3909
-    {
3910
-        return $this->_yes_no_values;
3911
-    }
3912
-
3913
-
3914
-    protected function _get_dir()
3915
-    {
3916
-        $reflector = new ReflectionClass(get_class($this));
3917
-        return dirname($reflector->getFileName());
3918
-    }
3919
-
3920
-
3921
-    /**
3922
-     * A helper for getting a "next link".
3923
-     *
3924
-     * @param string $url   The url to link to
3925
-     * @param string $class The class to use.
3926
-     * @return string
3927
-     */
3928
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3929
-    {
3930
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3931
-    }
3932
-
3933
-
3934
-    /**
3935
-     * A helper for getting a "previous link".
3936
-     *
3937
-     * @param string $url   The url to link to
3938
-     * @param string $class The class to use.
3939
-     * @return string
3940
-     */
3941
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3942
-    {
3943
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3944
-    }
3945
-
3946
-
3947
-
3948
-
3949
-
3950
-
3951
-
3952
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3953
-
3954
-
3955
-    /**
3956
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3957
-     * 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
3958
-     * _req_data array.
3959
-     *
3960
-     * @return bool success/fail
3961
-     * @throws EE_Error
3962
-     * @throws InvalidArgumentException
3963
-     * @throws ReflectionException
3964
-     * @throws InvalidDataTypeException
3965
-     * @throws InvalidInterfaceException
3966
-     */
3967
-    protected function _process_resend_registration()
3968
-    {
3969
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3970
-        do_action(
3971
-            'AHEE__EE_Admin_Page___process_resend_registration',
3972
-            $this->_template_args['success'],
3973
-            $this->request->requestParams()
3974
-        );
3975
-        return $this->_template_args['success'];
3976
-    }
3977
-
3978
-
3979
-    /**
3980
-     * This automatically processes any payment message notifications when manual payment has been applied.
3981
-     *
3982
-     * @param EE_Payment $payment
3983
-     * @return bool success/fail
3984
-     */
3985
-    protected function _process_payment_notification(EE_Payment $payment)
3986
-    {
3987
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3988
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3989
-        $this->_template_args['success'] = apply_filters(
3990
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3991
-            false,
3992
-            $payment
3993
-        );
3994
-        return $this->_template_args['success'];
3995
-    }
3996
-
3997
-
3998
-    /**
3999
-     * @param EEM_Base      $entity_model
4000
-     * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4001
-     * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4002
-     * @param string        $delete_column  name of the field that denotes whether entity is trashed
4003
-     * @param callable|null $callback       called after entity is trashed, restored, or deleted
4004
-     * @return int|float
4005
-     * @throws EE_Error
4006
-     */
4007
-    protected function trashRestoreDeleteEntities(
4008
-        EEM_Base $entity_model,
4009
-        string $entity_PK_name,
4010
-        string $action = EE_Admin_List_Table::ACTION_DELETE,
4011
-        string $delete_column = '',
4012
-        callable $callback = null
4013
-    ) {
4014
-        $entity_PK      = $entity_model->get_primary_key_field();
4015
-        $entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4016
-        $entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4017
-        // grab ID if deleting a single entity
4018
-        if ($this->request->requestParamIsSet($entity_PK_name)) {
4019
-            $ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4020
-            return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4021
-        }
4022
-        // or grab checkbox array if bulk deleting
4023
-        $checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4024
-        if (empty($checkboxes)) {
4025
-            return 0;
4026
-        }
4027
-        $success = 0;
4028
-        $IDs     = array_keys($checkboxes);
4029
-        // cycle thru bulk action checkboxes
4030
-        foreach ($IDs as $ID) {
4031
-            // increment $success
4032
-            if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4033
-                $success++;
4034
-            }
4035
-        }
4036
-        $count = (int) count($checkboxes);
4037
-        // if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4038
-        // otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4039
-        return $success === $count ? $count : $success / $count;
4040
-    }
4041
-
4042
-
4043
-    /**
4044
-     * @param EE_Primary_Key_Field_Base $entity_PK
4045
-     * @return string
4046
-     * @throws EE_Error
4047
-     * @since   $VID:$
4048
-     */
4049
-    private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK): string
4050
-    {
4051
-        $entity_PK_type = $entity_PK->getSchemaType();
4052
-        switch ($entity_PK_type) {
4053
-            case 'boolean':
4054
-                return 'bool';
4055
-            case 'integer':
4056
-                return 'int';
4057
-            case 'number':
4058
-                return 'float';
4059
-            case 'string':
4060
-                return 'string';
4061
-        }
4062
-        throw new RuntimeException(
4063
-            sprintf(
4064
-                esc_html__(
4065
-                    '"%1$s" is an invalid schema type for the %2$s primary key.',
4066
-                    'event_espresso'
4067
-                ),
4068
-                $entity_PK_type,
4069
-                $entity_PK->get_name()
4070
-            )
4071
-        );
4072
-    }
4073
-
4074
-
4075
-    /**
4076
-     * @param EEM_Base      $entity_model
4077
-     * @param int|string    $entity_ID
4078
-     * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4079
-     * @param string        $delete_column name of the field that denotes whether entity is trashed
4080
-     * @param callable|null $callback      called after entity is trashed, restored, or deleted
4081
-     * @return bool
4082
-     */
4083
-    protected function trashRestoreDeleteEntity(
4084
-        EEM_Base $entity_model,
4085
-        $entity_ID,
4086
-        string $action,
4087
-        string $delete_column,
4088
-        callable $callback = null
4089
-    ) {
4090
-        $entity_ID = absint($entity_ID);
4091
-        if (! $entity_ID) {
4092
-            $this->trashRestoreDeleteError($action, $entity_model);
4093
-        }
4094
-        $result = 0;
4095
-        try {
4096
-            switch ($action) {
4097
-                case EE_Admin_List_Table::ACTION_DELETE:
4098
-                    $result = (bool) $entity_model->delete_permanently_by_ID($entity_ID);
4099
-                    break;
4100
-                case EE_Admin_List_Table::ACTION_RESTORE:
4101
-                    $this->validateDeleteColumn($entity_model, $delete_column);
4102
-                    $result = $entity_model->update_by_ID([$delete_column => 0], $entity_ID);
4103
-                    break;
4104
-                case EE_Admin_List_Table::ACTION_TRASH:
4105
-                    $this->validateDeleteColumn($entity_model, $delete_column);
4106
-                    $result = $entity_model->update_by_ID([$delete_column => 1], $entity_ID);
4107
-                    break;
4108
-            }
4109
-        } catch (Exception $exception) {
4110
-            $this->trashRestoreDeleteError($action, $entity_model, $exception);
4111
-        }
4112
-        if (is_callable($callback)) {
4113
-            call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4114
-        }
4115
-        return $result;
4116
-    }
4117
-
4118
-
4119
-    /**
4120
-     * @param EEM_Base $entity_model
4121
-     * @param string   $delete_column
4122
-     * @since $VID:$
4123
-     */
4124
-    private function validateDeleteColumn(EEM_Base $entity_model, string $delete_column)
4125
-    {
4126
-        if (empty($delete_column)) {
4127
-            throw new DomainException(
4128
-                sprintf(
4129
-                    esc_html__(
4130
-                        'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4131
-                        'event_espresso'
4132
-                    ),
4133
-                    $entity_model->get_this_model_name()
4134
-                )
4135
-            );
4136
-        }
4137
-        if (! $entity_model->has_field($delete_column)) {
4138
-            throw new DomainException(
4139
-                sprintf(
4140
-                    esc_html__(
4141
-                        'The %1$s field does not exist on the %2$s model.',
4142
-                        'event_espresso'
4143
-                    ),
4144
-                    $delete_column,
4145
-                    $entity_model->get_this_model_name()
4146
-                )
4147
-            );
4148
-        }
4149
-    }
4150
-
4151
-
4152
-    /**
4153
-     * @param EEM_Base       $entity_model
4154
-     * @param Exception|null $exception
4155
-     * @param string         $action
4156
-     * @since $VID:$
4157
-     */
4158
-    private function trashRestoreDeleteError(string $action, EEM_Base $entity_model, ?Exception $exception = null)
4159
-    {
4160
-        if ($exception instanceof Exception) {
4161
-            throw new RuntimeException(
4162
-                sprintf(
4163
-                    esc_html__(
4164
-                        'Could not %1$s the %2$s because the following error occurred: %3$s',
4165
-                        'event_espresso'
4166
-                    ),
4167
-                    $action,
4168
-                    $entity_model->get_this_model_name(),
4169
-                    $exception->getMessage()
4170
-                )
4171
-            );
4172
-        }
4173
-        throw new RuntimeException(
4174
-            sprintf(
4175
-                esc_html__(
4176
-                    'Could not %1$s the %2$s because an invalid ID was received.',
4177
-                    'event_espresso'
4178
-                ),
4179
-                $action,
4180
-                $entity_model->get_this_model_name()
4181
-            )
4182
-        );
4183
-    }
2563
+	}
2564
+
2565
+
2566
+	/**
2567
+	 * facade for add_meta_box
2568
+	 *
2569
+	 * @param string  $action        where the metabox gets displayed
2570
+	 * @param string  $title         Title of Metabox (output in metabox header)
2571
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2572
+	 *                               instead of the one created in here.
2573
+	 * @param array   $callback_args an array of args supplied for the metabox
2574
+	 * @param string  $column        what metabox column
2575
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2576
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2577
+	 *                               created but just set our own callback for wp's add_meta_box.
2578
+	 * @throws DomainException
2579
+	 */
2580
+	public function _add_admin_page_meta_box(
2581
+		$action,
2582
+		$title,
2583
+		$callback,
2584
+		$callback_args,
2585
+		$column = 'normal',
2586
+		$priority = 'high',
2587
+		$create_func = true
2588
+	) {
2589
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2590
+		// 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.
2591
+		if (empty($callback_args) && $create_func) {
2592
+			$callback_args = [
2593
+				'template_path' => $this->_template_path,
2594
+				'template_args' => $this->_template_args,
2595
+			];
2596
+		}
2597
+		// 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)
2598
+		$call_back_func = $create_func
2599
+			? function ($post, $metabox) {
2600
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2601
+				echo EEH_Template::display_template(
2602
+					$metabox['args']['template_path'],
2603
+					$metabox['args']['template_args'],
2604
+					true
2605
+				);
2606
+			}
2607
+			: $callback;
2608
+		add_meta_box(
2609
+			str_replace('_', '-', $action) . '-mbox',
2610
+			$title,
2611
+			$call_back_func,
2612
+			$this->_wp_page_slug,
2613
+			$column,
2614
+			$priority,
2615
+			$callback_args
2616
+		);
2617
+	}
2618
+
2619
+
2620
+	/**
2621
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2622
+	 *
2623
+	 * @throws DomainException
2624
+	 * @throws EE_Error
2625
+	 */
2626
+	public function display_admin_page_with_metabox_columns()
2627
+	{
2628
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2629
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2630
+			$this->_column_template_path,
2631
+			$this->_template_args,
2632
+			true
2633
+		);
2634
+		// the final wrapper
2635
+		$this->admin_page_wrapper();
2636
+	}
2637
+
2638
+
2639
+	/**
2640
+	 * generates  HTML wrapper for an admin details page
2641
+	 *
2642
+	 * @return void
2643
+	 * @throws EE_Error
2644
+	 * @throws DomainException
2645
+	 */
2646
+	public function display_admin_page_with_sidebar()
2647
+	{
2648
+		$this->_display_admin_page(true);
2649
+	}
2650
+
2651
+
2652
+	/**
2653
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2654
+	 *
2655
+	 * @return void
2656
+	 * @throws EE_Error
2657
+	 * @throws DomainException
2658
+	 */
2659
+	public function display_admin_page_with_no_sidebar()
2660
+	{
2661
+		$this->_display_admin_page();
2662
+	}
2663
+
2664
+
2665
+	/**
2666
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2667
+	 *
2668
+	 * @return void
2669
+	 * @throws EE_Error
2670
+	 * @throws DomainException
2671
+	 */
2672
+	public function display_about_admin_page()
2673
+	{
2674
+		$this->_display_admin_page(false, true);
2675
+	}
2676
+
2677
+
2678
+	/**
2679
+	 * display_admin_page
2680
+	 * contains the code for actually displaying an admin page
2681
+	 *
2682
+	 * @param boolean $sidebar true with sidebar, false without
2683
+	 * @param boolean $about   use the about_admin_wrapper instead of the default.
2684
+	 * @return void
2685
+	 * @throws DomainException
2686
+	 * @throws EE_Error
2687
+	 */
2688
+	private function _display_admin_page($sidebar = false, $about = false)
2689
+	{
2690
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2691
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2692
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2693
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2694
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2695
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2696
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2697
+			? 'poststuff'
2698
+			: 'espresso-default-admin';
2699
+		$template_path                                     = $sidebar
2700
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2701
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2702
+		if ($this->request->isAjax()) {
2703
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2704
+		}
2705
+		$template_path                                     = ! empty($this->_column_template_path)
2706
+			? $this->_column_template_path : $template_path;
2707
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2708
+			? $this->_template_args['admin_page_content']
2709
+			: '';
2710
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2711
+			? $this->_template_args['before_admin_page_content']
2712
+			: '';
2713
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2714
+			? $this->_template_args['after_admin_page_content']
2715
+			: '';
2716
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2717
+			$template_path,
2718
+			$this->_template_args,
2719
+			true
2720
+		);
2721
+		// the final template wrapper
2722
+		$this->admin_page_wrapper($about);
2723
+	}
2724
+
2725
+
2726
+	/**
2727
+	 * This is used to display caf preview pages.
2728
+	 *
2729
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2730
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2731
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2732
+	 * @return void
2733
+	 * @throws DomainException
2734
+	 * @throws EE_Error
2735
+	 * @throws InvalidArgumentException
2736
+	 * @throws InvalidDataTypeException
2737
+	 * @throws InvalidInterfaceException
2738
+	 * @since 4.3.2
2739
+	 */
2740
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2741
+	{
2742
+		// let's generate a default preview action button if there isn't one already present.
2743
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2744
+			'Upgrade to Event Espresso 4 Right Now',
2745
+			'event_espresso'
2746
+		);
2747
+		$buy_now_url                                   = add_query_arg(
2748
+			[
2749
+				'ee_ver'       => 'ee4',
2750
+				'utm_source'   => 'ee4_plugin_admin',
2751
+				'utm_medium'   => 'link',
2752
+				'utm_campaign' => $utm_campaign_source,
2753
+				'utm_content'  => 'buy_now_button',
2754
+			],
2755
+			'https://eventespresso.com/pricing/'
2756
+		);
2757
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2758
+			? $this->get_action_link_or_button(
2759
+				'',
2760
+				'buy_now',
2761
+				[],
2762
+				'button-primary button-large',
2763
+				esc_url_raw($buy_now_url),
2764
+				true
2765
+			)
2766
+			: $this->_template_args['preview_action_button'];
2767
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2768
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2769
+			$this->_template_args,
2770
+			true
2771
+		);
2772
+		$this->_display_admin_page($display_sidebar);
2773
+	}
2774
+
2775
+
2776
+	/**
2777
+	 * display_admin_list_table_page_with_sidebar
2778
+	 * generates HTML wrapper for an admin_page with list_table
2779
+	 *
2780
+	 * @return void
2781
+	 * @throws EE_Error
2782
+	 * @throws DomainException
2783
+	 */
2784
+	public function display_admin_list_table_page_with_sidebar()
2785
+	{
2786
+		$this->_display_admin_list_table_page(true);
2787
+	}
2788
+
2789
+
2790
+	/**
2791
+	 * display_admin_list_table_page_with_no_sidebar
2792
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2793
+	 *
2794
+	 * @return void
2795
+	 * @throws EE_Error
2796
+	 * @throws DomainException
2797
+	 */
2798
+	public function display_admin_list_table_page_with_no_sidebar()
2799
+	{
2800
+		$this->_display_admin_list_table_page();
2801
+	}
2802
+
2803
+
2804
+	/**
2805
+	 * generates html wrapper for an admin_list_table page
2806
+	 *
2807
+	 * @param boolean $sidebar whether to display with sidebar or not.
2808
+	 * @return void
2809
+	 * @throws DomainException
2810
+	 * @throws EE_Error
2811
+	 */
2812
+	private function _display_admin_list_table_page($sidebar = false)
2813
+	{
2814
+		// setup search attributes
2815
+		$this->_set_search_attributes();
2816
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
2817
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2818
+		$this->_template_args['table_url']        = $this->request->isAjax()
2819
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2820
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2821
+		$this->_template_args['list_table']       = $this->_list_table_object;
2822
+		$this->_template_args['current_route']    = $this->_req_action;
2823
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2824
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2825
+		if (! empty($ajax_sorting_callback)) {
2826
+			$sortable_list_table_form_fields = wp_nonce_field(
2827
+				$ajax_sorting_callback . '_nonce',
2828
+				$ajax_sorting_callback . '_nonce',
2829
+				false,
2830
+				false
2831
+			);
2832
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2833
+												. $this->page_slug
2834
+												. '" />';
2835
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2836
+												. $ajax_sorting_callback
2837
+												. '" />';
2838
+		} else {
2839
+			$sortable_list_table_form_fields = '';
2840
+		}
2841
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2842
+		$hidden_form_fields                                      =
2843
+			isset($this->_template_args['list_table_hidden_fields'])
2844
+				? $this->_template_args['list_table_hidden_fields']
2845
+				: '';
2846
+		$nonce_ref                                               = $this->_req_action . '_nonce';
2847
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
2848
+																	. $nonce_ref
2849
+																	. '" value="'
2850
+																	. wp_create_nonce($nonce_ref)
2851
+																	. '">';
2852
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2853
+		// display message about search results?
2854
+		$search = $this->request->getRequestParam('s');
2855
+		$this->_template_args['before_list_table'] .= ! empty($search)
2856
+			? '<p class="ee-search-results">' . sprintf(
2857
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2858
+				trim($search, '%')
2859
+			) . '</p>'
2860
+			: '';
2861
+		// filter before_list_table template arg
2862
+		$this->_template_args['before_list_table'] = apply_filters(
2863
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2864
+			$this->_template_args['before_list_table'],
2865
+			$this->page_slug,
2866
+			$this->request->requestParams(),
2867
+			$this->_req_action
2868
+		);
2869
+		// convert to array and filter again
2870
+		// arrays are easier to inject new items in a specific location,
2871
+		// but would not be backwards compatible, so we have to add a new filter
2872
+		$this->_template_args['before_list_table'] = implode(
2873
+			" \n",
2874
+			(array) apply_filters(
2875
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2876
+				(array) $this->_template_args['before_list_table'],
2877
+				$this->page_slug,
2878
+				$this->request->requestParams(),
2879
+				$this->_req_action
2880
+			)
2881
+		);
2882
+		// filter after_list_table template arg
2883
+		$this->_template_args['after_list_table'] = apply_filters(
2884
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2885
+			$this->_template_args['after_list_table'],
2886
+			$this->page_slug,
2887
+			$this->request->requestParams(),
2888
+			$this->_req_action
2889
+		);
2890
+		// convert to array and filter again
2891
+		// arrays are easier to inject new items in a specific location,
2892
+		// but would not be backwards compatible, so we have to add a new filter
2893
+		$this->_template_args['after_list_table']   = implode(
2894
+			" \n",
2895
+			(array) apply_filters(
2896
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2897
+				(array) $this->_template_args['after_list_table'],
2898
+				$this->page_slug,
2899
+				$this->request->requestParams(),
2900
+				$this->_req_action
2901
+			)
2902
+		);
2903
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2904
+			$template_path,
2905
+			$this->_template_args,
2906
+			true
2907
+		);
2908
+		// the final template wrapper
2909
+		if ($sidebar) {
2910
+			$this->display_admin_page_with_sidebar();
2911
+		} else {
2912
+			$this->display_admin_page_with_no_sidebar();
2913
+		}
2914
+	}
2915
+
2916
+
2917
+	/**
2918
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2919
+	 * html string for the legend.
2920
+	 * $items are expected in an array in the following format:
2921
+	 * $legend_items = array(
2922
+	 *        'item_id' => array(
2923
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2924
+	 *            'desc' => esc_html__('localized description of item');
2925
+	 *        )
2926
+	 * );
2927
+	 *
2928
+	 * @param array $items see above for format of array
2929
+	 * @return string html string of legend
2930
+	 * @throws DomainException
2931
+	 */
2932
+	protected function _display_legend($items)
2933
+	{
2934
+		$this->_template_args['items'] = apply_filters(
2935
+			'FHEE__EE_Admin_Page___display_legend__items',
2936
+			(array) $items,
2937
+			$this
2938
+		);
2939
+		return EEH_Template::display_template(
2940
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2941
+			$this->_template_args,
2942
+			true
2943
+		);
2944
+	}
2945
+
2946
+
2947
+	/**
2948
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2949
+	 * The returned json object is created from an array in the following format:
2950
+	 * array(
2951
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2952
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
2953
+	 *  'notices' => '', // - contains any EE_Error formatted notices
2954
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
2955
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
2956
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
2957
+	 *  that might be included in here)
2958
+	 * )
2959
+	 * The json object is populated by whatever is set in the $_template_args property.
2960
+	 *
2961
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
2962
+	 *                                 instead of displayed.
2963
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
2964
+	 * @return void
2965
+	 * @throws EE_Error
2966
+	 */
2967
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
2968
+	{
2969
+		// make sure any EE_Error notices have been handled.
2970
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
2971
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
2972
+		unset($this->_template_args['data']);
2973
+		$json = [
2974
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2975
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2976
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2977
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2978
+			'notices'   => EE_Error::get_notices(),
2979
+			'content'   => isset($this->_template_args['admin_page_content'])
2980
+				? $this->_template_args['admin_page_content'] : '',
2981
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
2982
+			'isEEajax'  => true
2983
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2984
+		];
2985
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
2986
+		if (null === error_get_last() || ! headers_sent()) {
2987
+			header('Content-Type: application/json; charset=UTF-8');
2988
+		}
2989
+		echo wp_json_encode($json);
2990
+		exit();
2991
+	}
2992
+
2993
+
2994
+	/**
2995
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2996
+	 *
2997
+	 * @return void
2998
+	 * @throws EE_Error
2999
+	 */
3000
+	public function return_json()
3001
+	{
3002
+		if ($this->request->isAjax()) {
3003
+			$this->_return_json();
3004
+		} else {
3005
+			throw new EE_Error(
3006
+				sprintf(
3007
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3008
+					__FUNCTION__
3009
+				)
3010
+			);
3011
+		}
3012
+	}
3013
+
3014
+
3015
+	/**
3016
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3017
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3018
+	 *
3019
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3020
+	 */
3021
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3022
+	{
3023
+		$this->_hook_obj = $hook_obj;
3024
+	}
3025
+
3026
+
3027
+	/**
3028
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3029
+	 *
3030
+	 * @param boolean $about whether to use the special about page wrapper or default.
3031
+	 * @return void
3032
+	 * @throws DomainException
3033
+	 * @throws EE_Error
3034
+	 */
3035
+	public function admin_page_wrapper($about = false)
3036
+	{
3037
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3038
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3039
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3040
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3041
+
3042
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3043
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3044
+			isset($this->_template_args['before_admin_page_content'])
3045
+				? $this->_template_args['before_admin_page_content']
3046
+				: ''
3047
+		);
3048
+
3049
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3050
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3051
+			isset($this->_template_args['after_admin_page_content'])
3052
+				? $this->_template_args['after_admin_page_content']
3053
+				: ''
3054
+		);
3055
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3056
+
3057
+		if ($this->request->isAjax()) {
3058
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3059
+				// $template_path,
3060
+				EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3061
+				$this->_template_args,
3062
+				true
3063
+			);
3064
+			$this->_return_json();
3065
+		}
3066
+		// load settings page wrapper template
3067
+		$template_path = $about
3068
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3069
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3070
+
3071
+		EEH_Template::display_template($template_path, $this->_template_args);
3072
+	}
3073
+
3074
+
3075
+	/**
3076
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3077
+	 *
3078
+	 * @return string html
3079
+	 * @throws EE_Error
3080
+	 */
3081
+	protected function _get_main_nav_tabs()
3082
+	{
3083
+		// let's generate the html using the EEH_Tabbed_Content helper.
3084
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3085
+		// (rather than setting in the page_routes array)
3086
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3087
+	}
3088
+
3089
+
3090
+	/**
3091
+	 *        sort nav tabs
3092
+	 *
3093
+	 * @param $a
3094
+	 * @param $b
3095
+	 * @return int
3096
+	 */
3097
+	private function _sort_nav_tabs($a, $b)
3098
+	{
3099
+		if ($a['order'] === $b['order']) {
3100
+			return 0;
3101
+		}
3102
+		return ($a['order'] < $b['order']) ? -1 : 1;
3103
+	}
3104
+
3105
+
3106
+	/**
3107
+	 *    generates HTML for the forms used on admin pages
3108
+	 *
3109
+	 * @param array  $input_vars   - array of input field details
3110
+	 * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3111
+	 *                             use)
3112
+	 * @param bool   $id
3113
+	 * @return array|string
3114
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3115
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3116
+	 */
3117
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3118
+	{
3119
+		return $generator === 'string'
3120
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3121
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3122
+	}
3123
+
3124
+
3125
+	/**
3126
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3127
+	 *
3128
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3129
+	 *                                   Close" button.
3130
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3131
+	 *                                   'Save', [1] => 'save & close')
3132
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3133
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3134
+	 *                                   default actions by submitting some other value.
3135
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3136
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3137
+	 *                                   close (normal form handling).
3138
+	 */
3139
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3140
+	{
3141
+		// make sure $text and $actions are in an array
3142
+		$text          = (array) $text;
3143
+		$actions       = (array) $actions;
3144
+		$referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3145
+		$button_text   = ! empty($text)
3146
+			? $text
3147
+			: [
3148
+				esc_html__('Save', 'event_espresso'),
3149
+				esc_html__('Save and Close', 'event_espresso'),
3150
+			];
3151
+		$default_names = ['save', 'save_and_close'];
3152
+		$buttons = '';
3153
+		foreach ($button_text as $key => $button) {
3154
+			$ref     = $default_names[ $key ];
3155
+			$name    = ! empty($actions) ? $actions[ $key ] : $ref;
3156
+			$buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3157
+						. 'value="' . $button . '" name="' . $name . '" '
3158
+						. 'id="' . $this->_current_view . '_' . $ref . '" />';
3159
+			if (! $both) {
3160
+				break;
3161
+			}
3162
+		}
3163
+		// add in a hidden index for the current page (so save and close redirects properly)
3164
+		$buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3165
+				   . $referrer_url
3166
+				   . '" />';
3167
+		$this->_template_args['save_buttons'] = $buttons;
3168
+	}
3169
+
3170
+
3171
+	/**
3172
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3173
+	 *
3174
+	 * @param string $route
3175
+	 * @param array  $additional_hidden_fields
3176
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3177
+	 * @since 4.6.0
3178
+	 */
3179
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3180
+	{
3181
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3182
+	}
3183
+
3184
+
3185
+	/**
3186
+	 * set form open and close tags on add/edit pages.
3187
+	 *
3188
+	 * @param string $route                    the route you want the form to direct to
3189
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3190
+	 * @return void
3191
+	 */
3192
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3193
+	{
3194
+		if (empty($route)) {
3195
+			$user_msg = esc_html__(
3196
+				'An error occurred. No action was set for this page\'s form.',
3197
+				'event_espresso'
3198
+			);
3199
+			$dev_msg  = $user_msg . "\n"
3200
+						. sprintf(
3201
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3202
+							__FUNCTION__,
3203
+							__CLASS__
3204
+						);
3205
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3206
+		}
3207
+		// open form
3208
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3209
+															 . $this->_admin_base_url
3210
+															 . '" id="'
3211
+															 . $route
3212
+															 . '_event_form" >';
3213
+		// add nonce
3214
+		$nonce                                             =
3215
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3216
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3217
+		// add REQUIRED form action
3218
+		$hidden_fields = [
3219
+			'action' => ['type' => 'hidden', 'value' => $route],
3220
+		];
3221
+		// merge arrays
3222
+		$hidden_fields = is_array($additional_hidden_fields)
3223
+			? array_merge($hidden_fields, $additional_hidden_fields)
3224
+			: $hidden_fields;
3225
+		// generate form fields
3226
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3227
+		// add fields to form
3228
+		foreach ((array) $form_fields as $form_field) {
3229
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3230
+		}
3231
+		// close form
3232
+		$this->_template_args['after_admin_page_content'] = '</form>';
3233
+	}
3234
+
3235
+
3236
+	/**
3237
+	 * Public Wrapper for _redirect_after_action() method since its
3238
+	 * discovered it would be useful for external code to have access.
3239
+	 *
3240
+	 * @param bool   $success
3241
+	 * @param string $what
3242
+	 * @param string $action_desc
3243
+	 * @param array  $query_args
3244
+	 * @param bool   $override_overwrite
3245
+	 * @throws EE_Error
3246
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3247
+	 * @since 4.5.0
3248
+	 */
3249
+	public function redirect_after_action(
3250
+		$success = false,
3251
+		$what = 'item',
3252
+		$action_desc = 'processed',
3253
+		$query_args = [],
3254
+		$override_overwrite = false
3255
+	) {
3256
+		$this->_redirect_after_action(
3257
+			$success,
3258
+			$what,
3259
+			$action_desc,
3260
+			$query_args,
3261
+			$override_overwrite
3262
+		);
3263
+	}
3264
+
3265
+
3266
+	/**
3267
+	 * Helper method for merging existing request data with the returned redirect url.
3268
+	 *
3269
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3270
+	 * filters are still applied.
3271
+	 *
3272
+	 * @param array $new_route_data
3273
+	 * @return array
3274
+	 */
3275
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3276
+	{
3277
+		foreach ($this->request->requestParams() as $ref => $value) {
3278
+			// unset nonces
3279
+			if (strpos($ref, 'nonce') !== false) {
3280
+				$this->request->unSetRequestParam($ref);
3281
+				continue;
3282
+			}
3283
+			// urlencode values.
3284
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3285
+			$this->request->setRequestParam($ref, $value);
3286
+		}
3287
+		return array_merge($this->request->requestParams(), $new_route_data);
3288
+	}
3289
+
3290
+
3291
+	/**
3292
+	 *    _redirect_after_action
3293
+	 *
3294
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3295
+	 * @param string $what               - what the action was performed on
3296
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3297
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3298
+	 *                                   action is completed
3299
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3300
+	 *                                   override this so that they show.
3301
+	 * @return void
3302
+	 * @throws EE_Error
3303
+	 */
3304
+	protected function _redirect_after_action(
3305
+		$success = 0,
3306
+		$what = 'item',
3307
+		$action_desc = 'processed',
3308
+		$query_args = [],
3309
+		$override_overwrite = false
3310
+	) {
3311
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3312
+		// class name for actions/filters.
3313
+		$classname = get_class($this);
3314
+		// set redirect url.
3315
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3316
+		// otherwise we go with whatever is set as the _admin_base_url
3317
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3318
+		$notices      = EE_Error::get_notices(false);
3319
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3320
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3321
+			EE_Error::overwrite_success();
3322
+		}
3323
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3324
+			// how many records affected ? more than one record ? or just one ?
3325
+			if ($success > 1) {
3326
+				// set plural msg
3327
+				EE_Error::add_success(
3328
+					sprintf(
3329
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3330
+						$what,
3331
+						$action_desc
3332
+					),
3333
+					__FILE__,
3334
+					__FUNCTION__,
3335
+					__LINE__
3336
+				);
3337
+			} elseif ($success === 1) {
3338
+				// set singular msg
3339
+				EE_Error::add_success(
3340
+					sprintf(
3341
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3342
+						$what,
3343
+						$action_desc
3344
+					),
3345
+					__FILE__,
3346
+					__FUNCTION__,
3347
+					__LINE__
3348
+				);
3349
+			}
3350
+		}
3351
+		// check that $query_args isn't something crazy
3352
+		if (! is_array($query_args)) {
3353
+			$query_args = [];
3354
+		}
3355
+		/**
3356
+		 * Allow injecting actions before the query_args are modified for possible different
3357
+		 * redirections on save and close actions
3358
+		 *
3359
+		 * @param array $query_args       The original query_args array coming into the
3360
+		 *                                method.
3361
+		 * @since 4.2.0
3362
+		 */
3363
+		do_action(
3364
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3365
+			$query_args
3366
+		);
3367
+		// calculate where we're going (if we have a "save and close" button pushed)
3368
+
3369
+		if (
3370
+			$this->request->requestParamIsSet('save_and_close')
3371
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3372
+		) {
3373
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3374
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3375
+			// regenerate query args array from referrer URL
3376
+			parse_str($parsed_url['query'], $query_args);
3377
+			// correct page and action will be in the query args now
3378
+			$redirect_url = admin_url('admin.php');
3379
+		}
3380
+		// merge any default query_args set in _default_route_query_args property
3381
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3382
+			$args_to_merge = [];
3383
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3384
+				// is there a wp_referer array in our _default_route_query_args property?
3385
+				if ($query_param === 'wp_referer') {
3386
+					$query_value = (array) $query_value;
3387
+					foreach ($query_value as $reference => $value) {
3388
+						if (strpos($reference, 'nonce') !== false) {
3389
+							continue;
3390
+						}
3391
+						// finally we will override any arguments in the referer with
3392
+						// what might be set on the _default_route_query_args array.
3393
+						if (isset($this->_default_route_query_args[ $reference ])) {
3394
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3395
+						} else {
3396
+							$args_to_merge[ $reference ] = urlencode($value);
3397
+						}
3398
+					}
3399
+					continue;
3400
+				}
3401
+				$args_to_merge[ $query_param ] = $query_value;
3402
+			}
3403
+			// now let's merge these arguments but override with what was specifically sent in to the
3404
+			// redirect.
3405
+			$query_args = array_merge($args_to_merge, $query_args);
3406
+		}
3407
+		$this->_process_notices($query_args);
3408
+		// generate redirect url
3409
+		// if redirecting to anything other than the main page, add a nonce
3410
+		if (isset($query_args['action'])) {
3411
+			// manually generate wp_nonce and merge that with the query vars
3412
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3413
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3414
+		}
3415
+		// we're adding some hooks and filters in here for processing any things just before redirects
3416
+		// (example: an admin page has done an insert or update and we want to run something after that).
3417
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3418
+		$redirect_url = apply_filters(
3419
+			'FHEE_redirect_' . $classname . $this->_req_action,
3420
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3421
+			$query_args
3422
+		);
3423
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3424
+		if ($this->request->isAjax()) {
3425
+			$default_data                    = [
3426
+				'close'        => true,
3427
+				'redirect_url' => $redirect_url,
3428
+				'where'        => 'main',
3429
+				'what'         => 'append',
3430
+			];
3431
+			$this->_template_args['success'] = $success;
3432
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3433
+				$default_data,
3434
+				$this->_template_args['data']
3435
+			) : $default_data;
3436
+			$this->_return_json();
3437
+		}
3438
+		wp_safe_redirect($redirect_url);
3439
+		exit();
3440
+	}
3441
+
3442
+
3443
+	/**
3444
+	 * process any notices before redirecting (or returning ajax request)
3445
+	 * This method sets the $this->_template_args['notices'] attribute;
3446
+	 *
3447
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3448
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3449
+	 *                                  page_routes haven't been defined yet.
3450
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3451
+	 *                                  still save a transient for the notice.
3452
+	 * @return void
3453
+	 * @throws EE_Error
3454
+	 */
3455
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3456
+	{
3457
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3458
+		if ($this->request->isAjax()) {
3459
+			$notices = EE_Error::get_notices(false);
3460
+			if (empty($this->_template_args['success'])) {
3461
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3462
+			}
3463
+			if (empty($this->_template_args['errors'])) {
3464
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3465
+			}
3466
+			if (empty($this->_template_args['attention'])) {
3467
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3468
+			}
3469
+		}
3470
+		$this->_template_args['notices'] = EE_Error::get_notices();
3471
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3472
+		if (! $this->request->isAjax() || $sticky_notices) {
3473
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3474
+			$this->_add_transient(
3475
+				$route,
3476
+				$this->_template_args['notices'],
3477
+				true,
3478
+				$skip_route_verify
3479
+			);
3480
+		}
3481
+	}
3482
+
3483
+
3484
+	/**
3485
+	 * get_action_link_or_button
3486
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3487
+	 *
3488
+	 * @param string $action        use this to indicate which action the url is generated with.
3489
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3490
+	 *                              property.
3491
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3492
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3493
+	 * @param string $base_url      If this is not provided
3494
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3495
+	 *                              Otherwise this value will be used.
3496
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3497
+	 * @return string
3498
+	 * @throws InvalidArgumentException
3499
+	 * @throws InvalidInterfaceException
3500
+	 * @throws InvalidDataTypeException
3501
+	 * @throws EE_Error
3502
+	 */
3503
+	public function get_action_link_or_button(
3504
+		$action,
3505
+		$type = 'add',
3506
+		$extra_request = [],
3507
+		$class = 'button-primary',
3508
+		$base_url = '',
3509
+		$exclude_nonce = false
3510
+	) {
3511
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3512
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3513
+			throw new EE_Error(
3514
+				sprintf(
3515
+					esc_html__(
3516
+						'There is no page route for given action for the button.  This action was given: %s',
3517
+						'event_espresso'
3518
+					),
3519
+					$action
3520
+				)
3521
+			);
3522
+		}
3523
+		if (! isset($this->_labels['buttons'][ $type ])) {
3524
+			throw new EE_Error(
3525
+				sprintf(
3526
+					esc_html__(
3527
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3528
+						'event_espresso'
3529
+					),
3530
+					$type
3531
+				)
3532
+			);
3533
+		}
3534
+		// finally check user access for this button.
3535
+		$has_access = $this->check_user_access($action, true);
3536
+		if (! $has_access) {
3537
+			return '';
3538
+		}
3539
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3540
+		$query_args = [
3541
+			'action' => $action,
3542
+		];
3543
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3544
+		if (! empty($extra_request)) {
3545
+			$query_args = array_merge($extra_request, $query_args);
3546
+		}
3547
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3548
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3549
+	}
3550
+
3551
+
3552
+	/**
3553
+	 * _per_page_screen_option
3554
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3555
+	 *
3556
+	 * @return void
3557
+	 * @throws InvalidArgumentException
3558
+	 * @throws InvalidInterfaceException
3559
+	 * @throws InvalidDataTypeException
3560
+	 */
3561
+	protected function _per_page_screen_option()
3562
+	{
3563
+		$option = 'per_page';
3564
+		$args   = [
3565
+			'label'   => apply_filters(
3566
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3567
+				$this->_admin_page_title,
3568
+				$this
3569
+			),
3570
+			'default' => (int) apply_filters(
3571
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3572
+				20
3573
+			),
3574
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3575
+		];
3576
+		// ONLY add the screen option if the user has access to it.
3577
+		if ($this->check_user_access($this->_current_view, true)) {
3578
+			add_screen_option($option, $args);
3579
+		}
3580
+	}
3581
+
3582
+
3583
+	/**
3584
+	 * set_per_page_screen_option
3585
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3586
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3587
+	 * admin_menu.
3588
+	 *
3589
+	 * @return void
3590
+	 */
3591
+	private function _set_per_page_screen_options()
3592
+	{
3593
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3594
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3595
+			if (! $user = wp_get_current_user()) {
3596
+				return;
3597
+			}
3598
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3599
+			if (! $option) {
3600
+				return;
3601
+			}
3602
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3603
+			$map_option = $option;
3604
+			$option     = str_replace('-', '_', $option);
3605
+			switch ($map_option) {
3606
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3607
+					$max_value = apply_filters(
3608
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3609
+						999,
3610
+						$this->_current_page,
3611
+						$this->_current_view
3612
+					);
3613
+					if ($value < 1) {
3614
+						return;
3615
+					}
3616
+					$value = min($value, $max_value);
3617
+					break;
3618
+				default:
3619
+					$value = apply_filters(
3620
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3621
+						false,
3622
+						$option,
3623
+						$value
3624
+					);
3625
+					if (false === $value) {
3626
+						return;
3627
+					}
3628
+					break;
3629
+			}
3630
+			update_user_meta($user->ID, $option, $value);
3631
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3632
+			exit;
3633
+		}
3634
+	}
3635
+
3636
+
3637
+	/**
3638
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3639
+	 *
3640
+	 * @param array $data array that will be assigned to template args.
3641
+	 */
3642
+	public function set_template_args($data)
3643
+	{
3644
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3645
+	}
3646
+
3647
+
3648
+	/**
3649
+	 * This makes available the WP transient system for temporarily moving data between routes
3650
+	 *
3651
+	 * @param string $route             the route that should receive the transient
3652
+	 * @param array  $data              the data that gets sent
3653
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3654
+	 *                                  normal route transient.
3655
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3656
+	 *                                  when we are adding a transient before page_routes have been defined.
3657
+	 * @return void
3658
+	 * @throws EE_Error
3659
+	 */
3660
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3661
+	{
3662
+		$user_id = get_current_user_id();
3663
+		if (! $skip_route_verify) {
3664
+			$this->_verify_route($route);
3665
+		}
3666
+		// now let's set the string for what kind of transient we're setting
3667
+		$transient = $notices
3668
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3669
+			: 'rte_tx_' . $route . '_' . $user_id;
3670
+		$data      = $notices ? ['notices' => $data] : $data;
3671
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3672
+		$existing = is_multisite() && is_network_admin()
3673
+			? get_site_transient($transient)
3674
+			: get_transient($transient);
3675
+		if ($existing) {
3676
+			$data = array_merge((array) $data, (array) $existing);
3677
+		}
3678
+		if (is_multisite() && is_network_admin()) {
3679
+			set_site_transient($transient, $data, 8);
3680
+		} else {
3681
+			set_transient($transient, $data, 8);
3682
+		}
3683
+	}
3684
+
3685
+
3686
+	/**
3687
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3688
+	 *
3689
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3690
+	 * @param string $route
3691
+	 * @return mixed data
3692
+	 */
3693
+	protected function _get_transient($notices = false, $route = '')
3694
+	{
3695
+		$user_id   = get_current_user_id();
3696
+		$route     = ! $route ? $this->_req_action : $route;
3697
+		$transient = $notices
3698
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3699
+			: 'rte_tx_' . $route . '_' . $user_id;
3700
+		$data      = is_multisite() && is_network_admin()
3701
+			? get_site_transient($transient)
3702
+			: get_transient($transient);
3703
+		// delete transient after retrieval (just in case it hasn't expired);
3704
+		if (is_multisite() && is_network_admin()) {
3705
+			delete_site_transient($transient);
3706
+		} else {
3707
+			delete_transient($transient);
3708
+		}
3709
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3710
+	}
3711
+
3712
+
3713
+	/**
3714
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3715
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3716
+	 * default route callback on the EE_Admin page you want it run.)
3717
+	 *
3718
+	 * @return void
3719
+	 */
3720
+	protected function _transient_garbage_collection()
3721
+	{
3722
+		global $wpdb;
3723
+		// retrieve all existing transients
3724
+		$query =
3725
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3726
+		if ($results = $wpdb->get_results($query)) {
3727
+			foreach ($results as $result) {
3728
+				$transient = str_replace('_transient_', '', $result->option_name);
3729
+				get_transient($transient);
3730
+				if (is_multisite() && is_network_admin()) {
3731
+					get_site_transient($transient);
3732
+				}
3733
+			}
3734
+		}
3735
+	}
3736
+
3737
+
3738
+	/**
3739
+	 * get_view
3740
+	 *
3741
+	 * @return string content of _view property
3742
+	 */
3743
+	public function get_view()
3744
+	{
3745
+		return $this->_view;
3746
+	}
3747
+
3748
+
3749
+	/**
3750
+	 * getter for the protected $_views property
3751
+	 *
3752
+	 * @return array
3753
+	 */
3754
+	public function get_views()
3755
+	{
3756
+		return $this->_views;
3757
+	}
3758
+
3759
+
3760
+	/**
3761
+	 * get_current_page
3762
+	 *
3763
+	 * @return string _current_page property value
3764
+	 */
3765
+	public function get_current_page()
3766
+	{
3767
+		return $this->_current_page;
3768
+	}
3769
+
3770
+
3771
+	/**
3772
+	 * get_current_view
3773
+	 *
3774
+	 * @return string _current_view property value
3775
+	 */
3776
+	public function get_current_view()
3777
+	{
3778
+		return $this->_current_view;
3779
+	}
3780
+
3781
+
3782
+	/**
3783
+	 * get_current_screen
3784
+	 *
3785
+	 * @return object The current WP_Screen object
3786
+	 */
3787
+	public function get_current_screen()
3788
+	{
3789
+		return $this->_current_screen;
3790
+	}
3791
+
3792
+
3793
+	/**
3794
+	 * get_current_page_view_url
3795
+	 *
3796
+	 * @return string This returns the url for the current_page_view.
3797
+	 */
3798
+	public function get_current_page_view_url()
3799
+	{
3800
+		return $this->_current_page_view_url;
3801
+	}
3802
+
3803
+
3804
+	/**
3805
+	 * just returns the Request
3806
+	 *
3807
+	 * @return RequestInterface
3808
+	 */
3809
+	public function get_request()
3810
+	{
3811
+		return $this->request;
3812
+	}
3813
+
3814
+
3815
+	/**
3816
+	 * just returns the _req_data property
3817
+	 *
3818
+	 * @return array
3819
+	 */
3820
+	public function get_request_data()
3821
+	{
3822
+		return $this->request->requestParams();
3823
+	}
3824
+
3825
+
3826
+	/**
3827
+	 * returns the _req_data protected property
3828
+	 *
3829
+	 * @return string
3830
+	 */
3831
+	public function get_req_action()
3832
+	{
3833
+		return $this->_req_action;
3834
+	}
3835
+
3836
+
3837
+	/**
3838
+	 * @return bool  value of $_is_caf property
3839
+	 */
3840
+	public function is_caf()
3841
+	{
3842
+		return $this->_is_caf;
3843
+	}
3844
+
3845
+
3846
+	/**
3847
+	 * @return mixed
3848
+	 */
3849
+	public function default_espresso_metaboxes()
3850
+	{
3851
+		return $this->_default_espresso_metaboxes;
3852
+	}
3853
+
3854
+
3855
+	/**
3856
+	 * @return mixed
3857
+	 */
3858
+	public function admin_base_url()
3859
+	{
3860
+		return $this->_admin_base_url;
3861
+	}
3862
+
3863
+
3864
+	/**
3865
+	 * @return mixed
3866
+	 */
3867
+	public function wp_page_slug()
3868
+	{
3869
+		return $this->_wp_page_slug;
3870
+	}
3871
+
3872
+
3873
+	/**
3874
+	 * updates  espresso configuration settings
3875
+	 *
3876
+	 * @param string                   $tab
3877
+	 * @param EE_Config_Base|EE_Config $config
3878
+	 * @param string                   $file file where error occurred
3879
+	 * @param string                   $func function  where error occurred
3880
+	 * @param string                   $line line no where error occurred
3881
+	 * @return boolean
3882
+	 */
3883
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3884
+	{
3885
+		// remove any options that are NOT going to be saved with the config settings.
3886
+		if (isset($config->core->ee_ueip_optin)) {
3887
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3888
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3889
+			update_option('ee_ueip_has_notified', true);
3890
+		}
3891
+		// and save it (note we're also doing the network save here)
3892
+		$net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
3893
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3894
+		if ($config_saved && $net_saved) {
3895
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3896
+			return true;
3897
+		}
3898
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3899
+		return false;
3900
+	}
3901
+
3902
+
3903
+	/**
3904
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3905
+	 *
3906
+	 * @return array
3907
+	 */
3908
+	public function get_yes_no_values()
3909
+	{
3910
+		return $this->_yes_no_values;
3911
+	}
3912
+
3913
+
3914
+	protected function _get_dir()
3915
+	{
3916
+		$reflector = new ReflectionClass(get_class($this));
3917
+		return dirname($reflector->getFileName());
3918
+	}
3919
+
3920
+
3921
+	/**
3922
+	 * A helper for getting a "next link".
3923
+	 *
3924
+	 * @param string $url   The url to link to
3925
+	 * @param string $class The class to use.
3926
+	 * @return string
3927
+	 */
3928
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3929
+	{
3930
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3931
+	}
3932
+
3933
+
3934
+	/**
3935
+	 * A helper for getting a "previous link".
3936
+	 *
3937
+	 * @param string $url   The url to link to
3938
+	 * @param string $class The class to use.
3939
+	 * @return string
3940
+	 */
3941
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3942
+	{
3943
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3944
+	}
3945
+
3946
+
3947
+
3948
+
3949
+
3950
+
3951
+
3952
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3953
+
3954
+
3955
+	/**
3956
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3957
+	 * 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
3958
+	 * _req_data array.
3959
+	 *
3960
+	 * @return bool success/fail
3961
+	 * @throws EE_Error
3962
+	 * @throws InvalidArgumentException
3963
+	 * @throws ReflectionException
3964
+	 * @throws InvalidDataTypeException
3965
+	 * @throws InvalidInterfaceException
3966
+	 */
3967
+	protected function _process_resend_registration()
3968
+	{
3969
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3970
+		do_action(
3971
+			'AHEE__EE_Admin_Page___process_resend_registration',
3972
+			$this->_template_args['success'],
3973
+			$this->request->requestParams()
3974
+		);
3975
+		return $this->_template_args['success'];
3976
+	}
3977
+
3978
+
3979
+	/**
3980
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3981
+	 *
3982
+	 * @param EE_Payment $payment
3983
+	 * @return bool success/fail
3984
+	 */
3985
+	protected function _process_payment_notification(EE_Payment $payment)
3986
+	{
3987
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3988
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3989
+		$this->_template_args['success'] = apply_filters(
3990
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3991
+			false,
3992
+			$payment
3993
+		);
3994
+		return $this->_template_args['success'];
3995
+	}
3996
+
3997
+
3998
+	/**
3999
+	 * @param EEM_Base      $entity_model
4000
+	 * @param string        $entity_PK_name name of the primary key field used as a request param, ie: id, ID, etc
4001
+	 * @param string        $action         one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4002
+	 * @param string        $delete_column  name of the field that denotes whether entity is trashed
4003
+	 * @param callable|null $callback       called after entity is trashed, restored, or deleted
4004
+	 * @return int|float
4005
+	 * @throws EE_Error
4006
+	 */
4007
+	protected function trashRestoreDeleteEntities(
4008
+		EEM_Base $entity_model,
4009
+		string $entity_PK_name,
4010
+		string $action = EE_Admin_List_Table::ACTION_DELETE,
4011
+		string $delete_column = '',
4012
+		callable $callback = null
4013
+	) {
4014
+		$entity_PK      = $entity_model->get_primary_key_field();
4015
+		$entity_PK_name = $entity_PK_name ?: $entity_PK->get_name();
4016
+		$entity_PK_type = $this->resolveEntityFieldDataType($entity_PK);
4017
+		// grab ID if deleting a single entity
4018
+		if ($this->request->requestParamIsSet($entity_PK_name)) {
4019
+			$ID = $this->request->getRequestParam($entity_PK_name, 0, $entity_PK_type);
4020
+			return $this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback) ? 1 : 0;
4021
+		}
4022
+		// or grab checkbox array if bulk deleting
4023
+		$checkboxes = $this->request->getRequestParam('checkbox', [], $entity_PK_type, true);
4024
+		if (empty($checkboxes)) {
4025
+			return 0;
4026
+		}
4027
+		$success = 0;
4028
+		$IDs     = array_keys($checkboxes);
4029
+		// cycle thru bulk action checkboxes
4030
+		foreach ($IDs as $ID) {
4031
+			// increment $success
4032
+			if ($this->trashRestoreDeleteEntity($entity_model, $ID, $action, $delete_column, $callback)) {
4033
+				$success++;
4034
+			}
4035
+		}
4036
+		$count = (int) count($checkboxes);
4037
+		// if multiple entities were deleted successfully, then $deleted will be full count of deletions,
4038
+		// otherwise it will be a fraction of ( actual deletions / total entities to be deleted )
4039
+		return $success === $count ? $count : $success / $count;
4040
+	}
4041
+
4042
+
4043
+	/**
4044
+	 * @param EE_Primary_Key_Field_Base $entity_PK
4045
+	 * @return string
4046
+	 * @throws EE_Error
4047
+	 * @since   $VID:$
4048
+	 */
4049
+	private function resolveEntityFieldDataType(EE_Primary_Key_Field_Base $entity_PK): string
4050
+	{
4051
+		$entity_PK_type = $entity_PK->getSchemaType();
4052
+		switch ($entity_PK_type) {
4053
+			case 'boolean':
4054
+				return 'bool';
4055
+			case 'integer':
4056
+				return 'int';
4057
+			case 'number':
4058
+				return 'float';
4059
+			case 'string':
4060
+				return 'string';
4061
+		}
4062
+		throw new RuntimeException(
4063
+			sprintf(
4064
+				esc_html__(
4065
+					'"%1$s" is an invalid schema type for the %2$s primary key.',
4066
+					'event_espresso'
4067
+				),
4068
+				$entity_PK_type,
4069
+				$entity_PK->get_name()
4070
+			)
4071
+		);
4072
+	}
4073
+
4074
+
4075
+	/**
4076
+	 * @param EEM_Base      $entity_model
4077
+	 * @param int|string    $entity_ID
4078
+	 * @param string        $action        one of the EE_Admin_List_Table::ACTION_* constants: delete, restore, trash
4079
+	 * @param string        $delete_column name of the field that denotes whether entity is trashed
4080
+	 * @param callable|null $callback      called after entity is trashed, restored, or deleted
4081
+	 * @return bool
4082
+	 */
4083
+	protected function trashRestoreDeleteEntity(
4084
+		EEM_Base $entity_model,
4085
+		$entity_ID,
4086
+		string $action,
4087
+		string $delete_column,
4088
+		callable $callback = null
4089
+	) {
4090
+		$entity_ID = absint($entity_ID);
4091
+		if (! $entity_ID) {
4092
+			$this->trashRestoreDeleteError($action, $entity_model);
4093
+		}
4094
+		$result = 0;
4095
+		try {
4096
+			switch ($action) {
4097
+				case EE_Admin_List_Table::ACTION_DELETE:
4098
+					$result = (bool) $entity_model->delete_permanently_by_ID($entity_ID);
4099
+					break;
4100
+				case EE_Admin_List_Table::ACTION_RESTORE:
4101
+					$this->validateDeleteColumn($entity_model, $delete_column);
4102
+					$result = $entity_model->update_by_ID([$delete_column => 0], $entity_ID);
4103
+					break;
4104
+				case EE_Admin_List_Table::ACTION_TRASH:
4105
+					$this->validateDeleteColumn($entity_model, $delete_column);
4106
+					$result = $entity_model->update_by_ID([$delete_column => 1], $entity_ID);
4107
+					break;
4108
+			}
4109
+		} catch (Exception $exception) {
4110
+			$this->trashRestoreDeleteError($action, $entity_model, $exception);
4111
+		}
4112
+		if (is_callable($callback)) {
4113
+			call_user_func_array($callback, [$entity_model, $entity_ID, $action, $result, $delete_column]);
4114
+		}
4115
+		return $result;
4116
+	}
4117
+
4118
+
4119
+	/**
4120
+	 * @param EEM_Base $entity_model
4121
+	 * @param string   $delete_column
4122
+	 * @since $VID:$
4123
+	 */
4124
+	private function validateDeleteColumn(EEM_Base $entity_model, string $delete_column)
4125
+	{
4126
+		if (empty($delete_column)) {
4127
+			throw new DomainException(
4128
+				sprintf(
4129
+					esc_html__(
4130
+						'You need to specify the name of the "delete column" on the %2$s model, in order to trash or restore an entity.',
4131
+						'event_espresso'
4132
+					),
4133
+					$entity_model->get_this_model_name()
4134
+				)
4135
+			);
4136
+		}
4137
+		if (! $entity_model->has_field($delete_column)) {
4138
+			throw new DomainException(
4139
+				sprintf(
4140
+					esc_html__(
4141
+						'The %1$s field does not exist on the %2$s model.',
4142
+						'event_espresso'
4143
+					),
4144
+					$delete_column,
4145
+					$entity_model->get_this_model_name()
4146
+				)
4147
+			);
4148
+		}
4149
+	}
4150
+
4151
+
4152
+	/**
4153
+	 * @param EEM_Base       $entity_model
4154
+	 * @param Exception|null $exception
4155
+	 * @param string         $action
4156
+	 * @since $VID:$
4157
+	 */
4158
+	private function trashRestoreDeleteError(string $action, EEM_Base $entity_model, ?Exception $exception = null)
4159
+	{
4160
+		if ($exception instanceof Exception) {
4161
+			throw new RuntimeException(
4162
+				sprintf(
4163
+					esc_html__(
4164
+						'Could not %1$s the %2$s because the following error occurred: %3$s',
4165
+						'event_espresso'
4166
+					),
4167
+					$action,
4168
+					$entity_model->get_this_model_name(),
4169
+					$exception->getMessage()
4170
+				)
4171
+			);
4172
+		}
4173
+		throw new RuntimeException(
4174
+			sprintf(
4175
+				esc_html__(
4176
+					'Could not %1$s the %2$s because an invalid ID was received.',
4177
+					'event_espresso'
4178
+				),
4179
+				$action,
4180
+				$entity_model->get_this_model_name()
4181
+			)
4182
+		);
4183
+	}
4184 4184
 }
Please login to merge, or discard this patch.
Spacing   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
         $ee_menu_slugs = (array) $ee_menu_slugs;
514 514
         if (
515 515
             ! $this->request->isAjax()
516
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
516
+            && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))
517 517
         ) {
518 518
             return;
519 519
         }
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
             : $req_action;
534 534
 
535 535
         $this->_current_view = $this->_req_action;
536
-        $this->_req_nonce    = $this->_req_action . '_nonce';
536
+        $this->_req_nonce    = $this->_req_action.'_nonce';
537 537
         $this->_define_page_props();
538 538
         $this->_current_page_view_url = add_query_arg(
539 539
             ['page' => $this->_current_page, 'action' => $this->_current_view],
@@ -570,21 +570,21 @@  discard block
 block discarded – undo
570 570
         }
571 571
         // filter routes and page_config so addons can add their stuff. Filtering done per class
572 572
         $this->_page_routes = apply_filters(
573
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
573
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
574 574
             $this->_page_routes,
575 575
             $this
576 576
         );
577 577
         $this->_page_config = apply_filters(
578
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
578
+            'FHEE__'.get_class($this).'__page_setup__page_config',
579 579
             $this->_page_config,
580 580
             $this
581 581
         );
582 582
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
583 583
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
584
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
584
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
585 585
             add_action(
586 586
                 'AHEE__EE_Admin_Page__route_admin_request',
587
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
587
+                [$this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view],
588 588
                 10,
589 589
                 2
590 590
             );
@@ -597,8 +597,8 @@  discard block
 block discarded – undo
597 597
             if ($this->_is_UI_request) {
598 598
                 // admin_init stuff - global, all views for this page class, specific view
599 599
                 add_action('admin_init', [$this, 'admin_init'], 10);
600
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
601
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
600
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
601
+                    add_action('admin_init', [$this, 'admin_init_'.$this->_current_view], 15);
602 602
                 }
603 603
             } else {
604 604
                 // hijack regular WP loading and route admin request immediately
@@ -617,12 +617,12 @@  discard block
 block discarded – undo
617 617
      */
618 618
     private function _do_other_page_hooks()
619 619
     {
620
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
620
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, []);
621 621
         foreach ($registered_pages as $page) {
622 622
             // now let's setup the file name and class that should be present
623 623
             $classname = str_replace('.class.php', '', $page);
624 624
             // autoloaders should take care of loading file
625
-            if (! class_exists($classname)) {
625
+            if ( ! class_exists($classname)) {
626 626
                 $error_msg[] = sprintf(
627 627
                     esc_html__(
628 628
                         'Something went wrong with loading the %s admin hooks page.',
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
                                    ),
640 640
                                    $page,
641 641
                                    '<br />',
642
-                                   '<strong>' . $classname . '</strong>'
642
+                                   '<strong>'.$classname.'</strong>'
643 643
                                );
644 644
                 throw new EE_Error(implode('||', $error_msg));
645 645
             }
@@ -681,13 +681,13 @@  discard block
 block discarded – undo
681 681
         // load admin_notices - global, page class, and view specific
682 682
         add_action('admin_notices', [$this, 'admin_notices_global'], 5);
683 683
         add_action('admin_notices', [$this, 'admin_notices'], 10);
684
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
685
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
684
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
685
+            add_action('admin_notices', [$this, 'admin_notices_'.$this->_current_view], 15);
686 686
         }
687 687
         // load network admin_notices - global, page class, and view specific
688 688
         add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
689
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
690
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
689
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
690
+            add_action('network_admin_notices', [$this, 'network_admin_notices_'.$this->_current_view]);
691 691
         }
692 692
         // this will save any per_page screen options if they are present
693 693
         $this->_set_per_page_screen_options();
@@ -808,7 +808,7 @@  discard block
 block discarded – undo
808 808
     protected function _verify_routes()
809 809
     {
810 810
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
811
-        if (! $this->_current_page && ! $this->request->isAjax()) {
811
+        if ( ! $this->_current_page && ! $this->request->isAjax()) {
812 812
             return false;
813 813
         }
814 814
         $this->_route = false;
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
                 $this->_admin_page_title
821 821
             );
822 822
             // developer error msg
823
-            $error_msg .= '||' . $error_msg
823
+            $error_msg .= '||'.$error_msg
824 824
                           . esc_html__(
825 825
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
826 826
                               'event_espresso'
@@ -829,9 +829,9 @@  discard block
 block discarded – undo
829 829
         }
830 830
         // and that the requested page route exists
831 831
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
832
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
833
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
834
-                ? $this->_page_config[ $this->_req_action ]
832
+            $this->_route        = $this->_page_routes[$this->_req_action];
833
+            $this->_route_config = isset($this->_page_config[$this->_req_action])
834
+                ? $this->_page_config[$this->_req_action]
835 835
                 : [];
836 836
         } else {
837 837
             // user error msg
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
                 $this->_admin_page_title
844 844
             );
845 845
             // developer error msg
846
-            $error_msg .= '||' . $error_msg
846
+            $error_msg .= '||'.$error_msg
847 847
                           . sprintf(
848 848
                               esc_html__(
849 849
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
             throw new EE_Error($error_msg);
855 855
         }
856 856
         // and that a default route exists
857
-        if (! array_key_exists('default', $this->_page_routes)) {
857
+        if ( ! array_key_exists('default', $this->_page_routes)) {
858 858
             // user error msg
859 859
             $error_msg = sprintf(
860 860
                 esc_html__(
@@ -864,7 +864,7 @@  discard block
 block discarded – undo
864 864
                 $this->_admin_page_title
865 865
             );
866 866
             // developer error msg
867
-            $error_msg .= '||' . $error_msg
867
+            $error_msg .= '||'.$error_msg
868 868
                           . esc_html__(
869 869
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
870 870
                               'event_espresso'
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
             $this->_admin_page_title
906 906
         );
907 907
         // developer error msg
908
-        $error_msg .= '||' . $error_msg
908
+        $error_msg .= '||'.$error_msg
909 909
                       . sprintf(
910 910
                           esc_html__(
911 911
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
     protected function _verify_nonce($nonce, $nonce_ref)
931 931
     {
932 932
         // verify nonce against expected value
933
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
933
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
934 934
             // these are not the droids you are looking for !!!
935 935
             $msg = sprintf(
936 936
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
                     __CLASS__
948 948
                 );
949 949
             }
950
-            if (! $this->request->isAjax()) {
950
+            if ( ! $this->request->isAjax()) {
951 951
                 wp_die($msg);
952 952
             }
953 953
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
      */
972 972
     protected function _route_admin_request()
973 973
     {
974
-        if (! $this->_is_UI_request) {
974
+        if ( ! $this->_is_UI_request) {
975 975
             $this->_verify_routes();
976 976
         }
977 977
         $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
         $error_msg = '';
992 992
         // action right before calling route
993 993
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
994
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
994
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
995 995
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
996 996
         }
997 997
         // right before calling the route, let's clean the _wp_http_referer
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
                 wp_unslash($this->request->getServerParam('REQUEST_URI'))
1003 1003
             )
1004 1004
         );
1005
-        if (! empty($func)) {
1005
+        if ( ! empty($func)) {
1006 1006
             if (is_array($func)) {
1007 1007
                 list($class, $method) = $func;
1008 1008
             } elseif (strpos($func, '::') !== false) {
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
                 $class  = $this;
1012 1012
                 $method = $func;
1013 1013
             }
1014
-            if (! (is_object($class) && $class === $this)) {
1014
+            if ( ! (is_object($class) && $class === $this)) {
1015 1015
                 // send along this admin page object for access by addons.
1016 1016
                 $args['admin_page_object'] = $this;
1017 1017
             }
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
                     $method
1053 1053
                 );
1054 1054
             }
1055
-            if (! empty($error_msg)) {
1055
+            if ( ! empty($error_msg)) {
1056 1056
                 throw new EE_Error($error_msg);
1057 1057
             }
1058 1058
         }
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
                 if (strpos($key, 'nonce') !== false) {
1138 1138
                     continue;
1139 1139
                 }
1140
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1140
+                $args['wp_referer['.$key.']'] = is_string($value) ? htmlspecialchars($value) : $value;
1141 1141
             }
1142 1142
         }
1143 1143
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1176,12 +1176,12 @@  discard block
 block discarded – undo
1176 1176
      */
1177 1177
     protected function _add_help_tabs()
1178 1178
     {
1179
-        if (isset($this->_page_config[ $this->_req_action ])) {
1180
-            $config = $this->_page_config[ $this->_req_action ];
1179
+        if (isset($this->_page_config[$this->_req_action])) {
1180
+            $config = $this->_page_config[$this->_req_action];
1181 1181
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1182 1182
             if (is_array($config) && isset($config['help_sidebar'])) {
1183 1183
                 // check that the callback given is valid
1184
-                if (! method_exists($this, $config['help_sidebar'])) {
1184
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1185 1185
                     throw new EE_Error(
1186 1186
                         sprintf(
1187 1187
                             esc_html__(
@@ -1194,18 +1194,18 @@  discard block
 block discarded – undo
1194 1194
                     );
1195 1195
                 }
1196 1196
                 $content = apply_filters(
1197
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1197
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1198 1198
                     $this->{$config['help_sidebar']}()
1199 1199
                 );
1200 1200
                 $this->_current_screen->set_help_sidebar($content);
1201 1201
             }
1202
-            if (! isset($config['help_tabs'])) {
1202
+            if ( ! isset($config['help_tabs'])) {
1203 1203
                 return;
1204 1204
             } //no help tabs for this route
1205 1205
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1206 1206
                 // we're here so there ARE help tabs!
1207 1207
                 // make sure we've got what we need
1208
-                if (! isset($cfg['title'])) {
1208
+                if ( ! isset($cfg['title'])) {
1209 1209
                     throw new EE_Error(
1210 1210
                         esc_html__(
1211 1211
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
                         )
1214 1214
                     );
1215 1215
                 }
1216
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1216
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1217 1217
                     throw new EE_Error(
1218 1218
                         esc_html__(
1219 1219
                             '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',
@@ -1222,11 +1222,11 @@  discard block
 block discarded – undo
1222 1222
                     );
1223 1223
                 }
1224 1224
                 // first priority goes to content.
1225
-                if (! empty($cfg['content'])) {
1225
+                if ( ! empty($cfg['content'])) {
1226 1226
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1227 1227
                     // second priority goes to filename
1228
-                } elseif (! empty($cfg['filename'])) {
1229
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1228
+                } elseif ( ! empty($cfg['filename'])) {
1229
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1230 1230
                     // 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)
1231 1231
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1232 1232
                                                              . basename($this->_get_dir())
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
                                                              . $cfg['filename']
1235 1235
                                                              . '.help_tab.php' : $file_path;
1236 1236
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1237
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1237
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1238 1238
                         EE_Error::add_error(
1239 1239
                             sprintf(
1240 1240
                                 esc_html__(
@@ -1282,7 +1282,7 @@  discard block
 block discarded – undo
1282 1282
                     return;
1283 1283
                 }
1284 1284
                 // setup config array for help tab method
1285
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1285
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1286 1286
                 $_ht = [
1287 1287
                     'id'       => $id,
1288 1288
                     'title'    => $cfg['title'],
@@ -1306,8 +1306,8 @@  discard block
 block discarded – undo
1306 1306
             $qtips = (array) $this->_route_config['qtips'];
1307 1307
             // load qtip loader
1308 1308
             $path = [
1309
-                $this->_get_dir() . '/qtips/',
1310
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1309
+                $this->_get_dir().'/qtips/',
1310
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1311 1311
             ];
1312 1312
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1313 1313
         }
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1330 1330
         $i = 0;
1331 1331
         foreach ($this->_page_config as $slug => $config) {
1332
-            if (! is_array($config) || empty($config['nav'])) {
1332
+            if ( ! is_array($config) || empty($config['nav'])) {
1333 1333
                 continue;
1334 1334
             }
1335 1335
             // no nav tab for this config
@@ -1338,12 +1338,12 @@  discard block
 block discarded – undo
1338 1338
                 // nav tab is only to appear when route requested.
1339 1339
                 continue;
1340 1340
             }
1341
-            if (! $this->check_user_access($slug, true)) {
1341
+            if ( ! $this->check_user_access($slug, true)) {
1342 1342
                 // no nav tab because current user does not have access.
1343 1343
                 continue;
1344 1344
             }
1345
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1346
-            $this->_nav_tabs[ $slug ] = [
1345
+            $css_class                = isset($config['css_class']) ? $config['css_class'].' ' : '';
1346
+            $this->_nav_tabs[$slug] = [
1347 1347
                 'url'       => isset($config['nav']['url'])
1348 1348
                     ? $config['nav']['url']
1349 1349
                     : self::add_query_args_and_nonce(
@@ -1355,14 +1355,14 @@  discard block
 block discarded – undo
1355 1355
                     : ucwords(
1356 1356
                         str_replace('_', ' ', $slug)
1357 1357
                     ),
1358
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1358
+                'css_class' => $this->_req_action === $slug ? $css_class.'nav-tab-active' : $css_class,
1359 1359
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1360 1360
             ];
1361 1361
             $i++;
1362 1362
         }
1363 1363
         // if $this->_nav_tabs is empty then lets set the default
1364 1364
         if (empty($this->_nav_tabs)) {
1365
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1365
+            $this->_nav_tabs[$this->_default_nav_tab_name] = [
1366 1366
                 'url'       => $this->_admin_base_url,
1367 1367
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1368 1368
                 'css_class' => 'nav-tab-active',
@@ -1387,10 +1387,10 @@  discard block
 block discarded – undo
1387 1387
             foreach ($this->_route_config['labels'] as $label => $text) {
1388 1388
                 if (is_array($text)) {
1389 1389
                     foreach ($text as $sublabel => $subtext) {
1390
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1390
+                        $this->_labels[$label][$sublabel] = $subtext;
1391 1391
                     }
1392 1392
                 } else {
1393
-                    $this->_labels[ $label ] = $text;
1393
+                    $this->_labels[$label] = $text;
1394 1394
                 }
1395 1395
             }
1396 1396
         }
@@ -1412,12 +1412,12 @@  discard block
 block discarded – undo
1412 1412
     {
1413 1413
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1414 1414
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1415
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1415
+        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1416 1416
                           && is_array(
1417
-                              $this->_page_routes[ $route_to_check ]
1417
+                              $this->_page_routes[$route_to_check]
1418 1418
                           )
1419
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1420
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1419
+                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1420
+            ? $this->_page_routes[$route_to_check]['capability'] : null;
1421 1421
         if (empty($capability) && empty($route_to_check)) {
1422 1422
             $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1423 1423
                 : $this->_route['capability'];
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
         ';
1538 1538
 
1539 1539
         // current set timezone for timezone js
1540
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1540
+        echo '<span id="current_timezone" class="hidden">'.esc_html(EEH_DTT_Helper::get_timezone()).'</span>';
1541 1541
     }
1542 1542
 
1543 1543
 
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
         // loop through the array and setup content
1572 1572
         foreach ($help_array as $trigger => $help) {
1573 1573
             // make sure the array is setup properly
1574
-            if (! isset($help['title']) || ! isset($help['content'])) {
1574
+            if ( ! isset($help['title']) || ! isset($help['content'])) {
1575 1575
                 throw new EE_Error(
1576 1576
                     esc_html__(
1577 1577
                         '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',
@@ -1585,8 +1585,8 @@  discard block
 block discarded – undo
1585 1585
                 'help_popup_title'   => $help['title'],
1586 1586
                 'help_popup_content' => $help['content'],
1587 1587
             ];
1588
-            $content       .= EEH_Template::display_template(
1589
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1588
+            $content .= EEH_Template::display_template(
1589
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1590 1590
                 $template_args,
1591 1591
                 true
1592 1592
             );
@@ -1608,15 +1608,15 @@  discard block
 block discarded – undo
1608 1608
     private function _get_help_content()
1609 1609
     {
1610 1610
         // what is the method we're looking for?
1611
-        $method_name = '_help_popup_content_' . $this->_req_action;
1611
+        $method_name = '_help_popup_content_'.$this->_req_action;
1612 1612
         // if method doesn't exist let's get out.
1613
-        if (! method_exists($this, $method_name)) {
1613
+        if ( ! method_exists($this, $method_name)) {
1614 1614
             return [];
1615 1615
         }
1616 1616
         // k we're good to go let's retrieve the help array
1617 1617
         $help_array = call_user_func([$this, $method_name]);
1618 1618
         // make sure we've got an array!
1619
-        if (! is_array($help_array)) {
1619
+        if ( ! is_array($help_array)) {
1620 1620
             throw new EE_Error(
1621 1621
                 esc_html__(
1622 1622
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1648,15 +1648,15 @@  discard block
 block discarded – undo
1648 1648
         // 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
1649 1649
         $help_array   = $this->_get_help_content();
1650 1650
         $help_content = '';
1651
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1652
-            $help_array[ $trigger_id ] = [
1651
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1652
+            $help_array[$trigger_id] = [
1653 1653
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1654 1654
                 'content' => esc_html__(
1655 1655
                     '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.)',
1656 1656
                     'event_espresso'
1657 1657
                 ),
1658 1658
             ];
1659
-            $help_content              = $this->_set_help_popup_content($help_array);
1659
+            $help_content = $this->_set_help_popup_content($help_array);
1660 1660
         }
1661 1661
         // let's setup the trigger
1662 1662
         $content = '<a class="ee-dialog" href="?height='
@@ -1724,15 +1724,15 @@  discard block
 block discarded – undo
1724 1724
         // register all styles
1725 1725
         wp_register_style(
1726 1726
             'espresso-ui-theme',
1727
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1727
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1728 1728
             [],
1729 1729
             EVENT_ESPRESSO_VERSION
1730 1730
         );
1731
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1731
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1732 1732
         // helpers styles
1733 1733
         wp_register_style(
1734 1734
             'ee-text-links',
1735
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1735
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css',
1736 1736
             [],
1737 1737
             EVENT_ESPRESSO_VERSION
1738 1738
         );
@@ -1740,21 +1740,21 @@  discard block
 block discarded – undo
1740 1740
         // register all scripts
1741 1741
         wp_register_script(
1742 1742
             'ee-dialog',
1743
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1743
+            EE_ADMIN_URL.'assets/ee-dialog-helper.js',
1744 1744
             ['jquery', 'jquery-ui-draggable'],
1745 1745
             EVENT_ESPRESSO_VERSION,
1746 1746
             true
1747 1747
         );
1748 1748
         wp_register_script(
1749 1749
             'ee_admin_js',
1750
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1750
+            EE_ADMIN_URL.'assets/ee-admin-page.js',
1751 1751
             ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1752 1752
             EVENT_ESPRESSO_VERSION,
1753 1753
             true
1754 1754
         );
1755 1755
         wp_register_script(
1756 1756
             'jquery-ui-timepicker-addon',
1757
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1757
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js',
1758 1758
             ['jquery-ui-datepicker', 'jquery-ui-slider'],
1759 1759
             EVENT_ESPRESSO_VERSION,
1760 1760
             true
@@ -1762,7 +1762,7 @@  discard block
 block discarded – undo
1762 1762
         // script for sorting tables
1763 1763
         wp_register_script(
1764 1764
             'espresso_ajax_table_sorting',
1765
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1765
+            EE_ADMIN_URL.'assets/espresso_ajax_table_sorting.js',
1766 1766
             ['ee_admin_js', 'jquery-ui-sortable'],
1767 1767
             EVENT_ESPRESSO_VERSION,
1768 1768
             true
@@ -1770,7 +1770,7 @@  discard block
 block discarded – undo
1770 1770
         // script for parsing uri's
1771 1771
         wp_register_script(
1772 1772
             'ee-parse-uri',
1773
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1773
+            EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js',
1774 1774
             [],
1775 1775
             EVENT_ESPRESSO_VERSION,
1776 1776
             true
@@ -1778,7 +1778,7 @@  discard block
 block discarded – undo
1778 1778
         // and parsing associative serialized form elements
1779 1779
         wp_register_script(
1780 1780
             'ee-serialize-full-array',
1781
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1781
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js',
1782 1782
             ['jquery'],
1783 1783
             EVENT_ESPRESSO_VERSION,
1784 1784
             true
@@ -1786,28 +1786,28 @@  discard block
 block discarded – undo
1786 1786
         // helpers scripts
1787 1787
         wp_register_script(
1788 1788
             'ee-text-links',
1789
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1789
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js',
1790 1790
             ['jquery'],
1791 1791
             EVENT_ESPRESSO_VERSION,
1792 1792
             true
1793 1793
         );
1794 1794
         wp_register_script(
1795 1795
             'ee-moment-core',
1796
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1796
+            EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js',
1797 1797
             [],
1798 1798
             EVENT_ESPRESSO_VERSION,
1799 1799
             true
1800 1800
         );
1801 1801
         wp_register_script(
1802 1802
             'ee-moment',
1803
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1803
+            EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js',
1804 1804
             ['ee-moment-core'],
1805 1805
             EVENT_ESPRESSO_VERSION,
1806 1806
             true
1807 1807
         );
1808 1808
         wp_register_script(
1809 1809
             'ee-datepicker',
1810
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1810
+            EE_ADMIN_URL.'assets/ee-datepicker.js',
1811 1811
             ['jquery-ui-timepicker-addon', 'ee-moment'],
1812 1812
             EVENT_ESPRESSO_VERSION,
1813 1813
             true
@@ -1840,7 +1840,7 @@  discard block
 block discarded – undo
1840 1840
         wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1841 1841
         add_filter(
1842 1842
             'admin_body_class',
1843
-            function ($classes) {
1843
+            function($classes) {
1844 1844
                 if (strpos($classes, 'espresso-admin') === false) {
1845 1845
                     $classes .= ' espresso-admin';
1846 1846
                 }
@@ -1928,12 +1928,12 @@  discard block
 block discarded – undo
1928 1928
     protected function _set_list_table()
1929 1929
     {
1930 1930
         // first is this a list_table view?
1931
-        if (! isset($this->_route_config['list_table'])) {
1931
+        if ( ! isset($this->_route_config['list_table'])) {
1932 1932
             return;
1933 1933
         } //not a list_table view so get out.
1934 1934
         // list table functions are per view specific (because some admin pages might have more than one list table!)
1935
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
1936
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1935
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
1936
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
1937 1937
             // user error msg
1938 1938
             $error_msg = esc_html__(
1939 1939
                 'An error occurred. The requested list table views could not be found.',
@@ -1953,10 +1953,10 @@  discard block
 block discarded – undo
1953 1953
         }
1954 1954
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1955 1955
         $this->_views = apply_filters(
1956
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
1956
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
1957 1957
             $this->_views
1958 1958
         );
1959
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1959
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1960 1960
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1961 1961
         $this->_set_list_table_view();
1962 1962
         $this->_set_list_table_object();
@@ -1991,7 +1991,7 @@  discard block
 block discarded – undo
1991 1991
     protected function _set_list_table_object()
1992 1992
     {
1993 1993
         if (isset($this->_route_config['list_table'])) {
1994
-            if (! class_exists($this->_route_config['list_table'])) {
1994
+            if ( ! class_exists($this->_route_config['list_table'])) {
1995 1995
                 throw new EE_Error(
1996 1996
                     sprintf(
1997 1997
                         esc_html__(
@@ -2029,15 +2029,15 @@  discard block
 block discarded – undo
2029 2029
         foreach ($this->_views as $key => $view) {
2030 2030
             $query_args = [];
2031 2031
             // check for current view
2032
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2032
+            $this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2033 2033
             $query_args['action']                        = $this->_req_action;
2034
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2034
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2035 2035
             $query_args['status']                        = $view['slug'];
2036 2036
             // merge any other arguments sent in.
2037
-            if (isset($extra_query_args[ $view['slug'] ])) {
2038
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2037
+            if (isset($extra_query_args[$view['slug']])) {
2038
+                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2039 2039
             }
2040
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2040
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2041 2041
         }
2042 2042
         return $this->_views;
2043 2043
     }
@@ -2068,14 +2068,14 @@  discard block
 block discarded – undo
2068 2068
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2069 2069
         foreach ($values as $value) {
2070 2070
             if ($value < $max_entries) {
2071
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2071
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2072 2072
                 $entries_per_page_dropdown .= '
2073
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2073
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2074 2074
             }
2075 2075
         }
2076
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2076
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2077 2077
         $entries_per_page_dropdown .= '
2078
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2078
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2079 2079
         $entries_per_page_dropdown .= '
2080 2080
 					</select>
2081 2081
 					entries
@@ -2099,7 +2099,7 @@  discard block
 block discarded – undo
2099 2099
             empty($this->_search_btn_label) ? $this->page_label
2100 2100
                 : $this->_search_btn_label
2101 2101
         );
2102
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2102
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2103 2103
     }
2104 2104
 
2105 2105
 
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
             $total_columns                                       = ! empty($screen_columns)
2188 2188
                 ? $screen_columns
2189 2189
                 : $this->_route_config['columns'][1];
2190
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2190
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2191 2191
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2192 2192
             $this->_template_args['screen']                      = $this->_current_screen;
2193 2193
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2232,7 +2232,7 @@  discard block
 block discarded – undo
2232 2232
      */
2233 2233
     protected function _espresso_ratings_request()
2234 2234
     {
2235
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2235
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2236 2236
             return;
2237 2237
         }
2238 2238
         $ratings_box_title = apply_filters(
@@ -2260,7 +2260,7 @@  discard block
 block discarded – undo
2260 2260
     public function espresso_ratings_request()
2261 2261
     {
2262 2262
         EEH_Template::display_template(
2263
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2263
+            EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php',
2264 2264
             []
2265 2265
         );
2266 2266
     }
@@ -2268,22 +2268,22 @@  discard block
 block discarded – undo
2268 2268
 
2269 2269
     public static function cached_rss_display($rss_id, $url)
2270 2270
     {
2271
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2271
+        $loading = '<p class="widget-loading hide-if-no-js">'
2272 2272
                      . esc_html__('Loading&#8230;', 'event_espresso')
2273 2273
                      . '</p><p class="hide-if-js">'
2274 2274
                      . esc_html__('This widget requires JavaScript.', 'event_espresso')
2275 2275
                      . '</p>';
2276
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2277
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2278
-        $post      = '</div>' . "\n";
2279
-        $cache_key = 'ee_rss_' . md5($rss_id);
2276
+        $pre       = '<div class="espresso-rss-display">'."\n\t";
2277
+        $pre .= '<span id="'.esc_attr($rss_id).'_url" class="hidden">'.esc_url_raw($url).'</span>';
2278
+        $post      = '</div>'."\n";
2279
+        $cache_key = 'ee_rss_'.md5($rss_id);
2280 2280
         $output    = get_transient($cache_key);
2281 2281
         if ($output !== false) {
2282
-            echo $pre . $output . $post; // already escaped
2282
+            echo $pre.$output.$post; // already escaped
2283 2283
             return true;
2284 2284
         }
2285
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2286
-            echo $pre . $loading . $post; // already escaped
2285
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2286
+            echo $pre.$loading.$post; // already escaped
2287 2287
             return false;
2288 2288
         }
2289 2289
         ob_start();
@@ -2350,19 +2350,19 @@  discard block
 block discarded – undo
2350 2350
     public function espresso_sponsors_post_box()
2351 2351
     {
2352 2352
         EEH_Template::display_template(
2353
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2353
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2354 2354
         );
2355 2355
     }
2356 2356
 
2357 2357
 
2358 2358
     private function _publish_post_box()
2359 2359
     {
2360
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2360
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2361 2361
         // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2362 2362
         // then we'll use that for the metabox label.
2363 2363
         // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2364
-        if (! empty($this->_labels['publishbox'])) {
2365
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2364
+        if ( ! empty($this->_labels['publishbox'])) {
2365
+            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2366 2366
                 : $this->_labels['publishbox'];
2367 2367
         } else {
2368 2368
             $box_label = esc_html__('Publish', 'event_espresso');
@@ -2391,7 +2391,7 @@  discard block
 block discarded – undo
2391 2391
             ? $this->_template_args['publish_box_extra_content']
2392 2392
             : '';
2393 2393
         echo EEH_Template::display_template(
2394
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2394
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2395 2395
             $this->_template_args,
2396 2396
             true
2397 2397
         );
@@ -2483,18 +2483,18 @@  discard block
 block discarded – undo
2483 2483
             );
2484 2484
         }
2485 2485
         $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2486
-        if (! empty($name) && ! empty($id)) {
2487
-            $hidden_field_arr[ $name ] = [
2486
+        if ( ! empty($name) && ! empty($id)) {
2487
+            $hidden_field_arr[$name] = [
2488 2488
                 'type'  => 'hidden',
2489 2489
                 'value' => $id,
2490 2490
             ];
2491
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2491
+            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2492 2492
         } else {
2493 2493
             $hf = '';
2494 2494
         }
2495 2495
         // add hidden field
2496 2496
         $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2497
-            ? $hf[ $name ]['field']
2497
+            ? $hf[$name]['field']
2498 2498
             : $hf;
2499 2499
     }
2500 2500
 
@@ -2596,7 +2596,7 @@  discard block
 block discarded – undo
2596 2596
         }
2597 2597
         // 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)
2598 2598
         $call_back_func = $create_func
2599
-            ? function ($post, $metabox) {
2599
+            ? function($post, $metabox) {
2600 2600
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2601 2601
                 echo EEH_Template::display_template(
2602 2602
                     $metabox['args']['template_path'],
@@ -2606,7 +2606,7 @@  discard block
 block discarded – undo
2606 2606
             }
2607 2607
             : $callback;
2608 2608
         add_meta_box(
2609
-            str_replace('_', '-', $action) . '-mbox',
2609
+            str_replace('_', '-', $action).'-mbox',
2610 2610
             $title,
2611 2611
             $call_back_func,
2612 2612
             $this->_wp_page_slug,
@@ -2698,9 +2698,9 @@  discard block
 block discarded – undo
2698 2698
             : 'espresso-default-admin';
2699 2699
         $template_path                                     = $sidebar
2700 2700
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2701
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2701
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2702 2702
         if ($this->request->isAjax()) {
2703
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2703
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2704 2704
         }
2705 2705
         $template_path                                     = ! empty($this->_column_template_path)
2706 2706
             ? $this->_column_template_path : $template_path;
@@ -2740,11 +2740,11 @@  discard block
 block discarded – undo
2740 2740
     public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2741 2741
     {
2742 2742
         // let's generate a default preview action button if there isn't one already present.
2743
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2743
+        $this->_labels['buttons']['buy_now'] = esc_html__(
2744 2744
             'Upgrade to Event Espresso 4 Right Now',
2745 2745
             'event_espresso'
2746 2746
         );
2747
-        $buy_now_url                                   = add_query_arg(
2747
+        $buy_now_url = add_query_arg(
2748 2748
             [
2749 2749
                 'ee_ver'       => 'ee4',
2750 2750
                 'utm_source'   => 'ee4_plugin_admin',
@@ -2764,8 +2764,8 @@  discard block
 block discarded – undo
2764 2764
                 true
2765 2765
             )
2766 2766
             : $this->_template_args['preview_action_button'];
2767
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2768
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2767
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2768
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2769 2769
             $this->_template_args,
2770 2770
             true
2771 2771
         );
@@ -2814,7 +2814,7 @@  discard block
 block discarded – undo
2814 2814
         // setup search attributes
2815 2815
         $this->_set_search_attributes();
2816 2816
         $this->_template_args['current_page']     = $this->_wp_page_slug;
2817
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2817
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2818 2818
         $this->_template_args['table_url']        = $this->request->isAjax()
2819 2819
             ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2820 2820
             : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
@@ -2822,10 +2822,10 @@  discard block
 block discarded – undo
2822 2822
         $this->_template_args['current_route']    = $this->_req_action;
2823 2823
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2824 2824
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2825
-        if (! empty($ajax_sorting_callback)) {
2825
+        if ( ! empty($ajax_sorting_callback)) {
2826 2826
             $sortable_list_table_form_fields = wp_nonce_field(
2827
-                $ajax_sorting_callback . '_nonce',
2828
-                $ajax_sorting_callback . '_nonce',
2827
+                $ajax_sorting_callback.'_nonce',
2828
+                $ajax_sorting_callback.'_nonce',
2829 2829
                 false,
2830 2830
                 false
2831 2831
             );
@@ -2843,20 +2843,20 @@  discard block
 block discarded – undo
2843 2843
             isset($this->_template_args['list_table_hidden_fields'])
2844 2844
                 ? $this->_template_args['list_table_hidden_fields']
2845 2845
                 : '';
2846
-        $nonce_ref                                               = $this->_req_action . '_nonce';
2847
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
2846
+        $nonce_ref = $this->_req_action.'_nonce';
2847
+        $hidden_form_fields .= '<input type="hidden" name="'
2848 2848
                                                                     . $nonce_ref
2849 2849
                                                                     . '" value="'
2850 2850
                                                                     . wp_create_nonce($nonce_ref)
2851 2851
                                                                     . '">';
2852
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2852
+        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2853 2853
         // display message about search results?
2854 2854
         $search = $this->request->getRequestParam('s');
2855 2855
         $this->_template_args['before_list_table'] .= ! empty($search)
2856
-            ? '<p class="ee-search-results">' . sprintf(
2856
+            ? '<p class="ee-search-results">'.sprintf(
2857 2857
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2858 2858
                 trim($search, '%')
2859
-            ) . '</p>'
2859
+            ).'</p>'
2860 2860
             : '';
2861 2861
         // filter before_list_table template arg
2862 2862
         $this->_template_args['before_list_table'] = apply_filters(
@@ -2890,7 +2890,7 @@  discard block
 block discarded – undo
2890 2890
         // convert to array and filter again
2891 2891
         // arrays are easier to inject new items in a specific location,
2892 2892
         // but would not be backwards compatible, so we have to add a new filter
2893
-        $this->_template_args['after_list_table']   = implode(
2893
+        $this->_template_args['after_list_table'] = implode(
2894 2894
             " \n",
2895 2895
             (array) apply_filters(
2896 2896
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
@@ -2937,7 +2937,7 @@  discard block
 block discarded – undo
2937 2937
             $this
2938 2938
         );
2939 2939
         return EEH_Template::display_template(
2940
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
2940
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
2941 2941
             $this->_template_args,
2942 2942
             true
2943 2943
         );
@@ -3046,18 +3046,18 @@  discard block
 block discarded – undo
3046 3046
                 : ''
3047 3047
         );
3048 3048
 
3049
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3049
+        $this->_template_args['after_admin_page_content'] = apply_filters(
3050 3050
             "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3051 3051
             isset($this->_template_args['after_admin_page_content'])
3052 3052
                 ? $this->_template_args['after_admin_page_content']
3053 3053
                 : ''
3054 3054
         );
3055
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3055
+        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3056 3056
 
3057 3057
         if ($this->request->isAjax()) {
3058 3058
             $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3059 3059
                 // $template_path,
3060
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3060
+                EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php',
3061 3061
                 $this->_template_args,
3062 3062
                 true
3063 3063
             );
@@ -3066,7 +3066,7 @@  discard block
 block discarded – undo
3066 3066
         // load settings page wrapper template
3067 3067
         $template_path = $about
3068 3068
             ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3069
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3069
+            : EE_ADMIN_TEMPLATE.'admin_wrapper.template.php';
3070 3070
 
3071 3071
         EEH_Template::display_template($template_path, $this->_template_args);
3072 3072
     }
@@ -3151,12 +3151,12 @@  discard block
 block discarded – undo
3151 3151
         $default_names = ['save', 'save_and_close'];
3152 3152
         $buttons = '';
3153 3153
         foreach ($button_text as $key => $button) {
3154
-            $ref     = $default_names[ $key ];
3155
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3156
-            $buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3157
-                        . 'value="' . $button . '" name="' . $name . '" '
3158
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3159
-            if (! $both) {
3154
+            $ref     = $default_names[$key];
3155
+            $name    = ! empty($actions) ? $actions[$key] : $ref;
3156
+            $buttons .= '<input type="submit" class="button-primary '.$ref.'" '
3157
+                        . 'value="'.$button.'" name="'.$name.'" '
3158
+                        . 'id="'.$this->_current_view.'_'.$ref.'" />';
3159
+            if ( ! $both) {
3160 3160
                 break;
3161 3161
             }
3162 3162
         }
@@ -3196,13 +3196,13 @@  discard block
 block discarded – undo
3196 3196
                 'An error occurred. No action was set for this page\'s form.',
3197 3197
                 'event_espresso'
3198 3198
             );
3199
-            $dev_msg  = $user_msg . "\n"
3199
+            $dev_msg = $user_msg."\n"
3200 3200
                         . sprintf(
3201 3201
                             esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3202 3202
                             __FUNCTION__,
3203 3203
                             __CLASS__
3204 3204
                         );
3205
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3205
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3206 3206
         }
3207 3207
         // open form
3208 3208
         $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
@@ -3211,9 +3211,9 @@  discard block
 block discarded – undo
3211 3211
                                                              . $route
3212 3212
                                                              . '_event_form" >';
3213 3213
         // add nonce
3214
-        $nonce                                             =
3215
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3216
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3214
+        $nonce =
3215
+            wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3216
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3217 3217
         // add REQUIRED form action
3218 3218
         $hidden_fields = [
3219 3219
             'action' => ['type' => 'hidden', 'value' => $route],
@@ -3226,7 +3226,7 @@  discard block
 block discarded – undo
3226 3226
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3227 3227
         // add fields to form
3228 3228
         foreach ((array) $form_fields as $form_field) {
3229
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3229
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3230 3230
         }
3231 3231
         // close form
3232 3232
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3317,10 +3317,10 @@  discard block
 block discarded – undo
3317 3317
         $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3318 3318
         $notices      = EE_Error::get_notices(false);
3319 3319
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3320
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3320
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3321 3321
             EE_Error::overwrite_success();
3322 3322
         }
3323
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3323
+        if ( ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3324 3324
             // how many records affected ? more than one record ? or just one ?
3325 3325
             if ($success > 1) {
3326 3326
                 // set plural msg
@@ -3349,7 +3349,7 @@  discard block
 block discarded – undo
3349 3349
             }
3350 3350
         }
3351 3351
         // check that $query_args isn't something crazy
3352
-        if (! is_array($query_args)) {
3352
+        if ( ! is_array($query_args)) {
3353 3353
             $query_args = [];
3354 3354
         }
3355 3355
         /**
@@ -3378,7 +3378,7 @@  discard block
 block discarded – undo
3378 3378
             $redirect_url = admin_url('admin.php');
3379 3379
         }
3380 3380
         // merge any default query_args set in _default_route_query_args property
3381
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3381
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3382 3382
             $args_to_merge = [];
3383 3383
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3384 3384
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3390,15 +3390,15 @@  discard block
 block discarded – undo
3390 3390
                         }
3391 3391
                         // finally we will override any arguments in the referer with
3392 3392
                         // what might be set on the _default_route_query_args array.
3393
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3394
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3393
+                        if (isset($this->_default_route_query_args[$reference])) {
3394
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3395 3395
                         } else {
3396
-                            $args_to_merge[ $reference ] = urlencode($value);
3396
+                            $args_to_merge[$reference] = urlencode($value);
3397 3397
                         }
3398 3398
                     }
3399 3399
                     continue;
3400 3400
                 }
3401
-                $args_to_merge[ $query_param ] = $query_value;
3401
+                $args_to_merge[$query_param] = $query_value;
3402 3402
             }
3403 3403
             // now let's merge these arguments but override with what was specifically sent in to the
3404 3404
             // redirect.
@@ -3410,19 +3410,19 @@  discard block
 block discarded – undo
3410 3410
         if (isset($query_args['action'])) {
3411 3411
             // manually generate wp_nonce and merge that with the query vars
3412 3412
             // becuz the wp_nonce_url function wrecks havoc on some vars
3413
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3413
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3414 3414
         }
3415 3415
         // we're adding some hooks and filters in here for processing any things just before redirects
3416 3416
         // (example: an admin page has done an insert or update and we want to run something after that).
3417
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3417
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3418 3418
         $redirect_url = apply_filters(
3419
-            'FHEE_redirect_' . $classname . $this->_req_action,
3419
+            'FHEE_redirect_'.$classname.$this->_req_action,
3420 3420
             self::add_query_args_and_nonce($query_args, $redirect_url),
3421 3421
             $query_args
3422 3422
         );
3423 3423
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3424 3424
         if ($this->request->isAjax()) {
3425
-            $default_data                    = [
3425
+            $default_data = [
3426 3426
                 'close'        => true,
3427 3427
                 'redirect_url' => $redirect_url,
3428 3428
                 'where'        => 'main',
@@ -3469,7 +3469,7 @@  discard block
 block discarded – undo
3469 3469
         }
3470 3470
         $this->_template_args['notices'] = EE_Error::get_notices();
3471 3471
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3472
-        if (! $this->request->isAjax() || $sticky_notices) {
3472
+        if ( ! $this->request->isAjax() || $sticky_notices) {
3473 3473
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3474 3474
             $this->_add_transient(
3475 3475
                 $route,
@@ -3509,7 +3509,7 @@  discard block
 block discarded – undo
3509 3509
         $exclude_nonce = false
3510 3510
     ) {
3511 3511
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3512
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3512
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3513 3513
             throw new EE_Error(
3514 3514
                 sprintf(
3515 3515
                     esc_html__(
@@ -3520,7 +3520,7 @@  discard block
 block discarded – undo
3520 3520
                 )
3521 3521
             );
3522 3522
         }
3523
-        if (! isset($this->_labels['buttons'][ $type ])) {
3523
+        if ( ! isset($this->_labels['buttons'][$type])) {
3524 3524
             throw new EE_Error(
3525 3525
                 sprintf(
3526 3526
                     esc_html__(
@@ -3533,7 +3533,7 @@  discard block
 block discarded – undo
3533 3533
         }
3534 3534
         // finally check user access for this button.
3535 3535
         $has_access = $this->check_user_access($action, true);
3536
-        if (! $has_access) {
3536
+        if ( ! $has_access) {
3537 3537
             return '';
3538 3538
         }
3539 3539
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3541,11 +3541,11 @@  discard block
 block discarded – undo
3541 3541
             'action' => $action,
3542 3542
         ];
3543 3543
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3544
-        if (! empty($extra_request)) {
3544
+        if ( ! empty($extra_request)) {
3545 3545
             $query_args = array_merge($extra_request, $query_args);
3546 3546
         }
3547 3547
         $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3548
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3548
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3549 3549
     }
3550 3550
 
3551 3551
 
@@ -3571,7 +3571,7 @@  discard block
 block discarded – undo
3571 3571
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3572 3572
                 20
3573 3573
             ),
3574
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3574
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3575 3575
         ];
3576 3576
         // ONLY add the screen option if the user has access to it.
3577 3577
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3592,18 +3592,18 @@  discard block
 block discarded – undo
3592 3592
     {
3593 3593
         if ($this->request->requestParamIsSet('wp_screen_options')) {
3594 3594
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3595
-            if (! $user = wp_get_current_user()) {
3595
+            if ( ! $user = wp_get_current_user()) {
3596 3596
                 return;
3597 3597
             }
3598 3598
             $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3599
-            if (! $option) {
3599
+            if ( ! $option) {
3600 3600
                 return;
3601 3601
             }
3602
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3602
+            $value = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3603 3603
             $map_option = $option;
3604 3604
             $option     = str_replace('-', '_', $option);
3605 3605
             switch ($map_option) {
3606
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3606
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3607 3607
                     $max_value = apply_filters(
3608 3608
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3609 3609
                         999,
@@ -3660,13 +3660,13 @@  discard block
 block discarded – undo
3660 3660
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3661 3661
     {
3662 3662
         $user_id = get_current_user_id();
3663
-        if (! $skip_route_verify) {
3663
+        if ( ! $skip_route_verify) {
3664 3664
             $this->_verify_route($route);
3665 3665
         }
3666 3666
         // now let's set the string for what kind of transient we're setting
3667 3667
         $transient = $notices
3668
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3669
-            : 'rte_tx_' . $route . '_' . $user_id;
3668
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3669
+            : 'rte_tx_'.$route.'_'.$user_id;
3670 3670
         $data      = $notices ? ['notices' => $data] : $data;
3671 3671
         // is there already a transient for this route?  If there is then let's ADD to that transient
3672 3672
         $existing = is_multisite() && is_network_admin()
@@ -3695,8 +3695,8 @@  discard block
 block discarded – undo
3695 3695
         $user_id   = get_current_user_id();
3696 3696
         $route     = ! $route ? $this->_req_action : $route;
3697 3697
         $transient = $notices
3698
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3699
-            : 'rte_tx_' . $route . '_' . $user_id;
3698
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3699
+            : 'rte_tx_'.$route.'_'.$user_id;
3700 3700
         $data      = is_multisite() && is_network_admin()
3701 3701
             ? get_site_transient($transient)
3702 3702
             : get_transient($transient);
@@ -3927,7 +3927,7 @@  discard block
 block discarded – undo
3927 3927
      */
3928 3928
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3929 3929
     {
3930
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3930
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3931 3931
     }
3932 3932
 
3933 3933
 
@@ -3940,7 +3940,7 @@  discard block
 block discarded – undo
3940 3940
      */
3941 3941
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3942 3942
     {
3943
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3943
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3944 3944
     }
3945 3945
 
3946 3946
 
@@ -4088,7 +4088,7 @@  discard block
 block discarded – undo
4088 4088
         callable $callback = null
4089 4089
     ) {
4090 4090
         $entity_ID = absint($entity_ID);
4091
-        if (! $entity_ID) {
4091
+        if ( ! $entity_ID) {
4092 4092
             $this->trashRestoreDeleteError($action, $entity_model);
4093 4093
         }
4094 4094
         $result = 0;
@@ -4134,7 +4134,7 @@  discard block
 block discarded – undo
4134 4134
                 )
4135 4135
             );
4136 4136
         }
4137
-        if (! $entity_model->has_field($delete_column)) {
4137
+        if ( ! $entity_model->has_field($delete_column)) {
4138 4138
             throw new DomainException(
4139 4139
                 sprintf(
4140 4140
                     esc_html__(
Please login to merge, or discard this patch.