Completed
Branch FET/update-venues-admin-reques... (fe6c55)
by
unknown
13:17 queued 11:16
created
admin_pages/venues/Venues_Admin_Page.core.php 2 patches
Indentation   +1568 added lines, -1568 removed lines patch added patch discarded remove patch
@@ -14,1578 +14,1578 @@
 block discarded – undo
14 14
 class Venues_Admin_Page extends EE_Admin_Page_CPT
15 15
 {
16 16
 
17
-    /**
18
-     * _venue
19
-     * This will hold the venue object for venue_details screen.
20
-     *
21
-     * @access protected
22
-     * @var object
23
-     */
24
-    protected $_venue;
25
-
26
-
27
-    /**
28
-     * This will hold the category object for category_details screen.
29
-     *
30
-     * @var object
31
-     */
32
-    protected $_category;
33
-
34
-
35
-    /**
36
-     * This property will hold the venue model instance
37
-     *
38
-     * @var object
39
-     */
40
-    protected $_venue_model;
41
-
42
-
43
-    /**
44
-     * @throws EE_Error
45
-     */
46
-    protected function _init_page_props()
47
-    {
48
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
49
-        $this->page_slug        = EE_VENUES_PG_SLUG;
50
-        $this->_admin_base_url  = EE_VENUES_ADMIN_URL;
51
-        $this->_admin_base_path = EE_ADMIN_PAGES . 'venues';
52
-        $this->page_label       = esc_html__('Event Venues', 'event_espresso');
53
-        $this->_cpt_model_names = [
54
-            'create_new' => 'EEM_Venue',
55
-            'edit'       => 'EEM_Venue',
56
-        ];
57
-        $this->_cpt_edit_routes = [
58
-            'espresso_venues' => 'edit',
59
-        ];
60
-        $this->_venue_model     = EEM_Venue::instance();
61
-    }
62
-
63
-
64
-    protected function _ajax_hooks()
65
-    {
66
-        // todo: all hooks for ee_venues ajax goes in here.
67
-    }
68
-
69
-
70
-    protected function _define_page_props()
71
-    {
72
-        $this->_admin_page_title = $this->page_label;
73
-        $this->_labels           = [
74
-            'buttons'      => [
75
-                'add'             => esc_html__('Add New Venue', 'event_espresso'),
76
-                'edit'            => esc_html__('Edit Venue', 'event_espresso'),
77
-                'delete'          => esc_html__('Delete Venue', 'event_espresso'),
78
-                'add_category'    => esc_html__('Add New Category', 'event_espresso'),
79
-                'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
80
-                'delete_category' => esc_html__('Delete Category', 'event_espresso'),
81
-            ],
82
-            'editor_title' => [
83
-                'espresso_venues' => esc_html__('Enter Venue name here', 'event_espresso'),
84
-            ],
85
-            'publishbox'   => [
86
-                'create_new'          => esc_html__('Save New Venue', 'event_espresso'),
87
-                'edit'                => esc_html__('Update Venue', 'event_espresso'),
88
-                'add_category'        => esc_html__('Save New Category', 'event_espresso'),
89
-                'edit_category'       => esc_html__('Update Category', 'event_espresso'),
90
-                'google_map_settings' => esc_html__('Update Settings', 'event_espresso'),
91
-            ],
92
-        ];
93
-    }
94
-
95
-
96
-    protected function _set_page_routes()
97
-    {
98
-
99
-        // load formatter helper
100
-        // load field generator helper
101
-
102
-        // is there a vnu_id in the request?
103
-        $VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
104
-        $VNU_ID = $this->request->getRequestParam('post', $VNU_ID, 'int');
105
-
106
-        $this->_page_routes = [
107
-            'default'                    => [
108
-                'func'       => '_overview_list_table',
109
-                'capability' => 'ee_read_venues',
110
-            ],
111
-            'create_new'                 => [
112
-                'func'       => '_create_new_cpt_item',
113
-                'capability' => 'ee_edit_venues',
114
-            ],
115
-            'edit'                       => [
116
-                'func'       => '_edit_cpt_item',
117
-                'capability' => 'ee_edit_venue',
118
-                'obj_id'     => $VNU_ID,
119
-            ],
120
-            'trash_venue'                => [
121
-                'func'       => '_trash_or_restore_venue',
122
-                'args'       => ['venue_status' => 'trash'],
123
-                'noheader'   => true,
124
-                'capability' => 'ee_delete_venue',
125
-                'obj_id'     => $VNU_ID,
126
-            ],
127
-            'trash_venues'               => [
128
-                'func'       => '_trash_or_restore_venues',
129
-                'args'       => ['venue_status' => 'trash'],
130
-                'noheader'   => true,
131
-                'capability' => 'ee_delete_venues',
132
-            ],
133
-            'restore_venue'              => [
134
-                'func'       => '_trash_or_restore_venue',
135
-                'args'       => ['venue_status' => 'draft'],
136
-                'noheader'   => true,
137
-                'capability' => 'ee_delete_venue',
138
-                'obj_id'     => $VNU_ID,
139
-            ],
140
-            'restore_venues'             => [
141
-                'func'       => '_trash_or_restore_venues',
142
-                'args'       => ['venue_status' => 'draft'],
143
-                'noheader'   => true,
144
-                'capability' => 'ee_delete_venues',
145
-            ],
146
-            'delete_venues'              => [
147
-                'func'       => '_delete_venues',
148
-                'noheader'   => true,
149
-                'capability' => 'ee_delete_venues',
150
-            ],
151
-            'delete_venue'               => [
152
-                'func'       => '_delete_venue',
153
-                'noheader'   => true,
154
-                'capability' => 'ee_delete_venue',
155
-                'obj_id'     => $VNU_ID,
156
-            ],
157
-            // settings related
158
-            'google_map_settings'        => [
159
-                'func'       => '_google_map_settings',
160
-                'capability' => 'manage_options',
161
-            ],
162
-            'update_google_map_settings' => [
163
-                'func'       => '_update_google_map_settings',
164
-                'capability' => 'manage_options',
165
-                'noheader'   => true,
166
-            ],
167
-            // venue category tab related
168
-            'add_category'               => [
169
-                'func'       => '_category_details',
170
-                'args'       => ['add'],
171
-                'capability' => 'ee_edit_venue_category',
172
-            ],
173
-            'edit_category'              => [
174
-                'func'       => '_category_details',
175
-                'args'       => ['edit'],
176
-                'capability' => 'ee_edit_venue_category',
177
-            ],
178
-            'delete_categories'          => [
179
-                'func'       => '_delete_categories',
180
-                'noheader'   => true,
181
-                'capability' => 'ee_delete_venue_category',
182
-            ],
183
-
184
-            'delete_category' => [
185
-                'func'       => '_delete_categories',
186
-                'noheader'   => true,
187
-                'capability' => 'ee_delete_venue_category',
188
-            ],
189
-
190
-            'insert_category' => [
191
-                'func'       => '_insert_or_update_category',
192
-                'args'       => ['new_category' => true],
193
-                'noheader'   => true,
194
-                'capability' => 'ee_edit_venue_category',
195
-            ],
196
-
197
-            'update_category'   => [
198
-                'func'       => '_insert_or_update_category',
199
-                'args'       => ['new_category' => false],
200
-                'noheader'   => true,
201
-                'capability' => 'ee_edit_venue_category',
202
-            ],
203
-            'export_categories' => [
204
-                'func'       => '_categories_export',
205
-                'noheader'   => true,
206
-                'capability' => 'export',
207
-            ],
208
-            'import_categories' => [
209
-                'func'       => '_import_categories',
210
-                'capability' => 'import',
211
-            ],
212
-            'category_list'     => [
213
-                'func'       => '_category_list_table',
214
-                'capability' => 'ee_manage_venue_categories',
215
-            ],
216
-        ];
217
-    }
218
-
219
-
220
-    protected function _set_page_config()
221
-    {
222
-        $VNU_ID     = $this->request->getRequestParam('post', 0, 'int');
223
-        $EVT_CAT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
224
-
225
-        $this->_page_config = [
226
-            'default'             => [
227
-                'nav'           => [
228
-                    'label' => esc_html__('Overview', 'event_espresso'),
229
-                    'order' => 10,
230
-                ],
231
-                'list_table'    => 'Venues_Admin_List_Table',
232
-                'help_tabs'     => [
233
-                    'venues_overview_help_tab'                           => [
234
-                        'title'    => esc_html__('Venues Overview', 'event_espresso'),
235
-                        'filename' => 'venues_overview',
236
-                    ],
237
-                    'venues_overview_table_column_headings_help_tab'     => [
238
-                        'title'    => esc_html__('Venues Overview Table Column Headings', 'event_espresso'),
239
-                        'filename' => 'venues_overview_table_column_headings',
240
-                    ],
241
-                    'venues_overview_views_bulk_actions_search_help_tab' => [
242
-                        'title'    => esc_html__('Venues Overview Views & Bulk Actions & Search', 'event_espresso'),
243
-                        'filename' => 'venues_overview_views_bulk_actions_search',
244
-                    ],
245
-                ],
246
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
247
-                // 'help_tour'     => array('Venues_Overview_Help_Tour'),
248
-                'metaboxes'     => ['_espresso_news_post_box', '_espresso_links_post_box'],
249
-                'require_nonce' => false,
250
-            ],
251
-            'create_new'          => [
252
-                'nav'           => [
253
-                    'label'      => esc_html__('Add Venue', 'event_espresso'),
254
-                    'order'      => 5,
255
-                    'persistent' => false,
256
-                ],
257
-                'help_tabs'     => [
258
-                    'venues_editor_help_tab'                                               => [
259
-                        'title'    => esc_html__('Venue Editor', 'event_espresso'),
260
-                        'filename' => 'venues_editor',
261
-                    ],
262
-                    'venues_editor_title_richtexteditor_help_tab'                          => [
263
-                        'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
264
-                        'filename' => 'venues_editor_title_richtexteditor',
265
-                    ],
266
-                    'venues_editor_tags_categories_help_tab'                               => [
267
-                        'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
268
-                        'filename' => 'venues_editor_tags_categories',
269
-                    ],
270
-                    'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
271
-                        'title'    => esc_html__(
272
-                            'Venue Editor Physical Location & Google Map & Virtual Location',
273
-                            'event_espresso'
274
-                        ),
275
-                        'filename' => 'venues_editor_physical_location_google_map_virtual_location',
276
-                    ],
277
-                    'venues_editor_save_new_venue_help_tab'                                => [
278
-                        'title'    => esc_html__('Save New Venue', 'event_espresso'),
279
-                        'filename' => 'venues_editor_save_new_venue',
280
-                    ],
281
-                    'venues_editor_other_help_tab'                                         => [
282
-                        'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
283
-                        'filename' => 'venues_editor_other',
284
-                    ],
285
-                ],
286
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
287
-                // 'help_tour'     => array('Venues_Add_Venue_Help_Tour'),
288
-                'metaboxes'     => ['_venue_editor_metaboxes'],
289
-                'require_nonce' => false,
290
-            ],
291
-            'edit'                => [
292
-                'nav'           => [
293
-                    'label'      => esc_html__('Edit Venue', 'event_espresso'),
294
-                    'order'      => 5,
295
-                    'persistent' => false,
296
-                    'url'        => $VNU_ID
297
-                        ? add_query_arg(['post' => $VNU_ID], $this->_current_page_view_url)
298
-                        : $this->_admin_base_url,
299
-                ],
300
-                'help_tabs'     => [
301
-                    'venues_editor_help_tab'                                               => [
302
-                        'title'    => esc_html__('Venue Editor', 'event_espresso'),
303
-                        'filename' => 'venues_editor',
304
-                    ],
305
-                    'venues_editor_title_richtexteditor_help_tab'                          => [
306
-                        'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
307
-                        'filename' => 'venues_editor_title_richtexteditor',
308
-                    ],
309
-                    'venues_editor_tags_categories_help_tab'                               => [
310
-                        'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
311
-                        'filename' => 'venues_editor_tags_categories',
312
-                    ],
313
-                    'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
314
-                        'title'    => esc_html__(
315
-                            'Venue Editor Physical Location & Google Map & Virtual Location',
316
-                            'event_espresso'
317
-                        ),
318
-                        'filename' => 'venues_editor_physical_location_google_map_virtual_location',
319
-                    ],
320
-                    'venues_editor_save_new_venue_help_tab'                                => [
321
-                        'title'    => esc_html__('Save New Venue', 'event_espresso'),
322
-                        'filename' => 'venues_editor_save_new_venue',
323
-                    ],
324
-                    'venues_editor_other_help_tab'                                         => [
325
-                        'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
326
-                        'filename' => 'venues_editor_other',
327
-                    ],
328
-                ],
329
-                /*'help_tour' => array( 'Venues_Edit_Venue_Help_Tour' ),*/
330
-                'metaboxes'     => ['_venue_editor_metaboxes'],
331
-                'require_nonce' => false,
332
-            ],
333
-            'google_map_settings' => [
334
-                'nav'           => [
335
-                    'label' => esc_html__('Google Maps', 'event_espresso'),
336
-                    'order' => 40,
337
-                ],
338
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
339
-                'help_tabs'     => [
340
-                    'general_settings_google_maps_help_tab' => [
341
-                        'title'    => esc_html__('Google Maps', 'event_espresso'),
342
-                        'filename' => 'general_settings_google_maps',
343
-                    ],
344
-                ],
345
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
346
-                // 'help_tour'     => array('Google_Maps_Help_Tour'),
347
-                'require_nonce' => false,
348
-            ],
349
-            // venue category stuff
350
-            'add_category'        => [
351
-                'nav'           => [
352
-                    'label'      => esc_html__('Add Category', 'event_espresso'),
353
-                    'order'      => 15,
354
-                    'persistent' => false,
355
-                ],
356
-                'metaboxes'     => ['_publish_post_box'],
357
-                'help_tabs'     => [
358
-                    'venues_add_category_help_tab' => [
359
-                        'title'    => esc_html__('Add New Venue Category', 'event_espresso'),
360
-                        'filename' => 'venues_add_category',
361
-                    ],
362
-                ],
363
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
364
-                // 'help_tour'     => array('Venues_Add_Category_Help_Tour'),
365
-                'require_nonce' => false,
366
-            ],
367
-            'edit_category'       => [
368
-                'nav'           => [
369
-                    'label'      => esc_html__('Edit Category', 'event_espresso'),
370
-                    'order'      => 15,
371
-                    'persistent' => false,
372
-                    'url'        => $EVT_CAT_ID
373
-                        ? add_query_arg(['EVT_CAT_ID' => $EVT_CAT_ID], $this->_current_page_view_url)
374
-                        : $this->_admin_base_url,
375
-                ],
376
-                'metaboxes'     => ['_publish_post_box'],
377
-                'help_tabs'     => [
378
-                    'venues_edit_category_help_tab' => [
379
-                        'title'    => esc_html__('Edit Venue Category', 'event_espresso'),
380
-                        'filename' => 'venues_edit_category',
381
-                    ],
382
-                ],
383
-                /*'help_tour' => array( 'Venues_Edit_Category_Help_Tour' ),*/
384
-                'require_nonce' => false,
385
-            ],
386
-            'category_list'       => [
387
-                'nav'           => [
388
-                    'label' => esc_html__('Categories', 'event_espresso'),
389
-                    'order' => 20,
390
-                ],
391
-                'list_table'    => 'Venue_Categories_Admin_List_Table',
392
-                'help_tabs'     => [
393
-                    'venues_categories_help_tab'                       => [
394
-                        'title'    => esc_html__('Venue Categories', 'event_espresso'),
395
-                        'filename' => 'venues_categories',
396
-                    ],
397
-                    'venues_categories_table_column_headings_help_tab' => [
398
-                        'title'    => esc_html__('Venue Categories Table Column Headings', 'event_espresso'),
399
-                        'filename' => 'venues_categories_table_column_headings',
400
-                    ],
401
-                    'venues_categories_views_help_tab'                 => [
402
-                        'title'    => esc_html__('Venue Categories Views', 'event_espresso'),
403
-                        'filename' => 'venues_categories_views',
404
-                    ],
405
-                    'venues_categories_other_help_tab'                 => [
406
-                        'title'    => esc_html__('Venue Categories Other', 'event_espresso'),
407
-                        'filename' => 'venues_categories_other',
408
-                    ],
409
-                ],
410
-                // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
411
-                // 'help_tour'     => array('Venues_Categories_Help_Tour'),
412
-                'metaboxes'     => $this->_default_espresso_metaboxes,
413
-                'require_nonce' => false,
414
-            ],
415
-        ];
416
-    }
417
-
418
-
419
-    protected function _add_screen_options()
420
-    {
421
-        // todo
422
-    }
423
-
424
-
425
-    protected function _add_screen_options_default()
426
-    {
427
-        $this->_per_page_screen_option();
428
-    }
429
-
430
-
431
-    protected function _add_screen_options_category_list()
432
-    {
433
-        $page_title              = $this->_admin_page_title;
434
-        $this->_admin_page_title = esc_html__('Venue Categories', 'event_espresso');
435
-        $this->_per_page_screen_option();
436
-        $this->_admin_page_title = $page_title;
437
-    }
438
-
439
-
440
-    // none of the below group are currently used for Event Venues
441
-    protected function _add_feature_pointers()
442
-    {
443
-    }
444
-
445
-
446
-    public function admin_init()
447
-    {
448
-    }
449
-
450
-
451
-    public function admin_notices()
452
-    {
453
-    }
454
-
455
-
456
-    public function admin_footer_scripts()
457
-    {
458
-    }
459
-
460
-
461
-    public function load_scripts_styles_create_new()
462
-    {
463
-        $this->load_scripts_styles_edit();
464
-    }
465
-
466
-
467
-    public function load_scripts_styles()
468
-    {
469
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', [], EVENT_ESPRESSO_VERSION);
470
-        wp_enqueue_style('ee-cat-admin');
471
-    }
472
-
473
-
474
-    public function load_scripts_styles_add_category()
475
-    {
476
-        $this->load_scripts_styles_edit_category();
477
-    }
478
-
479
-
480
-    public function load_scripts_styles_edit_category()
481
-    {
482
-    }
483
-
484
-
485
-    public function load_scripts_styles_edit()
486
-    {
487
-        // styles
488
-        wp_enqueue_style('espresso-ui-theme');
489
-        wp_register_style(
490
-            'espresso_venues',
491
-            EE_VENUES_ASSETS_URL . 'ee-venues-admin.css',
492
-            [],
493
-            EVENT_ESPRESSO_VERSION
494
-        );
495
-        wp_enqueue_style('espresso_venues');
496
-    }
497
-
498
-
499
-    protected function _set_list_table_views_default()
500
-    {
501
-        $this->_views = [
502
-            'all' => [
503
-                'slug'        => 'all',
504
-                'label'       => esc_html__('View All Venues', 'event_espresso'),
505
-                'count'       => 0,
506
-                'bulk_action' => [],
507
-            ],
508
-        ];
509
-
510
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) {
511
-            $this->_views['all']['bulk_action'] = [
512
-                'trash_venues' => esc_html__('Move to Trash', 'event_espresso'),
513
-            ];
514
-            $this->_views['trash']              = [
515
-                'slug'        => 'trash',
516
-                'label'       => esc_html__('Trash', 'event_espresso'),
517
-                'count'       => 0,
518
-                'bulk_action' => [
519
-                    'restore_venues' => esc_html__('Restore from Trash', 'event_espresso'),
520
-                    'delete_venues'  => esc_html__('Delete', 'event_espresso'),
521
-                ],
522
-            ];
523
-        }
524
-    }
525
-
526
-
527
-    protected function _set_list_table_views_category_list()
528
-    {
529
-        $this->_views = [
530
-            'all' => [
531
-                'slug'        => 'all',
532
-                'label'       => esc_html__('All', 'event_espresso'),
533
-                'count'       => 0,
534
-                'bulk_action' => [
535
-                    'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
536
-                ],
537
-            ],
538
-        ];
539
-    }
540
-
541
-
542
-    /**
543
-     * @throws EE_Error
544
-     */
545
-    protected function _overview_list_table()
546
-    {
547
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
548
-        $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(
549
-            get_post_type_archive_link('espresso_venues'),
550
-            esc_html__("View Venue Archive Page", "event_espresso"),
551
-            'button'
552
-        );
553
-
554
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
555
-            'create_new',
556
-            'add',
557
-            [],
558
-            'add-new-h2'
559
-        );
560
-
561
-        $this->_search_btn_label  = esc_html__('Venues', 'event_espresso');
562
-        $this->display_admin_list_table_page_with_sidebar();
563
-    }
564
-
565
-
566
-    /**
567
-     * @throws EE_Error
568
-     * @throws ReflectionException
569
-     */
570
-    public function extra_misc_actions_publish_box()
571
-    {
572
-        $extra_rows = [
573
-            'vnu_capacity' => $this->_cpt_model_obj->get_f('VNU_capacity'),
574
-            'vnu_url'      => $this->_cpt_model_obj->get_f('VNU_url'),
575
-            'vnu_phone'    => $this->_cpt_model_obj->get_f('VNU_phone'),
576
-        ];
577
-        $template   = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php';
578
-        EEH_Template::display_template($template, $extra_rows);
579
-    }
580
-
581
-
582
-    /*************        Google Maps        *************
17
+	/**
18
+	 * _venue
19
+	 * This will hold the venue object for venue_details screen.
20
+	 *
21
+	 * @access protected
22
+	 * @var object
23
+	 */
24
+	protected $_venue;
25
+
26
+
27
+	/**
28
+	 * This will hold the category object for category_details screen.
29
+	 *
30
+	 * @var object
31
+	 */
32
+	protected $_category;
33
+
34
+
35
+	/**
36
+	 * This property will hold the venue model instance
37
+	 *
38
+	 * @var object
39
+	 */
40
+	protected $_venue_model;
41
+
42
+
43
+	/**
44
+	 * @throws EE_Error
45
+	 */
46
+	protected function _init_page_props()
47
+	{
48
+		require_once(EE_MODELS . 'EEM_Venue.model.php');
49
+		$this->page_slug        = EE_VENUES_PG_SLUG;
50
+		$this->_admin_base_url  = EE_VENUES_ADMIN_URL;
51
+		$this->_admin_base_path = EE_ADMIN_PAGES . 'venues';
52
+		$this->page_label       = esc_html__('Event Venues', 'event_espresso');
53
+		$this->_cpt_model_names = [
54
+			'create_new' => 'EEM_Venue',
55
+			'edit'       => 'EEM_Venue',
56
+		];
57
+		$this->_cpt_edit_routes = [
58
+			'espresso_venues' => 'edit',
59
+		];
60
+		$this->_venue_model     = EEM_Venue::instance();
61
+	}
62
+
63
+
64
+	protected function _ajax_hooks()
65
+	{
66
+		// todo: all hooks for ee_venues ajax goes in here.
67
+	}
68
+
69
+
70
+	protected function _define_page_props()
71
+	{
72
+		$this->_admin_page_title = $this->page_label;
73
+		$this->_labels           = [
74
+			'buttons'      => [
75
+				'add'             => esc_html__('Add New Venue', 'event_espresso'),
76
+				'edit'            => esc_html__('Edit Venue', 'event_espresso'),
77
+				'delete'          => esc_html__('Delete Venue', 'event_espresso'),
78
+				'add_category'    => esc_html__('Add New Category', 'event_espresso'),
79
+				'edit_category'   => esc_html__('Edit Category', 'event_espresso'),
80
+				'delete_category' => esc_html__('Delete Category', 'event_espresso'),
81
+			],
82
+			'editor_title' => [
83
+				'espresso_venues' => esc_html__('Enter Venue name here', 'event_espresso'),
84
+			],
85
+			'publishbox'   => [
86
+				'create_new'          => esc_html__('Save New Venue', 'event_espresso'),
87
+				'edit'                => esc_html__('Update Venue', 'event_espresso'),
88
+				'add_category'        => esc_html__('Save New Category', 'event_espresso'),
89
+				'edit_category'       => esc_html__('Update Category', 'event_espresso'),
90
+				'google_map_settings' => esc_html__('Update Settings', 'event_espresso'),
91
+			],
92
+		];
93
+	}
94
+
95
+
96
+	protected function _set_page_routes()
97
+	{
98
+
99
+		// load formatter helper
100
+		// load field generator helper
101
+
102
+		// is there a vnu_id in the request?
103
+		$VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
104
+		$VNU_ID = $this->request->getRequestParam('post', $VNU_ID, 'int');
105
+
106
+		$this->_page_routes = [
107
+			'default'                    => [
108
+				'func'       => '_overview_list_table',
109
+				'capability' => 'ee_read_venues',
110
+			],
111
+			'create_new'                 => [
112
+				'func'       => '_create_new_cpt_item',
113
+				'capability' => 'ee_edit_venues',
114
+			],
115
+			'edit'                       => [
116
+				'func'       => '_edit_cpt_item',
117
+				'capability' => 'ee_edit_venue',
118
+				'obj_id'     => $VNU_ID,
119
+			],
120
+			'trash_venue'                => [
121
+				'func'       => '_trash_or_restore_venue',
122
+				'args'       => ['venue_status' => 'trash'],
123
+				'noheader'   => true,
124
+				'capability' => 'ee_delete_venue',
125
+				'obj_id'     => $VNU_ID,
126
+			],
127
+			'trash_venues'               => [
128
+				'func'       => '_trash_or_restore_venues',
129
+				'args'       => ['venue_status' => 'trash'],
130
+				'noheader'   => true,
131
+				'capability' => 'ee_delete_venues',
132
+			],
133
+			'restore_venue'              => [
134
+				'func'       => '_trash_or_restore_venue',
135
+				'args'       => ['venue_status' => 'draft'],
136
+				'noheader'   => true,
137
+				'capability' => 'ee_delete_venue',
138
+				'obj_id'     => $VNU_ID,
139
+			],
140
+			'restore_venues'             => [
141
+				'func'       => '_trash_or_restore_venues',
142
+				'args'       => ['venue_status' => 'draft'],
143
+				'noheader'   => true,
144
+				'capability' => 'ee_delete_venues',
145
+			],
146
+			'delete_venues'              => [
147
+				'func'       => '_delete_venues',
148
+				'noheader'   => true,
149
+				'capability' => 'ee_delete_venues',
150
+			],
151
+			'delete_venue'               => [
152
+				'func'       => '_delete_venue',
153
+				'noheader'   => true,
154
+				'capability' => 'ee_delete_venue',
155
+				'obj_id'     => $VNU_ID,
156
+			],
157
+			// settings related
158
+			'google_map_settings'        => [
159
+				'func'       => '_google_map_settings',
160
+				'capability' => 'manage_options',
161
+			],
162
+			'update_google_map_settings' => [
163
+				'func'       => '_update_google_map_settings',
164
+				'capability' => 'manage_options',
165
+				'noheader'   => true,
166
+			],
167
+			// venue category tab related
168
+			'add_category'               => [
169
+				'func'       => '_category_details',
170
+				'args'       => ['add'],
171
+				'capability' => 'ee_edit_venue_category',
172
+			],
173
+			'edit_category'              => [
174
+				'func'       => '_category_details',
175
+				'args'       => ['edit'],
176
+				'capability' => 'ee_edit_venue_category',
177
+			],
178
+			'delete_categories'          => [
179
+				'func'       => '_delete_categories',
180
+				'noheader'   => true,
181
+				'capability' => 'ee_delete_venue_category',
182
+			],
183
+
184
+			'delete_category' => [
185
+				'func'       => '_delete_categories',
186
+				'noheader'   => true,
187
+				'capability' => 'ee_delete_venue_category',
188
+			],
189
+
190
+			'insert_category' => [
191
+				'func'       => '_insert_or_update_category',
192
+				'args'       => ['new_category' => true],
193
+				'noheader'   => true,
194
+				'capability' => 'ee_edit_venue_category',
195
+			],
196
+
197
+			'update_category'   => [
198
+				'func'       => '_insert_or_update_category',
199
+				'args'       => ['new_category' => false],
200
+				'noheader'   => true,
201
+				'capability' => 'ee_edit_venue_category',
202
+			],
203
+			'export_categories' => [
204
+				'func'       => '_categories_export',
205
+				'noheader'   => true,
206
+				'capability' => 'export',
207
+			],
208
+			'import_categories' => [
209
+				'func'       => '_import_categories',
210
+				'capability' => 'import',
211
+			],
212
+			'category_list'     => [
213
+				'func'       => '_category_list_table',
214
+				'capability' => 'ee_manage_venue_categories',
215
+			],
216
+		];
217
+	}
218
+
219
+
220
+	protected function _set_page_config()
221
+	{
222
+		$VNU_ID     = $this->request->getRequestParam('post', 0, 'int');
223
+		$EVT_CAT_ID = $this->request->getRequestParam('EVT_CAT_ID', 0, 'int');
224
+
225
+		$this->_page_config = [
226
+			'default'             => [
227
+				'nav'           => [
228
+					'label' => esc_html__('Overview', 'event_espresso'),
229
+					'order' => 10,
230
+				],
231
+				'list_table'    => 'Venues_Admin_List_Table',
232
+				'help_tabs'     => [
233
+					'venues_overview_help_tab'                           => [
234
+						'title'    => esc_html__('Venues Overview', 'event_espresso'),
235
+						'filename' => 'venues_overview',
236
+					],
237
+					'venues_overview_table_column_headings_help_tab'     => [
238
+						'title'    => esc_html__('Venues Overview Table Column Headings', 'event_espresso'),
239
+						'filename' => 'venues_overview_table_column_headings',
240
+					],
241
+					'venues_overview_views_bulk_actions_search_help_tab' => [
242
+						'title'    => esc_html__('Venues Overview Views & Bulk Actions & Search', 'event_espresso'),
243
+						'filename' => 'venues_overview_views_bulk_actions_search',
244
+					],
245
+				],
246
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
247
+				// 'help_tour'     => array('Venues_Overview_Help_Tour'),
248
+				'metaboxes'     => ['_espresso_news_post_box', '_espresso_links_post_box'],
249
+				'require_nonce' => false,
250
+			],
251
+			'create_new'          => [
252
+				'nav'           => [
253
+					'label'      => esc_html__('Add Venue', 'event_espresso'),
254
+					'order'      => 5,
255
+					'persistent' => false,
256
+				],
257
+				'help_tabs'     => [
258
+					'venues_editor_help_tab'                                               => [
259
+						'title'    => esc_html__('Venue Editor', 'event_espresso'),
260
+						'filename' => 'venues_editor',
261
+					],
262
+					'venues_editor_title_richtexteditor_help_tab'                          => [
263
+						'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
264
+						'filename' => 'venues_editor_title_richtexteditor',
265
+					],
266
+					'venues_editor_tags_categories_help_tab'                               => [
267
+						'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
268
+						'filename' => 'venues_editor_tags_categories',
269
+					],
270
+					'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
271
+						'title'    => esc_html__(
272
+							'Venue Editor Physical Location & Google Map & Virtual Location',
273
+							'event_espresso'
274
+						),
275
+						'filename' => 'venues_editor_physical_location_google_map_virtual_location',
276
+					],
277
+					'venues_editor_save_new_venue_help_tab'                                => [
278
+						'title'    => esc_html__('Save New Venue', 'event_espresso'),
279
+						'filename' => 'venues_editor_save_new_venue',
280
+					],
281
+					'venues_editor_other_help_tab'                                         => [
282
+						'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
283
+						'filename' => 'venues_editor_other',
284
+					],
285
+				],
286
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
287
+				// 'help_tour'     => array('Venues_Add_Venue_Help_Tour'),
288
+				'metaboxes'     => ['_venue_editor_metaboxes'],
289
+				'require_nonce' => false,
290
+			],
291
+			'edit'                => [
292
+				'nav'           => [
293
+					'label'      => esc_html__('Edit Venue', 'event_espresso'),
294
+					'order'      => 5,
295
+					'persistent' => false,
296
+					'url'        => $VNU_ID
297
+						? add_query_arg(['post' => $VNU_ID], $this->_current_page_view_url)
298
+						: $this->_admin_base_url,
299
+				],
300
+				'help_tabs'     => [
301
+					'venues_editor_help_tab'                                               => [
302
+						'title'    => esc_html__('Venue Editor', 'event_espresso'),
303
+						'filename' => 'venues_editor',
304
+					],
305
+					'venues_editor_title_richtexteditor_help_tab'                          => [
306
+						'title'    => esc_html__('Venue Title & Rich Text Editor', 'event_espresso'),
307
+						'filename' => 'venues_editor_title_richtexteditor',
308
+					],
309
+					'venues_editor_tags_categories_help_tab'                               => [
310
+						'title'    => esc_html__('Venue Tags & Categories', 'event_espresso'),
311
+						'filename' => 'venues_editor_tags_categories',
312
+					],
313
+					'venues_editor_physical_location_google_map_virtual_location_help_tab' => [
314
+						'title'    => esc_html__(
315
+							'Venue Editor Physical Location & Google Map & Virtual Location',
316
+							'event_espresso'
317
+						),
318
+						'filename' => 'venues_editor_physical_location_google_map_virtual_location',
319
+					],
320
+					'venues_editor_save_new_venue_help_tab'                                => [
321
+						'title'    => esc_html__('Save New Venue', 'event_espresso'),
322
+						'filename' => 'venues_editor_save_new_venue',
323
+					],
324
+					'venues_editor_other_help_tab'                                         => [
325
+						'title'    => esc_html__('Venue Editor Other', 'event_espresso'),
326
+						'filename' => 'venues_editor_other',
327
+					],
328
+				],
329
+				/*'help_tour' => array( 'Venues_Edit_Venue_Help_Tour' ),*/
330
+				'metaboxes'     => ['_venue_editor_metaboxes'],
331
+				'require_nonce' => false,
332
+			],
333
+			'google_map_settings' => [
334
+				'nav'           => [
335
+					'label' => esc_html__('Google Maps', 'event_espresso'),
336
+					'order' => 40,
337
+				],
338
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, ['_publish_post_box']),
339
+				'help_tabs'     => [
340
+					'general_settings_google_maps_help_tab' => [
341
+						'title'    => esc_html__('Google Maps', 'event_espresso'),
342
+						'filename' => 'general_settings_google_maps',
343
+					],
344
+				],
345
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
346
+				// 'help_tour'     => array('Google_Maps_Help_Tour'),
347
+				'require_nonce' => false,
348
+			],
349
+			// venue category stuff
350
+			'add_category'        => [
351
+				'nav'           => [
352
+					'label'      => esc_html__('Add Category', 'event_espresso'),
353
+					'order'      => 15,
354
+					'persistent' => false,
355
+				],
356
+				'metaboxes'     => ['_publish_post_box'],
357
+				'help_tabs'     => [
358
+					'venues_add_category_help_tab' => [
359
+						'title'    => esc_html__('Add New Venue Category', 'event_espresso'),
360
+						'filename' => 'venues_add_category',
361
+					],
362
+				],
363
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
364
+				// 'help_tour'     => array('Venues_Add_Category_Help_Tour'),
365
+				'require_nonce' => false,
366
+			],
367
+			'edit_category'       => [
368
+				'nav'           => [
369
+					'label'      => esc_html__('Edit Category', 'event_espresso'),
370
+					'order'      => 15,
371
+					'persistent' => false,
372
+					'url'        => $EVT_CAT_ID
373
+						? add_query_arg(['EVT_CAT_ID' => $EVT_CAT_ID], $this->_current_page_view_url)
374
+						: $this->_admin_base_url,
375
+				],
376
+				'metaboxes'     => ['_publish_post_box'],
377
+				'help_tabs'     => [
378
+					'venues_edit_category_help_tab' => [
379
+						'title'    => esc_html__('Edit Venue Category', 'event_espresso'),
380
+						'filename' => 'venues_edit_category',
381
+					],
382
+				],
383
+				/*'help_tour' => array( 'Venues_Edit_Category_Help_Tour' ),*/
384
+				'require_nonce' => false,
385
+			],
386
+			'category_list'       => [
387
+				'nav'           => [
388
+					'label' => esc_html__('Categories', 'event_espresso'),
389
+					'order' => 20,
390
+				],
391
+				'list_table'    => 'Venue_Categories_Admin_List_Table',
392
+				'help_tabs'     => [
393
+					'venues_categories_help_tab'                       => [
394
+						'title'    => esc_html__('Venue Categories', 'event_espresso'),
395
+						'filename' => 'venues_categories',
396
+					],
397
+					'venues_categories_table_column_headings_help_tab' => [
398
+						'title'    => esc_html__('Venue Categories Table Column Headings', 'event_espresso'),
399
+						'filename' => 'venues_categories_table_column_headings',
400
+					],
401
+					'venues_categories_views_help_tab'                 => [
402
+						'title'    => esc_html__('Venue Categories Views', 'event_espresso'),
403
+						'filename' => 'venues_categories_views',
404
+					],
405
+					'venues_categories_other_help_tab'                 => [
406
+						'title'    => esc_html__('Venue Categories Other', 'event_espresso'),
407
+						'filename' => 'venues_categories_other',
408
+					],
409
+				],
410
+				// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
411
+				// 'help_tour'     => array('Venues_Categories_Help_Tour'),
412
+				'metaboxes'     => $this->_default_espresso_metaboxes,
413
+				'require_nonce' => false,
414
+			],
415
+		];
416
+	}
417
+
418
+
419
+	protected function _add_screen_options()
420
+	{
421
+		// todo
422
+	}
423
+
424
+
425
+	protected function _add_screen_options_default()
426
+	{
427
+		$this->_per_page_screen_option();
428
+	}
429
+
430
+
431
+	protected function _add_screen_options_category_list()
432
+	{
433
+		$page_title              = $this->_admin_page_title;
434
+		$this->_admin_page_title = esc_html__('Venue Categories', 'event_espresso');
435
+		$this->_per_page_screen_option();
436
+		$this->_admin_page_title = $page_title;
437
+	}
438
+
439
+
440
+	// none of the below group are currently used for Event Venues
441
+	protected function _add_feature_pointers()
442
+	{
443
+	}
444
+
445
+
446
+	public function admin_init()
447
+	{
448
+	}
449
+
450
+
451
+	public function admin_notices()
452
+	{
453
+	}
454
+
455
+
456
+	public function admin_footer_scripts()
457
+	{
458
+	}
459
+
460
+
461
+	public function load_scripts_styles_create_new()
462
+	{
463
+		$this->load_scripts_styles_edit();
464
+	}
465
+
466
+
467
+	public function load_scripts_styles()
468
+	{
469
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', [], EVENT_ESPRESSO_VERSION);
470
+		wp_enqueue_style('ee-cat-admin');
471
+	}
472
+
473
+
474
+	public function load_scripts_styles_add_category()
475
+	{
476
+		$this->load_scripts_styles_edit_category();
477
+	}
478
+
479
+
480
+	public function load_scripts_styles_edit_category()
481
+	{
482
+	}
483
+
484
+
485
+	public function load_scripts_styles_edit()
486
+	{
487
+		// styles
488
+		wp_enqueue_style('espresso-ui-theme');
489
+		wp_register_style(
490
+			'espresso_venues',
491
+			EE_VENUES_ASSETS_URL . 'ee-venues-admin.css',
492
+			[],
493
+			EVENT_ESPRESSO_VERSION
494
+		);
495
+		wp_enqueue_style('espresso_venues');
496
+	}
497
+
498
+
499
+	protected function _set_list_table_views_default()
500
+	{
501
+		$this->_views = [
502
+			'all' => [
503
+				'slug'        => 'all',
504
+				'label'       => esc_html__('View All Venues', 'event_espresso'),
505
+				'count'       => 0,
506
+				'bulk_action' => [],
507
+			],
508
+		];
509
+
510
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) {
511
+			$this->_views['all']['bulk_action'] = [
512
+				'trash_venues' => esc_html__('Move to Trash', 'event_espresso'),
513
+			];
514
+			$this->_views['trash']              = [
515
+				'slug'        => 'trash',
516
+				'label'       => esc_html__('Trash', 'event_espresso'),
517
+				'count'       => 0,
518
+				'bulk_action' => [
519
+					'restore_venues' => esc_html__('Restore from Trash', 'event_espresso'),
520
+					'delete_venues'  => esc_html__('Delete', 'event_espresso'),
521
+				],
522
+			];
523
+		}
524
+	}
525
+
526
+
527
+	protected function _set_list_table_views_category_list()
528
+	{
529
+		$this->_views = [
530
+			'all' => [
531
+				'slug'        => 'all',
532
+				'label'       => esc_html__('All', 'event_espresso'),
533
+				'count'       => 0,
534
+				'bulk_action' => [
535
+					'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'),
536
+				],
537
+			],
538
+		];
539
+	}
540
+
541
+
542
+	/**
543
+	 * @throws EE_Error
544
+	 */
545
+	protected function _overview_list_table()
546
+	{
547
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
548
+		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(
549
+			get_post_type_archive_link('espresso_venues'),
550
+			esc_html__("View Venue Archive Page", "event_espresso"),
551
+			'button'
552
+		);
553
+
554
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
555
+			'create_new',
556
+			'add',
557
+			[],
558
+			'add-new-h2'
559
+		);
560
+
561
+		$this->_search_btn_label  = esc_html__('Venues', 'event_espresso');
562
+		$this->display_admin_list_table_page_with_sidebar();
563
+	}
564
+
565
+
566
+	/**
567
+	 * @throws EE_Error
568
+	 * @throws ReflectionException
569
+	 */
570
+	public function extra_misc_actions_publish_box()
571
+	{
572
+		$extra_rows = [
573
+			'vnu_capacity' => $this->_cpt_model_obj->get_f('VNU_capacity'),
574
+			'vnu_url'      => $this->_cpt_model_obj->get_f('VNU_url'),
575
+			'vnu_phone'    => $this->_cpt_model_obj->get_f('VNU_phone'),
576
+		];
577
+		$template   = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php';
578
+		EEH_Template::display_template($template, $extra_rows);
579
+	}
580
+
581
+
582
+	/*************        Google Maps        *************
583 583
      *
584 584
      * @throws EE_Error
585 585
      * @throws EE_Error
586 586
      */
587 587
 
588 588
 
589
-    protected function _google_map_settings()
590
-    {
591
-
592
-
593
-        $this->_template_args['values']           = $this->_yes_no_values;
594
-        $default_map_settings                     = new stdClass();
595
-        $default_map_settings->use_google_maps    = true;
596
-        $default_map_settings->google_map_api_key = '';
597
-        // for event details pages (reg page)
598
-        $default_map_settings->event_details_map_width    = 585;
599
-        // ee_map_width_single
600
-        $default_map_settings->event_details_map_height   = 362;
601
-        // ee_map_height_single
602
-        $default_map_settings->event_details_map_zoom     = 14;
603
-        // ee_map_zoom_single
604
-        $default_map_settings->event_details_display_nav  = true;
605
-        // ee_map_nav_display_single
606
-        $default_map_settings->event_details_nav_size     = false;
607
-        // ee_map_nav_size_single
608
-        $default_map_settings->event_details_control_type = 'default';
609
-        // ee_map_type_control_single
610
-        $default_map_settings->event_details_map_align    = 'center';
611
-        // ee_map_align_single
612
-
613
-        // for event list pages
614
-        $default_map_settings->event_list_map_width    = 300;
615
-        // ee_map_width
616
-        $default_map_settings->event_list_map_height   = 185;
617
-        // ee_map_height
618
-        $default_map_settings->event_list_map_zoom     = 12;
619
-        // ee_map_zoom
620
-        $default_map_settings->event_list_display_nav  = false;
621
-        // ee_map_nav_display
622
-        $default_map_settings->event_list_nav_size     = true;
623
-        // ee_map_nav_size
624
-        $default_map_settings->event_list_control_type = 'dropdown';
625
-        // ee_map_type_control
626
-        $default_map_settings->event_list_map_align    = 'center';
627
-        // ee_map_align
628
-
629
-        $this->_template_args['map_settings'] =
630
-            isset(EE_Registry::instance()->CFG->map_settings)
631
-            && ! empty(EE_Registry::instance()->CFG->map_settings)
632
-                ? (object) array_merge(
633
-                    (array) $default_map_settings,
634
-                    (array) EE_Registry::instance()->CFG->map_settings
635
-                )
636
-                : $default_map_settings;
637
-
638
-        $this->_set_add_edit_form_tags('update_google_map_settings');
639
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
640
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
641
-            EE_VENUES_TEMPLATE_PATH . 'google_map.template.php',
642
-            $this->_template_args,
643
-            true
644
-        );
645
-        $this->display_admin_page_with_sidebar();
646
-    }
647
-
648
-
649
-    /**
650
-     * @throws EE_Error
651
-     */
652
-    protected function _update_google_map_settings()
653
-    {
654
-        $map_settings = EE_Registry::instance()->CFG->map_settings;
655
-
656
-        $settings = [
657
-            'use_google_maps'            => 'int',
658
-            'google_map_api_key'         => 'string',
659
-            'event_details_map_width'    => 'int',
660
-            'event_details_map_zoom'     => 'int',
661
-            'event_details_display_nav'  => 'int',
662
-            'event_details_nav_size'     => 'int',
663
-            'event_details_control_type' => 'string',
664
-            'event_details_map_align'    => 'string',
665
-            'event_list_map_width'       => 'int',
666
-            'event_list_map_height'      => 'int',
667
-            'event_list_map_zoom'        => 'int',
668
-            'event_list_display_nav'     => 'int',
669
-            'event_list_nav_size'        => 'int',
670
-            'event_list_control_type'    => 'string',
671
-            'event_list_map_align'       => 'string',
672
-        ];
673
-
674
-        foreach ($settings as $setting => $type) {
675
-            $map_settings->{$setting} = $this->request->getRequestParam($setting, $map_settings->{$setting}, $type);
676
-        }
677
-
678
-        EE_Registry::instance()->CFG->map_settings = apply_filters(
679
-            'FHEE__Extend_General_Settings_Admin_Page___update_google_map_settings__CFG_map_settings',
680
-            $map_settings
681
-        );
682
-
683
-        $what    = 'Google Map Settings';
684
-        $success = $this->_update_espresso_configuration(
685
-            $what,
686
-            EE_Registry::instance()->CFG->map_settings,
687
-            __FILE__,
688
-            __FUNCTION__,
689
-            __LINE__
690
-        );
691
-        $this->_redirect_after_action($success, $what, 'updated', ['action' => 'google_map_settings']);
692
-    }
693
-
694
-
695
-    /**
696
-     * @throws EE_Error
697
-     * @throws ReflectionException
698
-     */
699
-    protected function _venue_editor_metaboxes()
700
-    {
701
-        $this->verify_cpt_object();
702
-
703
-        add_meta_box(
704
-            'espresso_venue_address_options',
705
-            esc_html__('Physical Location', 'event_espresso'),
706
-            [$this, 'venue_address_metabox'],
707
-            $this->page_slug,
708
-            'side'
709
-        );
710
-        add_meta_box(
711
-            'espresso_venue_gmap_options',
712
-            esc_html__('Google Map', 'event_espresso'),
713
-            [$this, 'venue_gmap_metabox'],
714
-            $this->page_slug,
715
-            'side'
716
-        );
717
-        add_meta_box(
718
-            'espresso_venue_virtual_loc_options',
719
-            esc_html__('Virtual Location', 'event_espresso'),
720
-            [$this, 'venue_virtual_loc_metabox'],
721
-            $this->page_slug,
722
-            'side'
723
-        );
724
-    }
725
-
726
-
727
-    public function venue_gmap_metabox()
728
-    {
729
-        $template_args = [
730
-            'vnu_enable_for_gmap' => EEH_Form_Fields::select_input(
731
-                'vnu_enable_for_gmap',
732
-                $this->get_yes_no_values(),
733
-                $this->_cpt_model_obj instanceof EE_Venue ? $this->_cpt_model_obj->enable_for_gmap() : false
734
-            ),
735
-            'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(),
736
-        ];
737
-        $template      = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php';
738
-        EEH_Template::display_template($template, $template_args);
739
-    }
740
-
741
-
742
-    /**
743
-     * @throws EE_Error
744
-     * @throws ReflectionException
745
-     */
746
-    public function venue_address_metabox()
747
-    {
748
-        $template_args['_venue'] = $this->_cpt_model_obj;
749
-
750
-        $template_args['states_dropdown']    = EEH_Form_Fields::generate_form_input(
751
-            new EE_Question_Form_Input(
752
-                EE_Question::new_instance(
753
-                    ['QST_display_text' => esc_html__('State', 'event_espresso'), 'QST_system' => 'state']
754
-                ),
755
-                EE_Answer::new_instance(
756
-                    [
757
-                        'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
758
-                            ? $this->_cpt_model_obj->state_ID()
759
-                            : 0,
760
-                    ]
761
-                ),
762
-                [
763
-                    'input_name'     => 'sta_id',
764
-                    'input_id'       => 'sta_id',
765
-                    'input_class'    => '',
766
-                    'input_prefix'   => '',
767
-                    'append_qstn_id' => false,
768
-                ]
769
-            )
770
-        );
771
-        $template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input(
772
-            new EE_Question_Form_Input(
773
-                EE_Question::new_instance(
774
-                    ['QST_display_text' => esc_html__('Country', 'event_espresso'), 'QST_system' => 'country']
775
-                ),
776
-                EE_Answer::new_instance(
777
-                    [
778
-                        'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
779
-                            ? $this->_cpt_model_obj->country_ID()
780
-                            : 0,
781
-                    ]
782
-                ),
783
-                [
784
-                    'input_name'     => 'cnt_iso',
785
-                    'input_id'       => 'cnt_iso',
786
-                    'input_class'    => '',
787
-                    'input_prefix'   => '',
788
-                    'append_qstn_id' => false,
789
-                ]
790
-            )
791
-        );
792
-
793
-        $template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php';
794
-        EEH_Template::display_template($template, $template_args);
795
-    }
796
-
797
-
798
-    public function venue_virtual_loc_metabox()
799
-    {
800
-        $template_args = [
801
-            '_venue' => $this->_cpt_model_obj,
802
-        ];
803
-        $template      = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php';
804
-        EEH_Template::display_template($template, $template_args);
805
-    }
806
-
807
-
808
-    protected function _restore_cpt_item($post_id, $revision_id)
809
-    {
810
-        $venue_obj = $this->_venue_model->get_one_by_ID($post_id);
811
-
812
-        // meta revision restore
813
-        $venue_obj->restore_revision($revision_id);
814
-    }
815
-
816
-
817
-    /**
818
-     * Handles updates for venue cpts
819
-     *
820
-     * @param int    $post_id ID of Venue CPT
821
-     * @param object $post    Post object (with "blessed" WP properties)
822
-     * @return void
823
-     */
824
-    protected function _insert_update_cpt_item($post_id, $post)
825
-    {
826
-
827
-        if ($post instanceof WP_Post && $post->post_type !== 'espresso_venues') {
828
-            return;// get out we're not processing the saving of venues.
829
-        }
830
-
831
-        $wheres = [$this->_venue_model->primary_key_name() => $post_id];
832
-
833
-        $venue_values = [
834
-            'VNU_address'         => $this->request->getRequestParam('vnu_address'),
835
-            'VNU_address2'        => $this->request->getRequestParam('vnu_address2'),
836
-            'VNU_city'            => $this->request->getRequestParam('vnu_city'),
837
-            'STA_ID'              => $this->request->getRequestParam('sta_id'),
838
-            'CNT_ISO'             => $this->request->getRequestParam('cnt_iso'),
839
-            'VNU_zip'             => $this->request->getRequestParam('vnu_zip'),
840
-            'VNU_phone'           => $this->request->getRequestParam('vnu_phone'),
841
-            'VNU_capacity'        => $this->request->requestParamIsSet('vnu_capacity')
842
-                ? str_replace(',', '', $this->request->getRequestParam('vnu_capacity'))
843
-                : EE_INF,
844
-            'VNU_url'             => $this->request->getRequestParam('vnu_url'),
845
-            'VNU_virtual_phone'   => $this->request->getRequestParam('vnu_virtual_phone'),
846
-            'VNU_virtual_url'     => $this->request->getRequestParam('vnu_virtual_url'),
847
-            'VNU_enable_for_gmap' => $this->request->getRequestParam('vnu_enable_for_gmap', false, 'bool'),
848
-            'VNU_google_map_link' => $this->request->getRequestParam('vnu_google_map_link'),
849
-        ];
850
-
851
-        // update venue
852
-        $success = $this->_venue_model->update($venue_values, [$wheres]);
853
-
854
-        // get venue_object for other metaboxes that might be added via the filter... though it would seem to make sense to just use $this->_venue_model->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
855
-        $get_one_where = [$this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status];
856
-        $venue         = $this->_venue_model->get_one([$get_one_where]);
857
-
858
-        // notice we've applied a filter for venue metabox callbacks but we don't actually have any default venue metaboxes in use.  So this is just here for addons to more easily hook into venue saves.
859
-        $venue_update_callbacks = apply_filters(
860
-            'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks',
861
-            []
862
-        );
863
-        $att_success            = true;
864
-        foreach ($venue_update_callbacks as $v_callback) {
865
-            // if ANY of these updates fail then we want the appropriate global error message
866
-            $att_success = call_user_func_array($v_callback, [$venue, $this->request->requestParams()])
867
-                ? $att_success
868
-                : false;
869
-        }
870
-
871
-        // any errors?
872
-        if ($success && ! $att_success) {
873
-            EE_Error::add_error(
874
-                esc_html__(
875
-                    'Venue Details saved successfully but something went wrong with saving attachments.',
876
-                    'event_espresso'
877
-                ),
878
-                __FILE__,
879
-                __FUNCTION__,
880
-                __LINE__
881
-            );
882
-        } elseif ($success === false) {
883
-            EE_Error::add_error(
884
-                esc_html__('Venue Details did not save successfully.', 'event_espresso'),
885
-                __FILE__,
886
-                __FUNCTION__,
887
-                __LINE__
888
-            );
889
-        }
890
-    }
891
-
892
-
893
-    /**
894
-     * @param int $post_id
895
-     * @throws EE_Error
896
-     * @throws ReflectionException
897
-     */
898
-    public function trash_cpt_item($post_id)
899
-    {
900
-        $this->request->setRequestParam('VNU_ID', $post_id);
901
-        $this->_trash_or_restore_venue('trash', false);
902
-    }
903
-
904
-
905
-    /**
906
-     * @param int $post_id
907
-     * @throws EE_Error
908
-     * @throws ReflectionException
909
-     */
910
-    public function restore_cpt_item($post_id)
911
-    {
912
-        $this->request->setRequestParam('VNU_ID', $post_id);
913
-        $this->_trash_or_restore_venue('draft', false);
914
-    }
915
-
916
-
917
-    /**
918
-     * @param int $post_id
919
-     * @throws EE_Error
920
-     * @throws ReflectionException
921
-     */
922
-    public function delete_cpt_item($post_id)
923
-    {
924
-        $this->request->setRequestParam('VNU_ID', $post_id);
925
-        $this->_delete_venue(false);
926
-    }
927
-
928
-
929
-    public function get_venue_object()
930
-    {
931
-        return $this->_cpt_model_obj;
932
-    }
933
-
934
-
935
-    /**
936
-     * @throws EE_Error
937
-     * @throws ReflectionException
938
-     */
939
-    protected function _trash_or_restore_venue($venue_status = 'trash', $redirect_after = true)
940
-    {
941
-        $VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
942
-
943
-        // loop thru venues
944
-        if ($VNU_ID) {
945
-            // clean status
946
-            $venue_status = sanitize_key($venue_status);
947
-            // grab status
948
-            if (! empty($venue_status)) {
949
-                $success = $this->_change_venue_status($VNU_ID, $venue_status);
950
-            } else {
951
-                $success = false;
952
-                $msg     = esc_html__(
953
-                    'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
954
-                    'event_espresso'
955
-                );
956
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
957
-            }
958
-        } else {
959
-            $success = false;
960
-            $msg     = esc_html__(
961
-                'An error occurred. The venue could not be moved to the trash because a valid venue ID was not not supplied.',
962
-                'event_espresso'
963
-            );
964
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
965
-        }
966
-        $action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
967
-
968
-        if ($redirect_after) {
969
-            $this->_redirect_after_action($success, 'Venue', $action, ['action' => 'default']);
970
-        }
971
-    }
972
-
973
-
974
-    /**
975
-     * @throws EE_Error
976
-     * @throws ReflectionException
977
-     */
978
-    protected function _trash_or_restore_venues($venue_status = 'trash')
979
-    {
980
-        // clean status
981
-        $venue_status = sanitize_key($venue_status);
982
-        // grab status
983
-        if (! empty($venue_status)) {
984
-            $success = true;
985
-            // determine the event id and set to array.
986
-            $VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
987
-            // loop thru events
988
-            foreach ($VNU_IDs as $VNU_ID) {
989
-                if ($VNU_ID = absint($VNU_ID)) {
990
-                    $results = $this->_change_venue_status($VNU_ID, $venue_status);
991
-                    $success = $results !== false ? $success : false;
992
-                } else {
993
-                    $msg = sprintf(
994
-                        esc_html__(
995
-                            'An error occurred. Venue #%d could not be moved to the trash because a valid venue ID was not not supplied.',
996
-                            'event_espresso'
997
-                        ),
998
-                        $VNU_ID
999
-                    );
1000
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1001
-                    $success = false;
1002
-                }
1003
-            }
1004
-        } else {
1005
-            $success = false;
1006
-            $msg     = esc_html__(
1007
-                'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
1008
-                'event_espresso'
1009
-            );
1010
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1011
-        }
1012
-        // in order to force a pluralized result message we need to send back a success status greater than 1
1013
-        $success = $success ? 2 : false;
1014
-        $action  = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1015
-        $this->_redirect_after_action($success, 'Venues', $action, ['action' => 'default']);
1016
-    }
1017
-
1018
-
1019
-    /**
1020
-     * _trash_or_restore_venues
1021
-     *
1022
-     * //todo this is pretty much the same as the corresponding change_event_status method in Events_Admin_Page.  We
1023
-     * should probably abstract this up to the EE_Admin_Page_CPT (or even EE_Admin_Page) and make this a common method
1024
-     * accepting a certain number of params.
1025
-     *
1026
-     * @access  private
1027
-     * @param int    $VNU_ID
1028
-     * @param string $venue_status
1029
-     * @return bool
1030
-     * @throws EE_Error
1031
-     * @throws ReflectionException
1032
-     */
1033
-    private function _change_venue_status($VNU_ID = 0, $venue_status = '')
1034
-    {
1035
-        // grab venue id
1036
-        if (! $VNU_ID) {
1037
-            $msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1038
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1039
-            return false;
1040
-        }
1041
-
1042
-        $this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1043
-
1044
-        // clean status
1045
-        $venue_status = sanitize_key($venue_status);
1046
-        // grab status
1047
-        if (! $venue_status) {
1048
-            $msg = esc_html__(
1049
-                'An error occurred. No Venue Status or an invalid Venue Status was received.',
1050
-                'event_espresso'
1051
-            );
1052
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1053
-            return false;
1054
-        }
1055
-
1056
-        // was event trashed or restored ?
1057
-        switch ($venue_status) {
1058
-            case 'draft':
1059
-                $action = 'restored from the trash';
1060
-                $hook   = 'AHEE_venue_restored_from_trash';
1061
-                break;
1062
-            case 'trash':
1063
-                $action = 'moved to the trash';
1064
-                $hook   = 'AHEE_venue_moved_to_trash';
1065
-                break;
1066
-            default:
1067
-                $action = 'updated';
1068
-                $hook   = false;
1069
-        }
1070
-        // use class to change status
1071
-        $this->_cpt_model_obj->set_status($venue_status);
1072
-        $success = $this->_cpt_model_obj->save();
1073
-
1074
-        if ($success === false) {
1075
-            $msg = sprintf(esc_html__('An error occurred. The venue could not be %s.', 'event_espresso'), $action);
1076
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1077
-            return false;
1078
-        }
1079
-        if ($hook) {
1080
-            do_action($hook);
1081
-        }
1082
-        return true;
1083
-    }
1084
-
1085
-
1086
-    /**
1087
-     * @param bool $redirect_after
1088
-     * @return void
1089
-     * @throws EE_Error
1090
-     * @throws ReflectionException
1091
-     */
1092
-    protected function _delete_venue($redirect_after = true)
1093
-    {
1094
-        // determine the venue id and set to array.
1095
-        $VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
1096
-        $VNU_ID = $this->request->getRequestParam('post', $VNU_ID, 'int');
1097
-
1098
-        // loop thru venues
1099
-        if ($VNU_ID) {
1100
-            $success = $this->_delete_or_trash_venue($VNU_ID);
1101
-        } else {
1102
-            $success = false;
1103
-            $msg     = esc_html__(
1104
-                'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1105
-                'event_espresso'
1106
-            );
1107
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1108
-        }
1109
-        if ($redirect_after) {
1110
-            $this->_redirect_after_action($success, 'Venue', 'deleted', ['action' => 'default']);
1111
-        }
1112
-    }
1113
-
1114
-
1115
-    /**
1116
-     * @throws EE_Error
1117
-     * @throws ReflectionException
1118
-     */
1119
-    protected function _delete_venues()
1120
-    {
1121
-        $success = true;
1122
-        // determine the event id and set to array.
1123
-        $VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
1124
-        // loop thru events
1125
-        foreach ($VNU_IDs as $VNU_ID) {
1126
-            if ($VNU_ID = absint($VNU_ID)) {
1127
-                $results = $this->_delete_or_trash_venue($VNU_ID);
1128
-                $success = $results !== false ? $success : false;
1129
-            } else {
1130
-                $success = false;
1131
-                $msg     = esc_html__(
1132
-                    'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1133
-                    'event_espresso'
1134
-                );
1135
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1136
-            }
1137
-        }
1138
-        // in order to force a pluralized result message we need to send back a success status greater than 1
1139
-        $success = $success ? 2 : false;
1140
-        $this->_redirect_after_action(
1141
-            $success,
1142
-            esc_html__('Venues', 'event_espresso'),
1143
-            esc_html__('deleted', 'event_espresso'),
1144
-            ['action' => 'default']
1145
-        );
1146
-    }
1147
-
1148
-
1149
-    // todo: put in parent
1150
-
1151
-
1152
-    /**
1153
-     * @throws EE_Error
1154
-     * @throws ReflectionException
1155
-     */
1156
-    private function _delete_or_trash_venue($VNU_ID = false)
1157
-    {
1158
-        // grab event id
1159
-        if (! $VNU_ID = absint($VNU_ID)) {
1160
-            $msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1161
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1162
-            return false;
1163
-        }
1164
-
1165
-
1166
-        $venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1167
-        // first need to remove all term relationships
1168
-        $venue->_remove_relations('Term_Taxonomy');
1169
-        $success = $venue->delete_permanently();
1170
-        // did it all go as planned ?
1171
-        if ($success) {
1172
-            $msg = sprintf(esc_html__('Venue ID # %d has been deleted.', 'event_espresso'), $VNU_ID);
1173
-            EE_Error::add_success($msg);
1174
-        } else {
1175
-            $msg =
1176
-                sprintf(
1177
-                    esc_html__('An error occurred. Venue ID # %d could not be deleted.', 'event_espresso'),
1178
-                    $VNU_ID
1179
-                );
1180
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1181
-            return false;
1182
-        }
1183
-        do_action('AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted');
1184
-        return true;
1185
-    }
1186
-
1187
-
1188
-
1189
-
1190
-    /***********/
1191
-    /* QUERIES */
1192
-
1193
-
1194
-    public function get_venues($per_page = 10, $count = false)
1195
-    {
1196
-
1197
-        $orderby = $this->request->getRequestParam('orderby', '');
1198
-
1199
-        switch ($orderby) {
1200
-            case 'id':
1201
-                $orderby = 'VNU_ID';
1202
-                break;
1203
-
1204
-            case 'capacity':
1205
-                $orderby = 'VNU_capacity';
1206
-                break;
1207
-
1208
-            case 'city':
1209
-                $orderby = 'VNU_city';
1210
-                break;
1211
-
1212
-            default:
1213
-                $orderby = 'VNU_name';
1214
-        }
1215
-
1216
-        $sort         = $this->request->getRequestParam('order', 'ASC');
1217
-        $current_page = $this->request->getRequestParam('paged', 1, 'int');
1218
-        $per_page     = ! empty($per_page) ? $per_page : 10;
1219
-        $per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1220
-
1221
-        $offset = ($current_page - 1) * $per_page;
1222
-        $limit  = [$offset, $per_page];
1223
-
1224
-        $category = $this->request->getRequestParam('category');
1225
-        $category = $category > 0 ? $category : null;
1226
-
1227
-        $where = [];
1228
-
1229
-        // only set initial status if it is in the incoming request.  Otherwise the "all" view display's all statuses.
1230
-        $status = $this->request->getRequestParam('status');
1231
-        if ($status && $status !== 'all') {
1232
-            $where['status'] = $status;
1233
-        }
1234
-
1235
-        $venue_status = $this->request->getRequestParam('venue_status');
1236
-        if ($venue_status) {
1237
-            $where['status'] = $venue_status;
1238
-        }
1239
-
1240
-
1241
-        if ($category) {
1242
-            $where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories';
1243
-            $where['Term_Taxonomy.term_id']  = $category;
1244
-        }
1245
-
1246
-
1247
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
1248
-            $where['VNU_wp_user'] = get_current_user_id();
1249
-        } else {
1250
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
1251
-                $where['OR'] = [
1252
-                    'status*restrict_private' => ['!=', 'private'],
1253
-                    'AND'                     => [
1254
-                        'status*inclusive' => ['=', 'private'],
1255
-                        'VNU_wp_user'      => get_current_user_id(),
1256
-                    ],
1257
-                ];
1258
-            }
1259
-        }
1260
-
1261
-        $search_term = $this->request->getRequestParam('s');
1262
-        if ($search_term) {
1263
-            $search_term = '%' . $search_term . '%';
1264
-            $where['OR'] = [
1265
-                'VNU_name'               => ['LIKE', $search_term],
1266
-                'VNU_desc'               => ['LIKE', $search_term],
1267
-                'VNU_short_desc'         => ['LIKE', $search_term],
1268
-                'VNU_address'            => ['LIKE', $search_term],
1269
-                'VNU_address2'           => ['LIKE', $search_term],
1270
-                'VNU_city'               => ['LIKE', $search_term],
1271
-                'VNU_zip'                => ['LIKE', $search_term],
1272
-                'VNU_phone'              => ['LIKE', $search_term],
1273
-                'VNU_url'                => ['LIKE', $search_term],
1274
-                'VNU_virtual_phone'      => ['LIKE', $search_term],
1275
-                'VNU_virtual_url'        => ['LIKE', $search_term],
1276
-                'VNU_google_map_link'    => ['LIKE', $search_term],
1277
-                'Event.EVT_name'         => ['LIKE', $search_term],
1278
-                'Event.EVT_desc'         => ['LIKE', $search_term],
1279
-                'Event.EVT_phone'        => ['LIKE', $search_term],
1280
-                'Event.EVT_external_URL' => ['LIKE', $search_term],
1281
-            ];
1282
-        }
1283
-
1284
-
1285
-        return $count
1286
-            ? $this->_venue_model->count([$where], 'VNU_ID')
1287
-            : $this->_venue_model->get_all(
1288
-                [$where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort]
1289
-            );
1290
-    }
1291
-
1292
-
1293
-
1294
-
1295
-    /** Venue Category Stuff **/
1296
-
1297
-    /**
1298
-     * set the _category property with the category object for the loaded page.
1299
-     *
1300
-     * @access private
1301
-     * @return void
1302
-     */
1303
-    private function _set_category_object()
1304
-    {
1305
-        if (isset($this->_category->id) && ! empty($this->_category->id)) {
1306
-            return;
1307
-        } // already have the category object so get out.
1308
-
1309
-        // set default category object
1310
-        $this->_set_empty_category_object();
1311
-
1312
-        // only set if we've got an id
1313
-        $category_ID = $this->request->getRequestParam('VEN_CAT_ID', 0, 'int');
1314
-        if (! $category_ID) {
1315
-            return;
1316
-        }
1317
-
1318
-        $term = get_term($category_ID, 'espresso_venue_categories');
1319
-
1320
-
1321
-        if (! empty($term)) {
1322
-            $this->_category->category_name       = $term->name;
1323
-            $this->_category->category_identifier = $term->slug;
1324
-            $this->_category->category_desc       = $term->description;
1325
-            $this->_category->id                  = $term->term_id;
1326
-            $this->_category->parent              = $term->parent;
1327
-        }
1328
-    }
1329
-
1330
-
1331
-    private function _set_empty_category_object()
1332
-    {
1333
-        $this->_category                = new stdClass();
1334
-        $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
1335
-        $this->_category->id            = $this->_category->parent = 0;
1336
-    }
1337
-
1338
-
1339
-    /**
1340
-     * @throws EE_Error
1341
-     */
1342
-    protected function _category_list_table()
1343
-    {
1344
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1345
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1346
-            'add_category',
1347
-            'add_category',
1348
-            [],
1349
-            'add-new-h2'
1350
-        );
1351
-        $this->_search_btn_label = esc_html__('Venue Categories', 'event_espresso');
1352
-        $this->display_admin_list_table_page_with_sidebar();
1353
-    }
1354
-
1355
-
1356
-    /**
1357
-     * @throws EE_Error
1358
-     */
1359
-    protected function _category_details($view)
1360
-    {
1361
-
1362
-        // load formatter helper
1363
-        // load field generator helper
1364
-
1365
-        $route = $view == 'edit' ? 'update_category' : 'insert_category';
1366
-        $this->_set_add_edit_form_tags($route);
1367
-
1368
-        $this->_set_category_object();
1369
-        $id = ! empty($this->_category->id) ? $this->_category->id : '';
1370
-
1371
-        $delete_action = 'delete_category';
1372
-
1373
-        $redirect = EE_Admin_Page::add_query_args_and_nonce(['action' => 'category_list'], $this->_admin_base_url);
1374
-
1375
-        $this->_set_publish_post_box_vars('VEN_CAT_ID', $id, $delete_action, $redirect);
1376
-
1377
-        // take care of contents
1378
-        $this->_template_args['admin_page_content'] = $this->_category_details_content();
1379
-        $this->display_admin_page_with_sidebar();
1380
-    }
1381
-
1382
-
1383
-    protected function _category_details_content()
1384
-    {
1385
-        $editor_args['category_desc'] = [
1386
-            'type'          => 'wp_editor',
1387
-            'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
1388
-            'class'         => 'my_editor_custom',
1389
-            'wpeditor_args' => ['media_buttons' => false],
1390
-        ];
1391
-        $_wp_editor                   = $this->_generate_admin_form_fields($editor_args, 'array');
1392
-
1393
-        $all_terms = get_terms(
1394
-            ['espresso_venue_categories'],
1395
-            ['hide_empty' => 0, 'exclude' => [$this->_category->id]]
1396
-        );
1397
-
1398
-        // setup category select for term parents.
1399
-        $category_select_values[] = [
1400
-            'text' => esc_html__('No Parent', 'event_espresso'),
1401
-            'id'   => 0,
1402
-        ];
1403
-        foreach ($all_terms as $term) {
1404
-            $category_select_values[] = [
1405
-                'text' => $term->name,
1406
-                'id'   => $term->term_id,
1407
-            ];
1408
-        }
1409
-
1410
-        $category_select = EEH_Form_Fields::select_input(
1411
-            'category_parent',
1412
-            $category_select_values,
1413
-            $this->_category->parent
1414
-        );
1415
-        $template_args   = [
1416
-            'category'                 => $this->_category,
1417
-            'category_select'          => $category_select,
1418
-            'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
1419
-            'category_desc_editor'     => $_wp_editor['category_desc']['field'],
1420
-            'disable'                  => '',
1421
-            'disabled_message'         => false,
1422
-        ];
1423
-        $template        = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
1424
-        return EEH_Template::display_template($template, $template_args, true);
1425
-    }
1426
-
1427
-
1428
-    /**
1429
-     * @throws EE_Error
1430
-     */
1431
-    protected function _delete_categories()
1432
-    {
1433
-        $category_ID  = $this->request->getRequestParam('category_id', 0, 'int');
1434
-        $category_IDs = $this->request->getRequestParam('VEN_CAT_ID', [$category_ID], 'int', true);
1435
-
1436
-        foreach ($category_IDs as $cat_id) {
1437
-            $this->_delete_category($cat_id);
1438
-        }
1439
-
1440
-        // doesn't matter what page we're coming from... we're going to the same place after delete.
1441
-        $query_args = [
1442
-            'action' => 'category_list',
1443
-        ];
1444
-        $this->_redirect_after_action(0, '', '', $query_args);
1445
-    }
1446
-
1447
-
1448
-    protected function _delete_category($cat_id)
1449
-    {
1450
-        $cat_id = absint($cat_id);
1451
-        wp_delete_term($cat_id, 'espresso_venue_categories');
1452
-    }
1453
-
1454
-
1455
-    /**
1456
-     * @throws EE_Error
1457
-     */
1458
-    protected function _insert_or_update_category($new_category)
1459
-    {
1460
-
1461
-        $cat_id  = $new_category ? $this->_insert_category() : $this->_insert_category(true);
1462
-        $success = 0; // we already have a success message so lets not send another.
1463
-        if ($cat_id) {
1464
-            $query_args = [
1465
-                'action'     => 'edit_category',
1466
-                'VEN_CAT_ID' => $cat_id,
1467
-            ];
1468
-        } else {
1469
-            $query_args = ['action' => 'add_category'];
1470
-        }
1471
-        $this->_redirect_after_action($success, '', '', $query_args, true);
1472
-    }
1473
-
1474
-
1475
-    private function _insert_category($update = false)
1476
-    {
1477
-        $category_ID     = $update ? $this->request->getRequestParam('VEN_CAT_ID', '', 'int') : '';
1478
-        $category_name   = $this->request->getRequestParam('category_name', '');
1479
-        $category_desc   = $this->request->getRequestParam('category_desc', '', 'html');
1480
-        $category_parent = $this->request->getRequestParam('category_parent', 0, 'int');
1481
-
1482
-        if (empty($category_name)) {
1483
-            $msg = esc_html__('You must add a name for the category.', 'event_espresso');
1484
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1485
-            return false;
1486
-        }
1487
-
1488
-
1489
-        $term_args = [
1490
-            'name'        => $category_name,
1491
-            'description' => $category_desc,
1492
-            'parent'      => $category_parent,
1493
-        ];
1494
-
1495
-        $insert_ids = $update
1496
-            ? wp_update_term($category_ID, 'espresso_venue_categories', $term_args)
1497
-            : wp_insert_term(
1498
-                $category_name,
1499
-                'espresso_venue_categories',
1500
-                $term_args
1501
-            );
1502
-
1503
-        if (! is_array($insert_ids)) {
1504
-            EE_Error::add_error(
1505
-                esc_html__('An error occurred and the category has not been saved to the database.', 'event_espresso'),
1506
-                __FILE__,
1507
-                __FUNCTION__,
1508
-                __LINE__
1509
-            );
1510
-        } else {
1511
-            $category_ID = $insert_ids['term_id'];
1512
-            EE_Error::add_success(
1513
-                sprintf(
1514
-                    esc_html__('The category %s was successfully created', 'event_espresso'),
1515
-                    $category_name
1516
-                )
1517
-            );
1518
-        }
1519
-
1520
-        return $category_ID;
1521
-    }
1522
-
1523
-
1524
-    /**
1525
-     * TODO handle category exports()
1526
-     *
1527
-     * @return void
1528
-     */
1529
-    protected function _categories_export()
1530
-    {
1531
-        // todo: I don't like doing this but it'll do until we modify EE_Export Class.
1532
-        $this->request->mergeRequestParams(
1533
-            [
1534
-                'export'       => 'report',
1535
-                'action'       => 'categories',
1536
-                'category_ids' => $this->request->getRequestParam('VEN_CAT_ID', 0, 'int'),
1537
-            ]
1538
-        );
1539
-
1540
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
1541
-            require_once(EE_CLASSES . 'EE_Export.class.php');
1542
-            $EE_Export = EE_Export::instance($this->request->requestParams());
1543
-            $EE_Export->export();
1544
-        }
1545
-    }
1546
-
1547
-
1548
-    protected function _import_categories()
1549
-    {
1550
-
1551
-        require_once(EE_CLASSES . 'EE_Import.class.php');
1552
-        EE_Import::instance()->import();
1553
-    }
1554
-
1555
-
1556
-    /**
1557
-     * @throws EE_Error
1558
-     */
1559
-    public function get_categories($per_page = 10, $current_page = 1, $count = false)
1560
-    {
1561
-
1562
-        // testing term stuff
1563
-        $orderby     = $this->request->getRequestParam('orderby', 'Term.term_id');
1564
-        $order       = $this->request->getRequestParam('order', 'DESC');
1565
-        $limit       = ($current_page - 1) * $per_page;
1566
-        $where       = ['taxonomy' => 'espresso_venue_categories'];
1567
-        $search_term = $this->request->getRequestParam('s');
1568
-        if ($search_term) {
1569
-            $search_term = '%' . $search_term . '%';
1570
-            $where['OR'] = [
1571
-                'Term.name'   => ['LIKE', $search_term],
1572
-                'description' => ['LIKE', $search_term],
1573
-            ];
1574
-        }
1575
-
1576
-        $query_params = [
1577
-            $where,
1578
-            'order_by'   => [$orderby => $order],
1579
-            'limit'      => $limit . ',' . $per_page,
1580
-            'force_join' => ['Term'],
1581
-        ];
1582
-
1583
-        return $count
1584
-            ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
1585
-            : EEM_Term_Taxonomy::instance()->get_all($query_params);
1586
-    }
1587
-
1588
-
1589
-    /* end category stuff */
1590
-    /**************/
589
+	protected function _google_map_settings()
590
+	{
591
+
592
+
593
+		$this->_template_args['values']           = $this->_yes_no_values;
594
+		$default_map_settings                     = new stdClass();
595
+		$default_map_settings->use_google_maps    = true;
596
+		$default_map_settings->google_map_api_key = '';
597
+		// for event details pages (reg page)
598
+		$default_map_settings->event_details_map_width    = 585;
599
+		// ee_map_width_single
600
+		$default_map_settings->event_details_map_height   = 362;
601
+		// ee_map_height_single
602
+		$default_map_settings->event_details_map_zoom     = 14;
603
+		// ee_map_zoom_single
604
+		$default_map_settings->event_details_display_nav  = true;
605
+		// ee_map_nav_display_single
606
+		$default_map_settings->event_details_nav_size     = false;
607
+		// ee_map_nav_size_single
608
+		$default_map_settings->event_details_control_type = 'default';
609
+		// ee_map_type_control_single
610
+		$default_map_settings->event_details_map_align    = 'center';
611
+		// ee_map_align_single
612
+
613
+		// for event list pages
614
+		$default_map_settings->event_list_map_width    = 300;
615
+		// ee_map_width
616
+		$default_map_settings->event_list_map_height   = 185;
617
+		// ee_map_height
618
+		$default_map_settings->event_list_map_zoom     = 12;
619
+		// ee_map_zoom
620
+		$default_map_settings->event_list_display_nav  = false;
621
+		// ee_map_nav_display
622
+		$default_map_settings->event_list_nav_size     = true;
623
+		// ee_map_nav_size
624
+		$default_map_settings->event_list_control_type = 'dropdown';
625
+		// ee_map_type_control
626
+		$default_map_settings->event_list_map_align    = 'center';
627
+		// ee_map_align
628
+
629
+		$this->_template_args['map_settings'] =
630
+			isset(EE_Registry::instance()->CFG->map_settings)
631
+			&& ! empty(EE_Registry::instance()->CFG->map_settings)
632
+				? (object) array_merge(
633
+					(array) $default_map_settings,
634
+					(array) EE_Registry::instance()->CFG->map_settings
635
+				)
636
+				: $default_map_settings;
637
+
638
+		$this->_set_add_edit_form_tags('update_google_map_settings');
639
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
640
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
641
+			EE_VENUES_TEMPLATE_PATH . 'google_map.template.php',
642
+			$this->_template_args,
643
+			true
644
+		);
645
+		$this->display_admin_page_with_sidebar();
646
+	}
647
+
648
+
649
+	/**
650
+	 * @throws EE_Error
651
+	 */
652
+	protected function _update_google_map_settings()
653
+	{
654
+		$map_settings = EE_Registry::instance()->CFG->map_settings;
655
+
656
+		$settings = [
657
+			'use_google_maps'            => 'int',
658
+			'google_map_api_key'         => 'string',
659
+			'event_details_map_width'    => 'int',
660
+			'event_details_map_zoom'     => 'int',
661
+			'event_details_display_nav'  => 'int',
662
+			'event_details_nav_size'     => 'int',
663
+			'event_details_control_type' => 'string',
664
+			'event_details_map_align'    => 'string',
665
+			'event_list_map_width'       => 'int',
666
+			'event_list_map_height'      => 'int',
667
+			'event_list_map_zoom'        => 'int',
668
+			'event_list_display_nav'     => 'int',
669
+			'event_list_nav_size'        => 'int',
670
+			'event_list_control_type'    => 'string',
671
+			'event_list_map_align'       => 'string',
672
+		];
673
+
674
+		foreach ($settings as $setting => $type) {
675
+			$map_settings->{$setting} = $this->request->getRequestParam($setting, $map_settings->{$setting}, $type);
676
+		}
677
+
678
+		EE_Registry::instance()->CFG->map_settings = apply_filters(
679
+			'FHEE__Extend_General_Settings_Admin_Page___update_google_map_settings__CFG_map_settings',
680
+			$map_settings
681
+		);
682
+
683
+		$what    = 'Google Map Settings';
684
+		$success = $this->_update_espresso_configuration(
685
+			$what,
686
+			EE_Registry::instance()->CFG->map_settings,
687
+			__FILE__,
688
+			__FUNCTION__,
689
+			__LINE__
690
+		);
691
+		$this->_redirect_after_action($success, $what, 'updated', ['action' => 'google_map_settings']);
692
+	}
693
+
694
+
695
+	/**
696
+	 * @throws EE_Error
697
+	 * @throws ReflectionException
698
+	 */
699
+	protected function _venue_editor_metaboxes()
700
+	{
701
+		$this->verify_cpt_object();
702
+
703
+		add_meta_box(
704
+			'espresso_venue_address_options',
705
+			esc_html__('Physical Location', 'event_espresso'),
706
+			[$this, 'venue_address_metabox'],
707
+			$this->page_slug,
708
+			'side'
709
+		);
710
+		add_meta_box(
711
+			'espresso_venue_gmap_options',
712
+			esc_html__('Google Map', 'event_espresso'),
713
+			[$this, 'venue_gmap_metabox'],
714
+			$this->page_slug,
715
+			'side'
716
+		);
717
+		add_meta_box(
718
+			'espresso_venue_virtual_loc_options',
719
+			esc_html__('Virtual Location', 'event_espresso'),
720
+			[$this, 'venue_virtual_loc_metabox'],
721
+			$this->page_slug,
722
+			'side'
723
+		);
724
+	}
725
+
726
+
727
+	public function venue_gmap_metabox()
728
+	{
729
+		$template_args = [
730
+			'vnu_enable_for_gmap' => EEH_Form_Fields::select_input(
731
+				'vnu_enable_for_gmap',
732
+				$this->get_yes_no_values(),
733
+				$this->_cpt_model_obj instanceof EE_Venue ? $this->_cpt_model_obj->enable_for_gmap() : false
734
+			),
735
+			'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(),
736
+		];
737
+		$template      = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php';
738
+		EEH_Template::display_template($template, $template_args);
739
+	}
740
+
741
+
742
+	/**
743
+	 * @throws EE_Error
744
+	 * @throws ReflectionException
745
+	 */
746
+	public function venue_address_metabox()
747
+	{
748
+		$template_args['_venue'] = $this->_cpt_model_obj;
749
+
750
+		$template_args['states_dropdown']    = EEH_Form_Fields::generate_form_input(
751
+			new EE_Question_Form_Input(
752
+				EE_Question::new_instance(
753
+					['QST_display_text' => esc_html__('State', 'event_espresso'), 'QST_system' => 'state']
754
+				),
755
+				EE_Answer::new_instance(
756
+					[
757
+						'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
758
+							? $this->_cpt_model_obj->state_ID()
759
+							: 0,
760
+					]
761
+				),
762
+				[
763
+					'input_name'     => 'sta_id',
764
+					'input_id'       => 'sta_id',
765
+					'input_class'    => '',
766
+					'input_prefix'   => '',
767
+					'append_qstn_id' => false,
768
+				]
769
+			)
770
+		);
771
+		$template_args['countries_dropdown'] = EEH_Form_Fields::generate_form_input(
772
+			new EE_Question_Form_Input(
773
+				EE_Question::new_instance(
774
+					['QST_display_text' => esc_html__('Country', 'event_espresso'), 'QST_system' => 'country']
775
+				),
776
+				EE_Answer::new_instance(
777
+					[
778
+						'ANS_value' => $this->_cpt_model_obj instanceof EE_Venue
779
+							? $this->_cpt_model_obj->country_ID()
780
+							: 0,
781
+					]
782
+				),
783
+				[
784
+					'input_name'     => 'cnt_iso',
785
+					'input_id'       => 'cnt_iso',
786
+					'input_class'    => '',
787
+					'input_prefix'   => '',
788
+					'append_qstn_id' => false,
789
+				]
790
+			)
791
+		);
792
+
793
+		$template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php';
794
+		EEH_Template::display_template($template, $template_args);
795
+	}
796
+
797
+
798
+	public function venue_virtual_loc_metabox()
799
+	{
800
+		$template_args = [
801
+			'_venue' => $this->_cpt_model_obj,
802
+		];
803
+		$template      = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php';
804
+		EEH_Template::display_template($template, $template_args);
805
+	}
806
+
807
+
808
+	protected function _restore_cpt_item($post_id, $revision_id)
809
+	{
810
+		$venue_obj = $this->_venue_model->get_one_by_ID($post_id);
811
+
812
+		// meta revision restore
813
+		$venue_obj->restore_revision($revision_id);
814
+	}
815
+
816
+
817
+	/**
818
+	 * Handles updates for venue cpts
819
+	 *
820
+	 * @param int    $post_id ID of Venue CPT
821
+	 * @param object $post    Post object (with "blessed" WP properties)
822
+	 * @return void
823
+	 */
824
+	protected function _insert_update_cpt_item($post_id, $post)
825
+	{
826
+
827
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_venues') {
828
+			return;// get out we're not processing the saving of venues.
829
+		}
830
+
831
+		$wheres = [$this->_venue_model->primary_key_name() => $post_id];
832
+
833
+		$venue_values = [
834
+			'VNU_address'         => $this->request->getRequestParam('vnu_address'),
835
+			'VNU_address2'        => $this->request->getRequestParam('vnu_address2'),
836
+			'VNU_city'            => $this->request->getRequestParam('vnu_city'),
837
+			'STA_ID'              => $this->request->getRequestParam('sta_id'),
838
+			'CNT_ISO'             => $this->request->getRequestParam('cnt_iso'),
839
+			'VNU_zip'             => $this->request->getRequestParam('vnu_zip'),
840
+			'VNU_phone'           => $this->request->getRequestParam('vnu_phone'),
841
+			'VNU_capacity'        => $this->request->requestParamIsSet('vnu_capacity')
842
+				? str_replace(',', '', $this->request->getRequestParam('vnu_capacity'))
843
+				: EE_INF,
844
+			'VNU_url'             => $this->request->getRequestParam('vnu_url'),
845
+			'VNU_virtual_phone'   => $this->request->getRequestParam('vnu_virtual_phone'),
846
+			'VNU_virtual_url'     => $this->request->getRequestParam('vnu_virtual_url'),
847
+			'VNU_enable_for_gmap' => $this->request->getRequestParam('vnu_enable_for_gmap', false, 'bool'),
848
+			'VNU_google_map_link' => $this->request->getRequestParam('vnu_google_map_link'),
849
+		];
850
+
851
+		// update venue
852
+		$success = $this->_venue_model->update($venue_values, [$wheres]);
853
+
854
+		// get venue_object for other metaboxes that might be added via the filter... though it would seem to make sense to just use $this->_venue_model->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
855
+		$get_one_where = [$this->_venue_model->primary_key_name() => $post_id, 'status' => $post->post_status];
856
+		$venue         = $this->_venue_model->get_one([$get_one_where]);
857
+
858
+		// notice we've applied a filter for venue metabox callbacks but we don't actually have any default venue metaboxes in use.  So this is just here for addons to more easily hook into venue saves.
859
+		$venue_update_callbacks = apply_filters(
860
+			'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks',
861
+			[]
862
+		);
863
+		$att_success            = true;
864
+		foreach ($venue_update_callbacks as $v_callback) {
865
+			// if ANY of these updates fail then we want the appropriate global error message
866
+			$att_success = call_user_func_array($v_callback, [$venue, $this->request->requestParams()])
867
+				? $att_success
868
+				: false;
869
+		}
870
+
871
+		// any errors?
872
+		if ($success && ! $att_success) {
873
+			EE_Error::add_error(
874
+				esc_html__(
875
+					'Venue Details saved successfully but something went wrong with saving attachments.',
876
+					'event_espresso'
877
+				),
878
+				__FILE__,
879
+				__FUNCTION__,
880
+				__LINE__
881
+			);
882
+		} elseif ($success === false) {
883
+			EE_Error::add_error(
884
+				esc_html__('Venue Details did not save successfully.', 'event_espresso'),
885
+				__FILE__,
886
+				__FUNCTION__,
887
+				__LINE__
888
+			);
889
+		}
890
+	}
891
+
892
+
893
+	/**
894
+	 * @param int $post_id
895
+	 * @throws EE_Error
896
+	 * @throws ReflectionException
897
+	 */
898
+	public function trash_cpt_item($post_id)
899
+	{
900
+		$this->request->setRequestParam('VNU_ID', $post_id);
901
+		$this->_trash_or_restore_venue('trash', false);
902
+	}
903
+
904
+
905
+	/**
906
+	 * @param int $post_id
907
+	 * @throws EE_Error
908
+	 * @throws ReflectionException
909
+	 */
910
+	public function restore_cpt_item($post_id)
911
+	{
912
+		$this->request->setRequestParam('VNU_ID', $post_id);
913
+		$this->_trash_or_restore_venue('draft', false);
914
+	}
915
+
916
+
917
+	/**
918
+	 * @param int $post_id
919
+	 * @throws EE_Error
920
+	 * @throws ReflectionException
921
+	 */
922
+	public function delete_cpt_item($post_id)
923
+	{
924
+		$this->request->setRequestParam('VNU_ID', $post_id);
925
+		$this->_delete_venue(false);
926
+	}
927
+
928
+
929
+	public function get_venue_object()
930
+	{
931
+		return $this->_cpt_model_obj;
932
+	}
933
+
934
+
935
+	/**
936
+	 * @throws EE_Error
937
+	 * @throws ReflectionException
938
+	 */
939
+	protected function _trash_or_restore_venue($venue_status = 'trash', $redirect_after = true)
940
+	{
941
+		$VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
942
+
943
+		// loop thru venues
944
+		if ($VNU_ID) {
945
+			// clean status
946
+			$venue_status = sanitize_key($venue_status);
947
+			// grab status
948
+			if (! empty($venue_status)) {
949
+				$success = $this->_change_venue_status($VNU_ID, $venue_status);
950
+			} else {
951
+				$success = false;
952
+				$msg     = esc_html__(
953
+					'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
954
+					'event_espresso'
955
+				);
956
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
957
+			}
958
+		} else {
959
+			$success = false;
960
+			$msg     = esc_html__(
961
+				'An error occurred. The venue could not be moved to the trash because a valid venue ID was not not supplied.',
962
+				'event_espresso'
963
+			);
964
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
965
+		}
966
+		$action = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
967
+
968
+		if ($redirect_after) {
969
+			$this->_redirect_after_action($success, 'Venue', $action, ['action' => 'default']);
970
+		}
971
+	}
972
+
973
+
974
+	/**
975
+	 * @throws EE_Error
976
+	 * @throws ReflectionException
977
+	 */
978
+	protected function _trash_or_restore_venues($venue_status = 'trash')
979
+	{
980
+		// clean status
981
+		$venue_status = sanitize_key($venue_status);
982
+		// grab status
983
+		if (! empty($venue_status)) {
984
+			$success = true;
985
+			// determine the event id and set to array.
986
+			$VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
987
+			// loop thru events
988
+			foreach ($VNU_IDs as $VNU_ID) {
989
+				if ($VNU_ID = absint($VNU_ID)) {
990
+					$results = $this->_change_venue_status($VNU_ID, $venue_status);
991
+					$success = $results !== false ? $success : false;
992
+				} else {
993
+					$msg = sprintf(
994
+						esc_html__(
995
+							'An error occurred. Venue #%d could not be moved to the trash because a valid venue ID was not not supplied.',
996
+							'event_espresso'
997
+						),
998
+						$VNU_ID
999
+					);
1000
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1001
+					$success = false;
1002
+				}
1003
+			}
1004
+		} else {
1005
+			$success = false;
1006
+			$msg     = esc_html__(
1007
+				'An error occurred. The venue could not be moved to the trash because a valid venue status was not not supplied.',
1008
+				'event_espresso'
1009
+			);
1010
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1011
+		}
1012
+		// in order to force a pluralized result message we need to send back a success status greater than 1
1013
+		$success = $success ? 2 : false;
1014
+		$action  = $venue_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1015
+		$this->_redirect_after_action($success, 'Venues', $action, ['action' => 'default']);
1016
+	}
1017
+
1018
+
1019
+	/**
1020
+	 * _trash_or_restore_venues
1021
+	 *
1022
+	 * //todo this is pretty much the same as the corresponding change_event_status method in Events_Admin_Page.  We
1023
+	 * should probably abstract this up to the EE_Admin_Page_CPT (or even EE_Admin_Page) and make this a common method
1024
+	 * accepting a certain number of params.
1025
+	 *
1026
+	 * @access  private
1027
+	 * @param int    $VNU_ID
1028
+	 * @param string $venue_status
1029
+	 * @return bool
1030
+	 * @throws EE_Error
1031
+	 * @throws ReflectionException
1032
+	 */
1033
+	private function _change_venue_status($VNU_ID = 0, $venue_status = '')
1034
+	{
1035
+		// grab venue id
1036
+		if (! $VNU_ID) {
1037
+			$msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1038
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1039
+			return false;
1040
+		}
1041
+
1042
+		$this->_cpt_model_obj = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1043
+
1044
+		// clean status
1045
+		$venue_status = sanitize_key($venue_status);
1046
+		// grab status
1047
+		if (! $venue_status) {
1048
+			$msg = esc_html__(
1049
+				'An error occurred. No Venue Status or an invalid Venue Status was received.',
1050
+				'event_espresso'
1051
+			);
1052
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1053
+			return false;
1054
+		}
1055
+
1056
+		// was event trashed or restored ?
1057
+		switch ($venue_status) {
1058
+			case 'draft':
1059
+				$action = 'restored from the trash';
1060
+				$hook   = 'AHEE_venue_restored_from_trash';
1061
+				break;
1062
+			case 'trash':
1063
+				$action = 'moved to the trash';
1064
+				$hook   = 'AHEE_venue_moved_to_trash';
1065
+				break;
1066
+			default:
1067
+				$action = 'updated';
1068
+				$hook   = false;
1069
+		}
1070
+		// use class to change status
1071
+		$this->_cpt_model_obj->set_status($venue_status);
1072
+		$success = $this->_cpt_model_obj->save();
1073
+
1074
+		if ($success === false) {
1075
+			$msg = sprintf(esc_html__('An error occurred. The venue could not be %s.', 'event_espresso'), $action);
1076
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1077
+			return false;
1078
+		}
1079
+		if ($hook) {
1080
+			do_action($hook);
1081
+		}
1082
+		return true;
1083
+	}
1084
+
1085
+
1086
+	/**
1087
+	 * @param bool $redirect_after
1088
+	 * @return void
1089
+	 * @throws EE_Error
1090
+	 * @throws ReflectionException
1091
+	 */
1092
+	protected function _delete_venue($redirect_after = true)
1093
+	{
1094
+		// determine the venue id and set to array.
1095
+		$VNU_ID = $this->request->getRequestParam('VNU_ID', 0, 'int');
1096
+		$VNU_ID = $this->request->getRequestParam('post', $VNU_ID, 'int');
1097
+
1098
+		// loop thru venues
1099
+		if ($VNU_ID) {
1100
+			$success = $this->_delete_or_trash_venue($VNU_ID);
1101
+		} else {
1102
+			$success = false;
1103
+			$msg     = esc_html__(
1104
+				'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1105
+				'event_espresso'
1106
+			);
1107
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1108
+		}
1109
+		if ($redirect_after) {
1110
+			$this->_redirect_after_action($success, 'Venue', 'deleted', ['action' => 'default']);
1111
+		}
1112
+	}
1113
+
1114
+
1115
+	/**
1116
+	 * @throws EE_Error
1117
+	 * @throws ReflectionException
1118
+	 */
1119
+	protected function _delete_venues()
1120
+	{
1121
+		$success = true;
1122
+		// determine the event id and set to array.
1123
+		$VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
1124
+		// loop thru events
1125
+		foreach ($VNU_IDs as $VNU_ID) {
1126
+			if ($VNU_ID = absint($VNU_ID)) {
1127
+				$results = $this->_delete_or_trash_venue($VNU_ID);
1128
+				$success = $results !== false ? $success : false;
1129
+			} else {
1130
+				$success = false;
1131
+				$msg     = esc_html__(
1132
+					'An error occurred. An venue could not be deleted because a valid venue ID was not not supplied.',
1133
+					'event_espresso'
1134
+				);
1135
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1136
+			}
1137
+		}
1138
+		// in order to force a pluralized result message we need to send back a success status greater than 1
1139
+		$success = $success ? 2 : false;
1140
+		$this->_redirect_after_action(
1141
+			$success,
1142
+			esc_html__('Venues', 'event_espresso'),
1143
+			esc_html__('deleted', 'event_espresso'),
1144
+			['action' => 'default']
1145
+		);
1146
+	}
1147
+
1148
+
1149
+	// todo: put in parent
1150
+
1151
+
1152
+	/**
1153
+	 * @throws EE_Error
1154
+	 * @throws ReflectionException
1155
+	 */
1156
+	private function _delete_or_trash_venue($VNU_ID = false)
1157
+	{
1158
+		// grab event id
1159
+		if (! $VNU_ID = absint($VNU_ID)) {
1160
+			$msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1161
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1162
+			return false;
1163
+		}
1164
+
1165
+
1166
+		$venue = EEM_Venue::instance()->get_one_by_ID($VNU_ID);
1167
+		// first need to remove all term relationships
1168
+		$venue->_remove_relations('Term_Taxonomy');
1169
+		$success = $venue->delete_permanently();
1170
+		// did it all go as planned ?
1171
+		if ($success) {
1172
+			$msg = sprintf(esc_html__('Venue ID # %d has been deleted.', 'event_espresso'), $VNU_ID);
1173
+			EE_Error::add_success($msg);
1174
+		} else {
1175
+			$msg =
1176
+				sprintf(
1177
+					esc_html__('An error occurred. Venue ID # %d could not be deleted.', 'event_espresso'),
1178
+					$VNU_ID
1179
+				);
1180
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1181
+			return false;
1182
+		}
1183
+		do_action('AHEE__Venues_Admin_Page___delete_or_trash_venue__after_venue_deleted');
1184
+		return true;
1185
+	}
1186
+
1187
+
1188
+
1189
+
1190
+	/***********/
1191
+	/* QUERIES */
1192
+
1193
+
1194
+	public function get_venues($per_page = 10, $count = false)
1195
+	{
1196
+
1197
+		$orderby = $this->request->getRequestParam('orderby', '');
1198
+
1199
+		switch ($orderby) {
1200
+			case 'id':
1201
+				$orderby = 'VNU_ID';
1202
+				break;
1203
+
1204
+			case 'capacity':
1205
+				$orderby = 'VNU_capacity';
1206
+				break;
1207
+
1208
+			case 'city':
1209
+				$orderby = 'VNU_city';
1210
+				break;
1211
+
1212
+			default:
1213
+				$orderby = 'VNU_name';
1214
+		}
1215
+
1216
+		$sort         = $this->request->getRequestParam('order', 'ASC');
1217
+		$current_page = $this->request->getRequestParam('paged', 1, 'int');
1218
+		$per_page     = ! empty($per_page) ? $per_page : 10;
1219
+		$per_page     = $this->request->getRequestParam('perpage', $per_page, 'int');
1220
+
1221
+		$offset = ($current_page - 1) * $per_page;
1222
+		$limit  = [$offset, $per_page];
1223
+
1224
+		$category = $this->request->getRequestParam('category');
1225
+		$category = $category > 0 ? $category : null;
1226
+
1227
+		$where = [];
1228
+
1229
+		// only set initial status if it is in the incoming request.  Otherwise the "all" view display's all statuses.
1230
+		$status = $this->request->getRequestParam('status');
1231
+		if ($status && $status !== 'all') {
1232
+			$where['status'] = $status;
1233
+		}
1234
+
1235
+		$venue_status = $this->request->getRequestParam('venue_status');
1236
+		if ($venue_status) {
1237
+			$where['status'] = $venue_status;
1238
+		}
1239
+
1240
+
1241
+		if ($category) {
1242
+			$where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories';
1243
+			$where['Term_Taxonomy.term_id']  = $category;
1244
+		}
1245
+
1246
+
1247
+		if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
1248
+			$where['VNU_wp_user'] = get_current_user_id();
1249
+		} else {
1250
+			if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
1251
+				$where['OR'] = [
1252
+					'status*restrict_private' => ['!=', 'private'],
1253
+					'AND'                     => [
1254
+						'status*inclusive' => ['=', 'private'],
1255
+						'VNU_wp_user'      => get_current_user_id(),
1256
+					],
1257
+				];
1258
+			}
1259
+		}
1260
+
1261
+		$search_term = $this->request->getRequestParam('s');
1262
+		if ($search_term) {
1263
+			$search_term = '%' . $search_term . '%';
1264
+			$where['OR'] = [
1265
+				'VNU_name'               => ['LIKE', $search_term],
1266
+				'VNU_desc'               => ['LIKE', $search_term],
1267
+				'VNU_short_desc'         => ['LIKE', $search_term],
1268
+				'VNU_address'            => ['LIKE', $search_term],
1269
+				'VNU_address2'           => ['LIKE', $search_term],
1270
+				'VNU_city'               => ['LIKE', $search_term],
1271
+				'VNU_zip'                => ['LIKE', $search_term],
1272
+				'VNU_phone'              => ['LIKE', $search_term],
1273
+				'VNU_url'                => ['LIKE', $search_term],
1274
+				'VNU_virtual_phone'      => ['LIKE', $search_term],
1275
+				'VNU_virtual_url'        => ['LIKE', $search_term],
1276
+				'VNU_google_map_link'    => ['LIKE', $search_term],
1277
+				'Event.EVT_name'         => ['LIKE', $search_term],
1278
+				'Event.EVT_desc'         => ['LIKE', $search_term],
1279
+				'Event.EVT_phone'        => ['LIKE', $search_term],
1280
+				'Event.EVT_external_URL' => ['LIKE', $search_term],
1281
+			];
1282
+		}
1283
+
1284
+
1285
+		return $count
1286
+			? $this->_venue_model->count([$where], 'VNU_ID')
1287
+			: $this->_venue_model->get_all(
1288
+				[$where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort]
1289
+			);
1290
+	}
1291
+
1292
+
1293
+
1294
+
1295
+	/** Venue Category Stuff **/
1296
+
1297
+	/**
1298
+	 * set the _category property with the category object for the loaded page.
1299
+	 *
1300
+	 * @access private
1301
+	 * @return void
1302
+	 */
1303
+	private function _set_category_object()
1304
+	{
1305
+		if (isset($this->_category->id) && ! empty($this->_category->id)) {
1306
+			return;
1307
+		} // already have the category object so get out.
1308
+
1309
+		// set default category object
1310
+		$this->_set_empty_category_object();
1311
+
1312
+		// only set if we've got an id
1313
+		$category_ID = $this->request->getRequestParam('VEN_CAT_ID', 0, 'int');
1314
+		if (! $category_ID) {
1315
+			return;
1316
+		}
1317
+
1318
+		$term = get_term($category_ID, 'espresso_venue_categories');
1319
+
1320
+
1321
+		if (! empty($term)) {
1322
+			$this->_category->category_name       = $term->name;
1323
+			$this->_category->category_identifier = $term->slug;
1324
+			$this->_category->category_desc       = $term->description;
1325
+			$this->_category->id                  = $term->term_id;
1326
+			$this->_category->parent              = $term->parent;
1327
+		}
1328
+	}
1329
+
1330
+
1331
+	private function _set_empty_category_object()
1332
+	{
1333
+		$this->_category                = new stdClass();
1334
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
1335
+		$this->_category->id            = $this->_category->parent = 0;
1336
+	}
1337
+
1338
+
1339
+	/**
1340
+	 * @throws EE_Error
1341
+	 */
1342
+	protected function _category_list_table()
1343
+	{
1344
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1345
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1346
+			'add_category',
1347
+			'add_category',
1348
+			[],
1349
+			'add-new-h2'
1350
+		);
1351
+		$this->_search_btn_label = esc_html__('Venue Categories', 'event_espresso');
1352
+		$this->display_admin_list_table_page_with_sidebar();
1353
+	}
1354
+
1355
+
1356
+	/**
1357
+	 * @throws EE_Error
1358
+	 */
1359
+	protected function _category_details($view)
1360
+	{
1361
+
1362
+		// load formatter helper
1363
+		// load field generator helper
1364
+
1365
+		$route = $view == 'edit' ? 'update_category' : 'insert_category';
1366
+		$this->_set_add_edit_form_tags($route);
1367
+
1368
+		$this->_set_category_object();
1369
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
1370
+
1371
+		$delete_action = 'delete_category';
1372
+
1373
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(['action' => 'category_list'], $this->_admin_base_url);
1374
+
1375
+		$this->_set_publish_post_box_vars('VEN_CAT_ID', $id, $delete_action, $redirect);
1376
+
1377
+		// take care of contents
1378
+		$this->_template_args['admin_page_content'] = $this->_category_details_content();
1379
+		$this->display_admin_page_with_sidebar();
1380
+	}
1381
+
1382
+
1383
+	protected function _category_details_content()
1384
+	{
1385
+		$editor_args['category_desc'] = [
1386
+			'type'          => 'wp_editor',
1387
+			'value'         => EEH_Formatter::admin_format_content($this->_category->category_desc),
1388
+			'class'         => 'my_editor_custom',
1389
+			'wpeditor_args' => ['media_buttons' => false],
1390
+		];
1391
+		$_wp_editor                   = $this->_generate_admin_form_fields($editor_args, 'array');
1392
+
1393
+		$all_terms = get_terms(
1394
+			['espresso_venue_categories'],
1395
+			['hide_empty' => 0, 'exclude' => [$this->_category->id]]
1396
+		);
1397
+
1398
+		// setup category select for term parents.
1399
+		$category_select_values[] = [
1400
+			'text' => esc_html__('No Parent', 'event_espresso'),
1401
+			'id'   => 0,
1402
+		];
1403
+		foreach ($all_terms as $term) {
1404
+			$category_select_values[] = [
1405
+				'text' => $term->name,
1406
+				'id'   => $term->term_id,
1407
+			];
1408
+		}
1409
+
1410
+		$category_select = EEH_Form_Fields::select_input(
1411
+			'category_parent',
1412
+			$category_select_values,
1413
+			$this->_category->parent
1414
+		);
1415
+		$template_args   = [
1416
+			'category'                 => $this->_category,
1417
+			'category_select'          => $category_select,
1418
+			'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
1419
+			'category_desc_editor'     => $_wp_editor['category_desc']['field'],
1420
+			'disable'                  => '',
1421
+			'disabled_message'         => false,
1422
+		];
1423
+		$template        = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
1424
+		return EEH_Template::display_template($template, $template_args, true);
1425
+	}
1426
+
1427
+
1428
+	/**
1429
+	 * @throws EE_Error
1430
+	 */
1431
+	protected function _delete_categories()
1432
+	{
1433
+		$category_ID  = $this->request->getRequestParam('category_id', 0, 'int');
1434
+		$category_IDs = $this->request->getRequestParam('VEN_CAT_ID', [$category_ID], 'int', true);
1435
+
1436
+		foreach ($category_IDs as $cat_id) {
1437
+			$this->_delete_category($cat_id);
1438
+		}
1439
+
1440
+		// doesn't matter what page we're coming from... we're going to the same place after delete.
1441
+		$query_args = [
1442
+			'action' => 'category_list',
1443
+		];
1444
+		$this->_redirect_after_action(0, '', '', $query_args);
1445
+	}
1446
+
1447
+
1448
+	protected function _delete_category($cat_id)
1449
+	{
1450
+		$cat_id = absint($cat_id);
1451
+		wp_delete_term($cat_id, 'espresso_venue_categories');
1452
+	}
1453
+
1454
+
1455
+	/**
1456
+	 * @throws EE_Error
1457
+	 */
1458
+	protected function _insert_or_update_category($new_category)
1459
+	{
1460
+
1461
+		$cat_id  = $new_category ? $this->_insert_category() : $this->_insert_category(true);
1462
+		$success = 0; // we already have a success message so lets not send another.
1463
+		if ($cat_id) {
1464
+			$query_args = [
1465
+				'action'     => 'edit_category',
1466
+				'VEN_CAT_ID' => $cat_id,
1467
+			];
1468
+		} else {
1469
+			$query_args = ['action' => 'add_category'];
1470
+		}
1471
+		$this->_redirect_after_action($success, '', '', $query_args, true);
1472
+	}
1473
+
1474
+
1475
+	private function _insert_category($update = false)
1476
+	{
1477
+		$category_ID     = $update ? $this->request->getRequestParam('VEN_CAT_ID', '', 'int') : '';
1478
+		$category_name   = $this->request->getRequestParam('category_name', '');
1479
+		$category_desc   = $this->request->getRequestParam('category_desc', '', 'html');
1480
+		$category_parent = $this->request->getRequestParam('category_parent', 0, 'int');
1481
+
1482
+		if (empty($category_name)) {
1483
+			$msg = esc_html__('You must add a name for the category.', 'event_espresso');
1484
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1485
+			return false;
1486
+		}
1487
+
1488
+
1489
+		$term_args = [
1490
+			'name'        => $category_name,
1491
+			'description' => $category_desc,
1492
+			'parent'      => $category_parent,
1493
+		];
1494
+
1495
+		$insert_ids = $update
1496
+			? wp_update_term($category_ID, 'espresso_venue_categories', $term_args)
1497
+			: wp_insert_term(
1498
+				$category_name,
1499
+				'espresso_venue_categories',
1500
+				$term_args
1501
+			);
1502
+
1503
+		if (! is_array($insert_ids)) {
1504
+			EE_Error::add_error(
1505
+				esc_html__('An error occurred and the category has not been saved to the database.', 'event_espresso'),
1506
+				__FILE__,
1507
+				__FUNCTION__,
1508
+				__LINE__
1509
+			);
1510
+		} else {
1511
+			$category_ID = $insert_ids['term_id'];
1512
+			EE_Error::add_success(
1513
+				sprintf(
1514
+					esc_html__('The category %s was successfully created', 'event_espresso'),
1515
+					$category_name
1516
+				)
1517
+			);
1518
+		}
1519
+
1520
+		return $category_ID;
1521
+	}
1522
+
1523
+
1524
+	/**
1525
+	 * TODO handle category exports()
1526
+	 *
1527
+	 * @return void
1528
+	 */
1529
+	protected function _categories_export()
1530
+	{
1531
+		// todo: I don't like doing this but it'll do until we modify EE_Export Class.
1532
+		$this->request->mergeRequestParams(
1533
+			[
1534
+				'export'       => 'report',
1535
+				'action'       => 'categories',
1536
+				'category_ids' => $this->request->getRequestParam('VEN_CAT_ID', 0, 'int'),
1537
+			]
1538
+		);
1539
+
1540
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
1541
+			require_once(EE_CLASSES . 'EE_Export.class.php');
1542
+			$EE_Export = EE_Export::instance($this->request->requestParams());
1543
+			$EE_Export->export();
1544
+		}
1545
+	}
1546
+
1547
+
1548
+	protected function _import_categories()
1549
+	{
1550
+
1551
+		require_once(EE_CLASSES . 'EE_Import.class.php');
1552
+		EE_Import::instance()->import();
1553
+	}
1554
+
1555
+
1556
+	/**
1557
+	 * @throws EE_Error
1558
+	 */
1559
+	public function get_categories($per_page = 10, $current_page = 1, $count = false)
1560
+	{
1561
+
1562
+		// testing term stuff
1563
+		$orderby     = $this->request->getRequestParam('orderby', 'Term.term_id');
1564
+		$order       = $this->request->getRequestParam('order', 'DESC');
1565
+		$limit       = ($current_page - 1) * $per_page;
1566
+		$where       = ['taxonomy' => 'espresso_venue_categories'];
1567
+		$search_term = $this->request->getRequestParam('s');
1568
+		if ($search_term) {
1569
+			$search_term = '%' . $search_term . '%';
1570
+			$where['OR'] = [
1571
+				'Term.name'   => ['LIKE', $search_term],
1572
+				'description' => ['LIKE', $search_term],
1573
+			];
1574
+		}
1575
+
1576
+		$query_params = [
1577
+			$where,
1578
+			'order_by'   => [$orderby => $order],
1579
+			'limit'      => $limit . ',' . $per_page,
1580
+			'force_join' => ['Term'],
1581
+		];
1582
+
1583
+		return $count
1584
+			? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id')
1585
+			: EEM_Term_Taxonomy::instance()->get_all($query_params);
1586
+	}
1587
+
1588
+
1589
+	/* end category stuff */
1590
+	/**************/
1591 1591
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
      */
46 46
     protected function _init_page_props()
47 47
     {
48
-        require_once(EE_MODELS . 'EEM_Venue.model.php');
48
+        require_once(EE_MODELS.'EEM_Venue.model.php');
49 49
         $this->page_slug        = EE_VENUES_PG_SLUG;
50 50
         $this->_admin_base_url  = EE_VENUES_ADMIN_URL;
51
-        $this->_admin_base_path = EE_ADMIN_PAGES . 'venues';
51
+        $this->_admin_base_path = EE_ADMIN_PAGES.'venues';
52 52
         $this->page_label       = esc_html__('Event Venues', 'event_espresso');
53 53
         $this->_cpt_model_names = [
54 54
             'create_new' => 'EEM_Venue',
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 
467 467
     public function load_scripts_styles()
468 468
     {
469
-        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', [], EVENT_ESPRESSO_VERSION);
469
+        wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', [], EVENT_ESPRESSO_VERSION);
470 470
         wp_enqueue_style('ee-cat-admin');
471 471
     }
472 472
 
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
         wp_enqueue_style('espresso-ui-theme');
489 489
         wp_register_style(
490 490
             'espresso_venues',
491
-            EE_VENUES_ASSETS_URL . 'ee-venues-admin.css',
491
+            EE_VENUES_ASSETS_URL.'ee-venues-admin.css',
492 492
             [],
493 493
             EVENT_ESPRESSO_VERSION
494 494
         );
@@ -551,14 +551,14 @@  discard block
 block discarded – undo
551 551
             'button'
552 552
         );
553 553
 
554
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
554
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
555 555
             'create_new',
556 556
             'add',
557 557
             [],
558 558
             'add-new-h2'
559 559
         );
560 560
 
561
-        $this->_search_btn_label  = esc_html__('Venues', 'event_espresso');
561
+        $this->_search_btn_label = esc_html__('Venues', 'event_espresso');
562 562
         $this->display_admin_list_table_page_with_sidebar();
563 563
     }
564 564
 
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
             'vnu_url'      => $this->_cpt_model_obj->get_f('VNU_url'),
575 575
             'vnu_phone'    => $this->_cpt_model_obj->get_f('VNU_phone'),
576 576
         ];
577
-        $template   = EE_VENUES_TEMPLATE_PATH . 'venue_publish_box_extras.template.php';
577
+        $template = EE_VENUES_TEMPLATE_PATH.'venue_publish_box_extras.template.php';
578 578
         EEH_Template::display_template($template, $extra_rows);
579 579
     }
580 580
 
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
         $this->_set_add_edit_form_tags('update_google_map_settings');
639 639
         $this->_set_publish_post_box_vars(null, false, false, null, false);
640 640
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
641
-            EE_VENUES_TEMPLATE_PATH . 'google_map.template.php',
641
+            EE_VENUES_TEMPLATE_PATH.'google_map.template.php',
642 642
             $this->_template_args,
643 643
             true
644 644
         );
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
             ),
735 735
             'vnu_google_map_link' => $this->_cpt_model_obj->google_map_link(),
736 736
         ];
737
-        $template      = EE_VENUES_TEMPLATE_PATH . 'venue_gmap_metabox_content.template.php';
737
+        $template = EE_VENUES_TEMPLATE_PATH.'venue_gmap_metabox_content.template.php';
738 738
         EEH_Template::display_template($template, $template_args);
739 739
     }
740 740
 
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
     {
748 748
         $template_args['_venue'] = $this->_cpt_model_obj;
749 749
 
750
-        $template_args['states_dropdown']    = EEH_Form_Fields::generate_form_input(
750
+        $template_args['states_dropdown'] = EEH_Form_Fields::generate_form_input(
751 751
             new EE_Question_Form_Input(
752 752
                 EE_Question::new_instance(
753 753
                     ['QST_display_text' => esc_html__('State', 'event_espresso'), 'QST_system' => 'state']
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
             )
791 791
         );
792 792
 
793
-        $template = EE_VENUES_TEMPLATE_PATH . 'venue_address_metabox_content.template.php';
793
+        $template = EE_VENUES_TEMPLATE_PATH.'venue_address_metabox_content.template.php';
794 794
         EEH_Template::display_template($template, $template_args);
795 795
     }
796 796
 
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
         $template_args = [
801 801
             '_venue' => $this->_cpt_model_obj,
802 802
         ];
803
-        $template      = EE_VENUES_TEMPLATE_PATH . 'venue_virtual_location_metabox_content.template.php';
803
+        $template      = EE_VENUES_TEMPLATE_PATH.'venue_virtual_location_metabox_content.template.php';
804 804
         EEH_Template::display_template($template, $template_args);
805 805
     }
806 806
 
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
     {
826 826
 
827 827
         if ($post instanceof WP_Post && $post->post_type !== 'espresso_venues') {
828
-            return;// get out we're not processing the saving of venues.
828
+            return; // get out we're not processing the saving of venues.
829 829
         }
830 830
 
831 831
         $wheres = [$this->_venue_model->primary_key_name() => $post_id];
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
             'FHEE__Venues_Admin_Page___insert_update_cpt_item__venue_update_callbacks',
861 861
             []
862 862
         );
863
-        $att_success            = true;
863
+        $att_success = true;
864 864
         foreach ($venue_update_callbacks as $v_callback) {
865 865
             // if ANY of these updates fail then we want the appropriate global error message
866 866
             $att_success = call_user_func_array($v_callback, [$venue, $this->request->requestParams()])
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
             // clean status
946 946
             $venue_status = sanitize_key($venue_status);
947 947
             // grab status
948
-            if (! empty($venue_status)) {
948
+            if ( ! empty($venue_status)) {
949 949
                 $success = $this->_change_venue_status($VNU_ID, $venue_status);
950 950
             } else {
951 951
                 $success = false;
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
         // clean status
981 981
         $venue_status = sanitize_key($venue_status);
982 982
         // grab status
983
-        if (! empty($venue_status)) {
983
+        if ( ! empty($venue_status)) {
984 984
             $success = true;
985 985
             // determine the event id and set to array.
986 986
             $VNU_IDs = $this->request->getRequestParam('venue_id', [], 'int', true);
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
     private function _change_venue_status($VNU_ID = 0, $venue_status = '')
1034 1034
     {
1035 1035
         // grab venue id
1036
-        if (! $VNU_ID) {
1036
+        if ( ! $VNU_ID) {
1037 1037
             $msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1038 1038
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1039 1039
             return false;
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
         // clean status
1045 1045
         $venue_status = sanitize_key($venue_status);
1046 1046
         // grab status
1047
-        if (! $venue_status) {
1047
+        if ( ! $venue_status) {
1048 1048
             $msg = esc_html__(
1049 1049
                 'An error occurred. No Venue Status or an invalid Venue Status was received.',
1050 1050
                 'event_espresso'
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
     private function _delete_or_trash_venue($VNU_ID = false)
1157 1157
     {
1158 1158
         // grab event id
1159
-        if (! $VNU_ID = absint($VNU_ID)) {
1159
+        if ( ! $VNU_ID = absint($VNU_ID)) {
1160 1160
             $msg = esc_html__('An error occurred. No Venue ID or an invalid Venue ID was received.', 'event_espresso');
1161 1161
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1162 1162
             return false;
@@ -1244,10 +1244,10 @@  discard block
 block discarded – undo
1244 1244
         }
1245 1245
 
1246 1246
 
1247
-        if (! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
1247
+        if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
1248 1248
             $where['VNU_wp_user'] = get_current_user_id();
1249 1249
         } else {
1250
-            if (! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
1250
+            if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
1251 1251
                 $where['OR'] = [
1252 1252
                     'status*restrict_private' => ['!=', 'private'],
1253 1253
                     'AND'                     => [
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
 
1261 1261
         $search_term = $this->request->getRequestParam('s');
1262 1262
         if ($search_term) {
1263
-            $search_term = '%' . $search_term . '%';
1263
+            $search_term = '%'.$search_term.'%';
1264 1264
             $where['OR'] = [
1265 1265
                 'VNU_name'               => ['LIKE', $search_term],
1266 1266
                 'VNU_desc'               => ['LIKE', $search_term],
@@ -1311,14 +1311,14 @@  discard block
 block discarded – undo
1311 1311
 
1312 1312
         // only set if we've got an id
1313 1313
         $category_ID = $this->request->getRequestParam('VEN_CAT_ID', 0, 'int');
1314
-        if (! $category_ID) {
1314
+        if ( ! $category_ID) {
1315 1315
             return;
1316 1316
         }
1317 1317
 
1318 1318
         $term = get_term($category_ID, 'espresso_venue_categories');
1319 1319
 
1320 1320
 
1321
-        if (! empty($term)) {
1321
+        if ( ! empty($term)) {
1322 1322
             $this->_category->category_name       = $term->name;
1323 1323
             $this->_category->category_identifier = $term->slug;
1324 1324
             $this->_category->category_desc       = $term->description;
@@ -1342,7 +1342,7 @@  discard block
 block discarded – undo
1342 1342
     protected function _category_list_table()
1343 1343
     {
1344 1344
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1345
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
1345
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
1346 1346
             'add_category',
1347 1347
             'add_category',
1348 1348
             [],
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
             'class'         => 'my_editor_custom',
1389 1389
             'wpeditor_args' => ['media_buttons' => false],
1390 1390
         ];
1391
-        $_wp_editor                   = $this->_generate_admin_form_fields($editor_args, 'array');
1391
+        $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
1392 1392
 
1393 1393
         $all_terms = get_terms(
1394 1394
             ['espresso_venue_categories'],
@@ -1412,7 +1412,7 @@  discard block
 block discarded – undo
1412 1412
             $category_select_values,
1413 1413
             $this->_category->parent
1414 1414
         );
1415
-        $template_args   = [
1415
+        $template_args = [
1416 1416
             'category'                 => $this->_category,
1417 1417
             'category_select'          => $category_select,
1418 1418
             'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'),
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
             'disable'                  => '',
1421 1421
             'disabled_message'         => false,
1422 1422
         ];
1423
-        $template        = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
1423
+        $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php';
1424 1424
         return EEH_Template::display_template($template, $template_args, true);
1425 1425
     }
1426 1426
 
@@ -1500,7 +1500,7 @@  discard block
 block discarded – undo
1500 1500
                 $term_args
1501 1501
             );
1502 1502
 
1503
-        if (! is_array($insert_ids)) {
1503
+        if ( ! is_array($insert_ids)) {
1504 1504
             EE_Error::add_error(
1505 1505
                 esc_html__('An error occurred and the category has not been saved to the database.', 'event_espresso'),
1506 1506
                 __FILE__,
@@ -1537,8 +1537,8 @@  discard block
 block discarded – undo
1537 1537
             ]
1538 1538
         );
1539 1539
 
1540
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
1541
-            require_once(EE_CLASSES . 'EE_Export.class.php');
1540
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
1541
+            require_once(EE_CLASSES.'EE_Export.class.php');
1542 1542
             $EE_Export = EE_Export::instance($this->request->requestParams());
1543 1543
             $EE_Export->export();
1544 1544
         }
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
     protected function _import_categories()
1549 1549
     {
1550 1550
 
1551
-        require_once(EE_CLASSES . 'EE_Import.class.php');
1551
+        require_once(EE_CLASSES.'EE_Import.class.php');
1552 1552
         EE_Import::instance()->import();
1553 1553
     }
1554 1554
 
@@ -1566,7 +1566,7 @@  discard block
 block discarded – undo
1566 1566
         $where       = ['taxonomy' => 'espresso_venue_categories'];
1567 1567
         $search_term = $this->request->getRequestParam('s');
1568 1568
         if ($search_term) {
1569
-            $search_term = '%' . $search_term . '%';
1569
+            $search_term = '%'.$search_term.'%';
1570 1570
             $where['OR'] = [
1571 1571
                 'Term.name'   => ['LIKE', $search_term],
1572 1572
                 'description' => ['LIKE', $search_term],
@@ -1576,7 +1576,7 @@  discard block
 block discarded – undo
1576 1576
         $query_params = [
1577 1577
             $where,
1578 1578
             'order_by'   => [$orderby => $order],
1579
-            'limit'      => $limit . ',' . $per_page,
1579
+            'limit'      => $limit.','.$per_page,
1580 1580
             'force_join' => ['Term'],
1581 1581
         ];
1582 1582
 
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +4103 added lines, -4103 removed lines patch added patch discarded remove patch
@@ -18,4179 +18,4179 @@
 block discarded – undo
18 18
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var LoaderInterface
23
-     */
24
-    protected $loader;
21
+	/**
22
+	 * @var LoaderInterface
23
+	 */
24
+	protected $loader;
25 25
 
26
-    /**
27
-     * @var RequestInterface
28
-     */
29
-    protected $request;
26
+	/**
27
+	 * @var RequestInterface
28
+	 */
29
+	protected $request;
30 30
 
31
-    // set in _init_page_props()
32
-    public $page_slug;
31
+	// set in _init_page_props()
32
+	public $page_slug;
33 33
 
34
-    public $page_label;
34
+	public $page_label;
35 35
 
36
-    public $page_folder;
36
+	public $page_folder;
37 37
 
38
-    // set in define_page_props()
39
-    protected $_admin_base_url;
38
+	// set in define_page_props()
39
+	protected $_admin_base_url;
40 40
 
41
-    protected $_admin_base_path;
41
+	protected $_admin_base_path;
42 42
 
43
-    protected $_admin_page_title;
43
+	protected $_admin_page_title;
44 44
 
45
-    protected $_labels;
45
+	protected $_labels;
46 46
 
47 47
 
48
-    // set early within EE_Admin_Init
49
-    protected $_wp_page_slug;
48
+	// set early within EE_Admin_Init
49
+	protected $_wp_page_slug;
50 50
 
51
-    // navtabs
52
-    protected $_nav_tabs;
51
+	// navtabs
52
+	protected $_nav_tabs;
53 53
 
54
-    protected $_default_nav_tab_name;
54
+	protected $_default_nav_tab_name;
55 55
 
56
-    /**
57
-     * @var array $_help_tour
58
-     */
59
-    protected $_help_tour = [];
56
+	/**
57
+	 * @var array $_help_tour
58
+	 */
59
+	protected $_help_tour = [];
60 60
 
61 61
 
62
-    // template variables (used by templates)
63
-    protected $_template_path;
62
+	// template variables (used by templates)
63
+	protected $_template_path;
64 64
 
65
-    protected $_column_template_path;
65
+	protected $_column_template_path;
66 66
 
67
-    /**
68
-     * @var array $_template_args
69
-     */
70
-    protected $_template_args = [];
67
+	/**
68
+	 * @var array $_template_args
69
+	 */
70
+	protected $_template_args = [];
71 71
 
72
-    /**
73
-     * this will hold the list table object for a given view.
74
-     *
75
-     * @var EE_Admin_List_Table $_list_table_object
76
-     */
77
-    protected $_list_table_object;
72
+	/**
73
+	 * this will hold the list table object for a given view.
74
+	 *
75
+	 * @var EE_Admin_List_Table $_list_table_object
76
+	 */
77
+	protected $_list_table_object;
78 78
 
79
-    // bools
80
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
79
+	// bools
80
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
81 81
 
82
-    protected $_routing;
82
+	protected $_routing;
83 83
 
84
-    // list table args
85
-    protected $_view;
84
+	// list table args
85
+	protected $_view;
86 86
 
87
-    protected $_views;
87
+	protected $_views;
88 88
 
89 89
 
90
-    // action => method pairs used for routing incoming requests
91
-    protected $_page_routes;
90
+	// action => method pairs used for routing incoming requests
91
+	protected $_page_routes;
92 92
 
93
-    /**
94
-     * @var array $_page_config
95
-     */
96
-    protected $_page_config;
93
+	/**
94
+	 * @var array $_page_config
95
+	 */
96
+	protected $_page_config;
97 97
 
98
-    /**
99
-     * the current page route and route config
100
-     *
101
-     * @var string $_route
102
-     */
103
-    protected $_route;
98
+	/**
99
+	 * the current page route and route config
100
+	 *
101
+	 * @var string $_route
102
+	 */
103
+	protected $_route;
104 104
 
105
-    /**
106
-     * @var string $_cpt_route
107
-     */
108
-    protected $_cpt_route;
105
+	/**
106
+	 * @var string $_cpt_route
107
+	 */
108
+	protected $_cpt_route;
109 109
 
110
-    /**
111
-     * @var array $_route_config
112
-     */
113
-    protected $_route_config;
110
+	/**
111
+	 * @var array $_route_config
112
+	 */
113
+	protected $_route_config;
114 114
 
115
-    /**
116
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
117
-     * actions.
118
-     *
119
-     * @since 4.6.x
120
-     * @var array.
121
-     */
122
-    protected $_default_route_query_args;
123
-
124
-    // set via request page and action args.
125
-    protected $_current_page;
126
-
127
-    protected $_current_view;
128
-
129
-    protected $_current_page_view_url;
130
-
131
-    /**
132
-     * unprocessed value for the 'action' request param (default '')
133
-     *
134
-     * @var string
135
-     */
136
-    protected $raw_req_action = '';
137
-
138
-    /**
139
-     * unprocessed value for the 'page' request param (default '')
140
-     *
141
-     * @var string
142
-     */
143
-    protected $raw_req_page = '';
144
-
145
-    /**
146
-     * sanitized request action (and nonce)
147
-     *
148
-     * @var string
149
-     */
150
-    protected $_req_action = '';
151
-
152
-    /**
153
-     * sanitized request action nonce
154
-     *
155
-     * @var string
156
-     */
157
-    protected $_req_nonce = '';
158
-
159
-    /**
160
-     * @var string
161
-     */
162
-    protected $_search_btn_label = '';
163
-
164
-    /**
165
-     * @var string
166
-     */
167
-    protected $_search_box_callback = '';
168
-
169
-    /**
170
-     * @var WP_Screen
171
-     */
172
-    protected $_current_screen;
173
-
174
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
175
-    protected $_hook_obj;
176
-
177
-    // for holding incoming request data
178
-    protected $_req_data = [];
179
-
180
-    // yes / no array for admin form fields
181
-    protected $_yes_no_values = [];
182
-
183
-    // some default things shared by all child classes
184
-    protected $_default_espresso_metaboxes;
185
-
186
-    /**
187
-     * @var EE_Registry
188
-     */
189
-    protected $EE = null;
190
-
191
-
192
-    /**
193
-     * This is just a property that flags whether the given route is a caffeinated route or not.
194
-     *
195
-     * @var boolean
196
-     */
197
-    protected $_is_caf = false;
198
-
199
-
200
-    /**
201
-     * @Constructor
202
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
203
-     * @throws EE_Error
204
-     * @throws InvalidArgumentException
205
-     * @throws ReflectionException
206
-     * @throws InvalidDataTypeException
207
-     * @throws InvalidInterfaceException
208
-     */
209
-    public function __construct($routing = true)
210
-    {
211
-        $this->loader  = LoaderFactory::getLoader();
212
-        $this->request = $this->loader->getShared(RequestInterface::class);
213
-        $this->_routing = $routing;
214
-
215
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
216
-            $this->_is_caf = true;
217
-        }
218
-        $this->_yes_no_values = [
219
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
220
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
221
-        ];
222
-        // set the _req_data property.
223
-        $this->_req_data = $this->request->requestParams();
224
-        // set initial page props (child method)
225
-        $this->_init_page_props();
226
-        // set global defaults
227
-        $this->_set_defaults();
228
-        // set early because incoming requests could be ajax related and we need to register those hooks.
229
-        $this->_global_ajax_hooks();
230
-        $this->_ajax_hooks();
231
-        // other_page_hooks have to be early too.
232
-        $this->_do_other_page_hooks();
233
-        // set up page dependencies
234
-        $this->_before_page_setup();
235
-        $this->_page_setup();
236
-        // die();
237
-    }
238
-
239
-
240
-    /**
241
-     * _init_page_props
242
-     * Child classes use to set at least the following properties:
243
-     * $page_slug.
244
-     * $page_label.
245
-     *
246
-     * @abstract
247
-     * @return void
248
-     */
249
-    abstract protected function _init_page_props();
250
-
251
-
252
-    /**
253
-     * _ajax_hooks
254
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
255
-     * Note: within the ajax callback methods.
256
-     *
257
-     * @abstract
258
-     * @return void
259
-     */
260
-    abstract protected function _ajax_hooks();
261
-
262
-
263
-    /**
264
-     * _define_page_props
265
-     * child classes define page properties in here.  Must include at least:
266
-     * $_admin_base_url = base_url for all admin pages
267
-     * $_admin_page_title = default admin_page_title for admin pages
268
-     * $_labels = array of default labels for various automatically generated elements:
269
-     *    array(
270
-     *        'buttons' => array(
271
-     *            'add' => esc_html__('label for add new button'),
272
-     *            'edit' => esc_html__('label for edit button'),
273
-     *            'delete' => esc_html__('label for delete button')
274
-     *            )
275
-     *        )
276
-     *
277
-     * @abstract
278
-     * @return void
279
-     */
280
-    abstract protected function _define_page_props();
281
-
282
-
283
-    /**
284
-     * _set_page_routes
285
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
286
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
287
-     * have a 'default' route. Here's the format
288
-     * $this->_page_routes = array(
289
-     *        'default' => array(
290
-     *            'func' => '_default_method_handling_route',
291
-     *            'args' => array('array','of','args'),
292
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
293
-     *            ajax request, backend processing)
294
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
295
-     *            headers route after.  The string you enter here should match the defined route reference for a
296
-     *            headers sent route.
297
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
298
-     *            this route.
299
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
300
-     *            checks).
301
-     *        ),
302
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
303
-     *        handling method.
304
-     *        )
305
-     * )
306
-     *
307
-     * @abstract
308
-     * @return void
309
-     */
310
-    abstract protected function _set_page_routes();
311
-
312
-
313
-    /**
314
-     * _set_page_config
315
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
316
-     * array corresponds to the page_route for the loaded page. Format:
317
-     * $this->_page_config = array(
318
-     *        'default' => array(
319
-     *            'labels' => array(
320
-     *                'buttons' => array(
321
-     *                    'add' => esc_html__('label for adding item'),
322
-     *                    'edit' => esc_html__('label for editing item'),
323
-     *                    'delete' => esc_html__('label for deleting item')
324
-     *                ),
325
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
326
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
327
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
328
-     *            _define_page_props() method
329
-     *            'nav' => array(
330
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
331
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
332
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
333
-     *                'order' => 10, //required to indicate tab position.
334
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
335
-     *                displayed then add this parameter.
336
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
337
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
338
-     *            metaboxes set for eventespresso admin pages.
339
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
340
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
341
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
342
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
343
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
344
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
345
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
346
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
347
-     *            want to display.
348
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
349
-     *                'tab_id' => array(
350
-     *                    'title' => 'tab_title',
351
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
352
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
353
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
354
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
355
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
356
-     *                    attempt to use the callback which should match the name of a method in the class
357
-     *                    ),
358
-     *                'tab2_id' => array(
359
-     *                    'title' => 'tab2 title',
360
-     *                    'filename' => 'file_name_2'
361
-     *                    'callback' => 'callback_method_for_content',
362
-     *                 ),
363
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
364
-     *            help tab area on an admin page. @return void
365
-     *
366
-     * @link
367
-     *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
368
-     *                'help_tour' => array(
369
-     *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
370
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
371
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
372
-     *                ),
373
-     *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
374
-     *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
375
-     *                visited just set
376
-     *                'require_nonce' to FALSE
377
-     *                )
378
-     *                )
379
-     *
380
-     * @abstract
381
-     */
382
-    abstract protected function _set_page_config();
383
-
384
-
385
-
386
-
387
-
388
-    /** end sample help_tour methods **/
389
-    /**
390
-     * _add_screen_options
391
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
392
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
393
-     * to a particular view.
394
-     *
395
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
396
-     *         see also WP_Screen object documents...
397
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
398
-     * @abstract
399
-     * @return void
400
-     */
401
-    abstract protected function _add_screen_options();
402
-
403
-
404
-    /**
405
-     * _add_feature_pointers
406
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
407
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
408
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
409
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
410
-     * extended) also see:
411
-     *
412
-     * @link   http://eamann.com/tech/wordpress-portland/
413
-     * @abstract
414
-     * @return void
415
-     */
416
-    abstract protected function _add_feature_pointers();
417
-
418
-
419
-    /**
420
-     * load_scripts_styles
421
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
422
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
423
-     * scripts/styles per view by putting them in a dynamic function in this format
424
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
425
-     *
426
-     * @abstract
427
-     * @return void
428
-     */
429
-    abstract public function load_scripts_styles();
430
-
431
-
432
-    /**
433
-     * admin_init
434
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
435
-     * all pages/views loaded by child class.
436
-     *
437
-     * @abstract
438
-     * @return void
439
-     */
440
-    abstract public function admin_init();
441
-
442
-
443
-    /**
444
-     * admin_notices
445
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
446
-     * all pages/views loaded by child class.
447
-     *
448
-     * @abstract
449
-     * @return void
450
-     */
451
-    abstract public function admin_notices();
452
-
453
-
454
-    /**
455
-     * admin_footer_scripts
456
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
457
-     * will apply to all pages/views loaded by child class.
458
-     *
459
-     * @return void
460
-     */
461
-    abstract public function admin_footer_scripts();
462
-
463
-
464
-    /**
465
-     * admin_footer
466
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
467
-     * apply to all pages/views loaded by child class.
468
-     *
469
-     * @return void
470
-     */
471
-    public function admin_footer()
472
-    {
473
-    }
474
-
475
-
476
-    /**
477
-     * _global_ajax_hooks
478
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
479
-     * Note: within the ajax callback methods.
480
-     *
481
-     * @abstract
482
-     * @return void
483
-     */
484
-    protected function _global_ajax_hooks()
485
-    {
486
-        // for lazy loading of metabox content
487
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
488
-    }
489
-
490
-
491
-    public function ajax_metabox_content()
492
-    {
493
-        $content_id  = $this->request->getRequestParam('contentid', '');
494
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
495
-        self::cached_rss_display($content_id, $content_url);
496
-        wp_die();
497
-    }
498
-
499
-
500
-    /**
501
-     * allows extending classes do something specific before the parent constructor runs _page_setup().
502
-     *
503
-     * @return void
504
-     */
505
-    protected function _before_page_setup()
506
-    {
507
-        // default is to do nothing
508
-    }
509
-
510
-
511
-    /**
512
-     * Makes sure any things that need to be loaded early get handled.
513
-     * We also escape early here if the page requested doesn't match the object.
514
-     *
515
-     * @final
516
-     * @return void
517
-     * @throws EE_Error
518
-     * @throws InvalidArgumentException
519
-     * @throws ReflectionException
520
-     * @throws InvalidDataTypeException
521
-     * @throws InvalidInterfaceException
522
-     */
523
-    final protected function _page_setup()
524
-    {
525
-        // requires?
526
-        // admin_init stuff - global - we're setting this REALLY early
527
-        // so if EE_Admin pages have to hook into other WP pages they can.
528
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
529
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
530
-        // next verify if we need to load anything...
531
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
532
-        $this->page_folder   = strtolower(
533
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
534
-        );
535
-        global $ee_menu_slugs;
536
-        $ee_menu_slugs = (array) $ee_menu_slugs;
537
-        if (
538
-            ! $this->request->isAjax()
539
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
540
-        ) {
541
-            return;
542
-        }
543
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
544
-        // we need to copy the action from the second to the first
545
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
546
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
547
-        $action     = $action !== '-1' ? $action : $action2;
548
-        $req_action = $action !== '-1' ? $action : 'default';
549
-
550
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
551
-        // then let's use the route as the action.
552
-        // This covers cases where we're coming in from a list table that isn't on the default route.
553
-        $route = $this->request->getRequestParam('route');
554
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
555
-            ? $route
556
-            : $req_action;
557
-
558
-        $this->_current_view = $this->_req_action;
559
-        $this->_req_nonce    = $this->_req_action . '_nonce';
560
-        $this->_define_page_props();
561
-        $this->_current_page_view_url = add_query_arg(
562
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
563
-            $this->_admin_base_url
564
-        );
565
-        // default things
566
-        $this->_default_espresso_metaboxes = [
567
-            '_espresso_news_post_box',
568
-            '_espresso_links_post_box',
569
-            '_espresso_ratings_request',
570
-            '_espresso_sponsors_post_box',
571
-        ];
572
-        // set page configs
573
-        $this->_set_page_routes();
574
-        $this->_set_page_config();
575
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
576
-        if ($this->request->requestParamIsSet('wp_referer')) {
577
-            $wp_referer = $this->request->getRequestParam('wp_referer');
578
-            if ($wp_referer) {
579
-                $this->_default_route_query_args['wp_referer'] = $wp_referer;
580
-            }
581
-        }
582
-        // for caffeinated and other extended functionality.
583
-        //  If there is a _extend_page_config method
584
-        // then let's run that to modify the all the various page configuration arrays
585
-        if (method_exists($this, '_extend_page_config')) {
586
-            $this->_extend_page_config();
587
-        }
588
-        // for CPT and other extended functionality.
589
-        // If there is an _extend_page_config_for_cpt
590
-        // then let's run that to modify all the various page configuration arrays.
591
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
592
-            $this->_extend_page_config_for_cpt();
593
-        }
594
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
595
-        $this->_page_routes = apply_filters(
596
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
597
-            $this->_page_routes,
598
-            $this
599
-        );
600
-        $this->_page_config = apply_filters(
601
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
602
-            $this->_page_config,
603
-            $this
604
-        );
605
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
606
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
607
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
608
-            add_action(
609
-                'AHEE__EE_Admin_Page__route_admin_request',
610
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
611
-                10,
612
-                2
613
-            );
614
-        }
615
-        // next route only if routing enabled
616
-        if ($this->_routing && ! $this->request->isAjax()) {
617
-            $this->_verify_routes();
618
-            // next let's just check user_access and kill if no access
619
-            $this->check_user_access();
620
-            if ($this->_is_UI_request) {
621
-                // admin_init stuff - global, all views for this page class, specific view
622
-                add_action('admin_init', [$this, 'admin_init'], 10);
623
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
624
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
625
-                }
626
-            } else {
627
-                // hijack regular WP loading and route admin request immediately
628
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
629
-                $this->route_admin_request();
630
-            }
631
-        }
632
-    }
633
-
634
-
635
-    /**
636
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
637
-     *
638
-     * @return void
639
-     * @throws EE_Error
640
-     */
641
-    private function _do_other_page_hooks()
642
-    {
643
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
644
-        foreach ($registered_pages as $page) {
645
-            // now let's setup the file name and class that should be present
646
-            $classname = str_replace('.class.php', '', $page);
647
-            // autoloaders should take care of loading file
648
-            if (! class_exists($classname)) {
649
-                $error_msg[] = sprintf(
650
-                    esc_html__(
651
-                        'Something went wrong with loading the %s admin hooks page.',
652
-                        'event_espresso'
653
-                    ),
654
-                    $page
655
-                );
656
-                $error_msg[] = $error_msg[0]
657
-                               . "\r\n"
658
-                               . sprintf(
659
-                                   esc_html__(
660
-                                       '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',
661
-                                       'event_espresso'
662
-                                   ),
663
-                                   $page,
664
-                                   '<br />',
665
-                                   '<strong>' . $classname . '</strong>'
666
-                               );
667
-                throw new EE_Error(implode('||', $error_msg));
668
-            }
669
-            // notice we are passing the instance of this class to the hook object.
670
-            $this->loader->getShared($classname, [$this]);
671
-        }
672
-    }
673
-
674
-
675
-    /**
676
-     * @throws ReflectionException
677
-     * @throws EE_Error
678
-     */
679
-    public function load_page_dependencies()
680
-    {
681
-        try {
682
-            $this->_load_page_dependencies();
683
-        } catch (EE_Error $e) {
684
-            $e->get_error();
685
-        }
686
-    }
687
-
688
-
689
-    /**
690
-     * load_page_dependencies
691
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
692
-     *
693
-     * @return void
694
-     * @throws DomainException
695
-     * @throws EE_Error
696
-     * @throws InvalidArgumentException
697
-     * @throws InvalidDataTypeException
698
-     * @throws InvalidInterfaceException
699
-     */
700
-    protected function _load_page_dependencies()
701
-    {
702
-        // let's set the current_screen and screen options to override what WP set
703
-        $this->_current_screen = get_current_screen();
704
-        // load admin_notices - global, page class, and view specific
705
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
706
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
707
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
708
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
709
-        }
710
-        // load network admin_notices - global, page class, and view specific
711
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
712
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
713
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
714
-        }
715
-        // this will save any per_page screen options if they are present
716
-        $this->_set_per_page_screen_options();
717
-        // setup list table properties
718
-        $this->_set_list_table();
719
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
720
-        // However in some cases the metaboxes will need to be added within a route handling callback.
721
-        $this->_add_registered_meta_boxes();
722
-        $this->_add_screen_columns();
723
-        // add screen options - global, page child class, and view specific
724
-        $this->_add_global_screen_options();
725
-        $this->_add_screen_options();
726
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
727
-        if (method_exists($this, $add_screen_options)) {
728
-            $this->{$add_screen_options}();
729
-        }
730
-        // add help tab(s) and tours- set via page_config and qtips.
731
-        // $this->_add_help_tour();
732
-        $this->_add_help_tabs();
733
-        $this->_add_qtips();
734
-        // add feature_pointers - global, page child class, and view specific
735
-        $this->_add_feature_pointers();
736
-        $this->_add_global_feature_pointers();
737
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
738
-        if (method_exists($this, $add_feature_pointer)) {
739
-            $this->{$add_feature_pointer}();
740
-        }
741
-        // enqueue scripts/styles - global, page class, and view specific
742
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
743
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
744
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
745
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
746
-        }
747
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
748
-        // admin_print_footer_scripts - global, page child class, and view specific.
749
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
750
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
751
-        // is a good use case. Notice the late priority we're giving these
752
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
753
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
754
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
755
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
756
-        }
757
-        // admin footer scripts
758
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
759
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
760
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
761
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
762
-        }
763
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
764
-        // targeted hook
765
-        do_action(
766
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
767
-        );
768
-    }
769
-
770
-
771
-    /**
772
-     * _set_defaults
773
-     * This sets some global defaults for class properties.
774
-     */
775
-    private function _set_defaults()
776
-    {
777
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
778
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
779
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
780
-        $this->_page_config          = $this->_default_route_query_args = [];
781
-        $this->_default_nav_tab_name = 'overview';
782
-        // init template args
783
-        $this->_template_args = [
784
-            'admin_page_header'  => '',
785
-            'admin_page_content' => '',
786
-            'post_body_content'  => '',
787
-            'before_list_table'  => '',
788
-            'after_list_table'   => '',
789
-        ];
790
-    }
791
-
792
-
793
-    /**
794
-     * route_admin_request
795
-     *
796
-     * @return void
797
-     * @throws InvalidArgumentException
798
-     * @throws InvalidInterfaceException
799
-     * @throws InvalidDataTypeException
800
-     * @throws EE_Error
801
-     * @throws ReflectionException
802
-     * @see    _route_admin_request()
803
-     */
804
-    public function route_admin_request()
805
-    {
806
-        try {
807
-            $this->_route_admin_request();
808
-        } catch (EE_Error $e) {
809
-            $e->get_error();
810
-        }
811
-    }
812
-
813
-
814
-    public function set_wp_page_slug($wp_page_slug)
815
-    {
816
-        $this->_wp_page_slug = $wp_page_slug;
817
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
818
-        if (is_network_admin()) {
819
-            $this->_wp_page_slug .= '-network';
820
-        }
821
-    }
822
-
823
-
824
-    /**
825
-     * _verify_routes
826
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
827
-     * we know if we need to drop out.
828
-     *
829
-     * @return bool
830
-     * @throws EE_Error
831
-     */
832
-    protected function _verify_routes()
833
-    {
834
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
835
-        if (! $this->_current_page && ! $this->request->isAjax()) {
836
-            return false;
837
-        }
838
-        $this->_route = false;
839
-        // check that the page_routes array is not empty
840
-        if (empty($this->_page_routes)) {
841
-            // user error msg
842
-            $error_msg = sprintf(
843
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
844
-                $this->_admin_page_title
845
-            );
846
-            // developer error msg
847
-            $error_msg .= '||' . $error_msg
848
-                          . esc_html__(
849
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
850
-                              'event_espresso'
851
-                          );
852
-            throw new EE_Error($error_msg);
853
-        }
854
-        // and that the requested page route exists
855
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
856
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
857
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
858
-                ? $this->_page_config[ $this->_req_action ]
859
-                : [];
860
-        } else {
861
-            // user error msg
862
-            $error_msg = sprintf(
863
-                esc_html__(
864
-                    'The requested page route does not exist for the %s admin page.',
865
-                    'event_espresso'
866
-                ),
867
-                $this->_admin_page_title
868
-            );
869
-            // developer error msg
870
-            $error_msg .= '||' . $error_msg
871
-                          . sprintf(
872
-                              esc_html__(
873
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
874
-                                  'event_espresso'
875
-                              ),
876
-                              $this->_req_action
877
-                          );
878
-            throw new EE_Error($error_msg);
879
-        }
880
-        // and that a default route exists
881
-        if (! array_key_exists('default', $this->_page_routes)) {
882
-            // user error msg
883
-            $error_msg = sprintf(
884
-                esc_html__(
885
-                    'A default page route has not been set for the % admin page.',
886
-                    'event_espresso'
887
-                ),
888
-                $this->_admin_page_title
889
-            );
890
-            // developer error msg
891
-            $error_msg .= '||' . $error_msg
892
-                          . esc_html__(
893
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
894
-                              'event_espresso'
895
-                          );
896
-            throw new EE_Error($error_msg);
897
-        }
898
-        // first lets' catch if the UI request has EVER been set.
899
-        if ($this->_is_UI_request === null) {
900
-            // lets set if this is a UI request or not.
901
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
902
-            // wait a minute... we might have a noheader in the route array
903
-            $this->_is_UI_request = ! (
904
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
905
-            )
906
-                ? $this->_is_UI_request
907
-                : false;
908
-        }
909
-        $this->_set_current_labels();
910
-        return true;
911
-    }
912
-
913
-
914
-    /**
915
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
916
-     *
917
-     * @param string $route the route name we're verifying
918
-     * @return bool we'll throw an exception if this isn't a valid route.
919
-     * @throws EE_Error
920
-     */
921
-    protected function _verify_route($route)
922
-    {
923
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
924
-            return true;
925
-        }
926
-        // user error msg
927
-        $error_msg = sprintf(
928
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
929
-            $this->_admin_page_title
930
-        );
931
-        // developer error msg
932
-        $error_msg .= '||' . $error_msg
933
-                      . sprintf(
934
-                          esc_html__(
935
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
936
-                              'event_espresso'
937
-                          ),
938
-                          $route
939
-                      );
940
-        throw new EE_Error($error_msg);
941
-    }
942
-
943
-
944
-    /**
945
-     * perform nonce verification
946
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
947
-     * using this method (and save retyping!)
948
-     *
949
-     * @param string $nonce     The nonce sent
950
-     * @param string $nonce_ref The nonce reference string (name0)
951
-     * @return void
952
-     * @throws EE_Error
953
-     */
954
-    protected function _verify_nonce($nonce, $nonce_ref)
955
-    {
956
-        // verify nonce against expected value
957
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
958
-            // these are not the droids you are looking for !!!
959
-            $msg = sprintf(
960
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
961
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
962
-                '</a>'
963
-            );
964
-            if (WP_DEBUG) {
965
-                $msg .= "\n  ";
966
-                $msg .= sprintf(
967
-                    esc_html__(
968
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
969
-                        'event_espresso'
970
-                    ),
971
-                    __CLASS__
972
-                );
973
-            }
974
-            if (! $this->request->isAjax()) {
975
-                wp_die($msg);
976
-            }
977
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
978
-            $this->_return_json();
979
-        }
980
-    }
981
-
982
-
983
-    /**
984
-     * _route_admin_request()
985
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
986
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
987
-     * in the page routes and then will try to load the corresponding method.
988
-     *
989
-     * @return void
990
-     * @throws EE_Error
991
-     * @throws InvalidArgumentException
992
-     * @throws InvalidDataTypeException
993
-     * @throws InvalidInterfaceException
994
-     * @throws ReflectionException
995
-     */
996
-    protected function _route_admin_request()
997
-    {
998
-        if (! $this->_is_UI_request) {
999
-            $this->_verify_routes();
1000
-        }
1001
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1002
-        if ($this->_req_action !== 'default' && $nonce_check) {
1003
-            // set nonce from post data
1004
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
1005
-            $this->_verify_nonce($nonce, $this->_req_nonce);
1006
-        }
1007
-        // set the nav_tabs array but ONLY if this is  UI_request
1008
-        if ($this->_is_UI_request) {
1009
-            $this->_set_nav_tabs();
1010
-        }
1011
-        // grab callback function
1012
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
1013
-        // check if callback has args
1014
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1015
-        $error_msg = '';
1016
-        // action right before calling route
1017
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1018
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1019
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1020
-        }
1021
-        // right before calling the route, let's clean the _wp_http_referer
1022
-        $this->request->setServerParam(
1023
-            'REQUEST_URI',
1024
-            remove_query_arg(
1025
-                '_wp_http_referer',
1026
-                wp_unslash($this->request->getServerParam('REQUEST_URI'))
1027
-            )
1028
-        );
1029
-        if (! empty($func)) {
1030
-            if (is_array($func)) {
1031
-                list($class, $method) = $func;
1032
-            } elseif (strpos($func, '::') !== false) {
1033
-                list($class, $method) = explode('::', $func);
1034
-            } else {
1035
-                $class  = $this;
1036
-                $method = $func;
1037
-            }
1038
-            if (! (is_object($class) && $class === $this)) {
1039
-                // send along this admin page object for access by addons.
1040
-                $args['admin_page_object'] = $this;
1041
-            }
1042
-            if (
115
+	/**
116
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
117
+	 * actions.
118
+	 *
119
+	 * @since 4.6.x
120
+	 * @var array.
121
+	 */
122
+	protected $_default_route_query_args;
123
+
124
+	// set via request page and action args.
125
+	protected $_current_page;
126
+
127
+	protected $_current_view;
128
+
129
+	protected $_current_page_view_url;
130
+
131
+	/**
132
+	 * unprocessed value for the 'action' request param (default '')
133
+	 *
134
+	 * @var string
135
+	 */
136
+	protected $raw_req_action = '';
137
+
138
+	/**
139
+	 * unprocessed value for the 'page' request param (default '')
140
+	 *
141
+	 * @var string
142
+	 */
143
+	protected $raw_req_page = '';
144
+
145
+	/**
146
+	 * sanitized request action (and nonce)
147
+	 *
148
+	 * @var string
149
+	 */
150
+	protected $_req_action = '';
151
+
152
+	/**
153
+	 * sanitized request action nonce
154
+	 *
155
+	 * @var string
156
+	 */
157
+	protected $_req_nonce = '';
158
+
159
+	/**
160
+	 * @var string
161
+	 */
162
+	protected $_search_btn_label = '';
163
+
164
+	/**
165
+	 * @var string
166
+	 */
167
+	protected $_search_box_callback = '';
168
+
169
+	/**
170
+	 * @var WP_Screen
171
+	 */
172
+	protected $_current_screen;
173
+
174
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
175
+	protected $_hook_obj;
176
+
177
+	// for holding incoming request data
178
+	protected $_req_data = [];
179
+
180
+	// yes / no array for admin form fields
181
+	protected $_yes_no_values = [];
182
+
183
+	// some default things shared by all child classes
184
+	protected $_default_espresso_metaboxes;
185
+
186
+	/**
187
+	 * @var EE_Registry
188
+	 */
189
+	protected $EE = null;
190
+
191
+
192
+	/**
193
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
194
+	 *
195
+	 * @var boolean
196
+	 */
197
+	protected $_is_caf = false;
198
+
199
+
200
+	/**
201
+	 * @Constructor
202
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
203
+	 * @throws EE_Error
204
+	 * @throws InvalidArgumentException
205
+	 * @throws ReflectionException
206
+	 * @throws InvalidDataTypeException
207
+	 * @throws InvalidInterfaceException
208
+	 */
209
+	public function __construct($routing = true)
210
+	{
211
+		$this->loader  = LoaderFactory::getLoader();
212
+		$this->request = $this->loader->getShared(RequestInterface::class);
213
+		$this->_routing = $routing;
214
+
215
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
216
+			$this->_is_caf = true;
217
+		}
218
+		$this->_yes_no_values = [
219
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
220
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
221
+		];
222
+		// set the _req_data property.
223
+		$this->_req_data = $this->request->requestParams();
224
+		// set initial page props (child method)
225
+		$this->_init_page_props();
226
+		// set global defaults
227
+		$this->_set_defaults();
228
+		// set early because incoming requests could be ajax related and we need to register those hooks.
229
+		$this->_global_ajax_hooks();
230
+		$this->_ajax_hooks();
231
+		// other_page_hooks have to be early too.
232
+		$this->_do_other_page_hooks();
233
+		// set up page dependencies
234
+		$this->_before_page_setup();
235
+		$this->_page_setup();
236
+		// die();
237
+	}
238
+
239
+
240
+	/**
241
+	 * _init_page_props
242
+	 * Child classes use to set at least the following properties:
243
+	 * $page_slug.
244
+	 * $page_label.
245
+	 *
246
+	 * @abstract
247
+	 * @return void
248
+	 */
249
+	abstract protected function _init_page_props();
250
+
251
+
252
+	/**
253
+	 * _ajax_hooks
254
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
255
+	 * Note: within the ajax callback methods.
256
+	 *
257
+	 * @abstract
258
+	 * @return void
259
+	 */
260
+	abstract protected function _ajax_hooks();
261
+
262
+
263
+	/**
264
+	 * _define_page_props
265
+	 * child classes define page properties in here.  Must include at least:
266
+	 * $_admin_base_url = base_url for all admin pages
267
+	 * $_admin_page_title = default admin_page_title for admin pages
268
+	 * $_labels = array of default labels for various automatically generated elements:
269
+	 *    array(
270
+	 *        'buttons' => array(
271
+	 *            'add' => esc_html__('label for add new button'),
272
+	 *            'edit' => esc_html__('label for edit button'),
273
+	 *            'delete' => esc_html__('label for delete button')
274
+	 *            )
275
+	 *        )
276
+	 *
277
+	 * @abstract
278
+	 * @return void
279
+	 */
280
+	abstract protected function _define_page_props();
281
+
282
+
283
+	/**
284
+	 * _set_page_routes
285
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
286
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
287
+	 * have a 'default' route. Here's the format
288
+	 * $this->_page_routes = array(
289
+	 *        'default' => array(
290
+	 *            'func' => '_default_method_handling_route',
291
+	 *            'args' => array('array','of','args'),
292
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
293
+	 *            ajax request, backend processing)
294
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
295
+	 *            headers route after.  The string you enter here should match the defined route reference for a
296
+	 *            headers sent route.
297
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
298
+	 *            this route.
299
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
300
+	 *            checks).
301
+	 *        ),
302
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
303
+	 *        handling method.
304
+	 *        )
305
+	 * )
306
+	 *
307
+	 * @abstract
308
+	 * @return void
309
+	 */
310
+	abstract protected function _set_page_routes();
311
+
312
+
313
+	/**
314
+	 * _set_page_config
315
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
316
+	 * array corresponds to the page_route for the loaded page. Format:
317
+	 * $this->_page_config = array(
318
+	 *        'default' => array(
319
+	 *            'labels' => array(
320
+	 *                'buttons' => array(
321
+	 *                    'add' => esc_html__('label for adding item'),
322
+	 *                    'edit' => esc_html__('label for editing item'),
323
+	 *                    'delete' => esc_html__('label for deleting item')
324
+	 *                ),
325
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
326
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
327
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
328
+	 *            _define_page_props() method
329
+	 *            'nav' => array(
330
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
331
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
332
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
333
+	 *                'order' => 10, //required to indicate tab position.
334
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
335
+	 *                displayed then add this parameter.
336
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
337
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
338
+	 *            metaboxes set for eventespresso admin pages.
339
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
340
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
341
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
342
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
343
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
344
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
345
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
346
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
347
+	 *            want to display.
348
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
349
+	 *                'tab_id' => array(
350
+	 *                    'title' => 'tab_title',
351
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
352
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
353
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
354
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
355
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
356
+	 *                    attempt to use the callback which should match the name of a method in the class
357
+	 *                    ),
358
+	 *                'tab2_id' => array(
359
+	 *                    'title' => 'tab2 title',
360
+	 *                    'filename' => 'file_name_2'
361
+	 *                    'callback' => 'callback_method_for_content',
362
+	 *                 ),
363
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
364
+	 *            help tab area on an admin page. @return void
365
+	 *
366
+	 * @link
367
+	 *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
368
+	 *                'help_tour' => array(
369
+	 *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
370
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
371
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
372
+	 *                ),
373
+	 *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
374
+	 *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
375
+	 *                visited just set
376
+	 *                'require_nonce' to FALSE
377
+	 *                )
378
+	 *                )
379
+	 *
380
+	 * @abstract
381
+	 */
382
+	abstract protected function _set_page_config();
383
+
384
+
385
+
386
+
387
+
388
+	/** end sample help_tour methods **/
389
+	/**
390
+	 * _add_screen_options
391
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
392
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
393
+	 * to a particular view.
394
+	 *
395
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
396
+	 *         see also WP_Screen object documents...
397
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
398
+	 * @abstract
399
+	 * @return void
400
+	 */
401
+	abstract protected function _add_screen_options();
402
+
403
+
404
+	/**
405
+	 * _add_feature_pointers
406
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
407
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
408
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
409
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
410
+	 * extended) also see:
411
+	 *
412
+	 * @link   http://eamann.com/tech/wordpress-portland/
413
+	 * @abstract
414
+	 * @return void
415
+	 */
416
+	abstract protected function _add_feature_pointers();
417
+
418
+
419
+	/**
420
+	 * load_scripts_styles
421
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
422
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
423
+	 * scripts/styles per view by putting them in a dynamic function in this format
424
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
425
+	 *
426
+	 * @abstract
427
+	 * @return void
428
+	 */
429
+	abstract public function load_scripts_styles();
430
+
431
+
432
+	/**
433
+	 * admin_init
434
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
435
+	 * all pages/views loaded by child class.
436
+	 *
437
+	 * @abstract
438
+	 * @return void
439
+	 */
440
+	abstract public function admin_init();
441
+
442
+
443
+	/**
444
+	 * admin_notices
445
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
446
+	 * all pages/views loaded by child class.
447
+	 *
448
+	 * @abstract
449
+	 * @return void
450
+	 */
451
+	abstract public function admin_notices();
452
+
453
+
454
+	/**
455
+	 * admin_footer_scripts
456
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
457
+	 * will apply to all pages/views loaded by child class.
458
+	 *
459
+	 * @return void
460
+	 */
461
+	abstract public function admin_footer_scripts();
462
+
463
+
464
+	/**
465
+	 * admin_footer
466
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
467
+	 * apply to all pages/views loaded by child class.
468
+	 *
469
+	 * @return void
470
+	 */
471
+	public function admin_footer()
472
+	{
473
+	}
474
+
475
+
476
+	/**
477
+	 * _global_ajax_hooks
478
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
479
+	 * Note: within the ajax callback methods.
480
+	 *
481
+	 * @abstract
482
+	 * @return void
483
+	 */
484
+	protected function _global_ajax_hooks()
485
+	{
486
+		// for lazy loading of metabox content
487
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
488
+	}
489
+
490
+
491
+	public function ajax_metabox_content()
492
+	{
493
+		$content_id  = $this->request->getRequestParam('contentid', '');
494
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
495
+		self::cached_rss_display($content_id, $content_url);
496
+		wp_die();
497
+	}
498
+
499
+
500
+	/**
501
+	 * allows extending classes do something specific before the parent constructor runs _page_setup().
502
+	 *
503
+	 * @return void
504
+	 */
505
+	protected function _before_page_setup()
506
+	{
507
+		// default is to do nothing
508
+	}
509
+
510
+
511
+	/**
512
+	 * Makes sure any things that need to be loaded early get handled.
513
+	 * We also escape early here if the page requested doesn't match the object.
514
+	 *
515
+	 * @final
516
+	 * @return void
517
+	 * @throws EE_Error
518
+	 * @throws InvalidArgumentException
519
+	 * @throws ReflectionException
520
+	 * @throws InvalidDataTypeException
521
+	 * @throws InvalidInterfaceException
522
+	 */
523
+	final protected function _page_setup()
524
+	{
525
+		// requires?
526
+		// admin_init stuff - global - we're setting this REALLY early
527
+		// so if EE_Admin pages have to hook into other WP pages they can.
528
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
529
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
530
+		// next verify if we need to load anything...
531
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
532
+		$this->page_folder   = strtolower(
533
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
534
+		);
535
+		global $ee_menu_slugs;
536
+		$ee_menu_slugs = (array) $ee_menu_slugs;
537
+		if (
538
+			! $this->request->isAjax()
539
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
540
+		) {
541
+			return;
542
+		}
543
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
544
+		// we need to copy the action from the second to the first
545
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
546
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
547
+		$action     = $action !== '-1' ? $action : $action2;
548
+		$req_action = $action !== '-1' ? $action : 'default';
549
+
550
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
551
+		// then let's use the route as the action.
552
+		// This covers cases where we're coming in from a list table that isn't on the default route.
553
+		$route = $this->request->getRequestParam('route');
554
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
555
+			? $route
556
+			: $req_action;
557
+
558
+		$this->_current_view = $this->_req_action;
559
+		$this->_req_nonce    = $this->_req_action . '_nonce';
560
+		$this->_define_page_props();
561
+		$this->_current_page_view_url = add_query_arg(
562
+			['page' => $this->_current_page, 'action' => $this->_current_view],
563
+			$this->_admin_base_url
564
+		);
565
+		// default things
566
+		$this->_default_espresso_metaboxes = [
567
+			'_espresso_news_post_box',
568
+			'_espresso_links_post_box',
569
+			'_espresso_ratings_request',
570
+			'_espresso_sponsors_post_box',
571
+		];
572
+		// set page configs
573
+		$this->_set_page_routes();
574
+		$this->_set_page_config();
575
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
576
+		if ($this->request->requestParamIsSet('wp_referer')) {
577
+			$wp_referer = $this->request->getRequestParam('wp_referer');
578
+			if ($wp_referer) {
579
+				$this->_default_route_query_args['wp_referer'] = $wp_referer;
580
+			}
581
+		}
582
+		// for caffeinated and other extended functionality.
583
+		//  If there is a _extend_page_config method
584
+		// then let's run that to modify the all the various page configuration arrays
585
+		if (method_exists($this, '_extend_page_config')) {
586
+			$this->_extend_page_config();
587
+		}
588
+		// for CPT and other extended functionality.
589
+		// If there is an _extend_page_config_for_cpt
590
+		// then let's run that to modify all the various page configuration arrays.
591
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
592
+			$this->_extend_page_config_for_cpt();
593
+		}
594
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
595
+		$this->_page_routes = apply_filters(
596
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
597
+			$this->_page_routes,
598
+			$this
599
+		);
600
+		$this->_page_config = apply_filters(
601
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
602
+			$this->_page_config,
603
+			$this
604
+		);
605
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
606
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
607
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
608
+			add_action(
609
+				'AHEE__EE_Admin_Page__route_admin_request',
610
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
611
+				10,
612
+				2
613
+			);
614
+		}
615
+		// next route only if routing enabled
616
+		if ($this->_routing && ! $this->request->isAjax()) {
617
+			$this->_verify_routes();
618
+			// next let's just check user_access and kill if no access
619
+			$this->check_user_access();
620
+			if ($this->_is_UI_request) {
621
+				// admin_init stuff - global, all views for this page class, specific view
622
+				add_action('admin_init', [$this, 'admin_init'], 10);
623
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
624
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
625
+				}
626
+			} else {
627
+				// hijack regular WP loading and route admin request immediately
628
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
629
+				$this->route_admin_request();
630
+			}
631
+		}
632
+	}
633
+
634
+
635
+	/**
636
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
637
+	 *
638
+	 * @return void
639
+	 * @throws EE_Error
640
+	 */
641
+	private function _do_other_page_hooks()
642
+	{
643
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
644
+		foreach ($registered_pages as $page) {
645
+			// now let's setup the file name and class that should be present
646
+			$classname = str_replace('.class.php', '', $page);
647
+			// autoloaders should take care of loading file
648
+			if (! class_exists($classname)) {
649
+				$error_msg[] = sprintf(
650
+					esc_html__(
651
+						'Something went wrong with loading the %s admin hooks page.',
652
+						'event_espresso'
653
+					),
654
+					$page
655
+				);
656
+				$error_msg[] = $error_msg[0]
657
+							   . "\r\n"
658
+							   . sprintf(
659
+								   esc_html__(
660
+									   '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',
661
+									   'event_espresso'
662
+								   ),
663
+								   $page,
664
+								   '<br />',
665
+								   '<strong>' . $classname . '</strong>'
666
+							   );
667
+				throw new EE_Error(implode('||', $error_msg));
668
+			}
669
+			// notice we are passing the instance of this class to the hook object.
670
+			$this->loader->getShared($classname, [$this]);
671
+		}
672
+	}
673
+
674
+
675
+	/**
676
+	 * @throws ReflectionException
677
+	 * @throws EE_Error
678
+	 */
679
+	public function load_page_dependencies()
680
+	{
681
+		try {
682
+			$this->_load_page_dependencies();
683
+		} catch (EE_Error $e) {
684
+			$e->get_error();
685
+		}
686
+	}
687
+
688
+
689
+	/**
690
+	 * load_page_dependencies
691
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
692
+	 *
693
+	 * @return void
694
+	 * @throws DomainException
695
+	 * @throws EE_Error
696
+	 * @throws InvalidArgumentException
697
+	 * @throws InvalidDataTypeException
698
+	 * @throws InvalidInterfaceException
699
+	 */
700
+	protected function _load_page_dependencies()
701
+	{
702
+		// let's set the current_screen and screen options to override what WP set
703
+		$this->_current_screen = get_current_screen();
704
+		// load admin_notices - global, page class, and view specific
705
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
706
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
707
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
708
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
709
+		}
710
+		// load network admin_notices - global, page class, and view specific
711
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
712
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
713
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
714
+		}
715
+		// this will save any per_page screen options if they are present
716
+		$this->_set_per_page_screen_options();
717
+		// setup list table properties
718
+		$this->_set_list_table();
719
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
720
+		// However in some cases the metaboxes will need to be added within a route handling callback.
721
+		$this->_add_registered_meta_boxes();
722
+		$this->_add_screen_columns();
723
+		// add screen options - global, page child class, and view specific
724
+		$this->_add_global_screen_options();
725
+		$this->_add_screen_options();
726
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
727
+		if (method_exists($this, $add_screen_options)) {
728
+			$this->{$add_screen_options}();
729
+		}
730
+		// add help tab(s) and tours- set via page_config and qtips.
731
+		// $this->_add_help_tour();
732
+		$this->_add_help_tabs();
733
+		$this->_add_qtips();
734
+		// add feature_pointers - global, page child class, and view specific
735
+		$this->_add_feature_pointers();
736
+		$this->_add_global_feature_pointers();
737
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
738
+		if (method_exists($this, $add_feature_pointer)) {
739
+			$this->{$add_feature_pointer}();
740
+		}
741
+		// enqueue scripts/styles - global, page class, and view specific
742
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
743
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
744
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
745
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
746
+		}
747
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
748
+		// admin_print_footer_scripts - global, page child class, and view specific.
749
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
750
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
751
+		// is a good use case. Notice the late priority we're giving these
752
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
753
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
754
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
755
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
756
+		}
757
+		// admin footer scripts
758
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
759
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
760
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
761
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
762
+		}
763
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
764
+		// targeted hook
765
+		do_action(
766
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
767
+		);
768
+	}
769
+
770
+
771
+	/**
772
+	 * _set_defaults
773
+	 * This sets some global defaults for class properties.
774
+	 */
775
+	private function _set_defaults()
776
+	{
777
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
778
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
779
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
780
+		$this->_page_config          = $this->_default_route_query_args = [];
781
+		$this->_default_nav_tab_name = 'overview';
782
+		// init template args
783
+		$this->_template_args = [
784
+			'admin_page_header'  => '',
785
+			'admin_page_content' => '',
786
+			'post_body_content'  => '',
787
+			'before_list_table'  => '',
788
+			'after_list_table'   => '',
789
+		];
790
+	}
791
+
792
+
793
+	/**
794
+	 * route_admin_request
795
+	 *
796
+	 * @return void
797
+	 * @throws InvalidArgumentException
798
+	 * @throws InvalidInterfaceException
799
+	 * @throws InvalidDataTypeException
800
+	 * @throws EE_Error
801
+	 * @throws ReflectionException
802
+	 * @see    _route_admin_request()
803
+	 */
804
+	public function route_admin_request()
805
+	{
806
+		try {
807
+			$this->_route_admin_request();
808
+		} catch (EE_Error $e) {
809
+			$e->get_error();
810
+		}
811
+	}
812
+
813
+
814
+	public function set_wp_page_slug($wp_page_slug)
815
+	{
816
+		$this->_wp_page_slug = $wp_page_slug;
817
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
818
+		if (is_network_admin()) {
819
+			$this->_wp_page_slug .= '-network';
820
+		}
821
+	}
822
+
823
+
824
+	/**
825
+	 * _verify_routes
826
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
827
+	 * we know if we need to drop out.
828
+	 *
829
+	 * @return bool
830
+	 * @throws EE_Error
831
+	 */
832
+	protected function _verify_routes()
833
+	{
834
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
835
+		if (! $this->_current_page && ! $this->request->isAjax()) {
836
+			return false;
837
+		}
838
+		$this->_route = false;
839
+		// check that the page_routes array is not empty
840
+		if (empty($this->_page_routes)) {
841
+			// user error msg
842
+			$error_msg = sprintf(
843
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
844
+				$this->_admin_page_title
845
+			);
846
+			// developer error msg
847
+			$error_msg .= '||' . $error_msg
848
+						  . esc_html__(
849
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
850
+							  'event_espresso'
851
+						  );
852
+			throw new EE_Error($error_msg);
853
+		}
854
+		// and that the requested page route exists
855
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
856
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
857
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
858
+				? $this->_page_config[ $this->_req_action ]
859
+				: [];
860
+		} else {
861
+			// user error msg
862
+			$error_msg = sprintf(
863
+				esc_html__(
864
+					'The requested page route does not exist for the %s admin page.',
865
+					'event_espresso'
866
+				),
867
+				$this->_admin_page_title
868
+			);
869
+			// developer error msg
870
+			$error_msg .= '||' . $error_msg
871
+						  . sprintf(
872
+							  esc_html__(
873
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
874
+								  'event_espresso'
875
+							  ),
876
+							  $this->_req_action
877
+						  );
878
+			throw new EE_Error($error_msg);
879
+		}
880
+		// and that a default route exists
881
+		if (! array_key_exists('default', $this->_page_routes)) {
882
+			// user error msg
883
+			$error_msg = sprintf(
884
+				esc_html__(
885
+					'A default page route has not been set for the % admin page.',
886
+					'event_espresso'
887
+				),
888
+				$this->_admin_page_title
889
+			);
890
+			// developer error msg
891
+			$error_msg .= '||' . $error_msg
892
+						  . esc_html__(
893
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
894
+							  'event_espresso'
895
+						  );
896
+			throw new EE_Error($error_msg);
897
+		}
898
+		// first lets' catch if the UI request has EVER been set.
899
+		if ($this->_is_UI_request === null) {
900
+			// lets set if this is a UI request or not.
901
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
902
+			// wait a minute... we might have a noheader in the route array
903
+			$this->_is_UI_request = ! (
904
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
905
+			)
906
+				? $this->_is_UI_request
907
+				: false;
908
+		}
909
+		$this->_set_current_labels();
910
+		return true;
911
+	}
912
+
913
+
914
+	/**
915
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
916
+	 *
917
+	 * @param string $route the route name we're verifying
918
+	 * @return bool we'll throw an exception if this isn't a valid route.
919
+	 * @throws EE_Error
920
+	 */
921
+	protected function _verify_route($route)
922
+	{
923
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
924
+			return true;
925
+		}
926
+		// user error msg
927
+		$error_msg = sprintf(
928
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
929
+			$this->_admin_page_title
930
+		);
931
+		// developer error msg
932
+		$error_msg .= '||' . $error_msg
933
+					  . sprintf(
934
+						  esc_html__(
935
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
936
+							  'event_espresso'
937
+						  ),
938
+						  $route
939
+					  );
940
+		throw new EE_Error($error_msg);
941
+	}
942
+
943
+
944
+	/**
945
+	 * perform nonce verification
946
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
947
+	 * using this method (and save retyping!)
948
+	 *
949
+	 * @param string $nonce     The nonce sent
950
+	 * @param string $nonce_ref The nonce reference string (name0)
951
+	 * @return void
952
+	 * @throws EE_Error
953
+	 */
954
+	protected function _verify_nonce($nonce, $nonce_ref)
955
+	{
956
+		// verify nonce against expected value
957
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
958
+			// these are not the droids you are looking for !!!
959
+			$msg = sprintf(
960
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
961
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
962
+				'</a>'
963
+			);
964
+			if (WP_DEBUG) {
965
+				$msg .= "\n  ";
966
+				$msg .= sprintf(
967
+					esc_html__(
968
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
969
+						'event_espresso'
970
+					),
971
+					__CLASS__
972
+				);
973
+			}
974
+			if (! $this->request->isAjax()) {
975
+				wp_die($msg);
976
+			}
977
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
978
+			$this->_return_json();
979
+		}
980
+	}
981
+
982
+
983
+	/**
984
+	 * _route_admin_request()
985
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
986
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
987
+	 * in the page routes and then will try to load the corresponding method.
988
+	 *
989
+	 * @return void
990
+	 * @throws EE_Error
991
+	 * @throws InvalidArgumentException
992
+	 * @throws InvalidDataTypeException
993
+	 * @throws InvalidInterfaceException
994
+	 * @throws ReflectionException
995
+	 */
996
+	protected function _route_admin_request()
997
+	{
998
+		if (! $this->_is_UI_request) {
999
+			$this->_verify_routes();
1000
+		}
1001
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
1002
+		if ($this->_req_action !== 'default' && $nonce_check) {
1003
+			// set nonce from post data
1004
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
1005
+			$this->_verify_nonce($nonce, $this->_req_nonce);
1006
+		}
1007
+		// set the nav_tabs array but ONLY if this is  UI_request
1008
+		if ($this->_is_UI_request) {
1009
+			$this->_set_nav_tabs();
1010
+		}
1011
+		// grab callback function
1012
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
1013
+		// check if callback has args
1014
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
1015
+		$error_msg = '';
1016
+		// action right before calling route
1017
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1018
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1019
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1020
+		}
1021
+		// right before calling the route, let's clean the _wp_http_referer
1022
+		$this->request->setServerParam(
1023
+			'REQUEST_URI',
1024
+			remove_query_arg(
1025
+				'_wp_http_referer',
1026
+				wp_unslash($this->request->getServerParam('REQUEST_URI'))
1027
+			)
1028
+		);
1029
+		if (! empty($func)) {
1030
+			if (is_array($func)) {
1031
+				list($class, $method) = $func;
1032
+			} elseif (strpos($func, '::') !== false) {
1033
+				list($class, $method) = explode('::', $func);
1034
+			} else {
1035
+				$class  = $this;
1036
+				$method = $func;
1037
+			}
1038
+			if (! (is_object($class) && $class === $this)) {
1039
+				// send along this admin page object for access by addons.
1040
+				$args['admin_page_object'] = $this;
1041
+			}
1042
+			if (
1043 1043
 // is it a method on a class that doesn't work?
1044
-                (
1045
-                    (
1046
-                        method_exists($class, $method)
1047
-                        && call_user_func_array([$class, $method], $args) === false
1048
-                    )
1049
-                    && (
1050
-                        // is it a standalone function that doesn't work?
1051
-                        function_exists($method)
1052
-                        && call_user_func_array(
1053
-                            $func,
1054
-                            array_merge(['admin_page_object' => $this], $args)
1055
-                        ) === false
1056
-                    )
1057
-                )
1058
-                || (
1059
-                    // is it neither a class method NOR a standalone function?
1060
-                    ! method_exists($class, $method)
1061
-                    && ! function_exists($method)
1062
-                )
1063
-            ) {
1064
-                // user error msg
1065
-                $error_msg = esc_html__(
1066
-                    'An error occurred. The  requested page route could not be found.',
1067
-                    'event_espresso'
1068
-                );
1069
-                // developer error msg
1070
-                $error_msg .= '||';
1071
-                $error_msg .= sprintf(
1072
-                    esc_html__(
1073
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1074
-                        'event_espresso'
1075
-                    ),
1076
-                    $method
1077
-                );
1078
-            }
1079
-            if (! empty($error_msg)) {
1080
-                throw new EE_Error($error_msg);
1081
-            }
1082
-        }
1083
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1084
-        // then we need to reset the routing properties to the new route.
1085
-        // 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.
1086
-        if (
1087
-            $this->_is_UI_request === false
1088
-            && is_array($this->_route)
1089
-            && ! empty($this->_route['headers_sent_route'])
1090
-        ) {
1091
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1092
-        }
1093
-    }
1094
-
1095
-
1096
-    /**
1097
-     * This method just allows the resetting of page properties in the case where a no headers
1098
-     * route redirects to a headers route in its route config.
1099
-     *
1100
-     * @param string $new_route New (non header) route to redirect to.
1101
-     * @return   void
1102
-     * @throws ReflectionException
1103
-     * @throws InvalidArgumentException
1104
-     * @throws InvalidInterfaceException
1105
-     * @throws InvalidDataTypeException
1106
-     * @throws EE_Error
1107
-     * @since   4.3.0
1108
-     */
1109
-    protected function _reset_routing_properties($new_route)
1110
-    {
1111
-        $this->_is_UI_request = true;
1112
-        // now we set the current route to whatever the headers_sent_route is set at
1113
-        $this->request->setRequestParam('action', $new_route);
1114
-        // rerun page setup
1115
-        $this->_page_setup();
1116
-    }
1117
-
1118
-
1119
-    /**
1120
-     * _add_query_arg
1121
-     * adds nonce to array of arguments then calls WP add_query_arg function
1122
-     *(internally just uses EEH_URL's function with the same name)
1123
-     *
1124
-     * @param array  $args
1125
-     * @param string $url
1126
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1127
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1128
-     *                                        Example usage: If the current page is:
1129
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1130
-     *                                        &action=default&event_id=20&month_range=March%202015
1131
-     *                                        &_wpnonce=5467821
1132
-     *                                        and you call:
1133
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1134
-     *                                        array(
1135
-     *                                        'action' => 'resend_something',
1136
-     *                                        'page=>espresso_registrations'
1137
-     *                                        ),
1138
-     *                                        $some_url,
1139
-     *                                        true
1140
-     *                                        );
1141
-     *                                        It will produce a url in this structure:
1142
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1143
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1144
-     *                                        month_range]=March%202015
1145
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1146
-     * @return string
1147
-     */
1148
-    public static function add_query_args_and_nonce(
1149
-        $args = [],
1150
-        $url = false,
1151
-        $sticky = false,
1152
-        $exclude_nonce = false
1153
-    ) {
1154
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1155
-        if ($sticky) {
1156
-            /** @var RequestInterface $request */
1157
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1158
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1159
-            foreach ($request->requestParams() as $key => $value) {
1160
-                // do not add nonces
1161
-                if (strpos($key, 'nonce') !== false) {
1162
-                    continue;
1163
-                }
1164
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1165
-            }
1166
-        }
1167
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1168
-    }
1169
-
1170
-
1171
-    /**
1172
-     * This returns a generated link that will load the related help tab.
1173
-     *
1174
-     * @param string $help_tab_id the id for the connected help tab
1175
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1176
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1177
-     * @return string              generated link
1178
-     * @uses EEH_Template::get_help_tab_link()
1179
-     */
1180
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1181
-    {
1182
-        return EEH_Template::get_help_tab_link(
1183
-            $help_tab_id,
1184
-            $this->page_slug,
1185
-            $this->_req_action,
1186
-            $icon_style,
1187
-            $help_text
1188
-        );
1189
-    }
1190
-
1191
-
1192
-    /**
1193
-     * _add_help_tabs
1194
-     * Note child classes define their help tabs within the page_config array.
1195
-     *
1196
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1197
-     * @return void
1198
-     * @throws DomainException
1199
-     * @throws EE_Error
1200
-     */
1201
-    protected function _add_help_tabs()
1202
-    {
1203
-        $tour_buttons = '';
1204
-        if (isset($this->_page_config[ $this->_req_action ])) {
1205
-            $config = $this->_page_config[ $this->_req_action ];
1206
-            // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1207
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1208
-            // if (isset($this->_help_tour[ $this->_req_action ])) {
1209
-            //     $tb = array();
1210
-            //     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1211
-            //     foreach ($this->_help_tour['tours'] as $tour) {
1212
-            //         // if this is the end tour then we don't need to setup a button
1213
-            //         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1214
-            //             continue;
1215
-            //         }
1216
-            //         $tb[] = '<button id="trigger-tour-'
1217
-            //                 . $tour->get_slug()
1218
-            //                 . '" class="button-primary trigger-ee-help-tour">'
1219
-            //                 . $tour->get_label()
1220
-            //                 . '</button>';
1221
-            //     }
1222
-            //     $tour_buttons .= implode('<br />', $tb);
1223
-            //     $tour_buttons .= '</div></div>';
1224
-            // }
1225
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1226
-            if (is_array($config) && isset($config['help_sidebar'])) {
1227
-                // check that the callback given is valid
1228
-                if (! method_exists($this, $config['help_sidebar'])) {
1229
-                    throw new EE_Error(
1230
-                        sprintf(
1231
-                            esc_html__(
1232
-                                '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',
1233
-                                'event_espresso'
1234
-                            ),
1235
-                            $config['help_sidebar'],
1236
-                            get_class($this)
1237
-                        )
1238
-                    );
1239
-                }
1240
-                $content = apply_filters(
1241
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1242
-                    $this->{$config['help_sidebar']}()
1243
-                );
1244
-                $content .= $tour_buttons; // add help tour buttons.
1245
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1246
-                $this->_current_screen->set_help_sidebar($content);
1247
-            }
1248
-            // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1249
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1250
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1251
-            }
1252
-            // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1253
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1254
-                $_ht['id']      = $this->page_slug;
1255
-                $_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1256
-                $_ht['content'] = '<p>'
1257
-                                  . esc_html__(
1258
-                                      'The buttons to the right allow you to start/restart any help tours available for this page',
1259
-                                      'event_espresso'
1260
-                                  ) . '</p>';
1261
-                $this->_current_screen->add_help_tab($_ht);
1262
-            }
1263
-            if (! isset($config['help_tabs'])) {
1264
-                return;
1265
-            } //no help tabs for this route
1266
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1267
-                // we're here so there ARE help tabs!
1268
-                // make sure we've got what we need
1269
-                if (! isset($cfg['title'])) {
1270
-                    throw new EE_Error(
1271
-                        esc_html__(
1272
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1273
-                            'event_espresso'
1274
-                        )
1275
-                    );
1276
-                }
1277
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1278
-                    throw new EE_Error(
1279
-                        esc_html__(
1280
-                            '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',
1281
-                            'event_espresso'
1282
-                        )
1283
-                    );
1284
-                }
1285
-                // first priority goes to content.
1286
-                if (! empty($cfg['content'])) {
1287
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1288
-                    // second priority goes to filename
1289
-                } elseif (! empty($cfg['filename'])) {
1290
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1291
-                    // 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)
1292
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1293
-                                                             . basename($this->_get_dir())
1294
-                                                             . '/help_tabs/'
1295
-                                                             . $cfg['filename']
1296
-                                                             . '.help_tab.php' : $file_path;
1297
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1298
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1299
-                        EE_Error::add_error(
1300
-                            sprintf(
1301
-                                esc_html__(
1302
-                                    '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',
1303
-                                    'event_espresso'
1304
-                                ),
1305
-                                $tab_id,
1306
-                                key($config),
1307
-                                $file_path
1308
-                            ),
1309
-                            __FILE__,
1310
-                            __FUNCTION__,
1311
-                            __LINE__
1312
-                        );
1313
-                        return;
1314
-                    }
1315
-                    $template_args['admin_page_obj'] = $this;
1316
-                    $content                         = EEH_Template::display_template(
1317
-                        $file_path,
1318
-                        $template_args,
1319
-                        true
1320
-                    );
1321
-                } else {
1322
-                    $content = '';
1323
-                }
1324
-                // check if callback is valid
1325
-                if (
1326
-                    empty($content)
1327
-                    && (
1328
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1329
-                    )
1330
-                ) {
1331
-                    EE_Error::add_error(
1332
-                        sprintf(
1333
-                            esc_html__(
1334
-                                '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.',
1335
-                                'event_espresso'
1336
-                            ),
1337
-                            $cfg['title']
1338
-                        ),
1339
-                        __FILE__,
1340
-                        __FUNCTION__,
1341
-                        __LINE__
1342
-                    );
1343
-                    return;
1344
-                }
1345
-                // setup config array for help tab method
1346
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1347
-                $_ht = [
1348
-                    'id'       => $id,
1349
-                    'title'    => $cfg['title'],
1350
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1351
-                    'content'  => $content,
1352
-                ];
1353
-                $this->_current_screen->add_help_tab($_ht);
1354
-            }
1355
-        }
1356
-    }
1357
-
1358
-
1359
-    /**
1360
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1361
-     * an array with properties for setting up usage of the joyride plugin
1362
-     *
1363
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1364
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1365
-     *         _set_page_config() comments
1366
-     * @return void
1367
-     * @throws InvalidArgumentException
1368
-     * @throws InvalidDataTypeException
1369
-     * @throws InvalidInterfaceException
1370
-     */
1371
-    protected function _add_help_tour()
1372
-    {
1373
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1374
-        // $tours = array();
1375
-        // $this->_help_tour = array();
1376
-        // // exit early if help tours are turned off globally
1377
-        // if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1378
-        //     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1379
-        // ) {
1380
-        //     return;
1381
-        // }
1382
-        // // loop through _page_config to find any help_tour defined
1383
-        // foreach ($this->_page_config as $route => $config) {
1384
-        //     // we're only going to set things up for this route
1385
-        //     if ($route !== $this->_req_action) {
1386
-        //         continue;
1387
-        //     }
1388
-        //     if (isset($config['help_tour'])) {
1389
-        //         foreach ($config['help_tour'] as $tour) {
1390
-        //             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1391
-        //             // let's see if we can get that file...
1392
-        //             // if not its possible this is a decaf route not set in caffeinated
1393
-        //             // so lets try and get the caffeinated equivalent
1394
-        //             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1395
-        //                                                      . basename($this->_get_dir())
1396
-        //                                                      . '/help_tours/'
1397
-        //                                                      . $tour
1398
-        //                                                      . '.class.php' : $file_path;
1399
-        //             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1400
-        //             if (! is_readable($file_path)) {
1401
-        //                 EE_Error::add_error(
1402
-        //                     sprintf(
1403
-        //                         esc_html__(
1404
-        //                             'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1405
-        //                             'event_espresso'
1406
-        //                         ),
1407
-        //                         $file_path,
1408
-        //                         $tour
1409
-        //                     ),
1410
-        //                     __FILE__,
1411
-        //                     __FUNCTION__,
1412
-        //                     __LINE__
1413
-        //                 );
1414
-        //                 return;
1415
-        //             }
1416
-        //             require_once $file_path;
1417
-        //             if (! class_exists($tour)) {
1418
-        //                 $error_msg[] = sprintf(
1419
-        //                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1420
-        //                     $tour
1421
-        //                 );
1422
-        //                 $error_msg[] = $error_msg[0] . "\r\n"
1423
-        //                                . sprintf(
1424
-        //                                    esc_html__(
1425
-        //                                        'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1426
-        //                                        'event_espresso'
1427
-        //                                    ),
1428
-        //                                    $tour,
1429
-        //                                    '<br />',
1430
-        //                                    $tour,
1431
-        //                                    $this->_req_action,
1432
-        //                                    get_class($this)
1433
-        //                                );
1434
-        //                 throw new EE_Error(implode('||', $error_msg));
1435
-        //             }
1436
-        //             $tour_obj = new $tour($this->_is_caf);
1437
-        //             $tours[] = $tour_obj;
1438
-        //             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1439
-        //         }
1440
-        //         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1441
-        //         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1442
-        //         $tours[] = $end_stop_tour;
1443
-        //         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1444
-        //     }
1445
-        // }
1446
-        //
1447
-        // if (! empty($tours)) {
1448
-        //     $this->_help_tour['tours'] = $tours;
1449
-        // }
1450
-        // // that's it!  Now that the $_help_tours property is set (or not)
1451
-        // // the scripts and html should be taken care of automatically.
1452
-        //
1453
-        // /**
1454
-        //  * Allow extending the help tours variable.
1455
-        //  *
1456
-        //  * @param Array $_help_tour The array containing all help tour information to be displayed.
1457
-        //  */
1458
-        // $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1459
-    }
1460
-
1461
-
1462
-    /**
1463
-     * This simply sets up any qtips that have been defined in the page config
1464
-     *
1465
-     * @return void
1466
-     */
1467
-    protected function _add_qtips()
1468
-    {
1469
-        if (isset($this->_route_config['qtips'])) {
1470
-            $qtips = (array) $this->_route_config['qtips'];
1471
-            // load qtip loader
1472
-            $path = [
1473
-                $this->_get_dir() . '/qtips/',
1474
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1475
-            ];
1476
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1477
-        }
1478
-    }
1479
-
1480
-
1481
-    /**
1482
-     * _set_nav_tabs
1483
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1484
-     * wish to add additional tabs or modify accordingly.
1485
-     *
1486
-     * @return void
1487
-     * @throws InvalidArgumentException
1488
-     * @throws InvalidInterfaceException
1489
-     * @throws InvalidDataTypeException
1490
-     */
1491
-    protected function _set_nav_tabs()
1492
-    {
1493
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1494
-        $i = 0;
1495
-        foreach ($this->_page_config as $slug => $config) {
1496
-            if (! is_array($config) || empty($config['nav'])) {
1497
-                continue;
1498
-            }
1499
-            // no nav tab for this config
1500
-            // check for persistent flag
1501
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1502
-                // nav tab is only to appear when route requested.
1503
-                continue;
1504
-            }
1505
-            if (! $this->check_user_access($slug, true)) {
1506
-                // no nav tab because current user does not have access.
1507
-                continue;
1508
-            }
1509
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1510
-            $this->_nav_tabs[ $slug ] = [
1511
-                'url'       => isset($config['nav']['url'])
1512
-                    ? $config['nav']['url']
1513
-                    : self::add_query_args_and_nonce(
1514
-                        ['action' => $slug],
1515
-                        $this->_admin_base_url
1516
-                    ),
1517
-                'link_text' => isset($config['nav']['label'])
1518
-                    ? $config['nav']['label']
1519
-                    : ucwords(
1520
-                        str_replace('_', ' ', $slug)
1521
-                    ),
1522
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1523
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1524
-            ];
1525
-            $i++;
1526
-        }
1527
-        // if $this->_nav_tabs is empty then lets set the default
1528
-        if (empty($this->_nav_tabs)) {
1529
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1530
-                'url'       => $this->_admin_base_url,
1531
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1532
-                'css_class' => 'nav-tab-active',
1533
-                'order'     => 10,
1534
-            ];
1535
-        }
1536
-        // now let's sort the tabs according to order
1537
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1538
-    }
1539
-
1540
-
1541
-    /**
1542
-     * _set_current_labels
1543
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1544
-     * property array
1545
-     *
1546
-     * @return void
1547
-     */
1548
-    private function _set_current_labels()
1549
-    {
1550
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1551
-            foreach ($this->_route_config['labels'] as $label => $text) {
1552
-                if (is_array($text)) {
1553
-                    foreach ($text as $sublabel => $subtext) {
1554
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1555
-                    }
1556
-                } else {
1557
-                    $this->_labels[ $label ] = $text;
1558
-                }
1559
-            }
1560
-        }
1561
-    }
1562
-
1563
-
1564
-    /**
1565
-     *        verifies user access for this admin page
1566
-     *
1567
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1568
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1569
-     *                               return false if verify fail.
1570
-     * @return bool
1571
-     * @throws InvalidArgumentException
1572
-     * @throws InvalidDataTypeException
1573
-     * @throws InvalidInterfaceException
1574
-     */
1575
-    public function check_user_access($route_to_check = '', $verify_only = false)
1576
-    {
1577
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1578
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1579
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1580
-                          && is_array(
1581
-                              $this->_page_routes[ $route_to_check ]
1582
-                          )
1583
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1584
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1585
-        if (empty($capability) && empty($route_to_check)) {
1586
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1587
-                : $this->_route['capability'];
1588
-        } else {
1589
-            $capability = empty($capability) ? 'manage_options' : $capability;
1590
-        }
1591
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1592
-        if (
1593
-            ! $this->request->isAjax()
1594
-            && (
1595
-                ! function_exists('is_admin')
1596
-                || ! EE_Registry::instance()->CAP->current_user_can(
1597
-                    $capability,
1598
-                    $this->page_slug
1599
-                    . '_'
1600
-                    . $route_to_check,
1601
-                    $id
1602
-                )
1603
-            )
1604
-        ) {
1605
-            if ($verify_only) {
1606
-                return false;
1607
-            }
1608
-            if (is_user_logged_in()) {
1609
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1610
-            } else {
1611
-                return false;
1612
-            }
1613
-        }
1614
-        return true;
1615
-    }
1616
-
1617
-
1618
-    /**
1619
-     * admin_init_global
1620
-     * This runs all the code that we want executed within the WP admin_init hook.
1621
-     * This method executes for ALL EE Admin pages.
1622
-     *
1623
-     * @return void
1624
-     */
1625
-    public function admin_init_global()
1626
-    {
1627
-    }
1628
-
1629
-
1630
-    /**
1631
-     * wp_loaded_global
1632
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1633
-     * EE_Admin page and will execute on every EE Admin Page load
1634
-     *
1635
-     * @return void
1636
-     */
1637
-    public function wp_loaded()
1638
-    {
1639
-    }
1640
-
1641
-
1642
-    /**
1643
-     * admin_notices
1644
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1645
-     * ALL EE_Admin pages.
1646
-     *
1647
-     * @return void
1648
-     */
1649
-    public function admin_notices_global()
1650
-    {
1651
-        $this->_display_no_javascript_warning();
1652
-        $this->_display_espresso_notices();
1653
-    }
1654
-
1655
-
1656
-    public function network_admin_notices_global()
1657
-    {
1658
-        $this->_display_no_javascript_warning();
1659
-        $this->_display_espresso_notices();
1660
-    }
1661
-
1662
-
1663
-    /**
1664
-     * admin_footer_scripts_global
1665
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1666
-     * will apply on ALL EE_Admin pages.
1667
-     *
1668
-     * @return void
1669
-     */
1670
-    public function admin_footer_scripts_global()
1671
-    {
1672
-        $this->_add_admin_page_ajax_loading_img();
1673
-        $this->_add_admin_page_overlay();
1674
-        // if metaboxes are present we need to add the nonce field
1675
-        if (
1676
-            isset($this->_route_config['metaboxes'])
1677
-            || isset($this->_route_config['list_table'])
1678
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1679
-        ) {
1680
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1681
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1682
-        }
1683
-    }
1684
-
1685
-
1686
-    /**
1687
-     * admin_footer_global
1688
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1689
-     * ALL EE_Admin Pages.
1690
-     *
1691
-     * @return void
1692
-     */
1693
-    public function admin_footer_global()
1694
-    {
1695
-        // dialog container for dialog helper
1696
-        echo '
1044
+				(
1045
+					(
1046
+						method_exists($class, $method)
1047
+						&& call_user_func_array([$class, $method], $args) === false
1048
+					)
1049
+					&& (
1050
+						// is it a standalone function that doesn't work?
1051
+						function_exists($method)
1052
+						&& call_user_func_array(
1053
+							$func,
1054
+							array_merge(['admin_page_object' => $this], $args)
1055
+						) === false
1056
+					)
1057
+				)
1058
+				|| (
1059
+					// is it neither a class method NOR a standalone function?
1060
+					! method_exists($class, $method)
1061
+					&& ! function_exists($method)
1062
+				)
1063
+			) {
1064
+				// user error msg
1065
+				$error_msg = esc_html__(
1066
+					'An error occurred. The  requested page route could not be found.',
1067
+					'event_espresso'
1068
+				);
1069
+				// developer error msg
1070
+				$error_msg .= '||';
1071
+				$error_msg .= sprintf(
1072
+					esc_html__(
1073
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1074
+						'event_espresso'
1075
+					),
1076
+					$method
1077
+				);
1078
+			}
1079
+			if (! empty($error_msg)) {
1080
+				throw new EE_Error($error_msg);
1081
+			}
1082
+		}
1083
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1084
+		// then we need to reset the routing properties to the new route.
1085
+		// 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.
1086
+		if (
1087
+			$this->_is_UI_request === false
1088
+			&& is_array($this->_route)
1089
+			&& ! empty($this->_route['headers_sent_route'])
1090
+		) {
1091
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1092
+		}
1093
+	}
1094
+
1095
+
1096
+	/**
1097
+	 * This method just allows the resetting of page properties in the case where a no headers
1098
+	 * route redirects to a headers route in its route config.
1099
+	 *
1100
+	 * @param string $new_route New (non header) route to redirect to.
1101
+	 * @return   void
1102
+	 * @throws ReflectionException
1103
+	 * @throws InvalidArgumentException
1104
+	 * @throws InvalidInterfaceException
1105
+	 * @throws InvalidDataTypeException
1106
+	 * @throws EE_Error
1107
+	 * @since   4.3.0
1108
+	 */
1109
+	protected function _reset_routing_properties($new_route)
1110
+	{
1111
+		$this->_is_UI_request = true;
1112
+		// now we set the current route to whatever the headers_sent_route is set at
1113
+		$this->request->setRequestParam('action', $new_route);
1114
+		// rerun page setup
1115
+		$this->_page_setup();
1116
+	}
1117
+
1118
+
1119
+	/**
1120
+	 * _add_query_arg
1121
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1122
+	 *(internally just uses EEH_URL's function with the same name)
1123
+	 *
1124
+	 * @param array  $args
1125
+	 * @param string $url
1126
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1127
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1128
+	 *                                        Example usage: If the current page is:
1129
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1130
+	 *                                        &action=default&event_id=20&month_range=March%202015
1131
+	 *                                        &_wpnonce=5467821
1132
+	 *                                        and you call:
1133
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1134
+	 *                                        array(
1135
+	 *                                        'action' => 'resend_something',
1136
+	 *                                        'page=>espresso_registrations'
1137
+	 *                                        ),
1138
+	 *                                        $some_url,
1139
+	 *                                        true
1140
+	 *                                        );
1141
+	 *                                        It will produce a url in this structure:
1142
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1143
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1144
+	 *                                        month_range]=March%202015
1145
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1146
+	 * @return string
1147
+	 */
1148
+	public static function add_query_args_and_nonce(
1149
+		$args = [],
1150
+		$url = false,
1151
+		$sticky = false,
1152
+		$exclude_nonce = false
1153
+	) {
1154
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1155
+		if ($sticky) {
1156
+			/** @var RequestInterface $request */
1157
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1158
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1159
+			foreach ($request->requestParams() as $key => $value) {
1160
+				// do not add nonces
1161
+				if (strpos($key, 'nonce') !== false) {
1162
+					continue;
1163
+				}
1164
+				$args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1165
+			}
1166
+		}
1167
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1168
+	}
1169
+
1170
+
1171
+	/**
1172
+	 * This returns a generated link that will load the related help tab.
1173
+	 *
1174
+	 * @param string $help_tab_id the id for the connected help tab
1175
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1176
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1177
+	 * @return string              generated link
1178
+	 * @uses EEH_Template::get_help_tab_link()
1179
+	 */
1180
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1181
+	{
1182
+		return EEH_Template::get_help_tab_link(
1183
+			$help_tab_id,
1184
+			$this->page_slug,
1185
+			$this->_req_action,
1186
+			$icon_style,
1187
+			$help_text
1188
+		);
1189
+	}
1190
+
1191
+
1192
+	/**
1193
+	 * _add_help_tabs
1194
+	 * Note child classes define their help tabs within the page_config array.
1195
+	 *
1196
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1197
+	 * @return void
1198
+	 * @throws DomainException
1199
+	 * @throws EE_Error
1200
+	 */
1201
+	protected function _add_help_tabs()
1202
+	{
1203
+		$tour_buttons = '';
1204
+		if (isset($this->_page_config[ $this->_req_action ])) {
1205
+			$config = $this->_page_config[ $this->_req_action ];
1206
+			// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1207
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1208
+			// if (isset($this->_help_tour[ $this->_req_action ])) {
1209
+			//     $tb = array();
1210
+			//     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1211
+			//     foreach ($this->_help_tour['tours'] as $tour) {
1212
+			//         // if this is the end tour then we don't need to setup a button
1213
+			//         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1214
+			//             continue;
1215
+			//         }
1216
+			//         $tb[] = '<button id="trigger-tour-'
1217
+			//                 . $tour->get_slug()
1218
+			//                 . '" class="button-primary trigger-ee-help-tour">'
1219
+			//                 . $tour->get_label()
1220
+			//                 . '</button>';
1221
+			//     }
1222
+			//     $tour_buttons .= implode('<br />', $tb);
1223
+			//     $tour_buttons .= '</div></div>';
1224
+			// }
1225
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1226
+			if (is_array($config) && isset($config['help_sidebar'])) {
1227
+				// check that the callback given is valid
1228
+				if (! method_exists($this, $config['help_sidebar'])) {
1229
+					throw new EE_Error(
1230
+						sprintf(
1231
+							esc_html__(
1232
+								'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',
1233
+								'event_espresso'
1234
+							),
1235
+							$config['help_sidebar'],
1236
+							get_class($this)
1237
+						)
1238
+					);
1239
+				}
1240
+				$content = apply_filters(
1241
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1242
+					$this->{$config['help_sidebar']}()
1243
+				);
1244
+				$content .= $tour_buttons; // add help tour buttons.
1245
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1246
+				$this->_current_screen->set_help_sidebar($content);
1247
+			}
1248
+			// if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1249
+			if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1250
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1251
+			}
1252
+			// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1253
+			if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1254
+				$_ht['id']      = $this->page_slug;
1255
+				$_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1256
+				$_ht['content'] = '<p>'
1257
+								  . esc_html__(
1258
+									  'The buttons to the right allow you to start/restart any help tours available for this page',
1259
+									  'event_espresso'
1260
+								  ) . '</p>';
1261
+				$this->_current_screen->add_help_tab($_ht);
1262
+			}
1263
+			if (! isset($config['help_tabs'])) {
1264
+				return;
1265
+			} //no help tabs for this route
1266
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1267
+				// we're here so there ARE help tabs!
1268
+				// make sure we've got what we need
1269
+				if (! isset($cfg['title'])) {
1270
+					throw new EE_Error(
1271
+						esc_html__(
1272
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1273
+							'event_espresso'
1274
+						)
1275
+					);
1276
+				}
1277
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1278
+					throw new EE_Error(
1279
+						esc_html__(
1280
+							'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',
1281
+							'event_espresso'
1282
+						)
1283
+					);
1284
+				}
1285
+				// first priority goes to content.
1286
+				if (! empty($cfg['content'])) {
1287
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1288
+					// second priority goes to filename
1289
+				} elseif (! empty($cfg['filename'])) {
1290
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1291
+					// 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)
1292
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1293
+															 . basename($this->_get_dir())
1294
+															 . '/help_tabs/'
1295
+															 . $cfg['filename']
1296
+															 . '.help_tab.php' : $file_path;
1297
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1298
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1299
+						EE_Error::add_error(
1300
+							sprintf(
1301
+								esc_html__(
1302
+									'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',
1303
+									'event_espresso'
1304
+								),
1305
+								$tab_id,
1306
+								key($config),
1307
+								$file_path
1308
+							),
1309
+							__FILE__,
1310
+							__FUNCTION__,
1311
+							__LINE__
1312
+						);
1313
+						return;
1314
+					}
1315
+					$template_args['admin_page_obj'] = $this;
1316
+					$content                         = EEH_Template::display_template(
1317
+						$file_path,
1318
+						$template_args,
1319
+						true
1320
+					);
1321
+				} else {
1322
+					$content = '';
1323
+				}
1324
+				// check if callback is valid
1325
+				if (
1326
+					empty($content)
1327
+					&& (
1328
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1329
+					)
1330
+				) {
1331
+					EE_Error::add_error(
1332
+						sprintf(
1333
+							esc_html__(
1334
+								'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.',
1335
+								'event_espresso'
1336
+							),
1337
+							$cfg['title']
1338
+						),
1339
+						__FILE__,
1340
+						__FUNCTION__,
1341
+						__LINE__
1342
+					);
1343
+					return;
1344
+				}
1345
+				// setup config array for help tab method
1346
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1347
+				$_ht = [
1348
+					'id'       => $id,
1349
+					'title'    => $cfg['title'],
1350
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1351
+					'content'  => $content,
1352
+				];
1353
+				$this->_current_screen->add_help_tab($_ht);
1354
+			}
1355
+		}
1356
+	}
1357
+
1358
+
1359
+	/**
1360
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1361
+	 * an array with properties for setting up usage of the joyride plugin
1362
+	 *
1363
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1364
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1365
+	 *         _set_page_config() comments
1366
+	 * @return void
1367
+	 * @throws InvalidArgumentException
1368
+	 * @throws InvalidDataTypeException
1369
+	 * @throws InvalidInterfaceException
1370
+	 */
1371
+	protected function _add_help_tour()
1372
+	{
1373
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1374
+		// $tours = array();
1375
+		// $this->_help_tour = array();
1376
+		// // exit early if help tours are turned off globally
1377
+		// if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1378
+		//     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1379
+		// ) {
1380
+		//     return;
1381
+		// }
1382
+		// // loop through _page_config to find any help_tour defined
1383
+		// foreach ($this->_page_config as $route => $config) {
1384
+		//     // we're only going to set things up for this route
1385
+		//     if ($route !== $this->_req_action) {
1386
+		//         continue;
1387
+		//     }
1388
+		//     if (isset($config['help_tour'])) {
1389
+		//         foreach ($config['help_tour'] as $tour) {
1390
+		//             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1391
+		//             // let's see if we can get that file...
1392
+		//             // if not its possible this is a decaf route not set in caffeinated
1393
+		//             // so lets try and get the caffeinated equivalent
1394
+		//             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1395
+		//                                                      . basename($this->_get_dir())
1396
+		//                                                      . '/help_tours/'
1397
+		//                                                      . $tour
1398
+		//                                                      . '.class.php' : $file_path;
1399
+		//             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1400
+		//             if (! is_readable($file_path)) {
1401
+		//                 EE_Error::add_error(
1402
+		//                     sprintf(
1403
+		//                         esc_html__(
1404
+		//                             'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1405
+		//                             'event_espresso'
1406
+		//                         ),
1407
+		//                         $file_path,
1408
+		//                         $tour
1409
+		//                     ),
1410
+		//                     __FILE__,
1411
+		//                     __FUNCTION__,
1412
+		//                     __LINE__
1413
+		//                 );
1414
+		//                 return;
1415
+		//             }
1416
+		//             require_once $file_path;
1417
+		//             if (! class_exists($tour)) {
1418
+		//                 $error_msg[] = sprintf(
1419
+		//                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1420
+		//                     $tour
1421
+		//                 );
1422
+		//                 $error_msg[] = $error_msg[0] . "\r\n"
1423
+		//                                . sprintf(
1424
+		//                                    esc_html__(
1425
+		//                                        'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1426
+		//                                        'event_espresso'
1427
+		//                                    ),
1428
+		//                                    $tour,
1429
+		//                                    '<br />',
1430
+		//                                    $tour,
1431
+		//                                    $this->_req_action,
1432
+		//                                    get_class($this)
1433
+		//                                );
1434
+		//                 throw new EE_Error(implode('||', $error_msg));
1435
+		//             }
1436
+		//             $tour_obj = new $tour($this->_is_caf);
1437
+		//             $tours[] = $tour_obj;
1438
+		//             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1439
+		//         }
1440
+		//         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1441
+		//         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1442
+		//         $tours[] = $end_stop_tour;
1443
+		//         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1444
+		//     }
1445
+		// }
1446
+		//
1447
+		// if (! empty($tours)) {
1448
+		//     $this->_help_tour['tours'] = $tours;
1449
+		// }
1450
+		// // that's it!  Now that the $_help_tours property is set (or not)
1451
+		// // the scripts and html should be taken care of automatically.
1452
+		//
1453
+		// /**
1454
+		//  * Allow extending the help tours variable.
1455
+		//  *
1456
+		//  * @param Array $_help_tour The array containing all help tour information to be displayed.
1457
+		//  */
1458
+		// $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1459
+	}
1460
+
1461
+
1462
+	/**
1463
+	 * This simply sets up any qtips that have been defined in the page config
1464
+	 *
1465
+	 * @return void
1466
+	 */
1467
+	protected function _add_qtips()
1468
+	{
1469
+		if (isset($this->_route_config['qtips'])) {
1470
+			$qtips = (array) $this->_route_config['qtips'];
1471
+			// load qtip loader
1472
+			$path = [
1473
+				$this->_get_dir() . '/qtips/',
1474
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1475
+			];
1476
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1477
+		}
1478
+	}
1479
+
1480
+
1481
+	/**
1482
+	 * _set_nav_tabs
1483
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1484
+	 * wish to add additional tabs or modify accordingly.
1485
+	 *
1486
+	 * @return void
1487
+	 * @throws InvalidArgumentException
1488
+	 * @throws InvalidInterfaceException
1489
+	 * @throws InvalidDataTypeException
1490
+	 */
1491
+	protected function _set_nav_tabs()
1492
+	{
1493
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1494
+		$i = 0;
1495
+		foreach ($this->_page_config as $slug => $config) {
1496
+			if (! is_array($config) || empty($config['nav'])) {
1497
+				continue;
1498
+			}
1499
+			// no nav tab for this config
1500
+			// check for persistent flag
1501
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1502
+				// nav tab is only to appear when route requested.
1503
+				continue;
1504
+			}
1505
+			if (! $this->check_user_access($slug, true)) {
1506
+				// no nav tab because current user does not have access.
1507
+				continue;
1508
+			}
1509
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1510
+			$this->_nav_tabs[ $slug ] = [
1511
+				'url'       => isset($config['nav']['url'])
1512
+					? $config['nav']['url']
1513
+					: self::add_query_args_and_nonce(
1514
+						['action' => $slug],
1515
+						$this->_admin_base_url
1516
+					),
1517
+				'link_text' => isset($config['nav']['label'])
1518
+					? $config['nav']['label']
1519
+					: ucwords(
1520
+						str_replace('_', ' ', $slug)
1521
+					),
1522
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1523
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1524
+			];
1525
+			$i++;
1526
+		}
1527
+		// if $this->_nav_tabs is empty then lets set the default
1528
+		if (empty($this->_nav_tabs)) {
1529
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1530
+				'url'       => $this->_admin_base_url,
1531
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1532
+				'css_class' => 'nav-tab-active',
1533
+				'order'     => 10,
1534
+			];
1535
+		}
1536
+		// now let's sort the tabs according to order
1537
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1538
+	}
1539
+
1540
+
1541
+	/**
1542
+	 * _set_current_labels
1543
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1544
+	 * property array
1545
+	 *
1546
+	 * @return void
1547
+	 */
1548
+	private function _set_current_labels()
1549
+	{
1550
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1551
+			foreach ($this->_route_config['labels'] as $label => $text) {
1552
+				if (is_array($text)) {
1553
+					foreach ($text as $sublabel => $subtext) {
1554
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1555
+					}
1556
+				} else {
1557
+					$this->_labels[ $label ] = $text;
1558
+				}
1559
+			}
1560
+		}
1561
+	}
1562
+
1563
+
1564
+	/**
1565
+	 *        verifies user access for this admin page
1566
+	 *
1567
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1568
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1569
+	 *                               return false if verify fail.
1570
+	 * @return bool
1571
+	 * @throws InvalidArgumentException
1572
+	 * @throws InvalidDataTypeException
1573
+	 * @throws InvalidInterfaceException
1574
+	 */
1575
+	public function check_user_access($route_to_check = '', $verify_only = false)
1576
+	{
1577
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1578
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1579
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1580
+						  && is_array(
1581
+							  $this->_page_routes[ $route_to_check ]
1582
+						  )
1583
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1584
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1585
+		if (empty($capability) && empty($route_to_check)) {
1586
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1587
+				: $this->_route['capability'];
1588
+		} else {
1589
+			$capability = empty($capability) ? 'manage_options' : $capability;
1590
+		}
1591
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1592
+		if (
1593
+			! $this->request->isAjax()
1594
+			&& (
1595
+				! function_exists('is_admin')
1596
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1597
+					$capability,
1598
+					$this->page_slug
1599
+					. '_'
1600
+					. $route_to_check,
1601
+					$id
1602
+				)
1603
+			)
1604
+		) {
1605
+			if ($verify_only) {
1606
+				return false;
1607
+			}
1608
+			if (is_user_logged_in()) {
1609
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1610
+			} else {
1611
+				return false;
1612
+			}
1613
+		}
1614
+		return true;
1615
+	}
1616
+
1617
+
1618
+	/**
1619
+	 * admin_init_global
1620
+	 * This runs all the code that we want executed within the WP admin_init hook.
1621
+	 * This method executes for ALL EE Admin pages.
1622
+	 *
1623
+	 * @return void
1624
+	 */
1625
+	public function admin_init_global()
1626
+	{
1627
+	}
1628
+
1629
+
1630
+	/**
1631
+	 * wp_loaded_global
1632
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1633
+	 * EE_Admin page and will execute on every EE Admin Page load
1634
+	 *
1635
+	 * @return void
1636
+	 */
1637
+	public function wp_loaded()
1638
+	{
1639
+	}
1640
+
1641
+
1642
+	/**
1643
+	 * admin_notices
1644
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1645
+	 * ALL EE_Admin pages.
1646
+	 *
1647
+	 * @return void
1648
+	 */
1649
+	public function admin_notices_global()
1650
+	{
1651
+		$this->_display_no_javascript_warning();
1652
+		$this->_display_espresso_notices();
1653
+	}
1654
+
1655
+
1656
+	public function network_admin_notices_global()
1657
+	{
1658
+		$this->_display_no_javascript_warning();
1659
+		$this->_display_espresso_notices();
1660
+	}
1661
+
1662
+
1663
+	/**
1664
+	 * admin_footer_scripts_global
1665
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1666
+	 * will apply on ALL EE_Admin pages.
1667
+	 *
1668
+	 * @return void
1669
+	 */
1670
+	public function admin_footer_scripts_global()
1671
+	{
1672
+		$this->_add_admin_page_ajax_loading_img();
1673
+		$this->_add_admin_page_overlay();
1674
+		// if metaboxes are present we need to add the nonce field
1675
+		if (
1676
+			isset($this->_route_config['metaboxes'])
1677
+			|| isset($this->_route_config['list_table'])
1678
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1679
+		) {
1680
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1681
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1682
+		}
1683
+	}
1684
+
1685
+
1686
+	/**
1687
+	 * admin_footer_global
1688
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1689
+	 * ALL EE_Admin Pages.
1690
+	 *
1691
+	 * @return void
1692
+	 */
1693
+	public function admin_footer_global()
1694
+	{
1695
+		// dialog container for dialog helper
1696
+		echo '
1697 1697
         <div class="ee-admin-dialog-container auto-hide hidden">
1698 1698
             <div class="ee-notices"></div>
1699 1699
             <div class="ee-admin-dialog-container-inner-content"></div>
1700 1700
         </div>
1701 1701
         ';
1702 1702
 
1703
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1704
-        // help tour stuff?
1705
-        // if (isset($this->_help_tour[ $this->_req_action ])) {
1706
-        //     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1707
-        // }
1708
-        // current set timezone for timezone js
1709
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1710
-    }
1711
-
1712
-
1713
-    /**
1714
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1715
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1716
-     * help popups then in your templates or your content you set "triggers" for the content using the
1717
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1718
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1719
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1720
-     * for the
1721
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1722
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1723
-     *    'help_trigger_id' => array(
1724
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1725
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1726
-     *    )
1727
-     * );
1728
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1729
-     *
1730
-     * @param array $help_array
1731
-     * @param bool  $display
1732
-     * @return string content
1733
-     * @throws DomainException
1734
-     * @throws EE_Error
1735
-     */
1736
-    protected function _set_help_popup_content($help_array = [], $display = false)
1737
-    {
1738
-        $content    = '';
1739
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1740
-        // loop through the array and setup content
1741
-        foreach ($help_array as $trigger => $help) {
1742
-            // make sure the array is setup properly
1743
-            if (! isset($help['title']) || ! isset($help['content'])) {
1744
-                throw new EE_Error(
1745
-                    esc_html__(
1746
-                        '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',
1747
-                        'event_espresso'
1748
-                    )
1749
-                );
1750
-            }
1751
-            // we're good so let's setup the template vars and then assign parsed template content to our content.
1752
-            $template_args = [
1753
-                'help_popup_id'      => $trigger,
1754
-                'help_popup_title'   => $help['title'],
1755
-                'help_popup_content' => $help['content'],
1756
-            ];
1757
-            $content       .= EEH_Template::display_template(
1758
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1759
-                $template_args,
1760
-                true
1761
-            );
1762
-        }
1763
-        if ($display) {
1764
-            echo $content; // already escaped
1765
-            return '';
1766
-        }
1767
-        return $content;
1768
-    }
1769
-
1770
-
1771
-    /**
1772
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1773
-     *
1774
-     * @return array properly formatted array for help popup content
1775
-     * @throws EE_Error
1776
-     */
1777
-    private function _get_help_content()
1778
-    {
1779
-        // what is the method we're looking for?
1780
-        $method_name = '_help_popup_content_' . $this->_req_action;
1781
-        // if method doesn't exist let's get out.
1782
-        if (! method_exists($this, $method_name)) {
1783
-            return [];
1784
-        }
1785
-        // k we're good to go let's retrieve the help array
1786
-        $help_array = call_user_func([$this, $method_name]);
1787
-        // make sure we've got an array!
1788
-        if (! is_array($help_array)) {
1789
-            throw new EE_Error(
1790
-                esc_html__(
1791
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1792
-                    'event_espresso'
1793
-                )
1794
-            );
1795
-        }
1796
-        return $help_array;
1797
-    }
1798
-
1799
-
1800
-    /**
1801
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1802
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1803
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1804
-     *
1805
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1806
-     * @param boolean $display    if false then we return the trigger string
1807
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1808
-     * @return string
1809
-     * @throws DomainException
1810
-     * @throws EE_Error
1811
-     */
1812
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1813
-    {
1814
-        if ($this->request->isAjax()) {
1815
-            return '';
1816
-        }
1817
-        // 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
1818
-        $help_array   = $this->_get_help_content();
1819
-        $help_content = '';
1820
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1821
-            $help_array[ $trigger_id ] = [
1822
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1823
-                'content' => esc_html__(
1824
-                    '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.)',
1825
-                    'event_espresso'
1826
-                ),
1827
-            ];
1828
-            $help_content              = $this->_set_help_popup_content($help_array);
1829
-        }
1830
-        // let's setup the trigger
1831
-        $content = '<a class="ee-dialog" href="?height='
1832
-                   . esc_attr($dimensions[0])
1833
-                   . '&width='
1834
-                   . esc_attr($dimensions[1])
1835
-                   . '&inlineId='
1836
-                   . esc_attr($trigger_id)
1837
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1838
-        $content .= $help_content;
1839
-        if ($display) {
1840
-            echo $content; // already escaped
1841
-            return '';
1842
-        }
1843
-        return $content;
1844
-    }
1845
-
1846
-
1847
-    /**
1848
-     * _add_global_screen_options
1849
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1850
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1851
-     *
1852
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1853
-     *         see also WP_Screen object documents...
1854
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1855
-     * @abstract
1856
-     * @return void
1857
-     */
1858
-    private function _add_global_screen_options()
1859
-    {
1860
-    }
1861
-
1862
-
1863
-    /**
1864
-     * _add_global_feature_pointers
1865
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1866
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1867
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1868
-     *
1869
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1870
-     *         extended) also see:
1871
-     * @link   http://eamann.com/tech/wordpress-portland/
1872
-     * @abstract
1873
-     * @return void
1874
-     */
1875
-    private function _add_global_feature_pointers()
1876
-    {
1877
-    }
1878
-
1879
-
1880
-    /**
1881
-     * load_global_scripts_styles
1882
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1883
-     *
1884
-     * @return void
1885
-     */
1886
-    public function load_global_scripts_styles()
1887
-    {
1888
-        /** STYLES **/
1889
-        // add debugging styles
1890
-        if (WP_DEBUG) {
1891
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1892
-        }
1893
-        // register all styles
1894
-        wp_register_style(
1895
-            'espresso-ui-theme',
1896
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1897
-            [],
1898
-            EVENT_ESPRESSO_VERSION
1899
-        );
1900
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1901
-        // helpers styles
1902
-        wp_register_style(
1903
-            'ee-text-links',
1904
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1905
-            [],
1906
-            EVENT_ESPRESSO_VERSION
1907
-        );
1908
-        /** SCRIPTS **/
1909
-        // register all scripts
1910
-        wp_register_script(
1911
-            'ee-dialog',
1912
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1913
-            ['jquery', 'jquery-ui-draggable'],
1914
-            EVENT_ESPRESSO_VERSION,
1915
-            true
1916
-        );
1917
-        wp_register_script(
1918
-            'ee_admin_js',
1919
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1920
-            ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1921
-            EVENT_ESPRESSO_VERSION,
1922
-            true
1923
-        );
1924
-        wp_register_script(
1925
-            'jquery-ui-timepicker-addon',
1926
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1927
-            ['jquery-ui-datepicker', 'jquery-ui-slider'],
1928
-            EVENT_ESPRESSO_VERSION,
1929
-            true
1930
-        );
1931
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1932
-        // if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1933
-        //     add_filter('FHEE_load_joyride', '__return_true');
1934
-        // }
1935
-        // script for sorting tables
1936
-        wp_register_script(
1937
-            'espresso_ajax_table_sorting',
1938
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1939
-            ['ee_admin_js', 'jquery-ui-sortable'],
1940
-            EVENT_ESPRESSO_VERSION,
1941
-            true
1942
-        );
1943
-        // script for parsing uri's
1944
-        wp_register_script(
1945
-            'ee-parse-uri',
1946
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1947
-            [],
1948
-            EVENT_ESPRESSO_VERSION,
1949
-            true
1950
-        );
1951
-        // and parsing associative serialized form elements
1952
-        wp_register_script(
1953
-            'ee-serialize-full-array',
1954
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1955
-            ['jquery'],
1956
-            EVENT_ESPRESSO_VERSION,
1957
-            true
1958
-        );
1959
-        // helpers scripts
1960
-        wp_register_script(
1961
-            'ee-text-links',
1962
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1963
-            ['jquery'],
1964
-            EVENT_ESPRESSO_VERSION,
1965
-            true
1966
-        );
1967
-        wp_register_script(
1968
-            'ee-moment-core',
1969
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1970
-            [],
1971
-            EVENT_ESPRESSO_VERSION,
1972
-            true
1973
-        );
1974
-        wp_register_script(
1975
-            'ee-moment',
1976
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1977
-            ['ee-moment-core'],
1978
-            EVENT_ESPRESSO_VERSION,
1979
-            true
1980
-        );
1981
-        wp_register_script(
1982
-            'ee-datepicker',
1983
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1984
-            ['jquery-ui-timepicker-addon', 'ee-moment'],
1985
-            EVENT_ESPRESSO_VERSION,
1986
-            true
1987
-        );
1988
-        // google charts
1989
-        wp_register_script(
1990
-            'google-charts',
1991
-            'https://www.gstatic.com/charts/loader.js',
1992
-            [],
1993
-            EVENT_ESPRESSO_VERSION
1994
-        );
1995
-        // ENQUEUE ALL BASICS BY DEFAULT
1996
-        wp_enqueue_style('ee-admin-css');
1997
-        wp_enqueue_script('ee_admin_js');
1998
-        wp_enqueue_script('ee-accounting');
1999
-        wp_enqueue_script('jquery-validate');
2000
-        // taking care of metaboxes
2001
-        if (
2002
-            empty($this->_cpt_route)
2003
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2004
-        ) {
2005
-            wp_enqueue_script('dashboard');
2006
-        }
2007
-        // LOCALIZED DATA
2008
-        // localize script for ajax lazy loading
2009
-        $lazy_loader_container_ids = apply_filters(
2010
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2011
-            ['espresso_news_post_box_content']
2012
-        );
2013
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2014
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
2015
-        // /**
2016
-        //  * help tour stuff
2017
-        //  */
2018
-        // if (! empty($this->_help_tour)) {
2019
-        //     // register the js for kicking things off
2020
-        //     wp_enqueue_script(
2021
-        //         'ee-help-tour',
2022
-        //         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2023
-        //         array('jquery-joyride'),
2024
-        //         EVENT_ESPRESSO_VERSION,
2025
-        //         true
2026
-        //     );
2027
-        //     $tours = array();
2028
-        //     // setup tours for the js tour object
2029
-        //     foreach ($this->_help_tour['tours'] as $tour) {
2030
-        //         if ($tour instanceof EE_Help_Tour) {
2031
-        //             $tours[] = array(
2032
-        //                 'id'      => $tour->get_slug(),
2033
-        //                 'options' => $tour->get_options(),
2034
-        //             );
2035
-        //         }
2036
-        //     }
2037
-        //     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2038
-        //     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2039
-        // }
2040
-
2041
-        add_filter(
2042
-            'admin_body_class',
2043
-            function ($classes) {
2044
-                if (strpos($classes, 'espresso-admin') === false) {
2045
-                    $classes .= ' espresso-admin';
2046
-                }
2047
-                return $classes;
2048
-            }
2049
-        );
2050
-    }
2051
-
2052
-
2053
-    /**
2054
-     *        admin_footer_scripts_eei18n_js_strings
2055
-     *
2056
-     * @return        void
2057
-     */
2058
-    public function admin_footer_scripts_eei18n_js_strings()
2059
-    {
2060
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2061
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2062
-            __(
2063
-                '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!!!',
2064
-                'event_espresso'
2065
-            )
2066
-        );
2067
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2068
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2069
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2070
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2071
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2072
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2073
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2074
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2075
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2076
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2077
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2078
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2079
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2080
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2081
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2082
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2083
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2084
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2085
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2086
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2087
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2088
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2089
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2090
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2091
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2092
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2093
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2094
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2095
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2096
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2097
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2098
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2099
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2100
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2101
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2102
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2103
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2104
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2105
-    }
2106
-
2107
-
2108
-    /**
2109
-     *        load enhanced xdebug styles for ppl with failing eyesight
2110
-     *
2111
-     * @return        void
2112
-     */
2113
-    public function add_xdebug_style()
2114
-    {
2115
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2116
-    }
2117
-
2118
-
2119
-    /************************/
2120
-    /** LIST TABLE METHODS **/
2121
-    /************************/
2122
-    /**
2123
-     * this sets up the list table if the current view requires it.
2124
-     *
2125
-     * @return void
2126
-     * @throws EE_Error
2127
-     */
2128
-    protected function _set_list_table()
2129
-    {
2130
-        // first is this a list_table view?
2131
-        if (! isset($this->_route_config['list_table'])) {
2132
-            return;
2133
-        } //not a list_table view so get out.
2134
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2135
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2136
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2137
-            // user error msg
2138
-            $error_msg = esc_html__(
2139
-                'An error occurred. The requested list table views could not be found.',
2140
-                'event_espresso'
2141
-            );
2142
-            // developer error msg
2143
-            $error_msg .= '||'
2144
-                          . sprintf(
2145
-                              esc_html__(
2146
-                                  '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.',
2147
-                                  'event_espresso'
2148
-                              ),
2149
-                              $this->_req_action,
2150
-                              $list_table_view
2151
-                          );
2152
-            throw new EE_Error($error_msg);
2153
-        }
2154
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2155
-        $this->_views = apply_filters(
2156
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2157
-            $this->_views
2158
-        );
2159
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2160
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2161
-        $this->_set_list_table_view();
2162
-        $this->_set_list_table_object();
2163
-    }
2164
-
2165
-
2166
-    /**
2167
-     * set current view for List Table
2168
-     *
2169
-     * @return void
2170
-     */
2171
-    protected function _set_list_table_view()
2172
-    {
2173
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2174
-        $status = $this->request->getRequestParam('status', null, 'key');
2175
-        $this->_view = $status && array_key_exists($status, $this->_views)
2176
-            ? $status
2177
-            : $this->_view;
2178
-    }
2179
-
2180
-
2181
-    /**
2182
-     * _set_list_table_object
2183
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2184
-     *
2185
-     * @throws InvalidInterfaceException
2186
-     * @throws InvalidArgumentException
2187
-     * @throws InvalidDataTypeException
2188
-     * @throws EE_Error
2189
-     * @throws InvalidInterfaceException
2190
-     */
2191
-    protected function _set_list_table_object()
2192
-    {
2193
-        if (isset($this->_route_config['list_table'])) {
2194
-            if (! class_exists($this->_route_config['list_table'])) {
2195
-                throw new EE_Error(
2196
-                    sprintf(
2197
-                        esc_html__(
2198
-                            '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.',
2199
-                            'event_espresso'
2200
-                        ),
2201
-                        $this->_route_config['list_table'],
2202
-                        get_class($this)
2203
-                    )
2204
-                );
2205
-            }
2206
-            $this->_list_table_object = $this->loader->getShared(
2207
-                $this->_route_config['list_table'],
2208
-                [$this]
2209
-            );
2210
-        }
2211
-    }
2212
-
2213
-
2214
-    /**
2215
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2216
-     *
2217
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2218
-     *                                                    urls.  The array should be indexed by the view it is being
2219
-     *                                                    added to.
2220
-     * @return array
2221
-     */
2222
-    public function get_list_table_view_RLs($extra_query_args = [])
2223
-    {
2224
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2225
-        if (empty($this->_views)) {
2226
-            $this->_views = [];
2227
-        }
2228
-        // cycle thru views
2229
-        foreach ($this->_views as $key => $view) {
2230
-            $query_args = [];
2231
-            // check for current view
2232
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2233
-            $query_args['action']                        = $this->_req_action;
2234
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2235
-            $query_args['status']                        = $view['slug'];
2236
-            // merge any other arguments sent in.
2237
-            if (isset($extra_query_args[ $view['slug'] ])) {
2238
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2239
-            }
2240
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2241
-        }
2242
-        return $this->_views;
2243
-    }
2244
-
2245
-
2246
-    /**
2247
-     * _entries_per_page_dropdown
2248
-     * generates a dropdown box for selecting the number of visible rows in an admin page list table
2249
-     *
2250
-     * @param int $max_entries total number of rows in the table
2251
-     * @return string
2252
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2253
-     *         WP does it.
2254
-     */
2255
-    protected function _entries_per_page_dropdown($max_entries = 0)
2256
-    {
2257
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2258
-        $values   = [10, 25, 50, 100];
2259
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2260
-        if ($max_entries) {
2261
-            $values[] = $max_entries;
2262
-            sort($values);
2263
-        }
2264
-        $entries_per_page_dropdown = '
1703
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1704
+		// help tour stuff?
1705
+		// if (isset($this->_help_tour[ $this->_req_action ])) {
1706
+		//     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1707
+		// }
1708
+		// current set timezone for timezone js
1709
+		echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1710
+	}
1711
+
1712
+
1713
+	/**
1714
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1715
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1716
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1717
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1718
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1719
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1720
+	 * for the
1721
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1722
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1723
+	 *    'help_trigger_id' => array(
1724
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1725
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1726
+	 *    )
1727
+	 * );
1728
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1729
+	 *
1730
+	 * @param array $help_array
1731
+	 * @param bool  $display
1732
+	 * @return string content
1733
+	 * @throws DomainException
1734
+	 * @throws EE_Error
1735
+	 */
1736
+	protected function _set_help_popup_content($help_array = [], $display = false)
1737
+	{
1738
+		$content    = '';
1739
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1740
+		// loop through the array and setup content
1741
+		foreach ($help_array as $trigger => $help) {
1742
+			// make sure the array is setup properly
1743
+			if (! isset($help['title']) || ! isset($help['content'])) {
1744
+				throw new EE_Error(
1745
+					esc_html__(
1746
+						'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',
1747
+						'event_espresso'
1748
+					)
1749
+				);
1750
+			}
1751
+			// we're good so let's setup the template vars and then assign parsed template content to our content.
1752
+			$template_args = [
1753
+				'help_popup_id'      => $trigger,
1754
+				'help_popup_title'   => $help['title'],
1755
+				'help_popup_content' => $help['content'],
1756
+			];
1757
+			$content       .= EEH_Template::display_template(
1758
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1759
+				$template_args,
1760
+				true
1761
+			);
1762
+		}
1763
+		if ($display) {
1764
+			echo $content; // already escaped
1765
+			return '';
1766
+		}
1767
+		return $content;
1768
+	}
1769
+
1770
+
1771
+	/**
1772
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1773
+	 *
1774
+	 * @return array properly formatted array for help popup content
1775
+	 * @throws EE_Error
1776
+	 */
1777
+	private function _get_help_content()
1778
+	{
1779
+		// what is the method we're looking for?
1780
+		$method_name = '_help_popup_content_' . $this->_req_action;
1781
+		// if method doesn't exist let's get out.
1782
+		if (! method_exists($this, $method_name)) {
1783
+			return [];
1784
+		}
1785
+		// k we're good to go let's retrieve the help array
1786
+		$help_array = call_user_func([$this, $method_name]);
1787
+		// make sure we've got an array!
1788
+		if (! is_array($help_array)) {
1789
+			throw new EE_Error(
1790
+				esc_html__(
1791
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1792
+					'event_espresso'
1793
+				)
1794
+			);
1795
+		}
1796
+		return $help_array;
1797
+	}
1798
+
1799
+
1800
+	/**
1801
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1802
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1803
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1804
+	 *
1805
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1806
+	 * @param boolean $display    if false then we return the trigger string
1807
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1808
+	 * @return string
1809
+	 * @throws DomainException
1810
+	 * @throws EE_Error
1811
+	 */
1812
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1813
+	{
1814
+		if ($this->request->isAjax()) {
1815
+			return '';
1816
+		}
1817
+		// 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
1818
+		$help_array   = $this->_get_help_content();
1819
+		$help_content = '';
1820
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1821
+			$help_array[ $trigger_id ] = [
1822
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1823
+				'content' => esc_html__(
1824
+					'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.)',
1825
+					'event_espresso'
1826
+				),
1827
+			];
1828
+			$help_content              = $this->_set_help_popup_content($help_array);
1829
+		}
1830
+		// let's setup the trigger
1831
+		$content = '<a class="ee-dialog" href="?height='
1832
+				   . esc_attr($dimensions[0])
1833
+				   . '&width='
1834
+				   . esc_attr($dimensions[1])
1835
+				   . '&inlineId='
1836
+				   . esc_attr($trigger_id)
1837
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1838
+		$content .= $help_content;
1839
+		if ($display) {
1840
+			echo $content; // already escaped
1841
+			return '';
1842
+		}
1843
+		return $content;
1844
+	}
1845
+
1846
+
1847
+	/**
1848
+	 * _add_global_screen_options
1849
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1850
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1851
+	 *
1852
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1853
+	 *         see also WP_Screen object documents...
1854
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1855
+	 * @abstract
1856
+	 * @return void
1857
+	 */
1858
+	private function _add_global_screen_options()
1859
+	{
1860
+	}
1861
+
1862
+
1863
+	/**
1864
+	 * _add_global_feature_pointers
1865
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1866
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1867
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1868
+	 *
1869
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1870
+	 *         extended) also see:
1871
+	 * @link   http://eamann.com/tech/wordpress-portland/
1872
+	 * @abstract
1873
+	 * @return void
1874
+	 */
1875
+	private function _add_global_feature_pointers()
1876
+	{
1877
+	}
1878
+
1879
+
1880
+	/**
1881
+	 * load_global_scripts_styles
1882
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1883
+	 *
1884
+	 * @return void
1885
+	 */
1886
+	public function load_global_scripts_styles()
1887
+	{
1888
+		/** STYLES **/
1889
+		// add debugging styles
1890
+		if (WP_DEBUG) {
1891
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1892
+		}
1893
+		// register all styles
1894
+		wp_register_style(
1895
+			'espresso-ui-theme',
1896
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1897
+			[],
1898
+			EVENT_ESPRESSO_VERSION
1899
+		);
1900
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1901
+		// helpers styles
1902
+		wp_register_style(
1903
+			'ee-text-links',
1904
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1905
+			[],
1906
+			EVENT_ESPRESSO_VERSION
1907
+		);
1908
+		/** SCRIPTS **/
1909
+		// register all scripts
1910
+		wp_register_script(
1911
+			'ee-dialog',
1912
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1913
+			['jquery', 'jquery-ui-draggable'],
1914
+			EVENT_ESPRESSO_VERSION,
1915
+			true
1916
+		);
1917
+		wp_register_script(
1918
+			'ee_admin_js',
1919
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1920
+			['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1921
+			EVENT_ESPRESSO_VERSION,
1922
+			true
1923
+		);
1924
+		wp_register_script(
1925
+			'jquery-ui-timepicker-addon',
1926
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1927
+			['jquery-ui-datepicker', 'jquery-ui-slider'],
1928
+			EVENT_ESPRESSO_VERSION,
1929
+			true
1930
+		);
1931
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1932
+		// if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1933
+		//     add_filter('FHEE_load_joyride', '__return_true');
1934
+		// }
1935
+		// script for sorting tables
1936
+		wp_register_script(
1937
+			'espresso_ajax_table_sorting',
1938
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1939
+			['ee_admin_js', 'jquery-ui-sortable'],
1940
+			EVENT_ESPRESSO_VERSION,
1941
+			true
1942
+		);
1943
+		// script for parsing uri's
1944
+		wp_register_script(
1945
+			'ee-parse-uri',
1946
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1947
+			[],
1948
+			EVENT_ESPRESSO_VERSION,
1949
+			true
1950
+		);
1951
+		// and parsing associative serialized form elements
1952
+		wp_register_script(
1953
+			'ee-serialize-full-array',
1954
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1955
+			['jquery'],
1956
+			EVENT_ESPRESSO_VERSION,
1957
+			true
1958
+		);
1959
+		// helpers scripts
1960
+		wp_register_script(
1961
+			'ee-text-links',
1962
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1963
+			['jquery'],
1964
+			EVENT_ESPRESSO_VERSION,
1965
+			true
1966
+		);
1967
+		wp_register_script(
1968
+			'ee-moment-core',
1969
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1970
+			[],
1971
+			EVENT_ESPRESSO_VERSION,
1972
+			true
1973
+		);
1974
+		wp_register_script(
1975
+			'ee-moment',
1976
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1977
+			['ee-moment-core'],
1978
+			EVENT_ESPRESSO_VERSION,
1979
+			true
1980
+		);
1981
+		wp_register_script(
1982
+			'ee-datepicker',
1983
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1984
+			['jquery-ui-timepicker-addon', 'ee-moment'],
1985
+			EVENT_ESPRESSO_VERSION,
1986
+			true
1987
+		);
1988
+		// google charts
1989
+		wp_register_script(
1990
+			'google-charts',
1991
+			'https://www.gstatic.com/charts/loader.js',
1992
+			[],
1993
+			EVENT_ESPRESSO_VERSION
1994
+		);
1995
+		// ENQUEUE ALL BASICS BY DEFAULT
1996
+		wp_enqueue_style('ee-admin-css');
1997
+		wp_enqueue_script('ee_admin_js');
1998
+		wp_enqueue_script('ee-accounting');
1999
+		wp_enqueue_script('jquery-validate');
2000
+		// taking care of metaboxes
2001
+		if (
2002
+			empty($this->_cpt_route)
2003
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
2004
+		) {
2005
+			wp_enqueue_script('dashboard');
2006
+		}
2007
+		// LOCALIZED DATA
2008
+		// localize script for ajax lazy loading
2009
+		$lazy_loader_container_ids = apply_filters(
2010
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
2011
+			['espresso_news_post_box_content']
2012
+		);
2013
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
2014
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
2015
+		// /**
2016
+		//  * help tour stuff
2017
+		//  */
2018
+		// if (! empty($this->_help_tour)) {
2019
+		//     // register the js for kicking things off
2020
+		//     wp_enqueue_script(
2021
+		//         'ee-help-tour',
2022
+		//         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2023
+		//         array('jquery-joyride'),
2024
+		//         EVENT_ESPRESSO_VERSION,
2025
+		//         true
2026
+		//     );
2027
+		//     $tours = array();
2028
+		//     // setup tours for the js tour object
2029
+		//     foreach ($this->_help_tour['tours'] as $tour) {
2030
+		//         if ($tour instanceof EE_Help_Tour) {
2031
+		//             $tours[] = array(
2032
+		//                 'id'      => $tour->get_slug(),
2033
+		//                 'options' => $tour->get_options(),
2034
+		//             );
2035
+		//         }
2036
+		//     }
2037
+		//     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2038
+		//     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2039
+		// }
2040
+
2041
+		add_filter(
2042
+			'admin_body_class',
2043
+			function ($classes) {
2044
+				if (strpos($classes, 'espresso-admin') === false) {
2045
+					$classes .= ' espresso-admin';
2046
+				}
2047
+				return $classes;
2048
+			}
2049
+		);
2050
+	}
2051
+
2052
+
2053
+	/**
2054
+	 *        admin_footer_scripts_eei18n_js_strings
2055
+	 *
2056
+	 * @return        void
2057
+	 */
2058
+	public function admin_footer_scripts_eei18n_js_strings()
2059
+	{
2060
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2061
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2062
+			__(
2063
+				'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!!!',
2064
+				'event_espresso'
2065
+			)
2066
+		);
2067
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2068
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2069
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2070
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2071
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2072
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2073
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2074
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2075
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2076
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2077
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2078
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2079
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2080
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2081
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2082
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2083
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2084
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2085
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2086
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2087
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2088
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2089
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2090
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2091
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2092
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2093
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2094
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2095
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2096
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2097
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2098
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2099
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2100
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2101
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2102
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2103
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2104
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2105
+	}
2106
+
2107
+
2108
+	/**
2109
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2110
+	 *
2111
+	 * @return        void
2112
+	 */
2113
+	public function add_xdebug_style()
2114
+	{
2115
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2116
+	}
2117
+
2118
+
2119
+	/************************/
2120
+	/** LIST TABLE METHODS **/
2121
+	/************************/
2122
+	/**
2123
+	 * this sets up the list table if the current view requires it.
2124
+	 *
2125
+	 * @return void
2126
+	 * @throws EE_Error
2127
+	 */
2128
+	protected function _set_list_table()
2129
+	{
2130
+		// first is this a list_table view?
2131
+		if (! isset($this->_route_config['list_table'])) {
2132
+			return;
2133
+		} //not a list_table view so get out.
2134
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2135
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2136
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2137
+			// user error msg
2138
+			$error_msg = esc_html__(
2139
+				'An error occurred. The requested list table views could not be found.',
2140
+				'event_espresso'
2141
+			);
2142
+			// developer error msg
2143
+			$error_msg .= '||'
2144
+						  . sprintf(
2145
+							  esc_html__(
2146
+								  '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.',
2147
+								  'event_espresso'
2148
+							  ),
2149
+							  $this->_req_action,
2150
+							  $list_table_view
2151
+						  );
2152
+			throw new EE_Error($error_msg);
2153
+		}
2154
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2155
+		$this->_views = apply_filters(
2156
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2157
+			$this->_views
2158
+		);
2159
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2160
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2161
+		$this->_set_list_table_view();
2162
+		$this->_set_list_table_object();
2163
+	}
2164
+
2165
+
2166
+	/**
2167
+	 * set current view for List Table
2168
+	 *
2169
+	 * @return void
2170
+	 */
2171
+	protected function _set_list_table_view()
2172
+	{
2173
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2174
+		$status = $this->request->getRequestParam('status', null, 'key');
2175
+		$this->_view = $status && array_key_exists($status, $this->_views)
2176
+			? $status
2177
+			: $this->_view;
2178
+	}
2179
+
2180
+
2181
+	/**
2182
+	 * _set_list_table_object
2183
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2184
+	 *
2185
+	 * @throws InvalidInterfaceException
2186
+	 * @throws InvalidArgumentException
2187
+	 * @throws InvalidDataTypeException
2188
+	 * @throws EE_Error
2189
+	 * @throws InvalidInterfaceException
2190
+	 */
2191
+	protected function _set_list_table_object()
2192
+	{
2193
+		if (isset($this->_route_config['list_table'])) {
2194
+			if (! class_exists($this->_route_config['list_table'])) {
2195
+				throw new EE_Error(
2196
+					sprintf(
2197
+						esc_html__(
2198
+							'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.',
2199
+							'event_espresso'
2200
+						),
2201
+						$this->_route_config['list_table'],
2202
+						get_class($this)
2203
+					)
2204
+				);
2205
+			}
2206
+			$this->_list_table_object = $this->loader->getShared(
2207
+				$this->_route_config['list_table'],
2208
+				[$this]
2209
+			);
2210
+		}
2211
+	}
2212
+
2213
+
2214
+	/**
2215
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2216
+	 *
2217
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2218
+	 *                                                    urls.  The array should be indexed by the view it is being
2219
+	 *                                                    added to.
2220
+	 * @return array
2221
+	 */
2222
+	public function get_list_table_view_RLs($extra_query_args = [])
2223
+	{
2224
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2225
+		if (empty($this->_views)) {
2226
+			$this->_views = [];
2227
+		}
2228
+		// cycle thru views
2229
+		foreach ($this->_views as $key => $view) {
2230
+			$query_args = [];
2231
+			// check for current view
2232
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2233
+			$query_args['action']                        = $this->_req_action;
2234
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2235
+			$query_args['status']                        = $view['slug'];
2236
+			// merge any other arguments sent in.
2237
+			if (isset($extra_query_args[ $view['slug'] ])) {
2238
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2239
+			}
2240
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2241
+		}
2242
+		return $this->_views;
2243
+	}
2244
+
2245
+
2246
+	/**
2247
+	 * _entries_per_page_dropdown
2248
+	 * generates a dropdown box for selecting the number of visible rows in an admin page list table
2249
+	 *
2250
+	 * @param int $max_entries total number of rows in the table
2251
+	 * @return string
2252
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2253
+	 *         WP does it.
2254
+	 */
2255
+	protected function _entries_per_page_dropdown($max_entries = 0)
2256
+	{
2257
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2258
+		$values   = [10, 25, 50, 100];
2259
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2260
+		if ($max_entries) {
2261
+			$values[] = $max_entries;
2262
+			sort($values);
2263
+		}
2264
+		$entries_per_page_dropdown = '
2265 2265
 			<div id="entries-per-page-dv" class="alignleft actions">
2266 2266
 				<label class="hide-if-no-js">
2267 2267
 					Show
2268 2268
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2269
-        foreach ($values as $value) {
2270
-            if ($value < $max_entries) {
2271
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2272
-                $entries_per_page_dropdown .= '
2269
+		foreach ($values as $value) {
2270
+			if ($value < $max_entries) {
2271
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2272
+				$entries_per_page_dropdown .= '
2273 2273
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2274
-            }
2275
-        }
2276
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2277
-        $entries_per_page_dropdown .= '
2274
+			}
2275
+		}
2276
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2277
+		$entries_per_page_dropdown .= '
2278 2278
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2279
-        $entries_per_page_dropdown .= '
2279
+		$entries_per_page_dropdown .= '
2280 2280
 					</select>
2281 2281
 					entries
2282 2282
 				</label>
2283 2283
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2284 2284
 			</div>
2285 2285
 		';
2286
-        return $entries_per_page_dropdown;
2287
-    }
2288
-
2289
-
2290
-    /**
2291
-     *        _set_search_attributes
2292
-     *
2293
-     * @return        void
2294
-     */
2295
-    public function _set_search_attributes()
2296
-    {
2297
-        $this->_template_args['search']['btn_label'] = sprintf(
2298
-            esc_html__('Search %s', 'event_espresso'),
2299
-            empty($this->_search_btn_label) ? $this->page_label
2300
-                : $this->_search_btn_label
2301
-        );
2302
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2303
-    }
2304
-
2305
-
2306
-
2307
-    /*** END LIST TABLE METHODS **/
2308
-
2309
-
2310
-    /**
2311
-     * _add_registered_metaboxes
2312
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2313
-     *
2314
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2315
-     * @return void
2316
-     * @throws EE_Error
2317
-     */
2318
-    private function _add_registered_meta_boxes()
2319
-    {
2320
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2321
-        // we only add meta boxes if the page_route calls for it
2322
-        if (
2323
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2324
-            && is_array(
2325
-                $this->_route_config['metaboxes']
2326
-            )
2327
-        ) {
2328
-            // this simply loops through the callbacks provided
2329
-            // and checks if there is a corresponding callback registered by the child
2330
-            // if there is then we go ahead and process the metabox loader.
2331
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2332
-                // first check for Closures
2333
-                if ($metabox_callback instanceof Closure) {
2334
-                    $result = $metabox_callback();
2335
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2336
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2337
-                } else {
2338
-                    $result = call_user_func([$this, &$metabox_callback]);
2339
-                }
2340
-                if ($result === false) {
2341
-                    // user error msg
2342
-                    $error_msg = esc_html__(
2343
-                        'An error occurred. The  requested metabox could not be found.',
2344
-                        'event_espresso'
2345
-                    );
2346
-                    // developer error msg
2347
-                    $error_msg .= '||'
2348
-                                  . sprintf(
2349
-                                      esc_html__(
2350
-                                          '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.',
2351
-                                          'event_espresso'
2352
-                                      ),
2353
-                                      $metabox_callback
2354
-                                  );
2355
-                    throw new EE_Error($error_msg);
2356
-                }
2357
-            }
2358
-        }
2359
-    }
2360
-
2361
-
2362
-    /**
2363
-     * _add_screen_columns
2364
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2365
-     * the dynamic column template and we'll setup the column options for the page.
2366
-     *
2367
-     * @return void
2368
-     */
2369
-    private function _add_screen_columns()
2370
-    {
2371
-        if (
2372
-            is_array($this->_route_config)
2373
-            && isset($this->_route_config['columns'])
2374
-            && is_array($this->_route_config['columns'])
2375
-            && count($this->_route_config['columns']) === 2
2376
-        ) {
2377
-            add_screen_option(
2378
-                'layout_columns',
2379
-                [
2380
-                    'max'     => (int) $this->_route_config['columns'][0],
2381
-                    'default' => (int) $this->_route_config['columns'][1],
2382
-                ]
2383
-            );
2384
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2385
-            $screen_id                                           = $this->_current_screen->id;
2386
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2387
-            $total_columns                                       = ! empty($screen_columns)
2388
-                ? $screen_columns
2389
-                : $this->_route_config['columns'][1];
2390
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2391
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2392
-            $this->_template_args['screen']                      = $this->_current_screen;
2393
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2394
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2395
-            // finally if we don't have has_metaboxes set in the route config
2396
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2397
-            $this->_route_config['has_metaboxes'] = true;
2398
-        }
2399
-    }
2400
-
2401
-
2402
-
2403
-    /** GLOBALLY AVAILABLE METABOXES **/
2404
-
2405
-
2406
-    /**
2407
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2408
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2409
-     * these get loaded on.
2410
-     */
2411
-    private function _espresso_news_post_box()
2412
-    {
2413
-        $news_box_title = apply_filters(
2414
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2415
-            esc_html__('New @ Event Espresso', 'event_espresso')
2416
-        );
2417
-        add_meta_box(
2418
-            'espresso_news_post_box',
2419
-            $news_box_title,
2420
-            [
2421
-                $this,
2422
-                'espresso_news_post_box',
2423
-            ],
2424
-            $this->_wp_page_slug,
2425
-            'side'
2426
-        );
2427
-    }
2428
-
2429
-
2430
-    /**
2431
-     * Code for setting up espresso ratings request metabox.
2432
-     */
2433
-    protected function _espresso_ratings_request()
2434
-    {
2435
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2436
-            return;
2437
-        }
2438
-        $ratings_box_title = apply_filters(
2439
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2440
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2441
-        );
2442
-        add_meta_box(
2443
-            'espresso_ratings_request',
2444
-            $ratings_box_title,
2445
-            [
2446
-                $this,
2447
-                'espresso_ratings_request',
2448
-            ],
2449
-            $this->_wp_page_slug,
2450
-            'side'
2451
-        );
2452
-    }
2453
-
2454
-
2455
-    /**
2456
-     * Code for setting up espresso ratings request metabox content.
2457
-     *
2458
-     * @throws DomainException
2459
-     */
2460
-    public function espresso_ratings_request()
2461
-    {
2462
-        EEH_Template::display_template(
2463
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2464
-            []
2465
-        );
2466
-    }
2467
-
2468
-
2469
-    public static function cached_rss_display($rss_id, $url)
2470
-    {
2471
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2472
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2473
-                     . '</p><p class="hide-if-js">'
2474
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2475
-                     . '</p>';
2476
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2477
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2478
-        $post      = '</div>' . "\n";
2479
-        $cache_key = 'ee_rss_' . md5($rss_id);
2480
-        $output    = get_transient($cache_key);
2481
-        if ($output !== false) {
2482
-            echo $pre . $output . $post; // already escaped
2483
-            return true;
2484
-        }
2485
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2486
-            echo $pre . $loading . $post; // already escaped
2487
-            return false;
2488
-        }
2489
-        ob_start();
2490
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2491
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2492
-        return true;
2493
-    }
2494
-
2495
-
2496
-    public function espresso_news_post_box()
2497
-    {
2498
-        ?>
2286
+		return $entries_per_page_dropdown;
2287
+	}
2288
+
2289
+
2290
+	/**
2291
+	 *        _set_search_attributes
2292
+	 *
2293
+	 * @return        void
2294
+	 */
2295
+	public function _set_search_attributes()
2296
+	{
2297
+		$this->_template_args['search']['btn_label'] = sprintf(
2298
+			esc_html__('Search %s', 'event_espresso'),
2299
+			empty($this->_search_btn_label) ? $this->page_label
2300
+				: $this->_search_btn_label
2301
+		);
2302
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2303
+	}
2304
+
2305
+
2306
+
2307
+	/*** END LIST TABLE METHODS **/
2308
+
2309
+
2310
+	/**
2311
+	 * _add_registered_metaboxes
2312
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2313
+	 *
2314
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2315
+	 * @return void
2316
+	 * @throws EE_Error
2317
+	 */
2318
+	private function _add_registered_meta_boxes()
2319
+	{
2320
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2321
+		// we only add meta boxes if the page_route calls for it
2322
+		if (
2323
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2324
+			&& is_array(
2325
+				$this->_route_config['metaboxes']
2326
+			)
2327
+		) {
2328
+			// this simply loops through the callbacks provided
2329
+			// and checks if there is a corresponding callback registered by the child
2330
+			// if there is then we go ahead and process the metabox loader.
2331
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2332
+				// first check for Closures
2333
+				if ($metabox_callback instanceof Closure) {
2334
+					$result = $metabox_callback();
2335
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2336
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2337
+				} else {
2338
+					$result = call_user_func([$this, &$metabox_callback]);
2339
+				}
2340
+				if ($result === false) {
2341
+					// user error msg
2342
+					$error_msg = esc_html__(
2343
+						'An error occurred. The  requested metabox could not be found.',
2344
+						'event_espresso'
2345
+					);
2346
+					// developer error msg
2347
+					$error_msg .= '||'
2348
+								  . sprintf(
2349
+									  esc_html__(
2350
+										  '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.',
2351
+										  'event_espresso'
2352
+									  ),
2353
+									  $metabox_callback
2354
+								  );
2355
+					throw new EE_Error($error_msg);
2356
+				}
2357
+			}
2358
+		}
2359
+	}
2360
+
2361
+
2362
+	/**
2363
+	 * _add_screen_columns
2364
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2365
+	 * the dynamic column template and we'll setup the column options for the page.
2366
+	 *
2367
+	 * @return void
2368
+	 */
2369
+	private function _add_screen_columns()
2370
+	{
2371
+		if (
2372
+			is_array($this->_route_config)
2373
+			&& isset($this->_route_config['columns'])
2374
+			&& is_array($this->_route_config['columns'])
2375
+			&& count($this->_route_config['columns']) === 2
2376
+		) {
2377
+			add_screen_option(
2378
+				'layout_columns',
2379
+				[
2380
+					'max'     => (int) $this->_route_config['columns'][0],
2381
+					'default' => (int) $this->_route_config['columns'][1],
2382
+				]
2383
+			);
2384
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2385
+			$screen_id                                           = $this->_current_screen->id;
2386
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2387
+			$total_columns                                       = ! empty($screen_columns)
2388
+				? $screen_columns
2389
+				: $this->_route_config['columns'][1];
2390
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2391
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2392
+			$this->_template_args['screen']                      = $this->_current_screen;
2393
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2394
+																   . 'admin_details_metabox_column_wrapper.template.php';
2395
+			// finally if we don't have has_metaboxes set in the route config
2396
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2397
+			$this->_route_config['has_metaboxes'] = true;
2398
+		}
2399
+	}
2400
+
2401
+
2402
+
2403
+	/** GLOBALLY AVAILABLE METABOXES **/
2404
+
2405
+
2406
+	/**
2407
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2408
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2409
+	 * these get loaded on.
2410
+	 */
2411
+	private function _espresso_news_post_box()
2412
+	{
2413
+		$news_box_title = apply_filters(
2414
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2415
+			esc_html__('New @ Event Espresso', 'event_espresso')
2416
+		);
2417
+		add_meta_box(
2418
+			'espresso_news_post_box',
2419
+			$news_box_title,
2420
+			[
2421
+				$this,
2422
+				'espresso_news_post_box',
2423
+			],
2424
+			$this->_wp_page_slug,
2425
+			'side'
2426
+		);
2427
+	}
2428
+
2429
+
2430
+	/**
2431
+	 * Code for setting up espresso ratings request metabox.
2432
+	 */
2433
+	protected function _espresso_ratings_request()
2434
+	{
2435
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2436
+			return;
2437
+		}
2438
+		$ratings_box_title = apply_filters(
2439
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2440
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2441
+		);
2442
+		add_meta_box(
2443
+			'espresso_ratings_request',
2444
+			$ratings_box_title,
2445
+			[
2446
+				$this,
2447
+				'espresso_ratings_request',
2448
+			],
2449
+			$this->_wp_page_slug,
2450
+			'side'
2451
+		);
2452
+	}
2453
+
2454
+
2455
+	/**
2456
+	 * Code for setting up espresso ratings request metabox content.
2457
+	 *
2458
+	 * @throws DomainException
2459
+	 */
2460
+	public function espresso_ratings_request()
2461
+	{
2462
+		EEH_Template::display_template(
2463
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2464
+			[]
2465
+		);
2466
+	}
2467
+
2468
+
2469
+	public static function cached_rss_display($rss_id, $url)
2470
+	{
2471
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2472
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2473
+					 . '</p><p class="hide-if-js">'
2474
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2475
+					 . '</p>';
2476
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2477
+		$pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2478
+		$post      = '</div>' . "\n";
2479
+		$cache_key = 'ee_rss_' . md5($rss_id);
2480
+		$output    = get_transient($cache_key);
2481
+		if ($output !== false) {
2482
+			echo $pre . $output . $post; // already escaped
2483
+			return true;
2484
+		}
2485
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2486
+			echo $pre . $loading . $post; // already escaped
2487
+			return false;
2488
+		}
2489
+		ob_start();
2490
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2491
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2492
+		return true;
2493
+	}
2494
+
2495
+
2496
+	public function espresso_news_post_box()
2497
+	{
2498
+		?>
2499 2499
         <div class="padding">
2500 2500
             <div id="espresso_news_post_box_content" class="infolinks">
2501 2501
                 <?php
2502
-                // Get RSS Feed(s)
2503
-                self::cached_rss_display(
2504
-                    'espresso_news_post_box_content',
2505
-                    esc_url_raw(
2506
-                        apply_filters(
2507
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2508
-                            'https://eventespresso.com/feed/'
2509
-                        )
2510
-                    )
2511
-                );
2512
-                ?>
2502
+				// Get RSS Feed(s)
2503
+				self::cached_rss_display(
2504
+					'espresso_news_post_box_content',
2505
+					esc_url_raw(
2506
+						apply_filters(
2507
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2508
+							'https://eventespresso.com/feed/'
2509
+						)
2510
+					)
2511
+				);
2512
+				?>
2513 2513
             </div>
2514 2514
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2515 2515
         </div>
2516 2516
         <?php
2517
-    }
2518
-
2519
-
2520
-    private function _espresso_links_post_box()
2521
-    {
2522
-        // Hiding until we actually have content to put in here...
2523
-        // 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');
2524
-    }
2525
-
2526
-
2527
-    public function espresso_links_post_box()
2528
-    {
2529
-        // Hiding until we actually have content to put in here...
2530
-        // EEH_Template::display_template(
2531
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2532
-        // );
2533
-    }
2534
-
2535
-
2536
-    protected function _espresso_sponsors_post_box()
2537
-    {
2538
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2539
-            add_meta_box(
2540
-                'espresso_sponsors_post_box',
2541
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2542
-                [$this, 'espresso_sponsors_post_box'],
2543
-                $this->_wp_page_slug,
2544
-                'side'
2545
-            );
2546
-        }
2547
-    }
2548
-
2549
-
2550
-    public function espresso_sponsors_post_box()
2551
-    {
2552
-        EEH_Template::display_template(
2553
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2554
-        );
2555
-    }
2556
-
2557
-
2558
-    private function _publish_post_box()
2559
-    {
2560
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2561
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2562
-        // then we'll use that for the metabox label.
2563
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2564
-        if (! empty($this->_labels['publishbox'])) {
2565
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2566
-                : $this->_labels['publishbox'];
2567
-        } else {
2568
-            $box_label = esc_html__('Publish', 'event_espresso');
2569
-        }
2570
-        $box_label = apply_filters(
2571
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2572
-            $box_label,
2573
-            $this->_req_action,
2574
-            $this
2575
-        );
2576
-        add_meta_box(
2577
-            $meta_box_ref,
2578
-            $box_label,
2579
-            [$this, 'editor_overview'],
2580
-            $this->_current_screen->id,
2581
-            'side',
2582
-            'high'
2583
-        );
2584
-    }
2585
-
2586
-
2587
-    public function editor_overview()
2588
-    {
2589
-        // if we have extra content set let's add it in if not make sure its empty
2590
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2591
-            ? $this->_template_args['publish_box_extra_content']
2592
-            : '';
2593
-        echo EEH_Template::display_template(
2594
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2595
-            $this->_template_args,
2596
-            true
2597
-        );
2598
-    }
2599
-
2600
-
2601
-    /** end of globally available metaboxes section **/
2602
-
2603
-
2604
-    /**
2605
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2606
-     * protected method.
2607
-     *
2608
-     * @param string $name
2609
-     * @param int    $id
2610
-     * @param bool   $delete
2611
-     * @param string $save_close_redirect_URL
2612
-     * @param bool   $both_btns
2613
-     * @throws EE_Error
2614
-     * @throws InvalidArgumentException
2615
-     * @throws InvalidDataTypeException
2616
-     * @throws InvalidInterfaceException
2617
-     * @see   $this->_set_publish_post_box_vars for param details
2618
-     * @since 4.6.0
2619
-     */
2620
-    public function set_publish_post_box_vars(
2621
-        $name = '',
2622
-        $id = 0,
2623
-        $delete = false,
2624
-        $save_close_redirect_URL = '',
2625
-        $both_btns = true
2626
-    ) {
2627
-        $this->_set_publish_post_box_vars(
2628
-            $name,
2629
-            $id,
2630
-            $delete,
2631
-            $save_close_redirect_URL,
2632
-            $both_btns
2633
-        );
2634
-    }
2635
-
2636
-
2637
-    /**
2638
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2639
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2640
-     * save, and save and close buttons to work properly, then you will want to include a
2641
-     * values for the name and id arguments.
2642
-     *
2643
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2644
-     * @param int     $id                         id attached to the item published
2645
-     * @param string  $delete                     page route callback for the delete action
2646
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2647
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2648
-     *                                            the Save button
2649
-     * @throws EE_Error
2650
-     * @throws InvalidArgumentException
2651
-     * @throws InvalidDataTypeException
2652
-     * @throws InvalidInterfaceException
2653
-     * @todo  Add in validation for name/id arguments.
2654
-     */
2655
-    protected function _set_publish_post_box_vars(
2656
-        $name = '',
2657
-        $id = 0,
2658
-        $delete = '',
2659
-        $save_close_redirect_URL = '',
2660
-        $both_btns = true
2661
-    ) {
2662
-        // if Save & Close, use a custom redirect URL or default to the main page?
2663
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2664
-            ? $save_close_redirect_URL
2665
-            : $this->_admin_base_url;
2666
-        // create the Save & Close and Save buttons
2667
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2668
-        // if we have extra content set let's add it in if not make sure its empty
2669
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2670
-            ? $this->_template_args['publish_box_extra_content']
2671
-            : '';
2672
-        if ($delete && ! empty($id)) {
2673
-            // make sure we have a default if just true is sent.
2674
-            $delete           = ! empty($delete) ? $delete : 'delete';
2675
-            $delete_link_args = [$name => $id];
2676
-            $delete           = $this->get_action_link_or_button(
2677
-                $delete,
2678
-                $delete,
2679
-                $delete_link_args,
2680
-                'submitdelete deletion',
2681
-                '',
2682
-                false
2683
-            );
2684
-        }
2685
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2686
-        if (! empty($name) && ! empty($id)) {
2687
-            $hidden_field_arr[ $name ] = [
2688
-                'type'  => 'hidden',
2689
-                'value' => $id,
2690
-            ];
2691
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2692
-        } else {
2693
-            $hf = '';
2694
-        }
2695
-        // add hidden field
2696
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2697
-            ? $hf[ $name ]['field']
2698
-            : $hf;
2699
-    }
2700
-
2701
-
2702
-    /**
2703
-     * displays an error message to ppl who have javascript disabled
2704
-     *
2705
-     * @return void
2706
-     */
2707
-    private function _display_no_javascript_warning()
2708
-    {
2709
-        ?>
2517
+	}
2518
+
2519
+
2520
+	private function _espresso_links_post_box()
2521
+	{
2522
+		// Hiding until we actually have content to put in here...
2523
+		// 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');
2524
+	}
2525
+
2526
+
2527
+	public function espresso_links_post_box()
2528
+	{
2529
+		// Hiding until we actually have content to put in here...
2530
+		// EEH_Template::display_template(
2531
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2532
+		// );
2533
+	}
2534
+
2535
+
2536
+	protected function _espresso_sponsors_post_box()
2537
+	{
2538
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2539
+			add_meta_box(
2540
+				'espresso_sponsors_post_box',
2541
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2542
+				[$this, 'espresso_sponsors_post_box'],
2543
+				$this->_wp_page_slug,
2544
+				'side'
2545
+			);
2546
+		}
2547
+	}
2548
+
2549
+
2550
+	public function espresso_sponsors_post_box()
2551
+	{
2552
+		EEH_Template::display_template(
2553
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2554
+		);
2555
+	}
2556
+
2557
+
2558
+	private function _publish_post_box()
2559
+	{
2560
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2561
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2562
+		// then we'll use that for the metabox label.
2563
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2564
+		if (! empty($this->_labels['publishbox'])) {
2565
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2566
+				: $this->_labels['publishbox'];
2567
+		} else {
2568
+			$box_label = esc_html__('Publish', 'event_espresso');
2569
+		}
2570
+		$box_label = apply_filters(
2571
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2572
+			$box_label,
2573
+			$this->_req_action,
2574
+			$this
2575
+		);
2576
+		add_meta_box(
2577
+			$meta_box_ref,
2578
+			$box_label,
2579
+			[$this, 'editor_overview'],
2580
+			$this->_current_screen->id,
2581
+			'side',
2582
+			'high'
2583
+		);
2584
+	}
2585
+
2586
+
2587
+	public function editor_overview()
2588
+	{
2589
+		// if we have extra content set let's add it in if not make sure its empty
2590
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2591
+			? $this->_template_args['publish_box_extra_content']
2592
+			: '';
2593
+		echo EEH_Template::display_template(
2594
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2595
+			$this->_template_args,
2596
+			true
2597
+		);
2598
+	}
2599
+
2600
+
2601
+	/** end of globally available metaboxes section **/
2602
+
2603
+
2604
+	/**
2605
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2606
+	 * protected method.
2607
+	 *
2608
+	 * @param string $name
2609
+	 * @param int    $id
2610
+	 * @param bool   $delete
2611
+	 * @param string $save_close_redirect_URL
2612
+	 * @param bool   $both_btns
2613
+	 * @throws EE_Error
2614
+	 * @throws InvalidArgumentException
2615
+	 * @throws InvalidDataTypeException
2616
+	 * @throws InvalidInterfaceException
2617
+	 * @see   $this->_set_publish_post_box_vars for param details
2618
+	 * @since 4.6.0
2619
+	 */
2620
+	public function set_publish_post_box_vars(
2621
+		$name = '',
2622
+		$id = 0,
2623
+		$delete = false,
2624
+		$save_close_redirect_URL = '',
2625
+		$both_btns = true
2626
+	) {
2627
+		$this->_set_publish_post_box_vars(
2628
+			$name,
2629
+			$id,
2630
+			$delete,
2631
+			$save_close_redirect_URL,
2632
+			$both_btns
2633
+		);
2634
+	}
2635
+
2636
+
2637
+	/**
2638
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2639
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2640
+	 * save, and save and close buttons to work properly, then you will want to include a
2641
+	 * values for the name and id arguments.
2642
+	 *
2643
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2644
+	 * @param int     $id                         id attached to the item published
2645
+	 * @param string  $delete                     page route callback for the delete action
2646
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2647
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2648
+	 *                                            the Save button
2649
+	 * @throws EE_Error
2650
+	 * @throws InvalidArgumentException
2651
+	 * @throws InvalidDataTypeException
2652
+	 * @throws InvalidInterfaceException
2653
+	 * @todo  Add in validation for name/id arguments.
2654
+	 */
2655
+	protected function _set_publish_post_box_vars(
2656
+		$name = '',
2657
+		$id = 0,
2658
+		$delete = '',
2659
+		$save_close_redirect_URL = '',
2660
+		$both_btns = true
2661
+	) {
2662
+		// if Save & Close, use a custom redirect URL or default to the main page?
2663
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2664
+			? $save_close_redirect_URL
2665
+			: $this->_admin_base_url;
2666
+		// create the Save & Close and Save buttons
2667
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2668
+		// if we have extra content set let's add it in if not make sure its empty
2669
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2670
+			? $this->_template_args['publish_box_extra_content']
2671
+			: '';
2672
+		if ($delete && ! empty($id)) {
2673
+			// make sure we have a default if just true is sent.
2674
+			$delete           = ! empty($delete) ? $delete : 'delete';
2675
+			$delete_link_args = [$name => $id];
2676
+			$delete           = $this->get_action_link_or_button(
2677
+				$delete,
2678
+				$delete,
2679
+				$delete_link_args,
2680
+				'submitdelete deletion',
2681
+				'',
2682
+				false
2683
+			);
2684
+		}
2685
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2686
+		if (! empty($name) && ! empty($id)) {
2687
+			$hidden_field_arr[ $name ] = [
2688
+				'type'  => 'hidden',
2689
+				'value' => $id,
2690
+			];
2691
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2692
+		} else {
2693
+			$hf = '';
2694
+		}
2695
+		// add hidden field
2696
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2697
+			? $hf[ $name ]['field']
2698
+			: $hf;
2699
+	}
2700
+
2701
+
2702
+	/**
2703
+	 * displays an error message to ppl who have javascript disabled
2704
+	 *
2705
+	 * @return void
2706
+	 */
2707
+	private function _display_no_javascript_warning()
2708
+	{
2709
+		?>
2710 2710
         <noscript>
2711 2711
             <div id="no-js-message" class="error">
2712 2712
                 <p style="font-size:1.3em;">
2713 2713
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2714 2714
                     <?php esc_html_e(
2715
-                        '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.',
2716
-                        'event_espresso'
2717
-                    ); ?>
2715
+						'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.',
2716
+						'event_espresso'
2717
+					); ?>
2718 2718
                 </p>
2719 2719
             </div>
2720 2720
         </noscript>
2721 2721
         <?php
2722
-    }
2723
-
2724
-
2725
-    /**
2726
-     * displays espresso success and/or error notices
2727
-     *
2728
-     * @return void
2729
-     */
2730
-    protected function _display_espresso_notices()
2731
-    {
2732
-        $notices = $this->_get_transient(true);
2733
-        echo stripslashes($notices);
2734
-    }
2735
-
2736
-
2737
-    /**
2738
-     * spinny things pacify the masses
2739
-     *
2740
-     * @return void
2741
-     */
2742
-    protected function _add_admin_page_ajax_loading_img()
2743
-    {
2744
-        ?>
2722
+	}
2723
+
2724
+
2725
+	/**
2726
+	 * displays espresso success and/or error notices
2727
+	 *
2728
+	 * @return void
2729
+	 */
2730
+	protected function _display_espresso_notices()
2731
+	{
2732
+		$notices = $this->_get_transient(true);
2733
+		echo stripslashes($notices);
2734
+	}
2735
+
2736
+
2737
+	/**
2738
+	 * spinny things pacify the masses
2739
+	 *
2740
+	 * @return void
2741
+	 */
2742
+	protected function _add_admin_page_ajax_loading_img()
2743
+	{
2744
+		?>
2745 2745
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2746 2746
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2747
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2747
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2748 2748
         </div>
2749 2749
         <?php
2750
-    }
2750
+	}
2751 2751
 
2752 2752
 
2753
-    /**
2754
-     * add admin page overlay for modal boxes
2755
-     *
2756
-     * @return void
2757
-     */
2758
-    protected function _add_admin_page_overlay()
2759
-    {
2760
-        ?>
2753
+	/**
2754
+	 * add admin page overlay for modal boxes
2755
+	 *
2756
+	 * @return void
2757
+	 */
2758
+	protected function _add_admin_page_overlay()
2759
+	{
2760
+		?>
2761 2761
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2762 2762
         <?php
2763
-    }
2764
-
2765
-
2766
-    /**
2767
-     * facade for add_meta_box
2768
-     *
2769
-     * @param string  $action        where the metabox gets displayed
2770
-     * @param string  $title         Title of Metabox (output in metabox header)
2771
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2772
-     *                               instead of the one created in here.
2773
-     * @param array   $callback_args an array of args supplied for the metabox
2774
-     * @param string  $column        what metabox column
2775
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2776
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2777
-     *                               created but just set our own callback for wp's add_meta_box.
2778
-     * @throws DomainException
2779
-     */
2780
-    public function _add_admin_page_meta_box(
2781
-        $action,
2782
-        $title,
2783
-        $callback,
2784
-        $callback_args,
2785
-        $column = 'normal',
2786
-        $priority = 'high',
2787
-        $create_func = true
2788
-    ) {
2789
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2790
-        // 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.
2791
-        if (empty($callback_args) && $create_func) {
2792
-            $callback_args = [
2793
-                'template_path' => $this->_template_path,
2794
-                'template_args' => $this->_template_args,
2795
-            ];
2796
-        }
2797
-        // 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)
2798
-        $call_back_func = $create_func
2799
-            ? function ($post, $metabox) {
2800
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2801
-                echo EEH_Template::display_template(
2802
-                    $metabox['args']['template_path'],
2803
-                    $metabox['args']['template_args'],
2804
-                    true
2805
-                );
2806
-            }
2807
-            : $callback;
2808
-        add_meta_box(
2809
-            str_replace('_', '-', $action) . '-mbox',
2810
-            $title,
2811
-            $call_back_func,
2812
-            $this->_wp_page_slug,
2813
-            $column,
2814
-            $priority,
2815
-            $callback_args
2816
-        );
2817
-    }
2818
-
2819
-
2820
-    /**
2821
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2822
-     *
2823
-     * @throws DomainException
2824
-     * @throws EE_Error
2825
-     */
2826
-    public function display_admin_page_with_metabox_columns()
2827
-    {
2828
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2829
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2830
-            $this->_column_template_path,
2831
-            $this->_template_args,
2832
-            true
2833
-        );
2834
-        // the final wrapper
2835
-        $this->admin_page_wrapper();
2836
-    }
2837
-
2838
-
2839
-    /**
2840
-     * generates  HTML wrapper for an admin details page
2841
-     *
2842
-     * @return void
2843
-     * @throws EE_Error
2844
-     * @throws DomainException
2845
-     */
2846
-    public function display_admin_page_with_sidebar()
2847
-    {
2848
-        $this->_display_admin_page(true);
2849
-    }
2850
-
2851
-
2852
-    /**
2853
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2854
-     *
2855
-     * @return void
2856
-     * @throws EE_Error
2857
-     * @throws DomainException
2858
-     */
2859
-    public function display_admin_page_with_no_sidebar()
2860
-    {
2861
-        $this->_display_admin_page();
2862
-    }
2863
-
2864
-
2865
-    /**
2866
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2867
-     *
2868
-     * @return void
2869
-     * @throws EE_Error
2870
-     * @throws DomainException
2871
-     */
2872
-    public function display_about_admin_page()
2873
-    {
2874
-        $this->_display_admin_page(false, true);
2875
-    }
2876
-
2877
-
2878
-    /**
2879
-     * display_admin_page
2880
-     * contains the code for actually displaying an admin page
2881
-     *
2882
-     * @param boolean $sidebar true with sidebar, false without
2883
-     * @param boolean $about   use the about_admin_wrapper instead of the default.
2884
-     * @return void
2885
-     * @throws DomainException
2886
-     * @throws EE_Error
2887
-     */
2888
-    private function _display_admin_page($sidebar = false, $about = false)
2889
-    {
2890
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2891
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2892
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2893
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2894
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2895
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2896
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2897
-            ? 'poststuff'
2898
-            : 'espresso-default-admin';
2899
-        $template_path                                     = $sidebar
2900
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2901
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2902
-        if ($this->request->isAjax()) {
2903
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2904
-        }
2905
-        $template_path                                     = ! empty($this->_column_template_path)
2906
-            ? $this->_column_template_path : $template_path;
2907
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2908
-            ? $this->_template_args['admin_page_content']
2909
-            : '';
2910
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2911
-            ? $this->_template_args['before_admin_page_content']
2912
-            : '';
2913
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2914
-            ? $this->_template_args['after_admin_page_content']
2915
-            : '';
2916
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2917
-            $template_path,
2918
-            $this->_template_args,
2919
-            true
2920
-        );
2921
-        // the final template wrapper
2922
-        $this->admin_page_wrapper($about);
2923
-    }
2924
-
2925
-
2926
-    /**
2927
-     * This is used to display caf preview pages.
2928
-     *
2929
-     * @param string $utm_campaign_source what is the key used for google analytics link
2930
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2931
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2932
-     * @return void
2933
-     * @throws DomainException
2934
-     * @throws EE_Error
2935
-     * @throws InvalidArgumentException
2936
-     * @throws InvalidDataTypeException
2937
-     * @throws InvalidInterfaceException
2938
-     * @since 4.3.2
2939
-     */
2940
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2941
-    {
2942
-        // let's generate a default preview action button if there isn't one already present.
2943
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2944
-            'Upgrade to Event Espresso 4 Right Now',
2945
-            'event_espresso'
2946
-        );
2947
-        $buy_now_url                                   = add_query_arg(
2948
-            [
2949
-                'ee_ver'       => 'ee4',
2950
-                'utm_source'   => 'ee4_plugin_admin',
2951
-                'utm_medium'   => 'link',
2952
-                'utm_campaign' => $utm_campaign_source,
2953
-                'utm_content'  => 'buy_now_button',
2954
-            ],
2955
-            'https://eventespresso.com/pricing/'
2956
-        );
2957
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2958
-            ? $this->get_action_link_or_button(
2959
-                '',
2960
-                'buy_now',
2961
-                [],
2962
-                'button-primary button-large',
2963
-                esc_url_raw($buy_now_url),
2964
-                true
2965
-            )
2966
-            : $this->_template_args['preview_action_button'];
2967
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2968
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2969
-            $this->_template_args,
2970
-            true
2971
-        );
2972
-        $this->_display_admin_page($display_sidebar);
2973
-    }
2974
-
2975
-
2976
-    /**
2977
-     * display_admin_list_table_page_with_sidebar
2978
-     * generates HTML wrapper for an admin_page with list_table
2979
-     *
2980
-     * @return void
2981
-     * @throws EE_Error
2982
-     * @throws DomainException
2983
-     */
2984
-    public function display_admin_list_table_page_with_sidebar()
2985
-    {
2986
-        $this->_display_admin_list_table_page(true);
2987
-    }
2988
-
2989
-
2990
-    /**
2991
-     * display_admin_list_table_page_with_no_sidebar
2992
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2993
-     *
2994
-     * @return void
2995
-     * @throws EE_Error
2996
-     * @throws DomainException
2997
-     */
2998
-    public function display_admin_list_table_page_with_no_sidebar()
2999
-    {
3000
-        $this->_display_admin_list_table_page();
3001
-    }
3002
-
3003
-
3004
-    /**
3005
-     * generates html wrapper for an admin_list_table page
3006
-     *
3007
-     * @param boolean $sidebar whether to display with sidebar or not.
3008
-     * @return void
3009
-     * @throws DomainException
3010
-     * @throws EE_Error
3011
-     */
3012
-    private function _display_admin_list_table_page($sidebar = false)
3013
-    {
3014
-        // setup search attributes
3015
-        $this->_set_search_attributes();
3016
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
3017
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3018
-        $this->_template_args['table_url']        = $this->request->isAjax()
3019
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3020
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
3021
-        $this->_template_args['list_table']       = $this->_list_table_object;
3022
-        $this->_template_args['current_route']    = $this->_req_action;
3023
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3024
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3025
-        if (! empty($ajax_sorting_callback)) {
3026
-            $sortable_list_table_form_fields = wp_nonce_field(
3027
-                $ajax_sorting_callback . '_nonce',
3028
-                $ajax_sorting_callback . '_nonce',
3029
-                false,
3030
-                false
3031
-            );
3032
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3033
-                                                . $this->page_slug
3034
-                                                . '" />';
3035
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3036
-                                                . $ajax_sorting_callback
3037
-                                                . '" />';
3038
-        } else {
3039
-            $sortable_list_table_form_fields = '';
3040
-        }
3041
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3042
-        $hidden_form_fields                                      =
3043
-            isset($this->_template_args['list_table_hidden_fields'])
3044
-                ? $this->_template_args['list_table_hidden_fields']
3045
-                : '';
3046
-        $nonce_ref                                               = $this->_req_action . '_nonce';
3047
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
3048
-                                                                    . $nonce_ref
3049
-                                                                    . '" value="'
3050
-                                                                    . wp_create_nonce($nonce_ref)
3051
-                                                                    . '">';
3052
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3053
-        // display message about search results?
3054
-        $search = $this->request->getRequestParam('s');
3055
-        $this->_template_args['before_list_table'] .= ! empty($search)
3056
-            ? '<p class="ee-search-results">' . sprintf(
3057
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3058
-                trim($search, '%')
3059
-            ) . '</p>'
3060
-            : '';
3061
-        // filter before_list_table template arg
3062
-        $this->_template_args['before_list_table'] = apply_filters(
3063
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3064
-            $this->_template_args['before_list_table'],
3065
-            $this->page_slug,
3066
-            $this->request->requestParams(),
3067
-            $this->_req_action
3068
-        );
3069
-        // convert to array and filter again
3070
-        // arrays are easier to inject new items in a specific location,
3071
-        // but would not be backwards compatible, so we have to add a new filter
3072
-        $this->_template_args['before_list_table'] = implode(
3073
-            " \n",
3074
-            (array) apply_filters(
3075
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3076
-                (array) $this->_template_args['before_list_table'],
3077
-                $this->page_slug,
3078
-                $this->request->requestParams(),
3079
-                $this->_req_action
3080
-            )
3081
-        );
3082
-        // filter after_list_table template arg
3083
-        $this->_template_args['after_list_table'] = apply_filters(
3084
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3085
-            $this->_template_args['after_list_table'],
3086
-            $this->page_slug,
3087
-            $this->request->requestParams(),
3088
-            $this->_req_action
3089
-        );
3090
-        // convert to array and filter again
3091
-        // arrays are easier to inject new items in a specific location,
3092
-        // but would not be backwards compatible, so we have to add a new filter
3093
-        $this->_template_args['after_list_table']   = implode(
3094
-            " \n",
3095
-            (array) apply_filters(
3096
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3097
-                (array) $this->_template_args['after_list_table'],
3098
-                $this->page_slug,
3099
-                $this->request->requestParams(),
3100
-                $this->_req_action
3101
-            )
3102
-        );
3103
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3104
-            $template_path,
3105
-            $this->_template_args,
3106
-            true
3107
-        );
3108
-        // the final template wrapper
3109
-        if ($sidebar) {
3110
-            $this->display_admin_page_with_sidebar();
3111
-        } else {
3112
-            $this->display_admin_page_with_no_sidebar();
3113
-        }
3114
-    }
3115
-
3116
-
3117
-    /**
3118
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3119
-     * html string for the legend.
3120
-     * $items are expected in an array in the following format:
3121
-     * $legend_items = array(
3122
-     *        'item_id' => array(
3123
-     *            'icon' => 'http://url_to_icon_being_described.png',
3124
-     *            'desc' => esc_html__('localized description of item');
3125
-     *        )
3126
-     * );
3127
-     *
3128
-     * @param array $items see above for format of array
3129
-     * @return string html string of legend
3130
-     * @throws DomainException
3131
-     */
3132
-    protected function _display_legend($items)
3133
-    {
3134
-        $this->_template_args['items'] = apply_filters(
3135
-            'FHEE__EE_Admin_Page___display_legend__items',
3136
-            (array) $items,
3137
-            $this
3138
-        );
3139
-        return EEH_Template::display_template(
3140
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3141
-            $this->_template_args,
3142
-            true
3143
-        );
3144
-    }
3145
-
3146
-
3147
-    /**
3148
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3149
-     * The returned json object is created from an array in the following format:
3150
-     * array(
3151
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3152
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3153
-     *  'notices' => '', // - contains any EE_Error formatted notices
3154
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3155
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3156
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3157
-     *  that might be included in here)
3158
-     * )
3159
-     * The json object is populated by whatever is set in the $_template_args property.
3160
-     *
3161
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3162
-     *                                 instead of displayed.
3163
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3164
-     * @return void
3165
-     * @throws EE_Error
3166
-     */
3167
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
3168
-    {
3169
-        // make sure any EE_Error notices have been handled.
3170
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3171
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3172
-        unset($this->_template_args['data']);
3173
-        $json = [
3174
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3175
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3176
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3177
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3178
-            'notices'   => EE_Error::get_notices(),
3179
-            'content'   => isset($this->_template_args['admin_page_content'])
3180
-                ? $this->_template_args['admin_page_content'] : '',
3181
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3182
-            'isEEajax'  => true
3183
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3184
-        ];
3185
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3186
-        if (null === error_get_last() || ! headers_sent()) {
3187
-            header('Content-Type: application/json; charset=UTF-8');
3188
-        }
3189
-        echo wp_json_encode($json);
3190
-        exit();
3191
-    }
3192
-
3193
-
3194
-    /**
3195
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3196
-     *
3197
-     * @return void
3198
-     * @throws EE_Error
3199
-     */
3200
-    public function return_json()
3201
-    {
3202
-        if ($this->request->isAjax()) {
3203
-            $this->_return_json();
3204
-        } else {
3205
-            throw new EE_Error(
3206
-                sprintf(
3207
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3208
-                    __FUNCTION__
3209
-                )
3210
-            );
3211
-        }
3212
-    }
3213
-
3214
-
3215
-    /**
3216
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3217
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3218
-     *
3219
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3220
-     */
3221
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3222
-    {
3223
-        $this->_hook_obj = $hook_obj;
3224
-    }
3225
-
3226
-
3227
-    /**
3228
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3229
-     *
3230
-     * @param boolean $about whether to use the special about page wrapper or default.
3231
-     * @return void
3232
-     * @throws DomainException
3233
-     * @throws EE_Error
3234
-     */
3235
-    public function admin_page_wrapper($about = false)
3236
-    {
3237
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3238
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3239
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3240
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3241
-
3242
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3243
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3244
-            isset($this->_template_args['before_admin_page_content'])
3245
-                ? $this->_template_args['before_admin_page_content']
3246
-                : ''
3247
-        );
3248
-
3249
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3250
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3251
-            isset($this->_template_args['after_admin_page_content'])
3252
-                ? $this->_template_args['after_admin_page_content']
3253
-                : ''
3254
-        );
3255
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3256
-
3257
-        if ($this->request->isAjax()) {
3258
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3259
-                // $template_path,
3260
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3261
-                $this->_template_args,
3262
-                true
3263
-            );
3264
-            $this->_return_json();
3265
-        }
3266
-        // load settings page wrapper template
3267
-        $template_path = $about
3268
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3269
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3270
-
3271
-        EEH_Template::display_template($template_path, $this->_template_args);
3272
-    }
3273
-
3274
-
3275
-    /**
3276
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3277
-     *
3278
-     * @return string html
3279
-     * @throws EE_Error
3280
-     */
3281
-    protected function _get_main_nav_tabs()
3282
-    {
3283
-        // let's generate the html using the EEH_Tabbed_Content helper.
3284
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3285
-        // (rather than setting in the page_routes array)
3286
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3287
-    }
3288
-
3289
-
3290
-    /**
3291
-     *        sort nav tabs
3292
-     *
3293
-     * @param $a
3294
-     * @param $b
3295
-     * @return int
3296
-     */
3297
-    private function _sort_nav_tabs($a, $b)
3298
-    {
3299
-        if ($a['order'] === $b['order']) {
3300
-            return 0;
3301
-        }
3302
-        return ($a['order'] < $b['order']) ? -1 : 1;
3303
-    }
3304
-
3305
-
3306
-    /**
3307
-     *    generates HTML for the forms used on admin pages
3308
-     *
3309
-     * @param array  $input_vars   - array of input field details
3310
-     * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3311
-     *                             use)
3312
-     * @param bool   $id
3313
-     * @return array|string
3314
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3315
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3316
-     */
3317
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3318
-    {
3319
-        return $generator === 'string'
3320
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3321
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3322
-    }
3323
-
3324
-
3325
-    /**
3326
-     * generates the "Save" and "Save & Close" buttons for edit forms
3327
-     *
3328
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3329
-     *                                   Close" button.
3330
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3331
-     *                                   'Save', [1] => 'save & close')
3332
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3333
-     *                                   via the "name" value in the button).  We can also use this to just dump
3334
-     *                                   default actions by submitting some other value.
3335
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3336
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3337
-     *                                   close (normal form handling).
3338
-     */
3339
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3340
-    {
3341
-        // make sure $text and $actions are in an array
3342
-        $text          = (array) $text;
3343
-        $actions       = (array) $actions;
3344
-        $referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3345
-        $button_text   = ! empty($text)
3346
-            ? $text
3347
-            : [
3348
-                esc_html__('Save', 'event_espresso'),
3349
-                esc_html__('Save and Close', 'event_espresso'),
3350
-            ];
3351
-        $default_names = ['save', 'save_and_close'];
3352
-        $buttons = '';
3353
-        foreach ($button_text as $key => $button) {
3354
-            $ref     = $default_names[ $key ];
3355
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3356
-            $buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3357
-                        . 'value="' . $button . '" name="' . $name . '" '
3358
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3359
-            if (! $both) {
3360
-                break;
3361
-            }
3362
-        }
3363
-        // add in a hidden index for the current page (so save and close redirects properly)
3364
-        $buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3365
-                   . $referrer_url
3366
-                   . '" />';
3367
-        $this->_template_args['save_buttons'] = $buttons;
3368
-    }
3369
-
3370
-
3371
-    /**
3372
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3373
-     *
3374
-     * @param string $route
3375
-     * @param array  $additional_hidden_fields
3376
-     * @see   $this->_set_add_edit_form_tags() for details on params
3377
-     * @since 4.6.0
3378
-     */
3379
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3380
-    {
3381
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3382
-    }
3383
-
3384
-
3385
-    /**
3386
-     * set form open and close tags on add/edit pages.
3387
-     *
3388
-     * @param string $route                    the route you want the form to direct to
3389
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3390
-     * @return void
3391
-     */
3392
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3393
-    {
3394
-        if (empty($route)) {
3395
-            $user_msg = esc_html__(
3396
-                'An error occurred. No action was set for this page\'s form.',
3397
-                'event_espresso'
3398
-            );
3399
-            $dev_msg  = $user_msg . "\n"
3400
-                        . sprintf(
3401
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3402
-                            __FUNCTION__,
3403
-                            __CLASS__
3404
-                        );
3405
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3406
-        }
3407
-        // open form
3408
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3409
-                                                             . $this->_admin_base_url
3410
-                                                             . '" id="'
3411
-                                                             . $route
3412
-                                                             . '_event_form" >';
3413
-        // add nonce
3414
-        $nonce                                             =
3415
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3416
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3417
-        // add REQUIRED form action
3418
-        $hidden_fields = [
3419
-            'action' => ['type' => 'hidden', 'value' => $route],
3420
-        ];
3421
-        // merge arrays
3422
-        $hidden_fields = is_array($additional_hidden_fields)
3423
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3424
-            : $hidden_fields;
3425
-        // generate form fields
3426
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3427
-        // add fields to form
3428
-        foreach ((array) $form_fields as $form_field) {
3429
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3430
-        }
3431
-        // close form
3432
-        $this->_template_args['after_admin_page_content'] = '</form>';
3433
-    }
3434
-
3435
-
3436
-    /**
3437
-     * Public Wrapper for _redirect_after_action() method since its
3438
-     * discovered it would be useful for external code to have access.
3439
-     *
3440
-     * @param bool   $success
3441
-     * @param string $what
3442
-     * @param string $action_desc
3443
-     * @param array  $query_args
3444
-     * @param bool   $override_overwrite
3445
-     * @throws EE_Error
3446
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3447
-     * @since 4.5.0
3448
-     */
3449
-    public function redirect_after_action(
3450
-        $success = false,
3451
-        $what = 'item',
3452
-        $action_desc = 'processed',
3453
-        $query_args = [],
3454
-        $override_overwrite = false
3455
-    ) {
3456
-        $this->_redirect_after_action(
3457
-            $success,
3458
-            $what,
3459
-            $action_desc,
3460
-            $query_args,
3461
-            $override_overwrite
3462
-        );
3463
-    }
3464
-
3465
-
3466
-    /**
3467
-     * Helper method for merging existing request data with the returned redirect url.
3468
-     *
3469
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3470
-     * filters are still applied.
3471
-     *
3472
-     * @param array $new_route_data
3473
-     * @return array
3474
-     */
3475
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3476
-    {
3477
-        foreach ($this->request->requestParams() as $ref => $value) {
3478
-            // unset nonces
3479
-            if (strpos($ref, 'nonce') !== false) {
3480
-                $this->request->unSetRequestParam($ref);
3481
-                continue;
3482
-            }
3483
-            // urlencode values.
3484
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3485
-            $this->request->setRequestParam($ref, $value);
3486
-        }
3487
-        return array_merge($this->request->requestParams(), $new_route_data);
3488
-    }
3489
-
3490
-
3491
-    /**
3492
-     *    _redirect_after_action
3493
-     *
3494
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3495
-     * @param string $what               - what the action was performed on
3496
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3497
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3498
-     *                                   action is completed
3499
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3500
-     *                                   override this so that they show.
3501
-     * @return void
3502
-     * @throws EE_Error
3503
-     */
3504
-    protected function _redirect_after_action(
3505
-        $success = 0,
3506
-        $what = 'item',
3507
-        $action_desc = 'processed',
3508
-        $query_args = [],
3509
-        $override_overwrite = false
3510
-    ) {
3511
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3512
-        // class name for actions/filters.
3513
-        $classname = get_class($this);
3514
-        // set redirect url.
3515
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3516
-        // otherwise we go with whatever is set as the _admin_base_url
3517
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3518
-        $notices      = EE_Error::get_notices(false);
3519
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3520
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3521
-            EE_Error::overwrite_success();
3522
-        }
3523
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3524
-            // how many records affected ? more than one record ? or just one ?
3525
-            if ($success > 1) {
3526
-                // set plural msg
3527
-                EE_Error::add_success(
3528
-                    sprintf(
3529
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3530
-                        $what,
3531
-                        $action_desc
3532
-                    ),
3533
-                    __FILE__,
3534
-                    __FUNCTION__,
3535
-                    __LINE__
3536
-                );
3537
-            } elseif ($success === 1) {
3538
-                // set singular msg
3539
-                EE_Error::add_success(
3540
-                    sprintf(
3541
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3542
-                        $what,
3543
-                        $action_desc
3544
-                    ),
3545
-                    __FILE__,
3546
-                    __FUNCTION__,
3547
-                    __LINE__
3548
-                );
3549
-            }
3550
-        }
3551
-        // check that $query_args isn't something crazy
3552
-        if (! is_array($query_args)) {
3553
-            $query_args = [];
3554
-        }
3555
-        /**
3556
-         * Allow injecting actions before the query_args are modified for possible different
3557
-         * redirections on save and close actions
3558
-         *
3559
-         * @param array $query_args       The original query_args array coming into the
3560
-         *                                method.
3561
-         * @since 4.2.0
3562
-         */
3563
-        do_action(
3564
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3565
-            $query_args
3566
-        );
3567
-        // calculate where we're going (if we have a "save and close" button pushed)
3568
-
3569
-        if (
3570
-            $this->request->requestParamIsSet('save_and_close')
3571
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3572
-        ) {
3573
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3574
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3575
-            // regenerate query args array from referrer URL
3576
-            parse_str($parsed_url['query'], $query_args);
3577
-            // correct page and action will be in the query args now
3578
-            $redirect_url = admin_url('admin.php');
3579
-        }
3580
-        // merge any default query_args set in _default_route_query_args property
3581
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3582
-            $args_to_merge = [];
3583
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3584
-                // is there a wp_referer array in our _default_route_query_args property?
3585
-                if ($query_param === 'wp_referer') {
3586
-                    $query_value = (array) $query_value;
3587
-                    foreach ($query_value as $reference => $value) {
3588
-                        if (strpos($reference, 'nonce') !== false) {
3589
-                            continue;
3590
-                        }
3591
-                        // finally we will override any arguments in the referer with
3592
-                        // what might be set on the _default_route_query_args array.
3593
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3594
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3595
-                        } else {
3596
-                            $args_to_merge[ $reference ] = urlencode($value);
3597
-                        }
3598
-                    }
3599
-                    continue;
3600
-                }
3601
-                $args_to_merge[ $query_param ] = $query_value;
3602
-            }
3603
-            // now let's merge these arguments but override with what was specifically sent in to the
3604
-            // redirect.
3605
-            $query_args = array_merge($args_to_merge, $query_args);
3606
-        }
3607
-        $this->_process_notices($query_args);
3608
-        // generate redirect url
3609
-        // if redirecting to anything other than the main page, add a nonce
3610
-        if (isset($query_args['action'])) {
3611
-            // manually generate wp_nonce and merge that with the query vars
3612
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3613
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3614
-        }
3615
-        // we're adding some hooks and filters in here for processing any things just before redirects
3616
-        // (example: an admin page has done an insert or update and we want to run something after that).
3617
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3618
-        $redirect_url = apply_filters(
3619
-            'FHEE_redirect_' . $classname . $this->_req_action,
3620
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3621
-            $query_args
3622
-        );
3623
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3624
-        if ($this->request->isAjax()) {
3625
-            $default_data                    = [
3626
-                'close'        => true,
3627
-                'redirect_url' => $redirect_url,
3628
-                'where'        => 'main',
3629
-                'what'         => 'append',
3630
-            ];
3631
-            $this->_template_args['success'] = $success;
3632
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3633
-                $default_data,
3634
-                $this->_template_args['data']
3635
-            ) : $default_data;
3636
-            $this->_return_json();
3637
-        }
3638
-        wp_safe_redirect($redirect_url);
3639
-        exit();
3640
-    }
3641
-
3642
-
3643
-    /**
3644
-     * process any notices before redirecting (or returning ajax request)
3645
-     * This method sets the $this->_template_args['notices'] attribute;
3646
-     *
3647
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3648
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3649
-     *                                  page_routes haven't been defined yet.
3650
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3651
-     *                                  still save a transient for the notice.
3652
-     * @return void
3653
-     * @throws EE_Error
3654
-     */
3655
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3656
-    {
3657
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3658
-        if ($this->request->isAjax()) {
3659
-            $notices = EE_Error::get_notices(false);
3660
-            if (empty($this->_template_args['success'])) {
3661
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3662
-            }
3663
-            if (empty($this->_template_args['errors'])) {
3664
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3665
-            }
3666
-            if (empty($this->_template_args['attention'])) {
3667
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3668
-            }
3669
-        }
3670
-        $this->_template_args['notices'] = EE_Error::get_notices();
3671
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3672
-        if (! $this->request->isAjax() || $sticky_notices) {
3673
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3674
-            $this->_add_transient(
3675
-                $route,
3676
-                $this->_template_args['notices'],
3677
-                true,
3678
-                $skip_route_verify
3679
-            );
3680
-        }
3681
-    }
3682
-
3683
-
3684
-    /**
3685
-     * get_action_link_or_button
3686
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3687
-     *
3688
-     * @param string $action        use this to indicate which action the url is generated with.
3689
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3690
-     *                              property.
3691
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3692
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3693
-     * @param string $base_url      If this is not provided
3694
-     *                              the _admin_base_url will be used as the default for the button base_url.
3695
-     *                              Otherwise this value will be used.
3696
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3697
-     * @return string
3698
-     * @throws InvalidArgumentException
3699
-     * @throws InvalidInterfaceException
3700
-     * @throws InvalidDataTypeException
3701
-     * @throws EE_Error
3702
-     */
3703
-    public function get_action_link_or_button(
3704
-        $action,
3705
-        $type = 'add',
3706
-        $extra_request = [],
3707
-        $class = 'button-primary',
3708
-        $base_url = '',
3709
-        $exclude_nonce = false
3710
-    ) {
3711
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3712
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3713
-            throw new EE_Error(
3714
-                sprintf(
3715
-                    esc_html__(
3716
-                        'There is no page route for given action for the button.  This action was given: %s',
3717
-                        'event_espresso'
3718
-                    ),
3719
-                    $action
3720
-                )
3721
-            );
3722
-        }
3723
-        if (! isset($this->_labels['buttons'][ $type ])) {
3724
-            throw new EE_Error(
3725
-                sprintf(
3726
-                    esc_html__(
3727
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3728
-                        'event_espresso'
3729
-                    ),
3730
-                    $type
3731
-                )
3732
-            );
3733
-        }
3734
-        // finally check user access for this button.
3735
-        $has_access = $this->check_user_access($action, true);
3736
-        if (! $has_access) {
3737
-            return '';
3738
-        }
3739
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3740
-        $query_args = [
3741
-            'action' => $action,
3742
-        ];
3743
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3744
-        if (! empty($extra_request)) {
3745
-            $query_args = array_merge($extra_request, $query_args);
3746
-        }
3747
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3748
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3749
-    }
3750
-
3751
-
3752
-    /**
3753
-     * _per_page_screen_option
3754
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3755
-     *
3756
-     * @return void
3757
-     * @throws InvalidArgumentException
3758
-     * @throws InvalidInterfaceException
3759
-     * @throws InvalidDataTypeException
3760
-     */
3761
-    protected function _per_page_screen_option()
3762
-    {
3763
-        $option = 'per_page';
3764
-        $args   = [
3765
-            'label'   => apply_filters(
3766
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3767
-                $this->_admin_page_title,
3768
-                $this
3769
-            ),
3770
-            'default' => (int) apply_filters(
3771
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3772
-                20
3773
-            ),
3774
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3775
-        ];
3776
-        // ONLY add the screen option if the user has access to it.
3777
-        if ($this->check_user_access($this->_current_view, true)) {
3778
-            add_screen_option($option, $args);
3779
-        }
3780
-    }
3781
-
3782
-
3783
-    /**
3784
-     * set_per_page_screen_option
3785
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3786
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3787
-     * admin_menu.
3788
-     *
3789
-     * @return void
3790
-     */
3791
-    private function _set_per_page_screen_options()
3792
-    {
3793
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3794
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3795
-            if (! $user = wp_get_current_user()) {
3796
-                return;
3797
-            }
3798
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3799
-            if (! $option) {
3800
-                return;
3801
-            }
3802
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3803
-            $map_option = $option;
3804
-            $option     = str_replace('-', '_', $option);
3805
-            switch ($map_option) {
3806
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3807
-                    $max_value = apply_filters(
3808
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3809
-                        999,
3810
-                        $this->_current_page,
3811
-                        $this->_current_view
3812
-                    );
3813
-                    if ($value < 1) {
3814
-                        return;
3815
-                    }
3816
-                    $value = min($value, $max_value);
3817
-                    break;
3818
-                default:
3819
-                    $value = apply_filters(
3820
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3821
-                        false,
3822
-                        $option,
3823
-                        $value
3824
-                    );
3825
-                    if (false === $value) {
3826
-                        return;
3827
-                    }
3828
-                    break;
3829
-            }
3830
-            update_user_meta($user->ID, $option, $value);
3831
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3832
-            exit;
3833
-        }
3834
-    }
3835
-
3836
-
3837
-    /**
3838
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3839
-     *
3840
-     * @param array $data array that will be assigned to template args.
3841
-     */
3842
-    public function set_template_args($data)
3843
-    {
3844
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3845
-    }
3846
-
3847
-
3848
-    /**
3849
-     * This makes available the WP transient system for temporarily moving data between routes
3850
-     *
3851
-     * @param string $route             the route that should receive the transient
3852
-     * @param array  $data              the data that gets sent
3853
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3854
-     *                                  normal route transient.
3855
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3856
-     *                                  when we are adding a transient before page_routes have been defined.
3857
-     * @return void
3858
-     * @throws EE_Error
3859
-     */
3860
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3861
-    {
3862
-        $user_id = get_current_user_id();
3863
-        if (! $skip_route_verify) {
3864
-            $this->_verify_route($route);
3865
-        }
3866
-        // now let's set the string for what kind of transient we're setting
3867
-        $transient = $notices
3868
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3869
-            : 'rte_tx_' . $route . '_' . $user_id;
3870
-        $data      = $notices ? ['notices' => $data] : $data;
3871
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3872
-        $existing = is_multisite() && is_network_admin()
3873
-            ? get_site_transient($transient)
3874
-            : get_transient($transient);
3875
-        if ($existing) {
3876
-            $data = array_merge((array) $data, (array) $existing);
3877
-        }
3878
-        if (is_multisite() && is_network_admin()) {
3879
-            set_site_transient($transient, $data, 8);
3880
-        } else {
3881
-            set_transient($transient, $data, 8);
3882
-        }
3883
-    }
3884
-
3885
-
3886
-    /**
3887
-     * this retrieves the temporary transient that has been set for moving data between routes.
3888
-     *
3889
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3890
-     * @param string $route
3891
-     * @return mixed data
3892
-     */
3893
-    protected function _get_transient($notices = false, $route = '')
3894
-    {
3895
-        $user_id   = get_current_user_id();
3896
-        $route     = ! $route ? $this->_req_action : $route;
3897
-        $transient = $notices
3898
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3899
-            : 'rte_tx_' . $route . '_' . $user_id;
3900
-        $data      = is_multisite() && is_network_admin()
3901
-            ? get_site_transient($transient)
3902
-            : get_transient($transient);
3903
-        // delete transient after retrieval (just in case it hasn't expired);
3904
-        if (is_multisite() && is_network_admin()) {
3905
-            delete_site_transient($transient);
3906
-        } else {
3907
-            delete_transient($transient);
3908
-        }
3909
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3910
-    }
3911
-
3912
-
3913
-    /**
3914
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3915
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3916
-     * default route callback on the EE_Admin page you want it run.)
3917
-     *
3918
-     * @return void
3919
-     */
3920
-    protected function _transient_garbage_collection()
3921
-    {
3922
-        global $wpdb;
3923
-        // retrieve all existing transients
3924
-        $query =
3925
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3926
-        if ($results = $wpdb->get_results($query)) {
3927
-            foreach ($results as $result) {
3928
-                $transient = str_replace('_transient_', '', $result->option_name);
3929
-                get_transient($transient);
3930
-                if (is_multisite() && is_network_admin()) {
3931
-                    get_site_transient($transient);
3932
-                }
3933
-            }
3934
-        }
3935
-    }
3936
-
3937
-
3938
-    /**
3939
-     * get_view
3940
-     *
3941
-     * @return string content of _view property
3942
-     */
3943
-    public function get_view()
3944
-    {
3945
-        return $this->_view;
3946
-    }
3947
-
3948
-
3949
-    /**
3950
-     * getter for the protected $_views property
3951
-     *
3952
-     * @return array
3953
-     */
3954
-    public function get_views()
3955
-    {
3956
-        return $this->_views;
3957
-    }
3958
-
3959
-
3960
-    /**
3961
-     * get_current_page
3962
-     *
3963
-     * @return string _current_page property value
3964
-     */
3965
-    public function get_current_page()
3966
-    {
3967
-        return $this->_current_page;
3968
-    }
3969
-
3970
-
3971
-    /**
3972
-     * get_current_view
3973
-     *
3974
-     * @return string _current_view property value
3975
-     */
3976
-    public function get_current_view()
3977
-    {
3978
-        return $this->_current_view;
3979
-    }
3980
-
3981
-
3982
-    /**
3983
-     * get_current_screen
3984
-     *
3985
-     * @return object The current WP_Screen object
3986
-     */
3987
-    public function get_current_screen()
3988
-    {
3989
-        return $this->_current_screen;
3990
-    }
3991
-
3992
-
3993
-    /**
3994
-     * get_current_page_view_url
3995
-     *
3996
-     * @return string This returns the url for the current_page_view.
3997
-     */
3998
-    public function get_current_page_view_url()
3999
-    {
4000
-        return $this->_current_page_view_url;
4001
-    }
4002
-
4003
-
4004
-    /**
4005
-     * just returns the Request
4006
-     *
4007
-     * @return RequestInterface
4008
-     */
4009
-    public function get_request()
4010
-    {
4011
-        return $this->request;
4012
-    }
4013
-
4014
-
4015
-    /**
4016
-     * just returns the _req_data property
4017
-     *
4018
-     * @return array
4019
-     */
4020
-    public function get_request_data()
4021
-    {
4022
-        return $this->request->requestParams();
4023
-    }
4024
-
4025
-
4026
-    /**
4027
-     * returns the _req_data protected property
4028
-     *
4029
-     * @return string
4030
-     */
4031
-    public function get_req_action()
4032
-    {
4033
-        return $this->_req_action;
4034
-    }
4035
-
4036
-
4037
-    /**
4038
-     * @return bool  value of $_is_caf property
4039
-     */
4040
-    public function is_caf()
4041
-    {
4042
-        return $this->_is_caf;
4043
-    }
4044
-
4045
-
4046
-    /**
4047
-     * @return mixed
4048
-     */
4049
-    public function default_espresso_metaboxes()
4050
-    {
4051
-        return $this->_default_espresso_metaboxes;
4052
-    }
4053
-
4054
-
4055
-    /**
4056
-     * @return mixed
4057
-     */
4058
-    public function admin_base_url()
4059
-    {
4060
-        return $this->_admin_base_url;
4061
-    }
4062
-
4063
-
4064
-    /**
4065
-     * @return mixed
4066
-     */
4067
-    public function wp_page_slug()
4068
-    {
4069
-        return $this->_wp_page_slug;
4070
-    }
4071
-
4072
-
4073
-    /**
4074
-     * updates  espresso configuration settings
4075
-     *
4076
-     * @param string                   $tab
4077
-     * @param EE_Config_Base|EE_Config $config
4078
-     * @param string                   $file file where error occurred
4079
-     * @param string                   $func function  where error occurred
4080
-     * @param string                   $line line no where error occurred
4081
-     * @return boolean
4082
-     */
4083
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4084
-    {
4085
-        // remove any options that are NOT going to be saved with the config settings.
4086
-        if (isset($config->core->ee_ueip_optin)) {
4087
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4088
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4089
-            update_option('ee_ueip_has_notified', true);
4090
-        }
4091
-        // and save it (note we're also doing the network save here)
4092
-        $net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
4093
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4094
-        if ($config_saved && $net_saved) {
4095
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4096
-            return true;
4097
-        }
4098
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4099
-        return false;
4100
-    }
4101
-
4102
-
4103
-    /**
4104
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4105
-     *
4106
-     * @return array
4107
-     */
4108
-    public function get_yes_no_values()
4109
-    {
4110
-        return $this->_yes_no_values;
4111
-    }
4112
-
4113
-
4114
-    protected function _get_dir()
4115
-    {
4116
-        $reflector = new ReflectionClass(get_class($this));
4117
-        return dirname($reflector->getFileName());
4118
-    }
4119
-
4120
-
4121
-    /**
4122
-     * A helper for getting a "next link".
4123
-     *
4124
-     * @param string $url   The url to link to
4125
-     * @param string $class The class to use.
4126
-     * @return string
4127
-     */
4128
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4129
-    {
4130
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4131
-    }
4132
-
4133
-
4134
-    /**
4135
-     * A helper for getting a "previous link".
4136
-     *
4137
-     * @param string $url   The url to link to
4138
-     * @param string $class The class to use.
4139
-     * @return string
4140
-     */
4141
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4142
-    {
4143
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4144
-    }
4145
-
4146
-
4147
-
4148
-
4149
-
4150
-
4151
-
4152
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4153
-
4154
-
4155
-    /**
4156
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4157
-     * 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
4158
-     * _req_data array.
4159
-     *
4160
-     * @return bool success/fail
4161
-     * @throws EE_Error
4162
-     * @throws InvalidArgumentException
4163
-     * @throws ReflectionException
4164
-     * @throws InvalidDataTypeException
4165
-     * @throws InvalidInterfaceException
4166
-     */
4167
-    protected function _process_resend_registration()
4168
-    {
4169
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4170
-        do_action(
4171
-            'AHEE__EE_Admin_Page___process_resend_registration',
4172
-            $this->_template_args['success'],
4173
-            $this->request->requestParams()
4174
-        );
4175
-        return $this->_template_args['success'];
4176
-    }
4177
-
4178
-
4179
-    /**
4180
-     * This automatically processes any payment message notifications when manual payment has been applied.
4181
-     *
4182
-     * @param EE_Payment $payment
4183
-     * @return bool success/fail
4184
-     */
4185
-    protected function _process_payment_notification(EE_Payment $payment)
4186
-    {
4187
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4188
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4189
-        $this->_template_args['success'] = apply_filters(
4190
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4191
-            false,
4192
-            $payment
4193
-        );
4194
-        return $this->_template_args['success'];
4195
-    }
2763
+	}
2764
+
2765
+
2766
+	/**
2767
+	 * facade for add_meta_box
2768
+	 *
2769
+	 * @param string  $action        where the metabox gets displayed
2770
+	 * @param string  $title         Title of Metabox (output in metabox header)
2771
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2772
+	 *                               instead of the one created in here.
2773
+	 * @param array   $callback_args an array of args supplied for the metabox
2774
+	 * @param string  $column        what metabox column
2775
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2776
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2777
+	 *                               created but just set our own callback for wp's add_meta_box.
2778
+	 * @throws DomainException
2779
+	 */
2780
+	public function _add_admin_page_meta_box(
2781
+		$action,
2782
+		$title,
2783
+		$callback,
2784
+		$callback_args,
2785
+		$column = 'normal',
2786
+		$priority = 'high',
2787
+		$create_func = true
2788
+	) {
2789
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2790
+		// 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.
2791
+		if (empty($callback_args) && $create_func) {
2792
+			$callback_args = [
2793
+				'template_path' => $this->_template_path,
2794
+				'template_args' => $this->_template_args,
2795
+			];
2796
+		}
2797
+		// 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)
2798
+		$call_back_func = $create_func
2799
+			? function ($post, $metabox) {
2800
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2801
+				echo EEH_Template::display_template(
2802
+					$metabox['args']['template_path'],
2803
+					$metabox['args']['template_args'],
2804
+					true
2805
+				);
2806
+			}
2807
+			: $callback;
2808
+		add_meta_box(
2809
+			str_replace('_', '-', $action) . '-mbox',
2810
+			$title,
2811
+			$call_back_func,
2812
+			$this->_wp_page_slug,
2813
+			$column,
2814
+			$priority,
2815
+			$callback_args
2816
+		);
2817
+	}
2818
+
2819
+
2820
+	/**
2821
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2822
+	 *
2823
+	 * @throws DomainException
2824
+	 * @throws EE_Error
2825
+	 */
2826
+	public function display_admin_page_with_metabox_columns()
2827
+	{
2828
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2829
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2830
+			$this->_column_template_path,
2831
+			$this->_template_args,
2832
+			true
2833
+		);
2834
+		// the final wrapper
2835
+		$this->admin_page_wrapper();
2836
+	}
2837
+
2838
+
2839
+	/**
2840
+	 * generates  HTML wrapper for an admin details page
2841
+	 *
2842
+	 * @return void
2843
+	 * @throws EE_Error
2844
+	 * @throws DomainException
2845
+	 */
2846
+	public function display_admin_page_with_sidebar()
2847
+	{
2848
+		$this->_display_admin_page(true);
2849
+	}
2850
+
2851
+
2852
+	/**
2853
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2854
+	 *
2855
+	 * @return void
2856
+	 * @throws EE_Error
2857
+	 * @throws DomainException
2858
+	 */
2859
+	public function display_admin_page_with_no_sidebar()
2860
+	{
2861
+		$this->_display_admin_page();
2862
+	}
2863
+
2864
+
2865
+	/**
2866
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2867
+	 *
2868
+	 * @return void
2869
+	 * @throws EE_Error
2870
+	 * @throws DomainException
2871
+	 */
2872
+	public function display_about_admin_page()
2873
+	{
2874
+		$this->_display_admin_page(false, true);
2875
+	}
2876
+
2877
+
2878
+	/**
2879
+	 * display_admin_page
2880
+	 * contains the code for actually displaying an admin page
2881
+	 *
2882
+	 * @param boolean $sidebar true with sidebar, false without
2883
+	 * @param boolean $about   use the about_admin_wrapper instead of the default.
2884
+	 * @return void
2885
+	 * @throws DomainException
2886
+	 * @throws EE_Error
2887
+	 */
2888
+	private function _display_admin_page($sidebar = false, $about = false)
2889
+	{
2890
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2891
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2892
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2893
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2894
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2895
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2896
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2897
+			? 'poststuff'
2898
+			: 'espresso-default-admin';
2899
+		$template_path                                     = $sidebar
2900
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2901
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2902
+		if ($this->request->isAjax()) {
2903
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2904
+		}
2905
+		$template_path                                     = ! empty($this->_column_template_path)
2906
+			? $this->_column_template_path : $template_path;
2907
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2908
+			? $this->_template_args['admin_page_content']
2909
+			: '';
2910
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2911
+			? $this->_template_args['before_admin_page_content']
2912
+			: '';
2913
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2914
+			? $this->_template_args['after_admin_page_content']
2915
+			: '';
2916
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2917
+			$template_path,
2918
+			$this->_template_args,
2919
+			true
2920
+		);
2921
+		// the final template wrapper
2922
+		$this->admin_page_wrapper($about);
2923
+	}
2924
+
2925
+
2926
+	/**
2927
+	 * This is used to display caf preview pages.
2928
+	 *
2929
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2930
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2931
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2932
+	 * @return void
2933
+	 * @throws DomainException
2934
+	 * @throws EE_Error
2935
+	 * @throws InvalidArgumentException
2936
+	 * @throws InvalidDataTypeException
2937
+	 * @throws InvalidInterfaceException
2938
+	 * @since 4.3.2
2939
+	 */
2940
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2941
+	{
2942
+		// let's generate a default preview action button if there isn't one already present.
2943
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2944
+			'Upgrade to Event Espresso 4 Right Now',
2945
+			'event_espresso'
2946
+		);
2947
+		$buy_now_url                                   = add_query_arg(
2948
+			[
2949
+				'ee_ver'       => 'ee4',
2950
+				'utm_source'   => 'ee4_plugin_admin',
2951
+				'utm_medium'   => 'link',
2952
+				'utm_campaign' => $utm_campaign_source,
2953
+				'utm_content'  => 'buy_now_button',
2954
+			],
2955
+			'https://eventespresso.com/pricing/'
2956
+		);
2957
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2958
+			? $this->get_action_link_or_button(
2959
+				'',
2960
+				'buy_now',
2961
+				[],
2962
+				'button-primary button-large',
2963
+				esc_url_raw($buy_now_url),
2964
+				true
2965
+			)
2966
+			: $this->_template_args['preview_action_button'];
2967
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2968
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2969
+			$this->_template_args,
2970
+			true
2971
+		);
2972
+		$this->_display_admin_page($display_sidebar);
2973
+	}
2974
+
2975
+
2976
+	/**
2977
+	 * display_admin_list_table_page_with_sidebar
2978
+	 * generates HTML wrapper for an admin_page with list_table
2979
+	 *
2980
+	 * @return void
2981
+	 * @throws EE_Error
2982
+	 * @throws DomainException
2983
+	 */
2984
+	public function display_admin_list_table_page_with_sidebar()
2985
+	{
2986
+		$this->_display_admin_list_table_page(true);
2987
+	}
2988
+
2989
+
2990
+	/**
2991
+	 * display_admin_list_table_page_with_no_sidebar
2992
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2993
+	 *
2994
+	 * @return void
2995
+	 * @throws EE_Error
2996
+	 * @throws DomainException
2997
+	 */
2998
+	public function display_admin_list_table_page_with_no_sidebar()
2999
+	{
3000
+		$this->_display_admin_list_table_page();
3001
+	}
3002
+
3003
+
3004
+	/**
3005
+	 * generates html wrapper for an admin_list_table page
3006
+	 *
3007
+	 * @param boolean $sidebar whether to display with sidebar or not.
3008
+	 * @return void
3009
+	 * @throws DomainException
3010
+	 * @throws EE_Error
3011
+	 */
3012
+	private function _display_admin_list_table_page($sidebar = false)
3013
+	{
3014
+		// setup search attributes
3015
+		$this->_set_search_attributes();
3016
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
3017
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3018
+		$this->_template_args['table_url']        = $this->request->isAjax()
3019
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3020
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
3021
+		$this->_template_args['list_table']       = $this->_list_table_object;
3022
+		$this->_template_args['current_route']    = $this->_req_action;
3023
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3024
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3025
+		if (! empty($ajax_sorting_callback)) {
3026
+			$sortable_list_table_form_fields = wp_nonce_field(
3027
+				$ajax_sorting_callback . '_nonce',
3028
+				$ajax_sorting_callback . '_nonce',
3029
+				false,
3030
+				false
3031
+			);
3032
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3033
+												. $this->page_slug
3034
+												. '" />';
3035
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3036
+												. $ajax_sorting_callback
3037
+												. '" />';
3038
+		} else {
3039
+			$sortable_list_table_form_fields = '';
3040
+		}
3041
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3042
+		$hidden_form_fields                                      =
3043
+			isset($this->_template_args['list_table_hidden_fields'])
3044
+				? $this->_template_args['list_table_hidden_fields']
3045
+				: '';
3046
+		$nonce_ref                                               = $this->_req_action . '_nonce';
3047
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
3048
+																	. $nonce_ref
3049
+																	. '" value="'
3050
+																	. wp_create_nonce($nonce_ref)
3051
+																	. '">';
3052
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3053
+		// display message about search results?
3054
+		$search = $this->request->getRequestParam('s');
3055
+		$this->_template_args['before_list_table'] .= ! empty($search)
3056
+			? '<p class="ee-search-results">' . sprintf(
3057
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3058
+				trim($search, '%')
3059
+			) . '</p>'
3060
+			: '';
3061
+		// filter before_list_table template arg
3062
+		$this->_template_args['before_list_table'] = apply_filters(
3063
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3064
+			$this->_template_args['before_list_table'],
3065
+			$this->page_slug,
3066
+			$this->request->requestParams(),
3067
+			$this->_req_action
3068
+		);
3069
+		// convert to array and filter again
3070
+		// arrays are easier to inject new items in a specific location,
3071
+		// but would not be backwards compatible, so we have to add a new filter
3072
+		$this->_template_args['before_list_table'] = implode(
3073
+			" \n",
3074
+			(array) apply_filters(
3075
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3076
+				(array) $this->_template_args['before_list_table'],
3077
+				$this->page_slug,
3078
+				$this->request->requestParams(),
3079
+				$this->_req_action
3080
+			)
3081
+		);
3082
+		// filter after_list_table template arg
3083
+		$this->_template_args['after_list_table'] = apply_filters(
3084
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3085
+			$this->_template_args['after_list_table'],
3086
+			$this->page_slug,
3087
+			$this->request->requestParams(),
3088
+			$this->_req_action
3089
+		);
3090
+		// convert to array and filter again
3091
+		// arrays are easier to inject new items in a specific location,
3092
+		// but would not be backwards compatible, so we have to add a new filter
3093
+		$this->_template_args['after_list_table']   = implode(
3094
+			" \n",
3095
+			(array) apply_filters(
3096
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3097
+				(array) $this->_template_args['after_list_table'],
3098
+				$this->page_slug,
3099
+				$this->request->requestParams(),
3100
+				$this->_req_action
3101
+			)
3102
+		);
3103
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3104
+			$template_path,
3105
+			$this->_template_args,
3106
+			true
3107
+		);
3108
+		// the final template wrapper
3109
+		if ($sidebar) {
3110
+			$this->display_admin_page_with_sidebar();
3111
+		} else {
3112
+			$this->display_admin_page_with_no_sidebar();
3113
+		}
3114
+	}
3115
+
3116
+
3117
+	/**
3118
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3119
+	 * html string for the legend.
3120
+	 * $items are expected in an array in the following format:
3121
+	 * $legend_items = array(
3122
+	 *        'item_id' => array(
3123
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3124
+	 *            'desc' => esc_html__('localized description of item');
3125
+	 *        )
3126
+	 * );
3127
+	 *
3128
+	 * @param array $items see above for format of array
3129
+	 * @return string html string of legend
3130
+	 * @throws DomainException
3131
+	 */
3132
+	protected function _display_legend($items)
3133
+	{
3134
+		$this->_template_args['items'] = apply_filters(
3135
+			'FHEE__EE_Admin_Page___display_legend__items',
3136
+			(array) $items,
3137
+			$this
3138
+		);
3139
+		return EEH_Template::display_template(
3140
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3141
+			$this->_template_args,
3142
+			true
3143
+		);
3144
+	}
3145
+
3146
+
3147
+	/**
3148
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3149
+	 * The returned json object is created from an array in the following format:
3150
+	 * array(
3151
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3152
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3153
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3154
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3155
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3156
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3157
+	 *  that might be included in here)
3158
+	 * )
3159
+	 * The json object is populated by whatever is set in the $_template_args property.
3160
+	 *
3161
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3162
+	 *                                 instead of displayed.
3163
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3164
+	 * @return void
3165
+	 * @throws EE_Error
3166
+	 */
3167
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
3168
+	{
3169
+		// make sure any EE_Error notices have been handled.
3170
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3171
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3172
+		unset($this->_template_args['data']);
3173
+		$json = [
3174
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3175
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3176
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3177
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3178
+			'notices'   => EE_Error::get_notices(),
3179
+			'content'   => isset($this->_template_args['admin_page_content'])
3180
+				? $this->_template_args['admin_page_content'] : '',
3181
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3182
+			'isEEajax'  => true
3183
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3184
+		];
3185
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3186
+		if (null === error_get_last() || ! headers_sent()) {
3187
+			header('Content-Type: application/json; charset=UTF-8');
3188
+		}
3189
+		echo wp_json_encode($json);
3190
+		exit();
3191
+	}
3192
+
3193
+
3194
+	/**
3195
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3196
+	 *
3197
+	 * @return void
3198
+	 * @throws EE_Error
3199
+	 */
3200
+	public function return_json()
3201
+	{
3202
+		if ($this->request->isAjax()) {
3203
+			$this->_return_json();
3204
+		} else {
3205
+			throw new EE_Error(
3206
+				sprintf(
3207
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3208
+					__FUNCTION__
3209
+				)
3210
+			);
3211
+		}
3212
+	}
3213
+
3214
+
3215
+	/**
3216
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3217
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3218
+	 *
3219
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3220
+	 */
3221
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3222
+	{
3223
+		$this->_hook_obj = $hook_obj;
3224
+	}
3225
+
3226
+
3227
+	/**
3228
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3229
+	 *
3230
+	 * @param boolean $about whether to use the special about page wrapper or default.
3231
+	 * @return void
3232
+	 * @throws DomainException
3233
+	 * @throws EE_Error
3234
+	 */
3235
+	public function admin_page_wrapper($about = false)
3236
+	{
3237
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3238
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3239
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3240
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3241
+
3242
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3243
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3244
+			isset($this->_template_args['before_admin_page_content'])
3245
+				? $this->_template_args['before_admin_page_content']
3246
+				: ''
3247
+		);
3248
+
3249
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3250
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3251
+			isset($this->_template_args['after_admin_page_content'])
3252
+				? $this->_template_args['after_admin_page_content']
3253
+				: ''
3254
+		);
3255
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3256
+
3257
+		if ($this->request->isAjax()) {
3258
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3259
+				// $template_path,
3260
+				EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3261
+				$this->_template_args,
3262
+				true
3263
+			);
3264
+			$this->_return_json();
3265
+		}
3266
+		// load settings page wrapper template
3267
+		$template_path = $about
3268
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3269
+			: EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3270
+
3271
+		EEH_Template::display_template($template_path, $this->_template_args);
3272
+	}
3273
+
3274
+
3275
+	/**
3276
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3277
+	 *
3278
+	 * @return string html
3279
+	 * @throws EE_Error
3280
+	 */
3281
+	protected function _get_main_nav_tabs()
3282
+	{
3283
+		// let's generate the html using the EEH_Tabbed_Content helper.
3284
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3285
+		// (rather than setting in the page_routes array)
3286
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3287
+	}
3288
+
3289
+
3290
+	/**
3291
+	 *        sort nav tabs
3292
+	 *
3293
+	 * @param $a
3294
+	 * @param $b
3295
+	 * @return int
3296
+	 */
3297
+	private function _sort_nav_tabs($a, $b)
3298
+	{
3299
+		if ($a['order'] === $b['order']) {
3300
+			return 0;
3301
+		}
3302
+		return ($a['order'] < $b['order']) ? -1 : 1;
3303
+	}
3304
+
3305
+
3306
+	/**
3307
+	 *    generates HTML for the forms used on admin pages
3308
+	 *
3309
+	 * @param array  $input_vars   - array of input field details
3310
+	 * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3311
+	 *                             use)
3312
+	 * @param bool   $id
3313
+	 * @return array|string
3314
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3315
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3316
+	 */
3317
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3318
+	{
3319
+		return $generator === 'string'
3320
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3321
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3322
+	}
3323
+
3324
+
3325
+	/**
3326
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3327
+	 *
3328
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3329
+	 *                                   Close" button.
3330
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3331
+	 *                                   'Save', [1] => 'save & close')
3332
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3333
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3334
+	 *                                   default actions by submitting some other value.
3335
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3336
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3337
+	 *                                   close (normal form handling).
3338
+	 */
3339
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3340
+	{
3341
+		// make sure $text and $actions are in an array
3342
+		$text          = (array) $text;
3343
+		$actions       = (array) $actions;
3344
+		$referrer_url  = ! empty($referrer) ? $referrer : $this->request->getServerParam('REQUEST_URI');
3345
+		$button_text   = ! empty($text)
3346
+			? $text
3347
+			: [
3348
+				esc_html__('Save', 'event_espresso'),
3349
+				esc_html__('Save and Close', 'event_espresso'),
3350
+			];
3351
+		$default_names = ['save', 'save_and_close'];
3352
+		$buttons = '';
3353
+		foreach ($button_text as $key => $button) {
3354
+			$ref     = $default_names[ $key ];
3355
+			$name    = ! empty($actions) ? $actions[ $key ] : $ref;
3356
+			$buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3357
+						. 'value="' . $button . '" name="' . $name . '" '
3358
+						. 'id="' . $this->_current_view . '_' . $ref . '" />';
3359
+			if (! $both) {
3360
+				break;
3361
+			}
3362
+		}
3363
+		// add in a hidden index for the current page (so save and close redirects properly)
3364
+		$buttons .= '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3365
+				   . $referrer_url
3366
+				   . '" />';
3367
+		$this->_template_args['save_buttons'] = $buttons;
3368
+	}
3369
+
3370
+
3371
+	/**
3372
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3373
+	 *
3374
+	 * @param string $route
3375
+	 * @param array  $additional_hidden_fields
3376
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3377
+	 * @since 4.6.0
3378
+	 */
3379
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3380
+	{
3381
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3382
+	}
3383
+
3384
+
3385
+	/**
3386
+	 * set form open and close tags on add/edit pages.
3387
+	 *
3388
+	 * @param string $route                    the route you want the form to direct to
3389
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3390
+	 * @return void
3391
+	 */
3392
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3393
+	{
3394
+		if (empty($route)) {
3395
+			$user_msg = esc_html__(
3396
+				'An error occurred. No action was set for this page\'s form.',
3397
+				'event_espresso'
3398
+			);
3399
+			$dev_msg  = $user_msg . "\n"
3400
+						. sprintf(
3401
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3402
+							__FUNCTION__,
3403
+							__CLASS__
3404
+						);
3405
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3406
+		}
3407
+		// open form
3408
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3409
+															 . $this->_admin_base_url
3410
+															 . '" id="'
3411
+															 . $route
3412
+															 . '_event_form" >';
3413
+		// add nonce
3414
+		$nonce                                             =
3415
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3416
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3417
+		// add REQUIRED form action
3418
+		$hidden_fields = [
3419
+			'action' => ['type' => 'hidden', 'value' => $route],
3420
+		];
3421
+		// merge arrays
3422
+		$hidden_fields = is_array($additional_hidden_fields)
3423
+			? array_merge($hidden_fields, $additional_hidden_fields)
3424
+			: $hidden_fields;
3425
+		// generate form fields
3426
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3427
+		// add fields to form
3428
+		foreach ((array) $form_fields as $form_field) {
3429
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3430
+		}
3431
+		// close form
3432
+		$this->_template_args['after_admin_page_content'] = '</form>';
3433
+	}
3434
+
3435
+
3436
+	/**
3437
+	 * Public Wrapper for _redirect_after_action() method since its
3438
+	 * discovered it would be useful for external code to have access.
3439
+	 *
3440
+	 * @param bool   $success
3441
+	 * @param string $what
3442
+	 * @param string $action_desc
3443
+	 * @param array  $query_args
3444
+	 * @param bool   $override_overwrite
3445
+	 * @throws EE_Error
3446
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3447
+	 * @since 4.5.0
3448
+	 */
3449
+	public function redirect_after_action(
3450
+		$success = false,
3451
+		$what = 'item',
3452
+		$action_desc = 'processed',
3453
+		$query_args = [],
3454
+		$override_overwrite = false
3455
+	) {
3456
+		$this->_redirect_after_action(
3457
+			$success,
3458
+			$what,
3459
+			$action_desc,
3460
+			$query_args,
3461
+			$override_overwrite
3462
+		);
3463
+	}
3464
+
3465
+
3466
+	/**
3467
+	 * Helper method for merging existing request data with the returned redirect url.
3468
+	 *
3469
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3470
+	 * filters are still applied.
3471
+	 *
3472
+	 * @param array $new_route_data
3473
+	 * @return array
3474
+	 */
3475
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3476
+	{
3477
+		foreach ($this->request->requestParams() as $ref => $value) {
3478
+			// unset nonces
3479
+			if (strpos($ref, 'nonce') !== false) {
3480
+				$this->request->unSetRequestParam($ref);
3481
+				continue;
3482
+			}
3483
+			// urlencode values.
3484
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3485
+			$this->request->setRequestParam($ref, $value);
3486
+		}
3487
+		return array_merge($this->request->requestParams(), $new_route_data);
3488
+	}
3489
+
3490
+
3491
+	/**
3492
+	 *    _redirect_after_action
3493
+	 *
3494
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3495
+	 * @param string $what               - what the action was performed on
3496
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3497
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3498
+	 *                                   action is completed
3499
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3500
+	 *                                   override this so that they show.
3501
+	 * @return void
3502
+	 * @throws EE_Error
3503
+	 */
3504
+	protected function _redirect_after_action(
3505
+		$success = 0,
3506
+		$what = 'item',
3507
+		$action_desc = 'processed',
3508
+		$query_args = [],
3509
+		$override_overwrite = false
3510
+	) {
3511
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3512
+		// class name for actions/filters.
3513
+		$classname = get_class($this);
3514
+		// set redirect url.
3515
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3516
+		// otherwise we go with whatever is set as the _admin_base_url
3517
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3518
+		$notices      = EE_Error::get_notices(false);
3519
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3520
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3521
+			EE_Error::overwrite_success();
3522
+		}
3523
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3524
+			// how many records affected ? more than one record ? or just one ?
3525
+			if ($success > 1) {
3526
+				// set plural msg
3527
+				EE_Error::add_success(
3528
+					sprintf(
3529
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3530
+						$what,
3531
+						$action_desc
3532
+					),
3533
+					__FILE__,
3534
+					__FUNCTION__,
3535
+					__LINE__
3536
+				);
3537
+			} elseif ($success === 1) {
3538
+				// set singular msg
3539
+				EE_Error::add_success(
3540
+					sprintf(
3541
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3542
+						$what,
3543
+						$action_desc
3544
+					),
3545
+					__FILE__,
3546
+					__FUNCTION__,
3547
+					__LINE__
3548
+				);
3549
+			}
3550
+		}
3551
+		// check that $query_args isn't something crazy
3552
+		if (! is_array($query_args)) {
3553
+			$query_args = [];
3554
+		}
3555
+		/**
3556
+		 * Allow injecting actions before the query_args are modified for possible different
3557
+		 * redirections on save and close actions
3558
+		 *
3559
+		 * @param array $query_args       The original query_args array coming into the
3560
+		 *                                method.
3561
+		 * @since 4.2.0
3562
+		 */
3563
+		do_action(
3564
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3565
+			$query_args
3566
+		);
3567
+		// calculate where we're going (if we have a "save and close" button pushed)
3568
+
3569
+		if (
3570
+			$this->request->requestParamIsSet('save_and_close')
3571
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3572
+		) {
3573
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3574
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3575
+			// regenerate query args array from referrer URL
3576
+			parse_str($parsed_url['query'], $query_args);
3577
+			// correct page and action will be in the query args now
3578
+			$redirect_url = admin_url('admin.php');
3579
+		}
3580
+		// merge any default query_args set in _default_route_query_args property
3581
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3582
+			$args_to_merge = [];
3583
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3584
+				// is there a wp_referer array in our _default_route_query_args property?
3585
+				if ($query_param === 'wp_referer') {
3586
+					$query_value = (array) $query_value;
3587
+					foreach ($query_value as $reference => $value) {
3588
+						if (strpos($reference, 'nonce') !== false) {
3589
+							continue;
3590
+						}
3591
+						// finally we will override any arguments in the referer with
3592
+						// what might be set on the _default_route_query_args array.
3593
+						if (isset($this->_default_route_query_args[ $reference ])) {
3594
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3595
+						} else {
3596
+							$args_to_merge[ $reference ] = urlencode($value);
3597
+						}
3598
+					}
3599
+					continue;
3600
+				}
3601
+				$args_to_merge[ $query_param ] = $query_value;
3602
+			}
3603
+			// now let's merge these arguments but override with what was specifically sent in to the
3604
+			// redirect.
3605
+			$query_args = array_merge($args_to_merge, $query_args);
3606
+		}
3607
+		$this->_process_notices($query_args);
3608
+		// generate redirect url
3609
+		// if redirecting to anything other than the main page, add a nonce
3610
+		if (isset($query_args['action'])) {
3611
+			// manually generate wp_nonce and merge that with the query vars
3612
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3613
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3614
+		}
3615
+		// we're adding some hooks and filters in here for processing any things just before redirects
3616
+		// (example: an admin page has done an insert or update and we want to run something after that).
3617
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3618
+		$redirect_url = apply_filters(
3619
+			'FHEE_redirect_' . $classname . $this->_req_action,
3620
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3621
+			$query_args
3622
+		);
3623
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3624
+		if ($this->request->isAjax()) {
3625
+			$default_data                    = [
3626
+				'close'        => true,
3627
+				'redirect_url' => $redirect_url,
3628
+				'where'        => 'main',
3629
+				'what'         => 'append',
3630
+			];
3631
+			$this->_template_args['success'] = $success;
3632
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3633
+				$default_data,
3634
+				$this->_template_args['data']
3635
+			) : $default_data;
3636
+			$this->_return_json();
3637
+		}
3638
+		wp_safe_redirect($redirect_url);
3639
+		exit();
3640
+	}
3641
+
3642
+
3643
+	/**
3644
+	 * process any notices before redirecting (or returning ajax request)
3645
+	 * This method sets the $this->_template_args['notices'] attribute;
3646
+	 *
3647
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3648
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3649
+	 *                                  page_routes haven't been defined yet.
3650
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3651
+	 *                                  still save a transient for the notice.
3652
+	 * @return void
3653
+	 * @throws EE_Error
3654
+	 */
3655
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3656
+	{
3657
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3658
+		if ($this->request->isAjax()) {
3659
+			$notices = EE_Error::get_notices(false);
3660
+			if (empty($this->_template_args['success'])) {
3661
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3662
+			}
3663
+			if (empty($this->_template_args['errors'])) {
3664
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3665
+			}
3666
+			if (empty($this->_template_args['attention'])) {
3667
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3668
+			}
3669
+		}
3670
+		$this->_template_args['notices'] = EE_Error::get_notices();
3671
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3672
+		if (! $this->request->isAjax() || $sticky_notices) {
3673
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3674
+			$this->_add_transient(
3675
+				$route,
3676
+				$this->_template_args['notices'],
3677
+				true,
3678
+				$skip_route_verify
3679
+			);
3680
+		}
3681
+	}
3682
+
3683
+
3684
+	/**
3685
+	 * get_action_link_or_button
3686
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3687
+	 *
3688
+	 * @param string $action        use this to indicate which action the url is generated with.
3689
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3690
+	 *                              property.
3691
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3692
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3693
+	 * @param string $base_url      If this is not provided
3694
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3695
+	 *                              Otherwise this value will be used.
3696
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3697
+	 * @return string
3698
+	 * @throws InvalidArgumentException
3699
+	 * @throws InvalidInterfaceException
3700
+	 * @throws InvalidDataTypeException
3701
+	 * @throws EE_Error
3702
+	 */
3703
+	public function get_action_link_or_button(
3704
+		$action,
3705
+		$type = 'add',
3706
+		$extra_request = [],
3707
+		$class = 'button-primary',
3708
+		$base_url = '',
3709
+		$exclude_nonce = false
3710
+	) {
3711
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3712
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3713
+			throw new EE_Error(
3714
+				sprintf(
3715
+					esc_html__(
3716
+						'There is no page route for given action for the button.  This action was given: %s',
3717
+						'event_espresso'
3718
+					),
3719
+					$action
3720
+				)
3721
+			);
3722
+		}
3723
+		if (! isset($this->_labels['buttons'][ $type ])) {
3724
+			throw new EE_Error(
3725
+				sprintf(
3726
+					esc_html__(
3727
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3728
+						'event_espresso'
3729
+					),
3730
+					$type
3731
+				)
3732
+			);
3733
+		}
3734
+		// finally check user access for this button.
3735
+		$has_access = $this->check_user_access($action, true);
3736
+		if (! $has_access) {
3737
+			return '';
3738
+		}
3739
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3740
+		$query_args = [
3741
+			'action' => $action,
3742
+		];
3743
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3744
+		if (! empty($extra_request)) {
3745
+			$query_args = array_merge($extra_request, $query_args);
3746
+		}
3747
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3748
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3749
+	}
3750
+
3751
+
3752
+	/**
3753
+	 * _per_page_screen_option
3754
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3755
+	 *
3756
+	 * @return void
3757
+	 * @throws InvalidArgumentException
3758
+	 * @throws InvalidInterfaceException
3759
+	 * @throws InvalidDataTypeException
3760
+	 */
3761
+	protected function _per_page_screen_option()
3762
+	{
3763
+		$option = 'per_page';
3764
+		$args   = [
3765
+			'label'   => apply_filters(
3766
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3767
+				$this->_admin_page_title,
3768
+				$this
3769
+			),
3770
+			'default' => (int) apply_filters(
3771
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3772
+				20
3773
+			),
3774
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3775
+		];
3776
+		// ONLY add the screen option if the user has access to it.
3777
+		if ($this->check_user_access($this->_current_view, true)) {
3778
+			add_screen_option($option, $args);
3779
+		}
3780
+	}
3781
+
3782
+
3783
+	/**
3784
+	 * set_per_page_screen_option
3785
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3786
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3787
+	 * admin_menu.
3788
+	 *
3789
+	 * @return void
3790
+	 */
3791
+	private function _set_per_page_screen_options()
3792
+	{
3793
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3794
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3795
+			if (! $user = wp_get_current_user()) {
3796
+				return;
3797
+			}
3798
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3799
+			if (! $option) {
3800
+				return;
3801
+			}
3802
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3803
+			$map_option = $option;
3804
+			$option     = str_replace('-', '_', $option);
3805
+			switch ($map_option) {
3806
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3807
+					$max_value = apply_filters(
3808
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3809
+						999,
3810
+						$this->_current_page,
3811
+						$this->_current_view
3812
+					);
3813
+					if ($value < 1) {
3814
+						return;
3815
+					}
3816
+					$value = min($value, $max_value);
3817
+					break;
3818
+				default:
3819
+					$value = apply_filters(
3820
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3821
+						false,
3822
+						$option,
3823
+						$value
3824
+					);
3825
+					if (false === $value) {
3826
+						return;
3827
+					}
3828
+					break;
3829
+			}
3830
+			update_user_meta($user->ID, $option, $value);
3831
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3832
+			exit;
3833
+		}
3834
+	}
3835
+
3836
+
3837
+	/**
3838
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3839
+	 *
3840
+	 * @param array $data array that will be assigned to template args.
3841
+	 */
3842
+	public function set_template_args($data)
3843
+	{
3844
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3845
+	}
3846
+
3847
+
3848
+	/**
3849
+	 * This makes available the WP transient system for temporarily moving data between routes
3850
+	 *
3851
+	 * @param string $route             the route that should receive the transient
3852
+	 * @param array  $data              the data that gets sent
3853
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3854
+	 *                                  normal route transient.
3855
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3856
+	 *                                  when we are adding a transient before page_routes have been defined.
3857
+	 * @return void
3858
+	 * @throws EE_Error
3859
+	 */
3860
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3861
+	{
3862
+		$user_id = get_current_user_id();
3863
+		if (! $skip_route_verify) {
3864
+			$this->_verify_route($route);
3865
+		}
3866
+		// now let's set the string for what kind of transient we're setting
3867
+		$transient = $notices
3868
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3869
+			: 'rte_tx_' . $route . '_' . $user_id;
3870
+		$data      = $notices ? ['notices' => $data] : $data;
3871
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3872
+		$existing = is_multisite() && is_network_admin()
3873
+			? get_site_transient($transient)
3874
+			: get_transient($transient);
3875
+		if ($existing) {
3876
+			$data = array_merge((array) $data, (array) $existing);
3877
+		}
3878
+		if (is_multisite() && is_network_admin()) {
3879
+			set_site_transient($transient, $data, 8);
3880
+		} else {
3881
+			set_transient($transient, $data, 8);
3882
+		}
3883
+	}
3884
+
3885
+
3886
+	/**
3887
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3888
+	 *
3889
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3890
+	 * @param string $route
3891
+	 * @return mixed data
3892
+	 */
3893
+	protected function _get_transient($notices = false, $route = '')
3894
+	{
3895
+		$user_id   = get_current_user_id();
3896
+		$route     = ! $route ? $this->_req_action : $route;
3897
+		$transient = $notices
3898
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3899
+			: 'rte_tx_' . $route . '_' . $user_id;
3900
+		$data      = is_multisite() && is_network_admin()
3901
+			? get_site_transient($transient)
3902
+			: get_transient($transient);
3903
+		// delete transient after retrieval (just in case it hasn't expired);
3904
+		if (is_multisite() && is_network_admin()) {
3905
+			delete_site_transient($transient);
3906
+		} else {
3907
+			delete_transient($transient);
3908
+		}
3909
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3910
+	}
3911
+
3912
+
3913
+	/**
3914
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3915
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3916
+	 * default route callback on the EE_Admin page you want it run.)
3917
+	 *
3918
+	 * @return void
3919
+	 */
3920
+	protected function _transient_garbage_collection()
3921
+	{
3922
+		global $wpdb;
3923
+		// retrieve all existing transients
3924
+		$query =
3925
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3926
+		if ($results = $wpdb->get_results($query)) {
3927
+			foreach ($results as $result) {
3928
+				$transient = str_replace('_transient_', '', $result->option_name);
3929
+				get_transient($transient);
3930
+				if (is_multisite() && is_network_admin()) {
3931
+					get_site_transient($transient);
3932
+				}
3933
+			}
3934
+		}
3935
+	}
3936
+
3937
+
3938
+	/**
3939
+	 * get_view
3940
+	 *
3941
+	 * @return string content of _view property
3942
+	 */
3943
+	public function get_view()
3944
+	{
3945
+		return $this->_view;
3946
+	}
3947
+
3948
+
3949
+	/**
3950
+	 * getter for the protected $_views property
3951
+	 *
3952
+	 * @return array
3953
+	 */
3954
+	public function get_views()
3955
+	{
3956
+		return $this->_views;
3957
+	}
3958
+
3959
+
3960
+	/**
3961
+	 * get_current_page
3962
+	 *
3963
+	 * @return string _current_page property value
3964
+	 */
3965
+	public function get_current_page()
3966
+	{
3967
+		return $this->_current_page;
3968
+	}
3969
+
3970
+
3971
+	/**
3972
+	 * get_current_view
3973
+	 *
3974
+	 * @return string _current_view property value
3975
+	 */
3976
+	public function get_current_view()
3977
+	{
3978
+		return $this->_current_view;
3979
+	}
3980
+
3981
+
3982
+	/**
3983
+	 * get_current_screen
3984
+	 *
3985
+	 * @return object The current WP_Screen object
3986
+	 */
3987
+	public function get_current_screen()
3988
+	{
3989
+		return $this->_current_screen;
3990
+	}
3991
+
3992
+
3993
+	/**
3994
+	 * get_current_page_view_url
3995
+	 *
3996
+	 * @return string This returns the url for the current_page_view.
3997
+	 */
3998
+	public function get_current_page_view_url()
3999
+	{
4000
+		return $this->_current_page_view_url;
4001
+	}
4002
+
4003
+
4004
+	/**
4005
+	 * just returns the Request
4006
+	 *
4007
+	 * @return RequestInterface
4008
+	 */
4009
+	public function get_request()
4010
+	{
4011
+		return $this->request;
4012
+	}
4013
+
4014
+
4015
+	/**
4016
+	 * just returns the _req_data property
4017
+	 *
4018
+	 * @return array
4019
+	 */
4020
+	public function get_request_data()
4021
+	{
4022
+		return $this->request->requestParams();
4023
+	}
4024
+
4025
+
4026
+	/**
4027
+	 * returns the _req_data protected property
4028
+	 *
4029
+	 * @return string
4030
+	 */
4031
+	public function get_req_action()
4032
+	{
4033
+		return $this->_req_action;
4034
+	}
4035
+
4036
+
4037
+	/**
4038
+	 * @return bool  value of $_is_caf property
4039
+	 */
4040
+	public function is_caf()
4041
+	{
4042
+		return $this->_is_caf;
4043
+	}
4044
+
4045
+
4046
+	/**
4047
+	 * @return mixed
4048
+	 */
4049
+	public function default_espresso_metaboxes()
4050
+	{
4051
+		return $this->_default_espresso_metaboxes;
4052
+	}
4053
+
4054
+
4055
+	/**
4056
+	 * @return mixed
4057
+	 */
4058
+	public function admin_base_url()
4059
+	{
4060
+		return $this->_admin_base_url;
4061
+	}
4062
+
4063
+
4064
+	/**
4065
+	 * @return mixed
4066
+	 */
4067
+	public function wp_page_slug()
4068
+	{
4069
+		return $this->_wp_page_slug;
4070
+	}
4071
+
4072
+
4073
+	/**
4074
+	 * updates  espresso configuration settings
4075
+	 *
4076
+	 * @param string                   $tab
4077
+	 * @param EE_Config_Base|EE_Config $config
4078
+	 * @param string                   $file file where error occurred
4079
+	 * @param string                   $func function  where error occurred
4080
+	 * @param string                   $line line no where error occurred
4081
+	 * @return boolean
4082
+	 */
4083
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4084
+	{
4085
+		// remove any options that are NOT going to be saved with the config settings.
4086
+		if (isset($config->core->ee_ueip_optin)) {
4087
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4088
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4089
+			update_option('ee_ueip_has_notified', true);
4090
+		}
4091
+		// and save it (note we're also doing the network save here)
4092
+		$net_saved    = ! is_main_site() || EE_Network_Config::instance()->update_config(false, false);
4093
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4094
+		if ($config_saved && $net_saved) {
4095
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4096
+			return true;
4097
+		}
4098
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4099
+		return false;
4100
+	}
4101
+
4102
+
4103
+	/**
4104
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4105
+	 *
4106
+	 * @return array
4107
+	 */
4108
+	public function get_yes_no_values()
4109
+	{
4110
+		return $this->_yes_no_values;
4111
+	}
4112
+
4113
+
4114
+	protected function _get_dir()
4115
+	{
4116
+		$reflector = new ReflectionClass(get_class($this));
4117
+		return dirname($reflector->getFileName());
4118
+	}
4119
+
4120
+
4121
+	/**
4122
+	 * A helper for getting a "next link".
4123
+	 *
4124
+	 * @param string $url   The url to link to
4125
+	 * @param string $class The class to use.
4126
+	 * @return string
4127
+	 */
4128
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4129
+	{
4130
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4131
+	}
4132
+
4133
+
4134
+	/**
4135
+	 * A helper for getting a "previous link".
4136
+	 *
4137
+	 * @param string $url   The url to link to
4138
+	 * @param string $class The class to use.
4139
+	 * @return string
4140
+	 */
4141
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4142
+	{
4143
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4144
+	}
4145
+
4146
+
4147
+
4148
+
4149
+
4150
+
4151
+
4152
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4153
+
4154
+
4155
+	/**
4156
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4157
+	 * 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
4158
+	 * _req_data array.
4159
+	 *
4160
+	 * @return bool success/fail
4161
+	 * @throws EE_Error
4162
+	 * @throws InvalidArgumentException
4163
+	 * @throws ReflectionException
4164
+	 * @throws InvalidDataTypeException
4165
+	 * @throws InvalidInterfaceException
4166
+	 */
4167
+	protected function _process_resend_registration()
4168
+	{
4169
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
4170
+		do_action(
4171
+			'AHEE__EE_Admin_Page___process_resend_registration',
4172
+			$this->_template_args['success'],
4173
+			$this->request->requestParams()
4174
+		);
4175
+		return $this->_template_args['success'];
4176
+	}
4177
+
4178
+
4179
+	/**
4180
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4181
+	 *
4182
+	 * @param EE_Payment $payment
4183
+	 * @return bool success/fail
4184
+	 */
4185
+	protected function _process_payment_notification(EE_Payment $payment)
4186
+	{
4187
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4188
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4189
+		$this->_template_args['success'] = apply_filters(
4190
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4191
+			false,
4192
+			$payment
4193
+		);
4194
+		return $this->_template_args['success'];
4195
+	}
4196 4196
 }
Please login to merge, or discard this patch.
Spacing   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
         $ee_menu_slugs = (array) $ee_menu_slugs;
537 537
         if (
538 538
             ! $this->request->isAjax()
539
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
539
+            && ( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page]))
540 540
         ) {
541 541
             return;
542 542
         }
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
             : $req_action;
557 557
 
558 558
         $this->_current_view = $this->_req_action;
559
-        $this->_req_nonce    = $this->_req_action . '_nonce';
559
+        $this->_req_nonce    = $this->_req_action.'_nonce';
560 560
         $this->_define_page_props();
561 561
         $this->_current_page_view_url = add_query_arg(
562 562
             ['page' => $this->_current_page, 'action' => $this->_current_view],
@@ -593,21 +593,21 @@  discard block
 block discarded – undo
593 593
         }
594 594
         // filter routes and page_config so addons can add their stuff. Filtering done per class
595 595
         $this->_page_routes = apply_filters(
596
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
596
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
597 597
             $this->_page_routes,
598 598
             $this
599 599
         );
600 600
         $this->_page_config = apply_filters(
601
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
601
+            'FHEE__'.get_class($this).'__page_setup__page_config',
602 602
             $this->_page_config,
603 603
             $this
604 604
         );
605 605
         // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
606 606
         // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
607
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
607
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
608 608
             add_action(
609 609
                 'AHEE__EE_Admin_Page__route_admin_request',
610
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
610
+                [$this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view],
611 611
                 10,
612 612
                 2
613 613
             );
@@ -620,8 +620,8 @@  discard block
 block discarded – undo
620 620
             if ($this->_is_UI_request) {
621 621
                 // admin_init stuff - global, all views for this page class, specific view
622 622
                 add_action('admin_init', [$this, 'admin_init'], 10);
623
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
624
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
623
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
624
+                    add_action('admin_init', [$this, 'admin_init_'.$this->_current_view], 15);
625 625
                 }
626 626
             } else {
627 627
                 // hijack regular WP loading and route admin request immediately
@@ -640,12 +640,12 @@  discard block
 block discarded – undo
640 640
      */
641 641
     private function _do_other_page_hooks()
642 642
     {
643
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
643
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, []);
644 644
         foreach ($registered_pages as $page) {
645 645
             // now let's setup the file name and class that should be present
646 646
             $classname = str_replace('.class.php', '', $page);
647 647
             // autoloaders should take care of loading file
648
-            if (! class_exists($classname)) {
648
+            if ( ! class_exists($classname)) {
649 649
                 $error_msg[] = sprintf(
650 650
                     esc_html__(
651 651
                         'Something went wrong with loading the %s admin hooks page.',
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
                                    ),
663 663
                                    $page,
664 664
                                    '<br />',
665
-                                   '<strong>' . $classname . '</strong>'
665
+                                   '<strong>'.$classname.'</strong>'
666 666
                                );
667 667
                 throw new EE_Error(implode('||', $error_msg));
668 668
             }
@@ -704,13 +704,13 @@  discard block
 block discarded – undo
704 704
         // load admin_notices - global, page class, and view specific
705 705
         add_action('admin_notices', [$this, 'admin_notices_global'], 5);
706 706
         add_action('admin_notices', [$this, 'admin_notices'], 10);
707
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
708
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
707
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
708
+            add_action('admin_notices', [$this, 'admin_notices_'.$this->_current_view], 15);
709 709
         }
710 710
         // load network admin_notices - global, page class, and view specific
711 711
         add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
712
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
713
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
712
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
713
+            add_action('network_admin_notices', [$this, 'network_admin_notices_'.$this->_current_view]);
714 714
         }
715 715
         // this will save any per_page screen options if they are present
716 716
         $this->_set_per_page_screen_options();
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
     protected function _verify_routes()
833 833
     {
834 834
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
835
-        if (! $this->_current_page && ! $this->request->isAjax()) {
835
+        if ( ! $this->_current_page && ! $this->request->isAjax()) {
836 836
             return false;
837 837
         }
838 838
         $this->_route = false;
@@ -844,7 +844,7 @@  discard block
 block discarded – undo
844 844
                 $this->_admin_page_title
845 845
             );
846 846
             // developer error msg
847
-            $error_msg .= '||' . $error_msg
847
+            $error_msg .= '||'.$error_msg
848 848
                           . esc_html__(
849 849
                               ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
850 850
                               'event_espresso'
@@ -853,9 +853,9 @@  discard block
 block discarded – undo
853 853
         }
854 854
         // and that the requested page route exists
855 855
         if (array_key_exists($this->_req_action, $this->_page_routes)) {
856
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
857
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
858
-                ? $this->_page_config[ $this->_req_action ]
856
+            $this->_route        = $this->_page_routes[$this->_req_action];
857
+            $this->_route_config = isset($this->_page_config[$this->_req_action])
858
+                ? $this->_page_config[$this->_req_action]
859 859
                 : [];
860 860
         } else {
861 861
             // user error msg
@@ -867,7 +867,7 @@  discard block
 block discarded – undo
867 867
                 $this->_admin_page_title
868 868
             );
869 869
             // developer error msg
870
-            $error_msg .= '||' . $error_msg
870
+            $error_msg .= '||'.$error_msg
871 871
                           . sprintf(
872 872
                               esc_html__(
873 873
                                   ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
             throw new EE_Error($error_msg);
879 879
         }
880 880
         // and that a default route exists
881
-        if (! array_key_exists('default', $this->_page_routes)) {
881
+        if ( ! array_key_exists('default', $this->_page_routes)) {
882 882
             // user error msg
883 883
             $error_msg = sprintf(
884 884
                 esc_html__(
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
                 $this->_admin_page_title
889 889
             );
890 890
             // developer error msg
891
-            $error_msg .= '||' . $error_msg
891
+            $error_msg .= '||'.$error_msg
892 892
                           . esc_html__(
893 893
                               ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
894 894
                               'event_espresso'
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
             $this->_admin_page_title
930 930
         );
931 931
         // developer error msg
932
-        $error_msg .= '||' . $error_msg
932
+        $error_msg .= '||'.$error_msg
933 933
                       . sprintf(
934 934
                           esc_html__(
935 935
                               ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
@@ -954,7 +954,7 @@  discard block
 block discarded – undo
954 954
     protected function _verify_nonce($nonce, $nonce_ref)
955 955
     {
956 956
         // verify nonce against expected value
957
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
957
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
958 958
             // these are not the droids you are looking for !!!
959 959
             $msg = sprintf(
960 960
                 esc_html__('%sNonce Fail.%s', 'event_espresso'),
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
                     __CLASS__
972 972
                 );
973 973
             }
974
-            if (! $this->request->isAjax()) {
974
+            if ( ! $this->request->isAjax()) {
975 975
                 wp_die($msg);
976 976
             }
977 977
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
      */
996 996
     protected function _route_admin_request()
997 997
     {
998
-        if (! $this->_is_UI_request) {
998
+        if ( ! $this->_is_UI_request) {
999 999
             $this->_verify_routes();
1000 1000
         }
1001 1001
         $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
         $error_msg = '';
1016 1016
         // action right before calling route
1017 1017
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
1018
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1018
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
1019 1019
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
1020 1020
         }
1021 1021
         // right before calling the route, let's clean the _wp_http_referer
@@ -1026,7 +1026,7 @@  discard block
 block discarded – undo
1026 1026
                 wp_unslash($this->request->getServerParam('REQUEST_URI'))
1027 1027
             )
1028 1028
         );
1029
-        if (! empty($func)) {
1029
+        if ( ! empty($func)) {
1030 1030
             if (is_array($func)) {
1031 1031
                 list($class, $method) = $func;
1032 1032
             } elseif (strpos($func, '::') !== false) {
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
                 $class  = $this;
1036 1036
                 $method = $func;
1037 1037
             }
1038
-            if (! (is_object($class) && $class === $this)) {
1038
+            if ( ! (is_object($class) && $class === $this)) {
1039 1039
                 // send along this admin page object for access by addons.
1040 1040
                 $args['admin_page_object'] = $this;
1041 1041
             }
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
                     $method
1077 1077
                 );
1078 1078
             }
1079
-            if (! empty($error_msg)) {
1079
+            if ( ! empty($error_msg)) {
1080 1080
                 throw new EE_Error($error_msg);
1081 1081
             }
1082 1082
         }
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
                 if (strpos($key, 'nonce') !== false) {
1162 1162
                     continue;
1163 1163
                 }
1164
-                $args[ 'wp_referer[' . $key . ']' ] = is_string($value) ? htmlspecialchars($value) : $value;
1164
+                $args['wp_referer['.$key.']'] = is_string($value) ? htmlspecialchars($value) : $value;
1165 1165
             }
1166 1166
         }
1167 1167
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1201,8 +1201,8 @@  discard block
 block discarded – undo
1201 1201
     protected function _add_help_tabs()
1202 1202
     {
1203 1203
         $tour_buttons = '';
1204
-        if (isset($this->_page_config[ $this->_req_action ])) {
1205
-            $config = $this->_page_config[ $this->_req_action ];
1204
+        if (isset($this->_page_config[$this->_req_action])) {
1205
+            $config = $this->_page_config[$this->_req_action];
1206 1206
             // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1207 1207
             // is there a help tour for the current route?  if there is let's setup the tour buttons
1208 1208
             // if (isset($this->_help_tour[ $this->_req_action ])) {
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1226 1226
             if (is_array($config) && isset($config['help_sidebar'])) {
1227 1227
                 // check that the callback given is valid
1228
-                if (! method_exists($this, $config['help_sidebar'])) {
1228
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1229 1229
                     throw new EE_Error(
1230 1230
                         sprintf(
1231 1231
                             esc_html__(
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
                     );
1239 1239
                 }
1240 1240
                 $content = apply_filters(
1241
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1241
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1242 1242
                     $this->{$config['help_sidebar']}()
1243 1243
                 );
1244 1244
                 $content .= $tour_buttons; // add help tour buttons.
@@ -1246,27 +1246,27 @@  discard block
 block discarded – undo
1246 1246
                 $this->_current_screen->set_help_sidebar($content);
1247 1247
             }
1248 1248
             // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1249
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1249
+            if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1250 1250
                 $this->_current_screen->set_help_sidebar($tour_buttons);
1251 1251
             }
1252 1252
             // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1253
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1253
+            if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1254 1254
                 $_ht['id']      = $this->page_slug;
1255 1255
                 $_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1256 1256
                 $_ht['content'] = '<p>'
1257 1257
                                   . esc_html__(
1258 1258
                                       'The buttons to the right allow you to start/restart any help tours available for this page',
1259 1259
                                       'event_espresso'
1260
-                                  ) . '</p>';
1260
+                                  ).'</p>';
1261 1261
                 $this->_current_screen->add_help_tab($_ht);
1262 1262
             }
1263
-            if (! isset($config['help_tabs'])) {
1263
+            if ( ! isset($config['help_tabs'])) {
1264 1264
                 return;
1265 1265
             } //no help tabs for this route
1266 1266
             foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1267 1267
                 // we're here so there ARE help tabs!
1268 1268
                 // make sure we've got what we need
1269
-                if (! isset($cfg['title'])) {
1269
+                if ( ! isset($cfg['title'])) {
1270 1270
                     throw new EE_Error(
1271 1271
                         esc_html__(
1272 1272
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1274,7 +1274,7 @@  discard block
 block discarded – undo
1274 1274
                         )
1275 1275
                     );
1276 1276
                 }
1277
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1277
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1278 1278
                     throw new EE_Error(
1279 1279
                         esc_html__(
1280 1280
                             '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',
@@ -1283,11 +1283,11 @@  discard block
 block discarded – undo
1283 1283
                     );
1284 1284
                 }
1285 1285
                 // first priority goes to content.
1286
-                if (! empty($cfg['content'])) {
1286
+                if ( ! empty($cfg['content'])) {
1287 1287
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1288 1288
                     // second priority goes to filename
1289
-                } elseif (! empty($cfg['filename'])) {
1290
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1289
+                } elseif ( ! empty($cfg['filename'])) {
1290
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1291 1291
                     // 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)
1292 1292
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1293 1293
                                                              . basename($this->_get_dir())
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
                                                              . $cfg['filename']
1296 1296
                                                              . '.help_tab.php' : $file_path;
1297 1297
                     // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1298
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1298
+                    if ( ! isset($cfg['callback']) && ! is_readable($file_path)) {
1299 1299
                         EE_Error::add_error(
1300 1300
                             sprintf(
1301 1301
                                 esc_html__(
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
                     return;
1344 1344
                 }
1345 1345
                 // setup config array for help tab method
1346
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1346
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1347 1347
                 $_ht = [
1348 1348
                     'id'       => $id,
1349 1349
                     'title'    => $cfg['title'],
@@ -1470,8 +1470,8 @@  discard block
 block discarded – undo
1470 1470
             $qtips = (array) $this->_route_config['qtips'];
1471 1471
             // load qtip loader
1472 1472
             $path = [
1473
-                $this->_get_dir() . '/qtips/',
1474
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1473
+                $this->_get_dir().'/qtips/',
1474
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1475 1475
             ];
1476 1476
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1477 1477
         }
@@ -1493,7 +1493,7 @@  discard block
 block discarded – undo
1493 1493
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1494 1494
         $i = 0;
1495 1495
         foreach ($this->_page_config as $slug => $config) {
1496
-            if (! is_array($config) || empty($config['nav'])) {
1496
+            if ( ! is_array($config) || empty($config['nav'])) {
1497 1497
                 continue;
1498 1498
             }
1499 1499
             // no nav tab for this config
@@ -1502,12 +1502,12 @@  discard block
 block discarded – undo
1502 1502
                 // nav tab is only to appear when route requested.
1503 1503
                 continue;
1504 1504
             }
1505
-            if (! $this->check_user_access($slug, true)) {
1505
+            if ( ! $this->check_user_access($slug, true)) {
1506 1506
                 // no nav tab because current user does not have access.
1507 1507
                 continue;
1508 1508
             }
1509
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1510
-            $this->_nav_tabs[ $slug ] = [
1509
+            $css_class                = isset($config['css_class']) ? $config['css_class'].' ' : '';
1510
+            $this->_nav_tabs[$slug] = [
1511 1511
                 'url'       => isset($config['nav']['url'])
1512 1512
                     ? $config['nav']['url']
1513 1513
                     : self::add_query_args_and_nonce(
@@ -1519,14 +1519,14 @@  discard block
 block discarded – undo
1519 1519
                     : ucwords(
1520 1520
                         str_replace('_', ' ', $slug)
1521 1521
                     ),
1522
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1522
+                'css_class' => $this->_req_action === $slug ? $css_class.'nav-tab-active' : $css_class,
1523 1523
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1524 1524
             ];
1525 1525
             $i++;
1526 1526
         }
1527 1527
         // if $this->_nav_tabs is empty then lets set the default
1528 1528
         if (empty($this->_nav_tabs)) {
1529
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1529
+            $this->_nav_tabs[$this->_default_nav_tab_name] = [
1530 1530
                 'url'       => $this->_admin_base_url,
1531 1531
                 'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1532 1532
                 'css_class' => 'nav-tab-active',
@@ -1551,10 +1551,10 @@  discard block
 block discarded – undo
1551 1551
             foreach ($this->_route_config['labels'] as $label => $text) {
1552 1552
                 if (is_array($text)) {
1553 1553
                     foreach ($text as $sublabel => $subtext) {
1554
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1554
+                        $this->_labels[$label][$sublabel] = $subtext;
1555 1555
                     }
1556 1556
                 } else {
1557
-                    $this->_labels[ $label ] = $text;
1557
+                    $this->_labels[$label] = $text;
1558 1558
                 }
1559 1559
             }
1560 1560
         }
@@ -1576,12 +1576,12 @@  discard block
 block discarded – undo
1576 1576
     {
1577 1577
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1578 1578
         $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1579
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1579
+        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1580 1580
                           && is_array(
1581
-                              $this->_page_routes[ $route_to_check ]
1581
+                              $this->_page_routes[$route_to_check]
1582 1582
                           )
1583
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1584
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1583
+                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1584
+            ? $this->_page_routes[$route_to_check]['capability'] : null;
1585 1585
         if (empty($capability) && empty($route_to_check)) {
1586 1586
             $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1587 1587
                 : $this->_route['capability'];
@@ -1706,7 +1706,7 @@  discard block
 block discarded – undo
1706 1706
         //     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1707 1707
         // }
1708 1708
         // current set timezone for timezone js
1709
-        echo '<span id="current_timezone" class="hidden">' . esc_html(EEH_DTT_Helper::get_timezone()) . '</span>';
1709
+        echo '<span id="current_timezone" class="hidden">'.esc_html(EEH_DTT_Helper::get_timezone()).'</span>';
1710 1710
     }
1711 1711
 
1712 1712
 
@@ -1740,7 +1740,7 @@  discard block
 block discarded – undo
1740 1740
         // loop through the array and setup content
1741 1741
         foreach ($help_array as $trigger => $help) {
1742 1742
             // make sure the array is setup properly
1743
-            if (! isset($help['title']) || ! isset($help['content'])) {
1743
+            if ( ! isset($help['title']) || ! isset($help['content'])) {
1744 1744
                 throw new EE_Error(
1745 1745
                     esc_html__(
1746 1746
                         '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',
@@ -1754,8 +1754,8 @@  discard block
 block discarded – undo
1754 1754
                 'help_popup_title'   => $help['title'],
1755 1755
                 'help_popup_content' => $help['content'],
1756 1756
             ];
1757
-            $content       .= EEH_Template::display_template(
1758
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1757
+            $content .= EEH_Template::display_template(
1758
+                EE_ADMIN_TEMPLATE.'admin_help_popup.template.php',
1759 1759
                 $template_args,
1760 1760
                 true
1761 1761
             );
@@ -1777,15 +1777,15 @@  discard block
 block discarded – undo
1777 1777
     private function _get_help_content()
1778 1778
     {
1779 1779
         // what is the method we're looking for?
1780
-        $method_name = '_help_popup_content_' . $this->_req_action;
1780
+        $method_name = '_help_popup_content_'.$this->_req_action;
1781 1781
         // if method doesn't exist let's get out.
1782
-        if (! method_exists($this, $method_name)) {
1782
+        if ( ! method_exists($this, $method_name)) {
1783 1783
             return [];
1784 1784
         }
1785 1785
         // k we're good to go let's retrieve the help array
1786 1786
         $help_array = call_user_func([$this, $method_name]);
1787 1787
         // make sure we've got an array!
1788
-        if (! is_array($help_array)) {
1788
+        if ( ! is_array($help_array)) {
1789 1789
             throw new EE_Error(
1790 1790
                 esc_html__(
1791 1791
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1817,15 +1817,15 @@  discard block
 block discarded – undo
1817 1817
         // 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
1818 1818
         $help_array   = $this->_get_help_content();
1819 1819
         $help_content = '';
1820
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1821
-            $help_array[ $trigger_id ] = [
1820
+        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1821
+            $help_array[$trigger_id] = [
1822 1822
                 'title'   => esc_html__('Missing Content', 'event_espresso'),
1823 1823
                 'content' => esc_html__(
1824 1824
                     '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.)',
1825 1825
                     'event_espresso'
1826 1826
                 ),
1827 1827
             ];
1828
-            $help_content              = $this->_set_help_popup_content($help_array);
1828
+            $help_content = $this->_set_help_popup_content($help_array);
1829 1829
         }
1830 1830
         // let's setup the trigger
1831 1831
         $content = '<a class="ee-dialog" href="?height='
@@ -1893,15 +1893,15 @@  discard block
 block discarded – undo
1893 1893
         // register all styles
1894 1894
         wp_register_style(
1895 1895
             'espresso-ui-theme',
1896
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1896
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1897 1897
             [],
1898 1898
             EVENT_ESPRESSO_VERSION
1899 1899
         );
1900
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1900
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1901 1901
         // helpers styles
1902 1902
         wp_register_style(
1903 1903
             'ee-text-links',
1904
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1904
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css',
1905 1905
             [],
1906 1906
             EVENT_ESPRESSO_VERSION
1907 1907
         );
@@ -1909,21 +1909,21 @@  discard block
 block discarded – undo
1909 1909
         // register all scripts
1910 1910
         wp_register_script(
1911 1911
             'ee-dialog',
1912
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1912
+            EE_ADMIN_URL.'assets/ee-dialog-helper.js',
1913 1913
             ['jquery', 'jquery-ui-draggable'],
1914 1914
             EVENT_ESPRESSO_VERSION,
1915 1915
             true
1916 1916
         );
1917 1917
         wp_register_script(
1918 1918
             'ee_admin_js',
1919
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1919
+            EE_ADMIN_URL.'assets/ee-admin-page.js',
1920 1920
             ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1921 1921
             EVENT_ESPRESSO_VERSION,
1922 1922
             true
1923 1923
         );
1924 1924
         wp_register_script(
1925 1925
             'jquery-ui-timepicker-addon',
1926
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1926
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js',
1927 1927
             ['jquery-ui-datepicker', 'jquery-ui-slider'],
1928 1928
             EVENT_ESPRESSO_VERSION,
1929 1929
             true
@@ -1935,7 +1935,7 @@  discard block
 block discarded – undo
1935 1935
         // script for sorting tables
1936 1936
         wp_register_script(
1937 1937
             'espresso_ajax_table_sorting',
1938
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1938
+            EE_ADMIN_URL.'assets/espresso_ajax_table_sorting.js',
1939 1939
             ['ee_admin_js', 'jquery-ui-sortable'],
1940 1940
             EVENT_ESPRESSO_VERSION,
1941 1941
             true
@@ -1943,7 +1943,7 @@  discard block
 block discarded – undo
1943 1943
         // script for parsing uri's
1944 1944
         wp_register_script(
1945 1945
             'ee-parse-uri',
1946
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1946
+            EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js',
1947 1947
             [],
1948 1948
             EVENT_ESPRESSO_VERSION,
1949 1949
             true
@@ -1951,7 +1951,7 @@  discard block
 block discarded – undo
1951 1951
         // and parsing associative serialized form elements
1952 1952
         wp_register_script(
1953 1953
             'ee-serialize-full-array',
1954
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1954
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js',
1955 1955
             ['jquery'],
1956 1956
             EVENT_ESPRESSO_VERSION,
1957 1957
             true
@@ -1959,28 +1959,28 @@  discard block
 block discarded – undo
1959 1959
         // helpers scripts
1960 1960
         wp_register_script(
1961 1961
             'ee-text-links',
1962
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1962
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js',
1963 1963
             ['jquery'],
1964 1964
             EVENT_ESPRESSO_VERSION,
1965 1965
             true
1966 1966
         );
1967 1967
         wp_register_script(
1968 1968
             'ee-moment-core',
1969
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1969
+            EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js',
1970 1970
             [],
1971 1971
             EVENT_ESPRESSO_VERSION,
1972 1972
             true
1973 1973
         );
1974 1974
         wp_register_script(
1975 1975
             'ee-moment',
1976
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1976
+            EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js',
1977 1977
             ['ee-moment-core'],
1978 1978
             EVENT_ESPRESSO_VERSION,
1979 1979
             true
1980 1980
         );
1981 1981
         wp_register_script(
1982 1982
             'ee-datepicker',
1983
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1983
+            EE_ADMIN_URL.'assets/ee-datepicker.js',
1984 1984
             ['jquery-ui-timepicker-addon', 'ee-moment'],
1985 1985
             EVENT_ESPRESSO_VERSION,
1986 1986
             true
@@ -2040,7 +2040,7 @@  discard block
 block discarded – undo
2040 2040
 
2041 2041
         add_filter(
2042 2042
             'admin_body_class',
2043
-            function ($classes) {
2043
+            function($classes) {
2044 2044
                 if (strpos($classes, 'espresso-admin') === false) {
2045 2045
                     $classes .= ' espresso-admin';
2046 2046
                 }
@@ -2128,12 +2128,12 @@  discard block
 block discarded – undo
2128 2128
     protected function _set_list_table()
2129 2129
     {
2130 2130
         // first is this a list_table view?
2131
-        if (! isset($this->_route_config['list_table'])) {
2131
+        if ( ! isset($this->_route_config['list_table'])) {
2132 2132
             return;
2133 2133
         } //not a list_table view so get out.
2134 2134
         // list table functions are per view specific (because some admin pages might have more than one list table!)
2135
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2136
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2135
+        $list_table_view = '_set_list_table_views_'.$this->_req_action;
2136
+        if ( ! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2137 2137
             // user error msg
2138 2138
             $error_msg = esc_html__(
2139 2139
                 'An error occurred. The requested list table views could not be found.',
@@ -2153,10 +2153,10 @@  discard block
 block discarded – undo
2153 2153
         }
2154 2154
         // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2155 2155
         $this->_views = apply_filters(
2156
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2156
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
2157 2157
             $this->_views
2158 2158
         );
2159
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2159
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
2160 2160
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2161 2161
         $this->_set_list_table_view();
2162 2162
         $this->_set_list_table_object();
@@ -2191,7 +2191,7 @@  discard block
 block discarded – undo
2191 2191
     protected function _set_list_table_object()
2192 2192
     {
2193 2193
         if (isset($this->_route_config['list_table'])) {
2194
-            if (! class_exists($this->_route_config['list_table'])) {
2194
+            if ( ! class_exists($this->_route_config['list_table'])) {
2195 2195
                 throw new EE_Error(
2196 2196
                     sprintf(
2197 2197
                         esc_html__(
@@ -2229,15 +2229,15 @@  discard block
 block discarded – undo
2229 2229
         foreach ($this->_views as $key => $view) {
2230 2230
             $query_args = [];
2231 2231
             // check for current view
2232
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2232
+            $this->_views[$key]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2233 2233
             $query_args['action']                        = $this->_req_action;
2234
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2234
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2235 2235
             $query_args['status']                        = $view['slug'];
2236 2236
             // merge any other arguments sent in.
2237
-            if (isset($extra_query_args[ $view['slug'] ])) {
2238
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2237
+            if (isset($extra_query_args[$view['slug']])) {
2238
+                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2239 2239
             }
2240
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2240
+            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2241 2241
         }
2242 2242
         return $this->_views;
2243 2243
     }
@@ -2268,14 +2268,14 @@  discard block
 block discarded – undo
2268 2268
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2269 2269
         foreach ($values as $value) {
2270 2270
             if ($value < $max_entries) {
2271
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2271
+                $selected = $value === $per_page ? ' selected="'.$per_page.'"' : '';
2272 2272
                 $entries_per_page_dropdown .= '
2273
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2273
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2274 2274
             }
2275 2275
         }
2276
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2276
+        $selected = $max_entries === $per_page ? ' selected="'.$per_page.'"' : '';
2277 2277
         $entries_per_page_dropdown .= '
2278
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2278
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2279 2279
         $entries_per_page_dropdown .= '
2280 2280
 					</select>
2281 2281
 					entries
@@ -2299,7 +2299,7 @@  discard block
 block discarded – undo
2299 2299
             empty($this->_search_btn_label) ? $this->page_label
2300 2300
                 : $this->_search_btn_label
2301 2301
         );
2302
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2302
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2303 2303
     }
2304 2304
 
2305 2305
 
@@ -2387,7 +2387,7 @@  discard block
 block discarded – undo
2387 2387
             $total_columns                                       = ! empty($screen_columns)
2388 2388
                 ? $screen_columns
2389 2389
                 : $this->_route_config['columns'][1];
2390
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2390
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2391 2391
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2392 2392
             $this->_template_args['screen']                      = $this->_current_screen;
2393 2393
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2432,7 +2432,7 @@  discard block
 block discarded – undo
2432 2432
      */
2433 2433
     protected function _espresso_ratings_request()
2434 2434
     {
2435
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2435
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2436 2436
             return;
2437 2437
         }
2438 2438
         $ratings_box_title = apply_filters(
@@ -2460,7 +2460,7 @@  discard block
 block discarded – undo
2460 2460
     public function espresso_ratings_request()
2461 2461
     {
2462 2462
         EEH_Template::display_template(
2463
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2463
+            EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php',
2464 2464
             []
2465 2465
         );
2466 2466
     }
@@ -2468,22 +2468,22 @@  discard block
 block discarded – undo
2468 2468
 
2469 2469
     public static function cached_rss_display($rss_id, $url)
2470 2470
     {
2471
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2471
+        $loading = '<p class="widget-loading hide-if-no-js">'
2472 2472
                      . esc_html__('Loading&#8230;', 'event_espresso')
2473 2473
                      . '</p><p class="hide-if-js">'
2474 2474
                      . esc_html__('This widget requires JavaScript.', 'event_espresso')
2475 2475
                      . '</p>';
2476
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2477
-        $pre       .= '<span id="' . esc_attr($rss_id) . '_url" class="hidden">' . esc_url_raw($url) . '</span>';
2478
-        $post      = '</div>' . "\n";
2479
-        $cache_key = 'ee_rss_' . md5($rss_id);
2476
+        $pre       = '<div class="espresso-rss-display">'."\n\t";
2477
+        $pre .= '<span id="'.esc_attr($rss_id).'_url" class="hidden">'.esc_url_raw($url).'</span>';
2478
+        $post      = '</div>'."\n";
2479
+        $cache_key = 'ee_rss_'.md5($rss_id);
2480 2480
         $output    = get_transient($cache_key);
2481 2481
         if ($output !== false) {
2482
-            echo $pre . $output . $post; // already escaped
2482
+            echo $pre.$output.$post; // already escaped
2483 2483
             return true;
2484 2484
         }
2485
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2486
-            echo $pre . $loading . $post; // already escaped
2485
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX)) {
2486
+            echo $pre.$loading.$post; // already escaped
2487 2487
             return false;
2488 2488
         }
2489 2489
         ob_start();
@@ -2550,19 +2550,19 @@  discard block
 block discarded – undo
2550 2550
     public function espresso_sponsors_post_box()
2551 2551
     {
2552 2552
         EEH_Template::display_template(
2553
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2553
+            EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'
2554 2554
         );
2555 2555
     }
2556 2556
 
2557 2557
 
2558 2558
     private function _publish_post_box()
2559 2559
     {
2560
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2560
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2561 2561
         // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2562 2562
         // then we'll use that for the metabox label.
2563 2563
         // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2564
-        if (! empty($this->_labels['publishbox'])) {
2565
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2564
+        if ( ! empty($this->_labels['publishbox'])) {
2565
+            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2566 2566
                 : $this->_labels['publishbox'];
2567 2567
         } else {
2568 2568
             $box_label = esc_html__('Publish', 'event_espresso');
@@ -2591,7 +2591,7 @@  discard block
 block discarded – undo
2591 2591
             ? $this->_template_args['publish_box_extra_content']
2592 2592
             : '';
2593 2593
         echo EEH_Template::display_template(
2594
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2594
+            EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php',
2595 2595
             $this->_template_args,
2596 2596
             true
2597 2597
         );
@@ -2683,18 +2683,18 @@  discard block
 block discarded – undo
2683 2683
             );
2684 2684
         }
2685 2685
         $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2686
-        if (! empty($name) && ! empty($id)) {
2687
-            $hidden_field_arr[ $name ] = [
2686
+        if ( ! empty($name) && ! empty($id)) {
2687
+            $hidden_field_arr[$name] = [
2688 2688
                 'type'  => 'hidden',
2689 2689
                 'value' => $id,
2690 2690
             ];
2691
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2691
+            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2692 2692
         } else {
2693 2693
             $hf = '';
2694 2694
         }
2695 2695
         // add hidden field
2696 2696
         $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2697
-            ? $hf[ $name ]['field']
2697
+            ? $hf[$name]['field']
2698 2698
             : $hf;
2699 2699
     }
2700 2700
 
@@ -2796,7 +2796,7 @@  discard block
 block discarded – undo
2796 2796
         }
2797 2797
         // 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)
2798 2798
         $call_back_func = $create_func
2799
-            ? function ($post, $metabox) {
2799
+            ? function($post, $metabox) {
2800 2800
                 do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2801 2801
                 echo EEH_Template::display_template(
2802 2802
                     $metabox['args']['template_path'],
@@ -2806,7 +2806,7 @@  discard block
 block discarded – undo
2806 2806
             }
2807 2807
             : $callback;
2808 2808
         add_meta_box(
2809
-            str_replace('_', '-', $action) . '-mbox',
2809
+            str_replace('_', '-', $action).'-mbox',
2810 2810
             $title,
2811 2811
             $call_back_func,
2812 2812
             $this->_wp_page_slug,
@@ -2898,9 +2898,9 @@  discard block
 block discarded – undo
2898 2898
             : 'espresso-default-admin';
2899 2899
         $template_path                                     = $sidebar
2900 2900
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2901
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2901
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2902 2902
         if ($this->request->isAjax()) {
2903
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2903
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2904 2904
         }
2905 2905
         $template_path                                     = ! empty($this->_column_template_path)
2906 2906
             ? $this->_column_template_path : $template_path;
@@ -2940,11 +2940,11 @@  discard block
 block discarded – undo
2940 2940
     public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2941 2941
     {
2942 2942
         // let's generate a default preview action button if there isn't one already present.
2943
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2943
+        $this->_labels['buttons']['buy_now'] = esc_html__(
2944 2944
             'Upgrade to Event Espresso 4 Right Now',
2945 2945
             'event_espresso'
2946 2946
         );
2947
-        $buy_now_url                                   = add_query_arg(
2947
+        $buy_now_url = add_query_arg(
2948 2948
             [
2949 2949
                 'ee_ver'       => 'ee4',
2950 2950
                 'utm_source'   => 'ee4_plugin_admin',
@@ -2964,8 +2964,8 @@  discard block
 block discarded – undo
2964 2964
                 true
2965 2965
             )
2966 2966
             : $this->_template_args['preview_action_button'];
2967
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2968
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2967
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2968
+            EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php',
2969 2969
             $this->_template_args,
2970 2970
             true
2971 2971
         );
@@ -3014,7 +3014,7 @@  discard block
 block discarded – undo
3014 3014
         // setup search attributes
3015 3015
         $this->_set_search_attributes();
3016 3016
         $this->_template_args['current_page']     = $this->_wp_page_slug;
3017
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
3017
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
3018 3018
         $this->_template_args['table_url']        = $this->request->isAjax()
3019 3019
             ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
3020 3020
             : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
@@ -3022,10 +3022,10 @@  discard block
 block discarded – undo
3022 3022
         $this->_template_args['current_route']    = $this->_req_action;
3023 3023
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
3024 3024
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
3025
-        if (! empty($ajax_sorting_callback)) {
3025
+        if ( ! empty($ajax_sorting_callback)) {
3026 3026
             $sortable_list_table_form_fields = wp_nonce_field(
3027
-                $ajax_sorting_callback . '_nonce',
3028
-                $ajax_sorting_callback . '_nonce',
3027
+                $ajax_sorting_callback.'_nonce',
3028
+                $ajax_sorting_callback.'_nonce',
3029 3029
                 false,
3030 3030
                 false
3031 3031
             );
@@ -3043,20 +3043,20 @@  discard block
 block discarded – undo
3043 3043
             isset($this->_template_args['list_table_hidden_fields'])
3044 3044
                 ? $this->_template_args['list_table_hidden_fields']
3045 3045
                 : '';
3046
-        $nonce_ref                                               = $this->_req_action . '_nonce';
3047
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
3046
+        $nonce_ref = $this->_req_action.'_nonce';
3047
+        $hidden_form_fields .= '<input type="hidden" name="'
3048 3048
                                                                     . $nonce_ref
3049 3049
                                                                     . '" value="'
3050 3050
                                                                     . wp_create_nonce($nonce_ref)
3051 3051
                                                                     . '">';
3052
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3052
+        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
3053 3053
         // display message about search results?
3054 3054
         $search = $this->request->getRequestParam('s');
3055 3055
         $this->_template_args['before_list_table'] .= ! empty($search)
3056
-            ? '<p class="ee-search-results">' . sprintf(
3056
+            ? '<p class="ee-search-results">'.sprintf(
3057 3057
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3058 3058
                 trim($search, '%')
3059
-            ) . '</p>'
3059
+            ).'</p>'
3060 3060
             : '';
3061 3061
         // filter before_list_table template arg
3062 3062
         $this->_template_args['before_list_table'] = apply_filters(
@@ -3090,7 +3090,7 @@  discard block
 block discarded – undo
3090 3090
         // convert to array and filter again
3091 3091
         // arrays are easier to inject new items in a specific location,
3092 3092
         // but would not be backwards compatible, so we have to add a new filter
3093
-        $this->_template_args['after_list_table']   = implode(
3093
+        $this->_template_args['after_list_table'] = implode(
3094 3094
             " \n",
3095 3095
             (array) apply_filters(
3096 3096
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
@@ -3137,7 +3137,7 @@  discard block
 block discarded – undo
3137 3137
             $this
3138 3138
         );
3139 3139
         return EEH_Template::display_template(
3140
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3140
+            EE_ADMIN_TEMPLATE.'admin_details_legend.template.php',
3141 3141
             $this->_template_args,
3142 3142
             true
3143 3143
         );
@@ -3246,18 +3246,18 @@  discard block
 block discarded – undo
3246 3246
                 : ''
3247 3247
         );
3248 3248
 
3249
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3249
+        $this->_template_args['after_admin_page_content'] = apply_filters(
3250 3250
             "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3251 3251
             isset($this->_template_args['after_admin_page_content'])
3252 3252
                 ? $this->_template_args['after_admin_page_content']
3253 3253
                 : ''
3254 3254
         );
3255
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3255
+        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3256 3256
 
3257 3257
         if ($this->request->isAjax()) {
3258 3258
             $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3259 3259
                 // $template_path,
3260
-                EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php',
3260
+                EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php',
3261 3261
                 $this->_template_args,
3262 3262
                 true
3263 3263
             );
@@ -3266,7 +3266,7 @@  discard block
 block discarded – undo
3266 3266
         // load settings page wrapper template
3267 3267
         $template_path = $about
3268 3268
             ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3269
-            : EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php';
3269
+            : EE_ADMIN_TEMPLATE.'admin_wrapper.template.php';
3270 3270
 
3271 3271
         EEH_Template::display_template($template_path, $this->_template_args);
3272 3272
     }
@@ -3351,12 +3351,12 @@  discard block
 block discarded – undo
3351 3351
         $default_names = ['save', 'save_and_close'];
3352 3352
         $buttons = '';
3353 3353
         foreach ($button_text as $key => $button) {
3354
-            $ref     = $default_names[ $key ];
3355
-            $name    = ! empty($actions) ? $actions[ $key ] : $ref;
3356
-            $buttons .= '<input type="submit" class="button-primary ' . $ref . '" '
3357
-                        . 'value="' . $button . '" name="' . $name . '" '
3358
-                        . 'id="' . $this->_current_view . '_' . $ref . '" />';
3359
-            if (! $both) {
3354
+            $ref     = $default_names[$key];
3355
+            $name    = ! empty($actions) ? $actions[$key] : $ref;
3356
+            $buttons .= '<input type="submit" class="button-primary '.$ref.'" '
3357
+                        . 'value="'.$button.'" name="'.$name.'" '
3358
+                        . 'id="'.$this->_current_view.'_'.$ref.'" />';
3359
+            if ( ! $both) {
3360 3360
                 break;
3361 3361
             }
3362 3362
         }
@@ -3396,13 +3396,13 @@  discard block
 block discarded – undo
3396 3396
                 'An error occurred. No action was set for this page\'s form.',
3397 3397
                 'event_espresso'
3398 3398
             );
3399
-            $dev_msg  = $user_msg . "\n"
3399
+            $dev_msg = $user_msg."\n"
3400 3400
                         . sprintf(
3401 3401
                             esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3402 3402
                             __FUNCTION__,
3403 3403
                             __CLASS__
3404 3404
                         );
3405
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3405
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3406 3406
         }
3407 3407
         // open form
3408 3408
         $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
@@ -3411,9 +3411,9 @@  discard block
 block discarded – undo
3411 3411
                                                              . $route
3412 3412
                                                              . '_event_form" >';
3413 3413
         // add nonce
3414
-        $nonce                                             =
3415
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3416
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3414
+        $nonce =
3415
+            wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3416
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3417 3417
         // add REQUIRED form action
3418 3418
         $hidden_fields = [
3419 3419
             'action' => ['type' => 'hidden', 'value' => $route],
@@ -3426,7 +3426,7 @@  discard block
 block discarded – undo
3426 3426
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3427 3427
         // add fields to form
3428 3428
         foreach ((array) $form_fields as $form_field) {
3429
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3429
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3430 3430
         }
3431 3431
         // close form
3432 3432
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3517,10 +3517,10 @@  discard block
 block discarded – undo
3517 3517
         $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3518 3518
         $notices      = EE_Error::get_notices(false);
3519 3519
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3520
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3520
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3521 3521
             EE_Error::overwrite_success();
3522 3522
         }
3523
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3523
+        if ( ! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3524 3524
             // how many records affected ? more than one record ? or just one ?
3525 3525
             if ($success > 1) {
3526 3526
                 // set plural msg
@@ -3549,7 +3549,7 @@  discard block
 block discarded – undo
3549 3549
             }
3550 3550
         }
3551 3551
         // check that $query_args isn't something crazy
3552
-        if (! is_array($query_args)) {
3552
+        if ( ! is_array($query_args)) {
3553 3553
             $query_args = [];
3554 3554
         }
3555 3555
         /**
@@ -3578,7 +3578,7 @@  discard block
 block discarded – undo
3578 3578
             $redirect_url = admin_url('admin.php');
3579 3579
         }
3580 3580
         // merge any default query_args set in _default_route_query_args property
3581
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3581
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3582 3582
             $args_to_merge = [];
3583 3583
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3584 3584
                 // is there a wp_referer array in our _default_route_query_args property?
@@ -3590,15 +3590,15 @@  discard block
 block discarded – undo
3590 3590
                         }
3591 3591
                         // finally we will override any arguments in the referer with
3592 3592
                         // what might be set on the _default_route_query_args array.
3593
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3594
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3593
+                        if (isset($this->_default_route_query_args[$reference])) {
3594
+                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3595 3595
                         } else {
3596
-                            $args_to_merge[ $reference ] = urlencode($value);
3596
+                            $args_to_merge[$reference] = urlencode($value);
3597 3597
                         }
3598 3598
                     }
3599 3599
                     continue;
3600 3600
                 }
3601
-                $args_to_merge[ $query_param ] = $query_value;
3601
+                $args_to_merge[$query_param] = $query_value;
3602 3602
             }
3603 3603
             // now let's merge these arguments but override with what was specifically sent in to the
3604 3604
             // redirect.
@@ -3610,19 +3610,19 @@  discard block
 block discarded – undo
3610 3610
         if (isset($query_args['action'])) {
3611 3611
             // manually generate wp_nonce and merge that with the query vars
3612 3612
             // becuz the wp_nonce_url function wrecks havoc on some vars
3613
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3613
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3614 3614
         }
3615 3615
         // we're adding some hooks and filters in here for processing any things just before redirects
3616 3616
         // (example: an admin page has done an insert or update and we want to run something after that).
3617
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3617
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3618 3618
         $redirect_url = apply_filters(
3619
-            'FHEE_redirect_' . $classname . $this->_req_action,
3619
+            'FHEE_redirect_'.$classname.$this->_req_action,
3620 3620
             self::add_query_args_and_nonce($query_args, $redirect_url),
3621 3621
             $query_args
3622 3622
         );
3623 3623
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3624 3624
         if ($this->request->isAjax()) {
3625
-            $default_data                    = [
3625
+            $default_data = [
3626 3626
                 'close'        => true,
3627 3627
                 'redirect_url' => $redirect_url,
3628 3628
                 'where'        => 'main',
@@ -3669,7 +3669,7 @@  discard block
 block discarded – undo
3669 3669
         }
3670 3670
         $this->_template_args['notices'] = EE_Error::get_notices();
3671 3671
         // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3672
-        if (! $this->request->isAjax() || $sticky_notices) {
3672
+        if ( ! $this->request->isAjax() || $sticky_notices) {
3673 3673
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3674 3674
             $this->_add_transient(
3675 3675
                 $route,
@@ -3709,7 +3709,7 @@  discard block
 block discarded – undo
3709 3709
         $exclude_nonce = false
3710 3710
     ) {
3711 3711
         // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3712
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3712
+        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3713 3713
             throw new EE_Error(
3714 3714
                 sprintf(
3715 3715
                     esc_html__(
@@ -3720,7 +3720,7 @@  discard block
 block discarded – undo
3720 3720
                 )
3721 3721
             );
3722 3722
         }
3723
-        if (! isset($this->_labels['buttons'][ $type ])) {
3723
+        if ( ! isset($this->_labels['buttons'][$type])) {
3724 3724
             throw new EE_Error(
3725 3725
                 sprintf(
3726 3726
                     esc_html__(
@@ -3733,7 +3733,7 @@  discard block
 block discarded – undo
3733 3733
         }
3734 3734
         // finally check user access for this button.
3735 3735
         $has_access = $this->check_user_access($action, true);
3736
-        if (! $has_access) {
3736
+        if ( ! $has_access) {
3737 3737
             return '';
3738 3738
         }
3739 3739
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3741,11 +3741,11 @@  discard block
 block discarded – undo
3741 3741
             'action' => $action,
3742 3742
         ];
3743 3743
         // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3744
-        if (! empty($extra_request)) {
3744
+        if ( ! empty($extra_request)) {
3745 3745
             $query_args = array_merge($extra_request, $query_args);
3746 3746
         }
3747 3747
         $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3748
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3748
+        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3749 3749
     }
3750 3750
 
3751 3751
 
@@ -3771,7 +3771,7 @@  discard block
 block discarded – undo
3771 3771
                 'FHEE__EE_Admin_Page___per_page_screen_options__default',
3772 3772
                 20
3773 3773
             ),
3774
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3774
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3775 3775
         ];
3776 3776
         // ONLY add the screen option if the user has access to it.
3777 3777
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3792,18 +3792,18 @@  discard block
 block discarded – undo
3792 3792
     {
3793 3793
         if ($this->request->requestParamIsSet('wp_screen_options')) {
3794 3794
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3795
-            if (! $user = wp_get_current_user()) {
3795
+            if ( ! $user = wp_get_current_user()) {
3796 3796
                 return;
3797 3797
             }
3798 3798
             $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3799
-            if (! $option) {
3799
+            if ( ! $option) {
3800 3800
                 return;
3801 3801
             }
3802
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3802
+            $value = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3803 3803
             $map_option = $option;
3804 3804
             $option     = str_replace('-', '_', $option);
3805 3805
             switch ($map_option) {
3806
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3806
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3807 3807
                     $max_value = apply_filters(
3808 3808
                         'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3809 3809
                         999,
@@ -3860,13 +3860,13 @@  discard block
 block discarded – undo
3860 3860
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3861 3861
     {
3862 3862
         $user_id = get_current_user_id();
3863
-        if (! $skip_route_verify) {
3863
+        if ( ! $skip_route_verify) {
3864 3864
             $this->_verify_route($route);
3865 3865
         }
3866 3866
         // now let's set the string for what kind of transient we're setting
3867 3867
         $transient = $notices
3868
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3869
-            : 'rte_tx_' . $route . '_' . $user_id;
3868
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3869
+            : 'rte_tx_'.$route.'_'.$user_id;
3870 3870
         $data      = $notices ? ['notices' => $data] : $data;
3871 3871
         // is there already a transient for this route?  If there is then let's ADD to that transient
3872 3872
         $existing = is_multisite() && is_network_admin()
@@ -3895,8 +3895,8 @@  discard block
 block discarded – undo
3895 3895
         $user_id   = get_current_user_id();
3896 3896
         $route     = ! $route ? $this->_req_action : $route;
3897 3897
         $transient = $notices
3898
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3899
-            : 'rte_tx_' . $route . '_' . $user_id;
3898
+            ? 'ee_rte_n_tx_'.$route.'_'.$user_id
3899
+            : 'rte_tx_'.$route.'_'.$user_id;
3900 3900
         $data      = is_multisite() && is_network_admin()
3901 3901
             ? get_site_transient($transient)
3902 3902
             : get_transient($transient);
@@ -4127,7 +4127,7 @@  discard block
 block discarded – undo
4127 4127
      */
4128 4128
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4129 4129
     {
4130
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4130
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4131 4131
     }
4132 4132
 
4133 4133
 
@@ -4140,7 +4140,7 @@  discard block
 block discarded – undo
4140 4140
      */
4141 4141
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4142 4142
     {
4143
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4143
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
4144 4144
     }
4145 4145
 
4146 4146
 
Please login to merge, or discard this patch.